Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all dependencies to most recent versions #106

Merged
merged 1 commit into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The included test application currently allows you to
* query a list of available configuration options
* query the values of specific configuration options

The test suite can be run using `npm test`. There's also a small test application in `test/test-server.coffee` which runs on `http://localhost:1337` and allows to change camera settings and to take pictures.
The test suite can be run using `npm test`. There's also a small test application (`npx coffee examples/server.coffee`) which runs on `http://localhost:1337` and allows to change camera settings and to take pictures.

## Prerequisites

Expand Down
10 changes: 5 additions & 5 deletions examples/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
stopPreview: ()->
$('#img').unbind('load')
loadSettings: (cb)=>
request.get '/settings', (settings)=>
request.get('/settings').then (settings)=>
cb JSON.parse(settings.text) if cb

enumSettings: (settings, gui)=>
Expand All @@ -40,14 +40,14 @@
foo[val.label] = val.value
changeFn = (newValue)->
console.log val.label, "changed to", newValue
request.put "/settings/#{key}", newValue:newValue, (response)->
request.put("/settings/#{key}", newValue:newValue).then (response)->
console.log response
if val.type is 'string'
gui.add(foo, val.label).onChange changeFn
else if val.type is 'toggle'
foo[val.label] = val.value != 0
gui.add(foo, val.label).onChange (newValue)->
request.put "/settings/#{key}", newValue: (if newValue then 1 else 0), (response)->
request.put("/settings/#{key}", newValue: (if newValue then 1 else 0)).then (response)->
console.log response
else if val.type is 'choice'
gui.add(foo, val.label, val.choices).onChange(changeFn)
Expand All @@ -61,7 +61,7 @@
'Start live preview' : ()=>
@startPreview()
'Take picture': ()=>
request.get 'takePicture', download:false, (res)=>
request.get('takePicture', download:false).then (res)=>
console.log res
if res.text
$('<a>').attr('href', res.text).text(res.text).appendTo($('#downloads')).css('display':'block')
Expand All @@ -75,7 +75,7 @@
window.gphoto.displaySettings()
</script>
</script>
<script type="text/javascript" src="/js/coffee-script.js"></script>
<script type="text/javascript" src="/js/coffeescript.js"></script>

</body>
</html>
25 changes: 0 additions & 25 deletions examples/public/js/coffee-script.js

This file was deleted.

8 changes: 8 additions & 0 deletions examples/public/js/coffeescript.js

Large diffs are not rendered by default.

25 changes: 13 additions & 12 deletions examples/server.coffee
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
process.title = 'node-gphoto2 test program'
global[id] ?= require name for id, name of {
"fs"
"GPhoto":"../"
"GPhoto": "../"
"express"
"bodyParser": "body-parser"
_: "underscore"
}

Expand Down Expand Up @@ -30,9 +31,9 @@ gphoto.list (cameras)->
app = express()

app.use express.static __dirname + '/public'
app.use express.bodyParser()
app.use bodyParser.json()

app.engine '.html', require('jade').__express
app.engine '.html', require('pug').__express
app.get '/', (req, res)->
res.render 'index.html'

Expand All @@ -49,42 +50,42 @@ logRequests = ()->
# save configuration
app.put '/settings/:name', (req, res)->
unless camera
res.send 404, 'Camera not connected'
res.status(404).send 'Camera not connected'
else
camera.setConfigValue req.params.name, req.body.newValue, (er)->
if er
res.send 404, JSON.stringify(er)
res.status(404).send JSON.stringify(er)
else
res.send 200
res.sendStatus 200

# get configuration
app.get '/settings', (req, res)->
unless camera
res.send 404, 'Camera not connected'
res.status(404).send 'Camera not connected'
else
camera.getConfig (er, settings)->
res.send JSON.stringify(settings)

app.get '/download/*', (req, res)->
unless camera
res.send 404, 'Camera not connected'
res.status(404).send 'Camera not connected'
else
if (match = req.url.match /download(.*)$/) and (path = match[1])
console.log "trying to DL #{path}"
camera.downloadPicture {cameraPath: path}, (er, data)->
if er
res.send 404, er
res.status(404).send er
else
res.header 'Content-Type', 'image/jpeg'
res.send data

app.get '/takePicture', (req, res)->
unless camera
res.send 404, 'Camera not connected'
res.status(404).send 'Camera not connected'
else
camera.takePicture download:(if req.query.download is 'false' then false else true), (er, data)->
if er
res.send 404, er
res.status(404).send er
else
if req.query.download is 'false'
console.log data
Expand All @@ -95,7 +96,7 @@ app.get '/takePicture', (req, res)->

app.get '/preview*', (req, res)->
unless camera
res.send 404, 'Camera not connected'
res.status(404).send 'Camera not connected'
else
preview_listeners.push res
if preview_listeners.length is 1
Expand Down
Loading