Skip to content

Commit

Permalink
cleanup. add extras
Browse files Browse the repository at this point in the history
  • Loading branch information
brentkirby committed Sep 25, 2012
1 parent bf1d249 commit aea7106
Show file tree
Hide file tree
Showing 43 changed files with 1,212 additions and 10,490 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
.sass-cache
node_modules
gh-pages
80 changes: 53 additions & 27 deletions Cakefile
Expand Up @@ -19,6 +19,7 @@ CoffeeScript = require 'coffee-script'
cleanCSS = require 'clean-css'
less = require 'less'
async = require 'async'
wrench = require 'wrench'

# Javascript sources
# Example configuration for two JS packages,
Expand All @@ -30,7 +31,10 @@ libraries = [
'src/core.coffee'
'src/core/browser.coffee'
'src/core/selection.coffee'

'src/core/validate.coffee'

'src/views/view.coffee'

'src/ui/manager.coffee'
'src/ui/modal.coffee'
'src/ui/notify.coffee'
Expand All @@ -43,10 +47,12 @@ libraries = [
'src/model/context.coffee'
'src/model/contexts.coffee'
'src/model/deliverable.coffee'

'src/views/asset_manager.coffee'
'src/views/view.coffee'
'src/views/context.coffee'
'src/views/region.coffee'
'src/views/form.coffee'

]

javascripts = []
Expand All @@ -60,6 +66,11 @@ javascripts.push
files: libraries
minify: false

javascripts.push
path: 'gh-pages/javascripts/transit.js'
files: libraries
minify: false

javascripts.push
path: 'build/themes/bootstrap.js'
files: ['src/themes/bootstrap.coffee']
Expand All @@ -69,6 +80,12 @@ javascripts.push
path: 'lib/themes/bootstrap.js'
files: ['src/themes/bootstrap.coffee']
minify: true


javascripts.push
path: 'gh-pages/javascripts/transit-bootstrap.js'
files: ['src/themes/bootstrap.coffee']
minify: true
#
# do ()->
# specs = []
Expand All @@ -93,6 +110,10 @@ stylesheets = {
'build/transit.css': [
'src/css/transit.scss'
]
# ,
# 'gh-pages/stylesheets/transit.css': [
# 'src/css/transit.scss'
# ]
}

task 'test', 'Run mocha suite', ->
Expand Down Expand Up @@ -124,9 +145,20 @@ test = ->


# Build JS
task 'build:js', 'Build JS from source', build = (cb) ->
task 'build', 'Build JS from source', build = (cb) ->
file_name = null
file_contents = null
try
files = wrench.readdirSyncRecursive('src/extras/')
for extra in files
file_name = path.join('src', 'extras', extra)
file_contents = CoffeeScript.compile "#{fs.readFileSync(file_name)}"
fname = path.basename(file_name).replace(/\.coffee$/,'.js')
write_js "build/extras/#{fname}", file_contents
write_js "gh-pages/javascripts/extras/#{fname}", file_contents
catch e
print_error e, file_name, file_contents

getdata = (files)->
code = ""
for source in files
Expand Down Expand Up @@ -154,28 +186,6 @@ task 'build:js', 'Build JS from source', build = (cb) ->
print_error e, file_name, file_contents


# Build CSS
task 'build:css', 'Build CSS', build = (cb) ->
file_name = null; file_contents = null
try
for stylesheet, sources of stylesheets
code = ''
for source in sources
file_name = source
file_contents = "#{fs.readFileSync source}"

code += file_contents

write_stylesheet stylesheet, code
unless process.env.MINIFY is 'false'
write_stylesheet stylesheet.replace(/\.css$/,'.min.css'), (
cleanCSS.process code
)
cb() if typeof cb is 'function'
catch e
print_error e, file_name, file_contents


# Watch task
task 'watch', 'Watch source files and build JS & CSS', ->
console.log "Watching for changes..."
Expand All @@ -187,8 +197,15 @@ task 'watch', 'Watch source files and build JS & CSS', ->
fs.watchFile file, { interval: 100}, (curr, prev) ->
if +curr.mtime isnt +prev.mtime
console.log "Saw change in #{file}"
invoke 'build:js'
invoke 'build'
)(file)


for file in wrench.readdirSyncRecursive('src/extras/')
file = path.join('src', 'extras', file)
fs.watchFile file, { interval: 100 }, (curr, prev) ->
if +curr.mtime isnt +prev.mtime
invoke "build"

fs.watchFile 'src/css/transit.scss', { interval: 100 }, (curr, prev)->
console.log "Compile transit.scss"
Expand All @@ -207,6 +224,15 @@ write_js = (filename, body) ->
"""
console.log "Wrote #{filename}"

get_libs = (dir, callback)->
files = []
wrench.readdirSyncRecursive dir, (path)->
unless path is null
fs.stat path, (err, stat)->
if stat and !stat.isDirectory()
files.push(path)
callback?(files)
files

# Write stylesheet with a header
write_stylesheet = (filename, body) ->
Expand Down
54 changes: 54 additions & 0 deletions build/extras/heading_text.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions build/extras/page.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions build/extras/text_block.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions build/themes/bootstrap.js
Expand Up @@ -60,6 +60,27 @@
<i class="icon-ok"></i> {{#if text}}{{text}}{{else}}Save{{/if}}\
</button>');

Handlebars.registerPartial('transit_progress_bar', '\
<div class="progress progress-striped active">\
<div class="bar" style="width:{{progress}}"></div>\
</div>\
');

Transit.AssetManager.prototype.template = Handlebars.compile('\
<div class="add-asset">\
<button class="btn btn-small btn-primary"><i class="icon-plus icon-white"></i> Upload</button>\
</div>\
');

Transit.Uploader.prototype.template = Handlebars.compile('\
<h4>Upload Files</h4>\
<span class="ui-fileinput">\
<input type="file" name="file" />\
<var class="ui-value">Choose a file</var>\
<button class="btn btn-mini btn-primary">Choose</button>\
</span>\
');

$.fn.modal.Constructor.prototype.removeBackdrop = function() {
this.$backdrop.remove();
return this.$backdrop = null;
Expand Down
2 changes: 1 addition & 1 deletion build/themes/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions build/transit.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aea7106

Please sign in to comment.