Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

Commit

Permalink
just left-indent
Browse files Browse the repository at this point in the history
  • Loading branch information
tmtk75 committed Jun 22, 2013
1 parent 8fb448f commit 6589963
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions routes/api.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,50 @@ _400_if_not_have = (res, str, vals)->
true

_diagrams = (is_post, jmcode, req, res)->
temp.open "jumly", (err, info)->
temp.open "jumly", (err, info)->
throw err if err

fs.write info.fd, jmcode
fs.close info.fd, (err)->
throw err if err

fs.write info.fd, jmcode
fs.close info.fd, (err)->
throw err if err
if is_post
#req.headers["content-type"].match /(^[^\/]+)\/([^+]+)\+?(.*)$/
[_, encoding, format, base64] = req.headers["accept"].match /(^[^\/]+)\/([^;]+)(;.*)?$/
encoding = "base64" if base64 is ";base64" and encoding.match /image/i
encoding = "html" if encoding.match(/^text$/i) and format.match(/^html$/i)
format = "png" if format is "*"
encoding = "image" if encoding is "*"

if is_post
#req.headers["content-type"].match /(^[^\/]+)\/([^+]+)\+?(.*)$/
[_, encoding, format, base64] = req.headers["accept"].match /(^[^\/]+)\/([^;]+)(;.*)?$/
encoding = "base64" if base64 is ";base64" and encoding.match /image/i
encoding = "html" if encoding.match(/^text$/i) and format.match(/^html$/i)
format = "png" if format is "*"
encoding = "image" if encoding is "*"
return if _400_if_not_have res, encoding, ["image", "base64", "html"]
return if _400_if_not_have res, format, ["png", "gif", "jpg", "jpeg", "html"]
else
format = "png"
encoding = "image"

return if _400_if_not_have res, encoding, ["image", "base64", "html"]
return if _400_if_not_have res, format, ["png", "gif", "jpg", "jpeg", "html"]
else
format = "png"
encoding = "image"
## jumly.sh prints tmpfile path to stdout if it creates image file
filepath = ""
if encoding.match /image/ ## jumly.sh prints the filepath to stdout
stdouth = (data)-> filepath += data
else
stdouth = (data)-> res.write data

## jumly.sh prints tmpfile path to stdout if it creates image file
filepath = ""
if encoding.match /image/ ## jumly.sh prints the filepath to stdout
stdouth = (data)-> filepath += data
else
stdouth = (data)-> res.write data
## exec jumly.sh
proc = child_process.spawn "#{__dirname}/../bin/jumly.sh", [info.path, format, encoding]
proc.stdout.on 'data', stdouth
proc.stderr.on 'data', (data)-> res.write data

## exec jumly.sh
proc = child_process.spawn "#{__dirname}/../bin/jumly.sh", [info.path, format, encoding]
proc.stdout.on 'data', stdouth
proc.stderr.on 'data', (data)-> res.write data

proc.on 'close', (code)->
if filepath
fs.readFile filepath.trim(), flags:"rb", (err, data)->
throw err if err
res.write data
res.end()
_unlink info.path
_unlink filepath.trim()
else
proc.on 'close', (code)->
if filepath
fs.readFile filepath.trim(), flags:"rb", (err, data)->
throw err if err
res.write data
res.end()
_unlink info.path
_unlink filepath.trim()
else
res.end()
_unlink info.path

module.exports = (ctx)->
b64decode: (req, res)->
Expand Down

0 comments on commit 6589963

Please sign in to comment.