Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged with upstream.

Signed-off-by: Peter Friese <peter.friese@itemis.de>
  • Loading branch information...
commit d2f8d2e2efff96652a782eb33c2ca09181360242 1 parent 21ee616
@peterfriese authored
View
6 examples/db-browser/app.js
@@ -3,7 +3,7 @@ var consumer_key = process.argv[2]
, consumer_secret = process.argv[3];
if (consumer_key == undefined || consumer_secret == undefined) {
- console.log("Usage: node app.js <dropbox key> <dropbox secret>");
+ console.log("Usage: node app.js <dropbox key> <dropbox secret>\n (You can get a dropbox key / secret at http://www.dropbox.com/developers/)");
process.exit(1);
}
@@ -14,8 +14,10 @@ var sys = require('sys')
// Create and configure an Express server.
var app = express.createServer();
+var pub = __dirname + '/public';
app.configure(function () {
- app.use(express.staticProvider(__dirname + '/public'))
+ app.use(express.staticProvider(pub))
+ , app.use(express.compiler({ src: pub, enable: ['sass'] }))
, app.use(express.logger())
, app.use(express.bodyDecoder())
, app.use(express.cookieDecoder())
View
0  examples/db-browser/static/style.sass → examples/db-browser/public/style.sass
File renamed without changes
View
75 examples/db-browser/server.js
@@ -1,75 +0,0 @@
-// read dropbox key and secret from the command line:
-var consumer_key = process.argv[2];
-var consumer_secret = process.argv[3];
-
-if (consumer_key == undefined || consumer_secret == undefined) {
- console.log("Please invoke with node server.js <dropbox key> <dropbox secret>");
- process.exit(1);
-}
-
-var sys = require('sys'),
- DropboxClient = require('../../lib/dropbox-node').DropboxClient,
- express = require('express'),
- app = express.createServer();
-
-// "static" will contain the static resources
-var pub = __dirname + '/static';
-
-// create and configure an express server
-var app = express.createServer(
- express.compiler({ src: pub, enable: ['sass'] }),
- express.staticProvider(pub),
- express.logger(),
- express.bodyDecoder(),
- express.cookieDecoder(),
- express.session({key: 'skey',
- secret: '1ts-s3cr3t!'})
-);
-
-// use Jade as our default template engine
-app.set('view engine', 'jade');
-
-// further app configuration
-app.configure(function(){
- app.set('views', __dirname + '/views');
-});
-
-// Login page.
-app.get('/', function (req, res) {
- res.render('login', {
- locals: {
- title: 'Dropbox File Browser'
- }
- })
-})
-
-// Dropbox credential processing.
-app.post('/process_creds', function (req, res) {
- // Create a DropboxClient and initialize it with an access token pair.
- req.session.db = new DropboxClient(consumer_key, consumer_secret)
- req.session.db.getAccessToken(req.body.email, req.body.password, function (err) {
- if (err) return console.log('Error: ' + sys.inspect(err))
- res.redirect('/file_browser')
- })
-})
-
-// File browser page.
-app.get('/file_browser(/*)?', function (req, res) {
- // Fetch target metadata and render the page.
- if (req.session.db) {
- req.session.db.getMetadata(req.params[1] || '', function (err, metadata) {
- if (err) return console.log('Error: ' + sys.inspect(err))
- // NOTE: Use this to strip leading path(s): str.replace(/^.*\//g, '')
- res.render('file_browser', {
- locals: {
- title: 'Dropbox File Browser',
- current_dir: (metadata.path.length > 0) ? metadata.path : 'root',
- items: metadata.contents
- }
- })
- })
- } else res.redirect('home')
-})
-
-app.listen(3000);
-console.log('Dropbox browser server running on port ' + app.address().port);
View
27 examples/db-browser/static/style.css
@@ -1,27 +0,0 @@
-body {
- font-family: "Gill Sans", Verdana;
- font-size: 13px;
- padding: 0;
- background-color: #fff;}
-
-div#wrapper {
- margin: 0 auto;
- padding: 25px;
- width: 500px;
- border: 3px solid #eee;
- background-color: #fefefe;}
-
-h1 {
- font-size: 24px;
- color: #333;}
-
-label {
- float: left;
- width: 5em;
- margin-right: 1em;}
-
-input.submit {
- line-height: 16px;
- background-color: #eee;
- border: 1px solid;
- border-color: #111;}
Please sign in to comment.
Something went wrong with that request. Please try again.