Permalink
Browse files

More updates/tweaks to design builds

* Another buildsPath fix
* Better error handling in test reset
* Add sublime text to .npmignore
* Add a preview link for Live
* Fix preview link for staging
* Wipe logs in grunt prepublish
* Async fix
* Bump to rc2
  • Loading branch information...
davidkaneda committed Oct 20, 2014
1 parent bcf407b commit 590bdf4bae5abc9c12e65fe1ed770e095bc74672
View
@@ -5,3 +5,5 @@ tmp
docs/api
newrelic_agent.log
.env
Buckets.sublime-project
Buckets.sublime-workspace
View
@@ -71,6 +71,7 @@ module.exports = (grunt) ->
clean:
app: ['public']
all: ['public', 'bower_components', 'tmp', 'deployments/*', '!deployments/base']
logs: ['*.log']
testem:
basic:
@@ -306,7 +307,7 @@ module.exports = (grunt) ->
# Building
grunt.registerTask 'default', ['clean:app', 'bower', 'apidoc', 'copy', 'uglify:vendor', 'browserify:plugins', 'uglify:plugins', 'build-scripts', 'build-style', 'modernizr']
grunt.registerTask 'prepublish', ['clean:all', 'default', 'uglify:app', 'cssmin']
grunt.registerTask 'prepublish', ['clean:all', 'clean:logs', 'default', 'uglify:app', 'cssmin']
grunt.registerTask 'publish', ['prepublish', 'shell:publish']
# Serving
View
@@ -12,10 +12,10 @@ A fast, simple way to build dynamic websites with [Node.js](http://nodejs.org).
Buckets requires [Node.js](http://nodejs.org) and [MongoDB](http://www.mongodb.org). Once you have those, the easiest way to use Buckets is to install it as an NPM module:
```bash
npm install buckets
npm install buckets@latest
```
You can also run the above command with `--save` to add Buckets to your app’s package.json. From here, you can run Buckets in a script like so:
You can also run the above command with `--save` to add Buckets to your app’s package.json (recommended). From here, you can run Buckets in a script like this:
```javascript
buckets = require('buckets');
@@ -69,6 +69,7 @@ If you're deploying directly from this repo, you'll need to make one change to y
* [Routes](docs/user-docs/routes.md)
* [Templates](docs/user-docs/templates.md)
* [Design](docs/user-docs/design.md)
# Community
@@ -26,11 +26,10 @@
<br>
<p>
<a href="/" class="btn btn-block btn-default" target="_blank">View Staging</a>
<a href="//{{stagingUrl}}" class="btn btn-block btn-default" target="_blank">View Staging</a>
<a href="/api/builds/staging/download" class="btn btn-block btn-default">Download Staging</a>
<a href="#publish" class="btn btn-block btn-success">Copy Staging to Live</a>
</p>
</div>
{{!-- Live --}}
@@ -39,7 +38,7 @@
{{> directory children=liveFiles env='live' active=filename}}
</ul>
<a href="/api/builds/live/download" class="btn btn-block btn-default noscript">Download Live</a>
<a href="/" class="btn btn-block btn-default noscript" target="_blank">View Live</a>
</div>
{{!-- Archives --}}
@@ -1,15 +1,14 @@
_ = require 'underscore'
Chaplin = require 'chaplin'
PageView = require 'views/base/page'
Template = require 'models/template'
_ = require 'underscore'
mediator = require('chaplin').mediator
mediator = require 'mediator'
FormMixin = require 'views/base/mixins/form'
tpl = require 'templates/templates/editor'
handlebars = require 'hbsfy/runtime'
handlebars.registerPartial 'directory', require('templates/templates/directory')
handlebars.registerPartial 'directory', require 'templates/templates/directory'
module.exports = class TemplateEditor extends PageView
template: tpl
@@ -29,20 +28,17 @@ module.exports = class TemplateEditor extends PageView
'click [href="#download"]': 'clickDownload'
'click [href="#stage"]': 'clickStage'
'click [href="#publish"]': 'clickPublish'
'click [href="#downloadLive"]': 'clickDownloadLive'
'keydown textarea, [type=text], [type=number]': 'keyDown'
'keyup textarea, [type=text], [type=number]': 'keyUp'
keyUp: (e) ->
if @cmdActive and e.which is 91
@cmdActive = false
e
keyDown: (e) ->
if @cmdActive and e.which is 13
@$('form').submit()
@cmdActive = e.metaKey
e
getTemplateData: ->
archives = _.where @builds.toJSON(), env: 'archive'
@@ -52,6 +48,7 @@ module.exports = class TemplateEditor extends PageView
stagingFiles: @stagingFiles.getTree()
archives: archives
env: @env
stagingUrl: mediator.options.stagingUrl
render: ->
super
@@ -197,11 +194,6 @@ module.exports = class TemplateEditor extends PageView
e.preventDefault()
# todo:
clickDownloadLive: (e) ->
build = @builds.findWhere(env: 'live')
if build
@$(e.currentTarget).attr 'href', "/api/builds/#{build.get('id')}/download"
clickPublish: (e) ->
e.preventDefault()
build = @builds.findWhere env: 'staging'
View
@@ -1,6 +1,6 @@
{
"name": "buckets",
"version": "0.0.6",
"version": "0.0.7-rc2",
"description": "Manage content better.",
"scripts": {
"start": "./node_modules/coffee-script/bin/coffee ./server/start.coffee",
View
@@ -20,12 +20,11 @@ Build = require './models/build'
logger = require './lib/logger'
class Buckets extends events.EventEmitter
listening: no
constructor: (config, callback) ->
@config = require('./config')
_.extend @config, config
constructor: (config={}, callback) ->
@config = require './config'
@config = _.extend @config, config
logger.verbose 'Starting Buckets', config: @config, callback: callback?
callback ?= ->
View
@@ -12,7 +12,7 @@ logger = new winston.Logger
new winston.transports.File
level: 'verbose'
filename: "buckets.#{config.env}.log"
maxsize: 1000000
maxsize: 20000000 # 20mbish
]
module.exports = logger
View
@@ -63,8 +63,7 @@ buildSchema.pre 'validate', (next) ->
Build.generateTar dirpath, (e, tar) =>
if e?
logger.error 'Error generating the tar', path: dirpath
console.log e
logger.error 'Error generating the tar', path: dirpath, error: e
@invalidate 'source', 'Buckets wasn’t able to compress the source.'
next()
else
@@ -76,7 +75,6 @@ buildSchema.pre 'validate', (next) ->
@invalidate 'source', 'A build with that md5 already exists.'
next()
buildSchema.pre 'save', (next) ->
@timestamp = Date.now()
env = @env
@@ -121,8 +119,8 @@ buildSchema.pre 'save', (next) ->
Build.find {env: env, md5: $ne: @md5}, (e, builds) ->
logger.verbose 'Found %d builds to archive', builds.length
async.map builds, (build) ->
callback() if build.id is id
async.map builds, (build, callback) ->
return callback() if build.id is id
logger.verbose "Backing up from #{build.env}", id: id, buildId: build.id
build.message = "Backed up from #{build.env}"
build.env = 'archive'
@@ -168,8 +166,10 @@ buildSchema.statics.scaffold = (env, callback) ->
fs.removeSync "#{config.buildsPath}#{env}"
fs.copy "./server/lib/skeletons/base/", "#{config.buildsPath}#{env}", ->
fs.copy "#{__dirname}/../lib/skeletons/base/", "#{config.buildsPath}#{env}", (e) ->
logger.error e if e
createNew 'Scaffolded from base.', (e, build) ->
logger.error e if e
if build
logger.verbose 'Created a new build', build.id
callback null, build
@@ -105,6 +105,7 @@ app.get '/:admin*?', (req, res) ->
else
"/#{adminSegment}"
apiSegment: config.apiSegment
stagingUrl: "staging." + (config.host || req.hostname) + if config.port isnt 80 then ":#{config.port}" else ''
needsInstall: userCount is 0
cloudinary: cloudinaryData
version: pkg.version
@@ -35,7 +35,7 @@ if config.host
buildEnv = req.vhost[0]
# Check buildEnv dir exists
fs.exists "./builds/#{buildEnv}", (exists) ->
fs.exists "#{config.buildsPath}#{buildEnv}", (exists) ->
# console.log "Using #{buildEnv} statics".rainbow, exists
if exists
app.set 'views', "#{config.buildsPath}#{buildEnv}"
@@ -49,13 +49,11 @@ app.use (req, res, next) ->
unless req.previewMode
req.originalUrl = req.url
req.url = "/live#{req.url}"
app.set 'views', "#{config.buildsPath}live"
# console.log 'just passing thru...', req.url
app.set 'views', "#{config.buildsPath}live" # This should symlink to DB build
next()
# Serve static (cached one week), and Harp pre-compiled, then reset the URL
app.use express.static(config.buildsPath, maxAge: 86400000 * 7), harp.mount(config.buildsPath), (req, res, next) ->
# console.log 'what?!', req.originalUrl, req.url
req.url = req.originalUrl if req.originalUrl
delete req.originalUrl
next()
@@ -166,5 +164,3 @@ app.all '/:frontend*?', (req, res, next) ->
next()
else
res.status(404).send html
View
@@ -58,6 +58,9 @@
{{~#if cloudinary~}}
,cloudinary: {{~json cloudinary~}}
{{~/if~}}
{{~#if stagingUrl~}}
,stagingUrl: '{{stagingUrl}}'
{{~/if~}}
{{~#if dropboxEnabled~}}
,dropboxEnabled: true
{{~/if~}}

0 comments on commit 590bdf4

Please sign in to comment.