Skip to content

Commit

Permalink
prettify code - formatting, indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
madhums committed Mar 3, 2012
1 parent 1b8cbca commit 89f13e6
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions lib/imager.js
@@ -1,18 +1,18 @@
var formidable = require('formidable'),
util = require('util'),
im = require('imagemagick'),
fs = require('fs'),
path = require('path'),
cloudfiles = require('cloudfiles')

var config_file = '../imager-example.json',
config = {},
client = undefined,
container = undefined,
uploaddir = undefined,
storage_type = undefined,
scope = undefined,
cdnUri = undefined
var formidable = require('formidable')
, util = require('util')
, im = require('imagemagick')
, fs = require('fs')
, path = require('path')
, cloudfiles = require('cloudfiles')

var config_file = '../imager-example.json'
, config = {}
, client = undefined
, container = undefined
, uploaddir = undefined
, storage_type = undefined
, scope = undefined
, cdnUri = undefined


var Imager = exports = module.exports = function Imager(options) {
Expand Down Expand Up @@ -50,10 +50,10 @@ Imager.prototype = {

, remove: function(file, callback, _scope) {
scope = (arguments.length == 3) ? _scope : undefined
var _variants = this.setupVariants()

var _resize = _variants['resize']
var _crop = _variants['crop']
var _variants = this.setupVariants()
, _resize = _variants['resize']
, _crop = _variants['crop']

for(version in _resize) {
eval('this.' + storage_type + 'Remove')( this.genFileName( file, version ), function(err) {
Expand Down Expand Up @@ -90,8 +90,6 @@ Imager.prototype = {
, fields = []
, new_file = undefined

//form.uploadDir = './tmp'

form
.on('field', function(field, value) {
fields.push([field, value])
Expand Down Expand Up @@ -125,13 +123,12 @@ Imager.prototype = {
, makeVariants: function(file, callback) {

var _this = this
var _variants = this.setupVariants()

var _resize = _variants["resize"] || JSON.parse( JSON.stringify({"null" : "null"}) )
var _crop = _variants["crop"] || JSON.parse( JSON.stringify({"null" : "null"}) )
, _variants = this.setupVariants()
, _resize = _variants["resize"] || JSON.parse( JSON.stringify({"null" : "null"}) )
, _crop = _variants["crop"] || JSON.parse( JSON.stringify({"null" : "null"}) )
, new_file = Math.round(new Date().getTime())
, ext = this.setExtension(file['type'])

var new_file = Math.round(new Date().getTime())
var ext = this.setExtension(file['type'])
new_file += ext

var i = 0
Expand All @@ -156,7 +153,7 @@ Imager.prototype = {

, setupVariants: function() {
var resize = (typeof scope === 'undefined') ? config.variants.resize : eval('config.variants.'+scope+'.resize')
var crop = (typeof scope === 'undefined') ? config.variants.crop : eval('config.variants.'+scope+'.crop')
, crop = (typeof scope === 'undefined') ? config.variants.crop : eval('config.variants.'+scope+'.crop')
return { "resize" : resize, "crop" : crop }
}

Expand All @@ -175,6 +172,7 @@ Imager.prototype = {
, 'Content-Length': buf.length
}
, local: sfile }

cdnUri = container.cdnUri
client.addFile(container, options, onUploadToContainer)
}
Expand Down Expand Up @@ -205,8 +203,8 @@ Imager.prototype = {
return callback(null)
}
var _this = this
var dfile = prefix
var tfile = (storage_type == 'dir') ? uploaddir + dfile : file['path'] + prefix
, dfile = prefix
, tfile = (storage_type == 'dir') ? uploaddir + dfile : file['path'] + prefix

eval(action)( this.imOptions(file, tfile, size), function(err, stdout, stderr){
if (storage_type == 'rs') {
Expand Down

0 comments on commit 89f13e6

Please sign in to comment.