@@ -135,6 +135,11 @@ module.exports.prototype = { | |||
this.end(JSON.stringify(obj)); | |||
}, | |||
err404: function() { | |||
this.setStatus(404); | |||
this.end(this.view("404")); | |||
}, | |||
template: function(name, args) { | |||
var str = this.templates[name]; | |||
if (!str) | |||
@@ -148,9 +153,6 @@ module.exports.prototype = { | |||
if (!str) | |||
throw new Error("No such view: "+name); | |||
if (name === "404") | |||
this.setStatus(404); | |||
return templatify(str, args, this, {view: name}); | |||
}, | |||
@@ -1,6 +1,6 @@ | |||
var vals = { | |||
env: "[^\\s}]+#[^\\s}]+", | |||
string: "\"[^\"}]+\"" | |||
string: "'[^'}]*'" | |||
} | |||
//Get regex for all values |
@@ -1,4 +1,5 @@ | |||
<div class="collection"> | |||
<span class="date-created">{{arg#date_created}}</span> | |||
<a class="name" href="/view?{{arg#id}}">{{arg#name}}</a> | |||
{{arg#own_profile ? '<button class="delete btn btn-default">X</button>' : ''}} | |||
</div> |
@@ -1,4 +1,4 @@ | |||
<div class="image"> | |||
<div class="image small-width bordered"> | |||
<div class="title">{{arg#title}}</div> | |||
<a href="/i?{{arg#id}}.{{arg#extension}}"> | |||
<img class="img-rounded" src="/i?{{arg#id}}.{{arg#extension}}"> |
@@ -12,7 +12,7 @@ | |||
<button class="btn btn-default" onclick="$('#uploader-input').click()" id="uploader-select-files"> | |||
Select Files | |||
</button> | |||
<input type="text" id="uploader-collection-name" placeholder="Collection"> | |||
<input type="text" id="uploader-collection-name" placeholder="Collection Name"> | |||
<button class="btn btn-default" id="uploader-upload" disabled> | |||
Upload | |||
</button> |
@@ -8,7 +8,7 @@ | |||
<div id="profile" class="container small-width-container"> | |||
<div class="title">{{arg#username}}</div> | |||
<div id="collections" class="container small-width"> | |||
<div id="collections" class="container small-width bordered"> | |||
{{noescape#collections}} | |||
</div> | |||
</div> |
@@ -7,7 +7,7 @@ | |||
{{template#body}} | |||
<div id="register" class="container small-width-container"> | |||
<form id="register-form" class="container small-width"> | |||
<form id="register-form" class="container small-width bordered"> | |||
<div class="form-group"> | |||
<label>Username<br> | |||
<input type="text" id="register-username"> |
@@ -9,13 +9,13 @@ | |||
<div id="settings" class="container small-width-container"> | |||
<div class="title" href="/profile?{{session#userId}}">{{session#username}}</div> | |||
<form id="collections-form" class="container small-width"> | |||
<form id="collections-form" class="container small-width bordered"> | |||
<div class="title">My Collections</div> | |||
<div class="submit-container"> | |||
<a class="btn btn-default" href="/profile?{{session#userId}}">My Collections</a> | |||
</div> | |||
</form> | |||
<form id="password-form" class="container small-width"> | |||
<form id="password-form" class="container small-width bordered"> | |||
<div class="title">Change Password</div> | |||
<div class="form-group"> | |||
<label>Old Password<br> | |||
@@ -37,7 +37,7 @@ | |||
</div> | |||
</form> | |||
<form id="logout-form" class="container small-width"> | |||
<form id="logout-form" class="container small-width bordered"> | |||
<div class="title">Log Out</div> | |||
<div class="submit-container"> | |||
<button type="submit" class="btn btn-default">Log Out</button> |
@@ -6,7 +6,7 @@ | |||
<body> | |||
{{template#body}} | |||
<div id="viewer" class="container"> | |||
<div id="viewer" class="container small-width-container"> | |||
{{noescape#images}} | |||
</div> | |||
</body> |
@@ -1,3 +1,3 @@ | |||
module.exports = function(ctx) { | |||
ctx.end(ctx.view("404")); | |||
ctx.err404(); | |||
} |
@@ -23,7 +23,6 @@ module.exports = function(ctx) { | |||
} else if (favicon) { | |||
ctx.res.end(favicon); | |||
} else { | |||
ctx.res.writeHead(404); | |||
ctx.end(ctx.view("404")); | |||
ctx.err404(); | |||
} | |||
} |
@@ -36,11 +36,11 @@ form input[type="password"] { | |||
form label { | |||
width: 100%; | |||
} | |||
form.container { | |||
.bordered { | |||
border: 1px solid #CCC; | |||
border-radius: 4px; | |||
padding: 10px !important; | |||
margin-bottom: 10px; | |||
} | |||
.title { | |||
@@ -55,8 +55,10 @@ form.container { | |||
.small-width { | |||
width: auto !important; | |||
text-align: left !important; | |||
max-width: 400px !important; | |||
max-width: 540px !important; | |||
width: 90% !important; | |||
margin-left: auto; | |||
margin-right: auto; | |||
} | |||
#notify-box { |
@@ -3,7 +3,7 @@ var fs = require("fs"); | |||
module.exports = function(ctx) { | |||
var id = ctx.query.replace(/\..*/, ""); | |||
if (!id) | |||
return ctx.end(ctx.view("404")); | |||
return ctx.err404(); | |||
ctx.res.setHeader( | |||
"Cache-Control", | |||
@@ -15,7 +15,7 @@ module.exports = function(ctx) { | |||
readStream.on("error", function(err){ | |||
if (err.code === "ENOENT") | |||
ctx.end(ctx.view("404")); | |||
ctx.err404(); | |||
else | |||
ctx.end(err.toString()); | |||
}); |
@@ -1,5 +1,8 @@ | |||
module.exports = function(ctx) { | |||
var id = ctx.query; | |||
var id = parseInt(ctx.query); | |||
if (isNaN(id)) | |||
return ctx.err404(); | |||
ctx.db.query( | |||
"SELECT name, date_created, id "+ | |||
@@ -22,11 +25,11 @@ module.exports = function(ctx) { | |||
return ctx.fail(err); | |||
if (!res.collections || !res.users) | |||
return ctx.end(ctx.view("404")); | |||
return ctx.err404(); | |||
var user = res.users.rows[0]; | |||
if (!user) | |||
return ctx.end(ctx.view("404")); | |||
return ctx.err404(); | |||
var collections = ""; | |||
res.collections.rows.forEach(function(row) { | |||
@@ -35,7 +38,8 @@ module.exports = function(ctx) { | |||
collections += ctx.template("collection", { | |||
name: row.name, | |||
date_created: d.toString(), | |||
id: row.id | |||
id: row.id, | |||
own_profile: (ctx.session.userId === id) | |||
}); | |||
}); | |||
@@ -0,0 +1,27 @@ | |||
.collection { | |||
height: 45px; | |||
white-space: nowrap; | |||
box-sizing: content-box; | |||
padding-bottom: 1px; | |||
border-bottom: 1px solid #CCC; | |||
} | |||
.collection:last-child { | |||
border: none; | |||
} | |||
.collection .date-created, | |||
.collection .name { | |||
line-height: 45px; | |||
display: inline-block; | |||
overflow: hidden; | |||
white-space: nowrap; | |||
text-overflow: ellipsis; | |||
vertical-align: middle; | |||
} | |||
.collection .date-created { | |||
width: 45%; | |||
} | |||
.collection .name { | |||
width: calc(55% - 43px); | |||
} |
@@ -1,6 +1,6 @@ | |||
module.exports = function(ctx) { | |||
if (!ctx.session.loggedIn) | |||
return ctx.end(ctx.view("404")); | |||
return ctx.err404(); | |||
ctx.end(ctx.view("settings")); | |||
} |
@@ -2,7 +2,7 @@ module.exports = function(ctx) { | |||
var id = parseInt(ctx.query); | |||
if (isNaN(id)) | |||
return ctx.end(ctx.view("404")); | |||
return ctx.err404(); | |||
ctx.db.query( | |||
"SELECT id, name, description, extension "+ | |||
@@ -17,7 +17,7 @@ module.exports = function(ctx) { | |||
return ctx.fail(err); | |||
if (!res.rows[0]) | |||
return ctx.end(ctx.view("404")); | |||
return ctx.err404(); | |||
var images = ""; | |||
res.rows.forEach(function(row) { |
@@ -1,18 +1,9 @@ | |||
#viewer { | |||
max-width: 400px; | |||
#viewer .image { | |||
margin-bottom: 20px; | |||
} | |||
#viewer .image img { | |||
width: 100%; | |||
} | |||
#viewer .image .url { | |||
width: 100%; | |||
} | |||
#viewer .image { | |||
margin-bottom: 20px; | |||
border: 1px solid #CCC; | |||
border-radius: 4px; | |||
padding: 6px; | |||
} |