Skip to content

Commit

Permalink
upgrade for 0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dbashford committed Nov 2, 2012
1 parent b1d0057 commit d9c40d1
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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



4 changes: 4 additions & 0 deletions dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
public/javascripts
public/stylesheets
public/img
Binary file added dist/APPMOFUCKA.tar.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions dist/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require('coffee-script')
server = require("./server");
config = require("./foo");
server.startServer(config);
23 changes: 23 additions & 0 deletions dist/foo.json
Original file line number Diff line number Diff line change
@@ -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
}
12 changes: 12 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
74 changes: 74 additions & 0 deletions dist/server.coffee
Original file line number Diff line number Diff line change
@@ -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
89 changes: 89 additions & 0 deletions dist/views/index.jade
Original file line number Diff line number Diff line change
@@ -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}}')

3 changes: 3 additions & 0 deletions dist/views/partials/people.jade
Original file line number Diff line number Diff line change
@@ -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')
6 changes: 6 additions & 0 deletions dist/views/partials/repos.jade
Original file line number Diff line number Diff line change
@@ -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')
9 changes: 9 additions & 0 deletions dist/views/partials/tweets.jade
Original file line number Diff line number Diff line change
@@ -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')
4 changes: 2 additions & 2 deletions mimosa-config.coffee
Original file line number Diff line number Diff line change
@@ -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"]
exclude:["\\.min\\.", "main.js"]
2 changes: 1 addition & 1 deletion views/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9c40d1

Please sign in to comment.