diff --git a/README.md b/README.md index 496a880..96c67ea 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,10 @@ This will 1) watch your directory structure and compile things on the fly and 2) or $ mimosa watch -som + +Use the `biuld` command and the optimize, minify, removeCombined and package flags and Mimosa will build all of the assets, optimize them into a single file, and then package the application for use outside of Mimosa. Go inside the created `dist` directory and execute `node app.js` and the app works the same. + + $ mimosa build -omrp + + + diff --git a/dist/.gitignore b/dist/.gitignore new file mode 100644 index 0000000..6105de7 --- /dev/null +++ b/dist/.gitignore @@ -0,0 +1,4 @@ +node_modules +public/javascripts +public/stylesheets +public/img \ No newline at end of file diff --git a/dist/APPMOFUCKA.tar.gz b/dist/APPMOFUCKA.tar.gz new file mode 100644 index 0000000..3b7401c Binary files /dev/null and b/dist/APPMOFUCKA.tar.gz differ diff --git a/dist/app.js b/dist/app.js new file mode 100644 index 0000000..c94a466 --- /dev/null +++ b/dist/app.js @@ -0,0 +1,4 @@ +require('coffee-script') +server = require("./server"); +config = require("./foo"); +server.startServer(config); \ No newline at end of file diff --git a/dist/foo.json b/dist/foo.json new file mode 100644 index 0000000..d68985f --- /dev/null +++ b/dist/foo.json @@ -0,0 +1,23 @@ +{ + "server": { + "useDefaultServer": false, + "useReload": false, + "path": "./server.coffee", + "port": 3000, + "base": "", + "views": { + "compileWith": "jade", + "extension": "jade", + "path": "./views" + } + }, + "watch": { + "sourceDir": "./assets", + "compiledDir": "./public", + "javascriptDir": "javascripts", + "exclude": {}, + "throttle": 0, + "compiledJavascriptDir": "./public/javascripts" + }, + "isOptimize": true +} \ No newline at end of file diff --git a/dist/package.json b/dist/package.json new file mode 100644 index 0000000..b416c35 --- /dev/null +++ b/dist/package.json @@ -0,0 +1,12 @@ +{ + "name": "Mimosa-LESSCoffeeScriptHTML-BootstrapAngular", + "version": "0.0.1", + "dependencies": { + "consolidate": "~0.4.0", + "jade": "~0.26.3", + "express": "~3.0.0beta4", + "watch-connect": "~0.3.4", + "coffee-script": "1.3.3" + }, + "engine": "node >= 0.8.1" +} diff --git a/dist/server.coffee b/dist/server.coffee new file mode 100644 index 0000000..f6c843f --- /dev/null +++ b/dist/server.coffee @@ -0,0 +1,74 @@ +express = require 'express' +reloadOnChange = require 'watch-connect' +engines = require 'consolidate' + +exports.startServer = (config) -> + + publicPath = config.watch.compiledDir + useReload = config.server.useReload + + nextId = 0 + + people = [ + {"id": "#{nextId++}", "name": "Saasha", "age": "5"} + {"id": "#{nextId++}", "name": "Planet", "age": "7"} + ] + + isUniqueName = (name) -> + (name for person in people when person.name is name).length is 0 + + app = express() + server = app.listen config.server.port, -> + console.log "Express server listening on port %d in %s mode", config.server.port, app.settings.env + + app.configure -> + app.set 'port', config.server.port + app.set 'views', config.server.views.path + app.engine config.server.views.extension, engines[config.server.views.compileWith] + app.set 'view engine', config.server.views.extension + app.use express.favicon() + app.use express.bodyParser() + app.use express.methodOverride() + if useReload + options = + server:server + watchdir:publicPath + skipAdding:true + exclude:["almond\\.js"] + additionaldirs:["#{__dirname}/views"] + app.use reloadOnChange(options) + app.use express.compress() + app.use app.router + app.use express.static(publicPath) + + app.configure 'development', -> + app.use express.errorHandler() + + index = (useReload, optimize) -> + options = + reload: config.server.useReload + optimize: config.isOptimize ? false + cachebust: if process.env.NODE_ENV isnt "production" then "?b=#{(new Date()).getTime()}" else '' + (req, res) -> res.render 'index', options + + app.get '/', index(useReload, config.isOptimize) + + app.get '/people', (req, res) -> res.json people + + app.post '/people', (req, res) -> + name = req.body.name + message = + "title": "Duplicate!" + "message": "#{name} is a duplicate. Please enter a new name." + return res.send(message, 403) if not isUniqueName name + person = + "id": "#{nextId++}" + "name": "#{name}" + "age": "0" + people.push person + res.json person + + app.get '/people/details/:id', (req, res) -> + id = req.params.id + current = person for person in people when parseInt(person.id, 10) is parseInt(id, 10) + res.json current \ No newline at end of file diff --git a/dist/views/index.jade b/dist/views/index.jade new file mode 100644 index 0000000..2018b4f --- /dev/null +++ b/dist/views/index.jade @@ -0,0 +1,89 @@ +doctype 5 +html(lang="en") + head + meta(charset='utf-8') + meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1') + title Angular Demo + meta(name='description', content='') + meta(name='viewport', content='width=device-width') + + link(rel='stylesheet', href='/stylesheets/vendor/bootstrap.css' + cachebust) + link(rel='stylesheet', href='/stylesheets/styles.css' + cachebust) + + if optimize + script(src='/javascripts/main-built.js') + else + script(src='/javascripts/vendor/require.js', data-main='/javascripts/main.js') + + if reload + script(src='/socket.io/socket.io.js') + script(src='/socket-enable.js') + + body(ng-cloak='ng-cloak') + ng:view + .container + .hero-unit + h1 + | Playing with  + a(href='http://angularjs.org', target='_blank') AngularJS + p + | and also  + a(href='http://requirejs.org/', target='_blank') RequireJS + p + | and also  + a(href='https://github.com/dbashford/mimosa', target='_blank') Mimosa + p Compiles both Stylus and Less (Bootstrap) and CoffeeScript. 2 lines of config. + .row + .span8 + tabs + tab(data-tab-id='twitter', caption='Twitter') + section(ng-controller='twitter') + .alert.alert-info(ng-show='!searchTerm.length') + h4.alert-heading Heads up! + span Enter Twitter search criteria. + form.well.form-search(ng-submit='search(searchTerm)') + input.input-medium.search-query(type='text', ng-model='searchTerm', autofocus='autofocus') + button.btn(type='submit') + i.icon-search + | Search + include partials/tweets + + tab(data-tab-id='gitHub', caption='GitHub') + section(ng-controller='gitHub') + .alert.alert-info(ng-show='!searchTerm.length') + h4.alert-heading Heads up! + span Enter GitHub search criteria. + form.well.form-search(ng-submit='search(searchTerm)') + input.input-medium.search-query(type='text', ng-model='searchTerm') + button.btn(type='submit') + i.icon-search + | Search + include partials/repos + + tab(data-tab-id='people', caption='People') + .row + .span4 + section(ng-controller='people') + .alert.alert-error(ng-show='!!error') + h4.alert-heading(ng-bind='error.title') + span(ng-bind='error.message') + form.well.form-search(ng-submit='insertPerson(name)') + input.input-medium.search-query(type='text', ng-model='name') + button.btn(type='submit') + i.icon-plus + | Insert + myinput(model='name', kind='text', caption='My Caption', placeholder='Enter something here', help-text='Help me out, bro!') + include partials/people + .span4 + section(ng-controller='personDetails') + | Age: + span(ng-bind='person.result.age') + .span4 + h2 Search History + section(ng-controller='searchHistory') + form.well.form-search + input.input-medium.search-query(type='text', placeholder='Type filter...', ng-model='query') + label(ng-bind-template='Displaying: {{(searchHistory | filter:query).length}}') + ol(ng-hide='!searchHistory.length') + li(ng-repeat='item in searchHistory | filter:query | orderBy:\'timeStamp\':true', ng-bind-template='{{item.source}}/{{item.criteria}}') + diff --git a/dist/views/partials/people.jade b/dist/views/partials/people.jade new file mode 100644 index 0000000..13fd155 --- /dev/null +++ b/dist/views/partials/people.jade @@ -0,0 +1,3 @@ +ul(ng-hide='!people.result.length') + li.row(ng-repeat='person in people.result | orderBy:\'name\'') + a(ng-href='#/people/details/{{person.id}}', ng-bind='person.name') diff --git a/dist/views/partials/repos.jade b/dist/views/partials/repos.jade new file mode 100644 index 0000000..3db58d8 --- /dev/null +++ b/dist/views/partials/repos.jade @@ -0,0 +1,6 @@ +ul(ng-hide='!repos.result.data.length') + li(ng-repeat='repo in repos.result.data') + div + b(ng-bind='repo.owner.login') + a(ng-href='{{repo.url}}', ng-bind='repo.name', target='_blank') + div(ng-bind='repo.description') diff --git a/dist/views/partials/tweets.jade b/dist/views/partials/tweets.jade new file mode 100644 index 0000000..6ca0c44 --- /dev/null +++ b/dist/views/partials/tweets.jade @@ -0,0 +1,9 @@ +ul(ng-hide='!tweets.result.results.length') + li.row(ng-repeat='tweet in tweets.result.results') + .span1.thumbnail + img(ng-src='{{tweet.profile_image_url}}') + .span10 + div + b(ng-bind='tweet.from_user_name') + a(ng-href='https://twitter.com/{{tweet.from_user}}', ng-bind='tweet.from_user | twitterfy', target='_blank') + div(ng-bind='tweet.text') diff --git a/mimosa-config.coffee b/mimosa-config.coffee index 331303c..dd8eec5 100644 --- a/mimosa-config.coffee +++ b/mimosa-config.coffee @@ -1,4 +1,4 @@ exports.config = - #modules:['lint','require','server','minify','web-package'] + modules:['lint','require','server','minify','web-package'] minify: - exclude:["\.min\.", "main.js"] \ No newline at end of file + exclude:["\\.min\\.", "main.js"] diff --git a/views/index.jade b/views/index.jade index 2018b4f..c519425 100644 --- a/views/index.jade +++ b/views/index.jade @@ -32,7 +32,7 @@ html(lang="en") p | and also  a(href='https://github.com/dbashford/mimosa', target='_blank') Mimosa - p Compiles both Stylus and Less (Bootstrap) and CoffeeScript. 2 lines of config. + p Compiles both Stylus and Less (Bootstrap) and CoffeeScript and packages app for non-Mimosa use. 3 lines of config. .row .span8 tabs