Browse Source

changes to CSS, and cleaned up some code

master
mort 8 years ago
parent
commit
6e7ffec734

+ 5
- 3
lib/context.js View File

this.end(JSON.stringify(obj)); this.end(JSON.stringify(obj));
}, },


err404: function() {
this.setStatus(404);
this.end(this.view("404"));
},

template: function(name, args) { template: function(name, args) {
var str = this.templates[name]; var str = this.templates[name];
if (!str) if (!str)
if (!str) if (!str)
throw new Error("No such view: "+name); throw new Error("No such view: "+name);


if (name === "404")
this.setStatus(404);

return templatify(str, args, this, {view: name}); return templatify(str, args, this, {view: name});
}, },



+ 1
- 1
lib/preprocess.js View File

var vals = { var vals = {
env: "[^\\s}]+#[^\\s}]+", env: "[^\\s}]+#[^\\s}]+",
string: "\"[^\"}]+\""
string: "'[^'}]*'"
} }


//Get regex for all values //Get regex for all values

+ 1
- 0
templates/collection.html View File

<div class="collection"> <div class="collection">
<span class="date-created">{{arg#date_created}}</span> <span class="date-created">{{arg#date_created}}</span>
<a class="name" href="/view?{{arg#id}}">{{arg#name}}</a> <a class="name" href="/view?{{arg#id}}">{{arg#name}}</a>
{{arg#own_profile ? '<button class="delete btn btn-default">X</button>' : ''}}
</div> </div>

+ 1
- 1
templates/image.html View File

<div class="image">
<div class="image small-width bordered">
<div class="title">{{arg#title}}</div> <div class="title">{{arg#title}}</div>
<a href="/i?{{arg#id}}.{{arg#extension}}"> <a href="/i?{{arg#id}}.{{arg#extension}}">
<img class="img-rounded" src="/i?{{arg#id}}.{{arg#extension}}"> <img class="img-rounded" src="/i?{{arg#id}}.{{arg#extension}}">

+ 1
- 1
views/index.html View File

<button class="btn btn-default" onclick="$('#uploader-input').click()" id="uploader-select-files"> <button class="btn btn-default" onclick="$('#uploader-input').click()" id="uploader-select-files">
Select Files Select Files
</button> </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> <button class="btn btn-default" id="uploader-upload" disabled>
Upload Upload
</button> </button>

+ 1
- 1
views/profile.html View File



<div id="profile" class="container small-width-container"> <div id="profile" class="container small-width-container">
<div class="title">{{arg#username}}</div> <div class="title">{{arg#username}}</div>
<div id="collections" class="container small-width">
<div id="collections" class="container small-width bordered">
{{noescape#collections}} {{noescape#collections}}
</div> </div>
</div> </div>

+ 1
- 1
views/register.html View File

{{template#body}} {{template#body}}


<div id="register" class="container small-width-container"> <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"> <div class="form-group">
<label>Username<br> <label>Username<br>
<input type="text" id="register-username"> <input type="text" id="register-username">

+ 3
- 3
views/settings.html View File

<div id="settings" class="container small-width-container"> <div id="settings" class="container small-width-container">
<div class="title" href="/profile?{{session#userId}}">{{session#username}}</div> <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="title">My Collections</div>
<div class="submit-container"> <div class="submit-container">
<a class="btn btn-default" href="/profile?{{session#userId}}">My Collections</a> <a class="btn btn-default" href="/profile?{{session#userId}}">My Collections</a>
</div> </div>
</form> </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="title">Change Password</div>
<div class="form-group"> <div class="form-group">
<label>Old Password<br> <label>Old Password<br>
</div> </div>
</form> </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="title">Log Out</div>
<div class="submit-container"> <div class="submit-container">
<button type="submit" class="btn btn-default">Log Out</button> <button type="submit" class="btn btn-default">Log Out</button>

+ 1
- 1
views/view.html View File

<body> <body>
{{template#body}} {{template#body}}


<div id="viewer" class="container">
<div id="viewer" class="container small-width-container">
{{noescape#images}} {{noescape#images}}
</div> </div>
</body> </body>

+ 1
- 1
web/404.node.js View File

module.exports = function(ctx) { module.exports = function(ctx) {
ctx.end(ctx.view("404"));
ctx.err404();
} }

+ 1
- 2
web/favicon.node.js View File

} else if (favicon) { } else if (favicon) {
ctx.res.end(favicon); ctx.res.end(favicon);
} else { } else {
ctx.res.writeHead(404);
ctx.end(ctx.view("404"));
ctx.err404();
} }
} }

+ 5
- 3
web/global.css View File

form label { form label {
width: 100%; width: 100%;
} }
form.container {

.bordered {
border: 1px solid #CCC; border: 1px solid #CCC;
border-radius: 4px; border-radius: 4px;
padding: 10px !important; padding: 10px !important;
margin-bottom: 10px;
} }


.title { .title {
.small-width { .small-width {
width: auto !important; width: auto !important;
text-align: left !important; text-align: left !important;
max-width: 400px !important;
max-width: 540px !important;
width: 90% !important; width: 90% !important;
margin-left: auto;
margin-right: auto;
} }


#notify-box { #notify-box {

+ 2
- 2
web/i/index.node.js View File

module.exports = function(ctx) { module.exports = function(ctx) {
var id = ctx.query.replace(/\..*/, ""); var id = ctx.query.replace(/\..*/, "");
if (!id) if (!id)
return ctx.end(ctx.view("404"));
return ctx.err404();


ctx.res.setHeader( ctx.res.setHeader(
"Cache-Control", "Cache-Control",


readStream.on("error", function(err){ readStream.on("error", function(err){
if (err.code === "ENOENT") if (err.code === "ENOENT")
ctx.end(ctx.view("404"));
ctx.err404();
else else
ctx.end(err.toString()); ctx.end(err.toString());
}); });

+ 8
- 4
web/profile/index.node.js View File

module.exports = function(ctx) { module.exports = function(ctx) {
var id = ctx.query;
var id = parseInt(ctx.query);

if (isNaN(id))
return ctx.err404();


ctx.db.query( ctx.db.query(
"SELECT name, date_created, id "+ "SELECT name, date_created, id "+
return ctx.fail(err); return ctx.fail(err);


if (!res.collections || !res.users) if (!res.collections || !res.users)
return ctx.end(ctx.view("404"));
return ctx.err404();


var user = res.users.rows[0]; var user = res.users.rows[0];
if (!user) if (!user)
return ctx.end(ctx.view("404"));
return ctx.err404();


var collections = ""; var collections = "";
res.collections.rows.forEach(function(row) { res.collections.rows.forEach(function(row) {
collections += ctx.template("collection", { collections += ctx.template("collection", {
name: row.name, name: row.name,
date_created: d.toString(), date_created: d.toString(),
id: row.id
id: row.id,
own_profile: (ctx.session.userId === id)
}); });
}); });



+ 27
- 0
web/profile/style.css View File

.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
- 1
web/settings/index.node.js View File

module.exports = function(ctx) { module.exports = function(ctx) {
if (!ctx.session.loggedIn) if (!ctx.session.loggedIn)
return ctx.end(ctx.view("404"));
return ctx.err404();


ctx.end(ctx.view("settings")); ctx.end(ctx.view("settings"));
} }

+ 2
- 2
web/view/index.node.js View File

var id = parseInt(ctx.query); var id = parseInt(ctx.query);


if (isNaN(id)) if (isNaN(id))
return ctx.end(ctx.view("404"));
return ctx.err404();


ctx.db.query( ctx.db.query(
"SELECT id, name, description, extension "+ "SELECT id, name, description, extension "+
return ctx.fail(err); return ctx.fail(err);


if (!res.rows[0]) if (!res.rows[0])
return ctx.end(ctx.view("404"));
return ctx.err404();


var images = ""; var images = "";
res.rows.forEach(function(row) { res.rows.forEach(function(row) {

+ 2
- 11
web/view/style.css View File

#viewer {
max-width: 400px;
#viewer .image {
margin-bottom: 20px;
} }

#viewer .image img { #viewer .image img {
width: 100%; width: 100%;
} }

#viewer .image .url { #viewer .image .url {
width: 100%; width: 100%;
} }

#viewer .image {
margin-bottom: 20px;
border: 1px solid #CCC;
border-radius: 4px;
padding: 6px;
}

Loading…
Cancel
Save