aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2012-11-19 21:24:48 -0800
committerAdam Soltys <[email protected]>2012-11-19 21:24:48 -0800
commit105090013ed42b0e262ea747424e25a5005bdb4b (patch)
treecb1d2d1f8d139ca0f0d2bfb66dd08d95dc53d5f3
parent9d275b1487f4d67d0b58db2f2f07221b50275e34 (diff)
downloadcoinos-server-105090013ed42b0e262ea747424e25a5005bdb4b.tar.gz
coinos-server-105090013ed42b0e262ea747424e25a5005bdb4b.zip
Create an edit page
-rw-r--r--app.coffee16
-rw-r--r--public/js/index.coffee9
-rw-r--r--views/index.html2
3 files changed, 26 insertions, 1 deletions
diff --git a/app.coffee b/app.coffee
index 0ede9972..decf269a 100644
--- a/app.coffee
+++ b/app.coffee
@@ -2,6 +2,7 @@ express = require('express')
http = require('http')
path = require('path')
engines = require('consolidate')
+passport = require('passport')
config = require('./config')
app = express()
@@ -74,6 +75,12 @@ app.get('/ticker', (req, res) ->
)
)
+app.post('/login',
+ passport.authenticate('local'),
+ (req, res) ->
+ res.redirect('/users/' + req.user.username)
+)
+
app.post('/users', (req, res) ->
if req.body.login
db = require("redis").createClient()
@@ -113,6 +120,15 @@ app.get('/calculator', (req, res) ->
)
)
+app.get('/:user/edit', (req, res) ->
+ res.render('index',
+ user: req.params.user,
+ js: (-> global.js),
+ css: (-> global.css)
+ )
+)
+
+
app.get('/:user', (req, res) ->
res.render('calculator',
user: req.params.user,
diff --git a/public/js/index.coffee b/public/js/index.coffee
index a5821e90..d53a4e48 100644
--- a/public/js/index.coffee
+++ b/public/js/index.coffee
@@ -17,4 +17,13 @@ $(->
else
$(this).css('color', 'red')
)
+
+ if $('#login').val() != ""
+ $.getJSON('/' + $('#login').val() + '.json', (data) ->
+ $('#name').val(data.name)
+ $('#image').val(data.image)
+ $('#address').val(data.address)
+ $('#symbol option[value=' + data.symbol + ']').attr('selected', 'selected')
+ $('#commission').val(data.commission)
+ )
)
diff --git a/views/index.html b/views/index.html
index 0625dd6f..9e97b16b 100644
--- a/views/index.html
+++ b/views/index.html
@@ -14,7 +14,7 @@
<h1>Calculator Setup</h1>
<label for="login">Alias:</label>
- <input type="text" id="login" name="login" />
+ <input type="text" id="login" name="login" value="{{user}}" />
<label for="name">Title:</label>
<input type="text" id="name" name="name" />