Skip to content

Commit

Permalink
Post from email test
Browse files Browse the repository at this point in the history
  • Loading branch information
neojp committed Jun 30, 2012
1 parent aea3377 commit 5edf8f5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 10 deletions.
47 changes: 45 additions & 2 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ task 'build', 'Build all source files', ->
setTimeout (-> invoke 'build:stylus'), 0
setTimeout (-> invoke 'build:coffee-src'), 1000
setTimeout (-> invoke 'build:coffee-static'), 2000
setTimeout (-> invoke 'build:coffee-scripts'), 3000



Expand Down Expand Up @@ -150,6 +151,48 @@ task 'build:coffee-static', 'Watch CoffeeScript source files and build JS files'



task 'build:coffee-scripts', 'Watch CoffeeScript source files and build JS files', (o) ->

console.log "\n=== BUILD: COFFEESCRIPT-SCRIPTS (Server side utils) ==="

# script
command = ['node_modules/coffee-script/bin/coffee']

# option arguments
options = [
# watch and compress
'--bare',
'--compile'
]

# watch files
if (o.watch)
options.push '--watch'

# list of files to compile
files = [
'scripts/'
]

# merge args & files
args = [].concat command, options, files

# spawn the new process
spawn = require('child_process').spawn
proc = spawn 'node', args

# log output and errors
logBuffer = (buffer) -> console.log buffer.toString()
proc.stdout.on 'data', logBuffer
proc.stderr.on 'data', logBuffer

# exit process
proc.on 'exit', (code, signal) ->
process.exit(1) if code > 0
# console.log 'child process terminated due to receipt of code ' + code



task 'supervisor', 'Watch source files and restart the server upon changes', (o) ->

console.log "\n=== SUPERVISOR ==="
Expand Down Expand Up @@ -193,7 +236,7 @@ task 'mkdir', 'Create directories and set permissions', ->

fs = require 'fs'
path = require 'path'
directories = ['public/uploads', 'logs', 'build']
directories = ['public/uploads', 'logs', 'build', 'tmp']

directories.forEach (dir) ->
fs.mkdirSync dir unless path.existsSync dir
Expand All @@ -204,4 +247,4 @@ task 'mkdir', 'Create directories and set permissions', ->
task 'start', 'Build and run all scripts', (options) ->
options.watch = true
setTimeout (-> invoke 'build'), 0
setTimeout (-> invoke('supervisor')), 3000
setTimeout (-> invoke('supervisor')), 4000
17 changes: 17 additions & 0 deletions config.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@
"permissions": ["email", "user_website"]
},

"mailer": {
"name": "",
"email": "",
"username": "",
"password": "",
"imap": {
"host": "",
"port": 143,
"secure": false
},
"smtp": {
"host": "",
"port": 25,
"ssl": false
}
},

"mongodb": "mongodb://localhost/l4c",

"port": 3000,
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
"gravatar": ">= 1.0.6",
"gm": "*",
"imagemagick": ">= 0.1.2",
"imap": "*",
"invoke": ">= 0.1.0",
"jade": ">= 0.20.3",
"mailparser": "*",
"marked": ">= 0.2.1",
"moment": ">= 1.4.0",
"mongoose": ">= 2.5.9",
Expand Down
2 changes: 1 addition & 1 deletion src/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ app.post '/fotos/publicar', middleware.auth, (req, res, next) ->
# image upload - move file from /tmp to /public/uploads
# image manipulation - resize & crop images asynchronously
.then (data, callback) ->
photo.upload_photo file, (err) ->
photo.upload_photo file.path, (err) ->
return callback err if err
photo.resize_photos callback

Expand Down
14 changes: 7 additions & 7 deletions src/models/photo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ methods =
graphicsmagick = ->
gm = require 'gm'
if size.action == 'resize'
console.log "photo resize start #{size.size}"
console.log "photo resize start #{size.size} - #{doc._id}_#{size.size}.#{doc.ext}"
gm(src).autoOrient().resize(size.width, size.height).write(dest, callback)
else if size.action == 'crop'
console.log "photo crop start #{size.size}"
console.log "photo crop start #{size.size} - #{doc._id}_#{size.size}.#{doc.ext}"
gm(src).autoOrient().thumb size.width, size.height, dest, 80 , ->
gm(dest).crop(size.width, size.height).write(dest, callback)
else
Expand All @@ -102,8 +102,8 @@ methods =
queue.rescue next
queue.end null, (data) -> next(null, data)

upload_photo: (file, next) ->
console.log 'photo upload', file.path
upload_photo: (file_path, next) ->
console.log 'photo upload', file_path

doc = this
upload_path = nodejs_path.normalize "#{__dirname}/../../public/uploads/#{doc._id}_o.#{doc.ext}"
Expand All @@ -114,8 +114,8 @@ methods =
util.pump origin, upload, (err) ->
fs.unlink path1, (err) -> next err

fs.rename file.path, upload_path, (err) ->
return alternate_upload file.path, upload_path if err
fs.rename file_path, upload_path, (err) ->
return alternate_upload file_path, upload_path if err
next err

pretty_date: () ->
Expand Down Expand Up @@ -172,7 +172,7 @@ photo = new Schema
slug:
# required: true
type: String
unique: true
# unique: true
views:
default: 0
type: Number
Expand Down

0 comments on commit 5edf8f5

Please sign in to comment.