From 8313e7b006fa365f7d942319f79e55318094f086 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 25 Jan 2014 13:55:00 -0600 Subject: [PATCH] Add HTML template config, fixes to account profile page --- config.template.yaml | 5 +++++ lib/config.js | 4 ++++ lib/web/jade.js | 34 +++++++++++----------------------- templates/account-profile.jade | 2 +- templates/nav.jade | 2 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/config.template.yaml b/config.template.yaml index b96a7c4a..6dcfb80a 100644 --- a/config.template.yaml +++ b/config.template.yaml @@ -24,6 +24,11 @@ https: passphrase: '' certfile: 'localhost.cert' +# Page template values +html-template: + title: 'CyTube', + description: 'Free, open source synchtube' + # Socket.IO server details io: port: 1337 diff --git a/lib/config.js b/lib/config.js index ab6a33f7..363ce766 100644 --- a/lib/config.js +++ b/lib/config.js @@ -57,6 +57,10 @@ var defaults = { aliases: { "purge-interval": 3600000, "max-age": 2592000000 + }, + "html-template": { + title: "CyTube Beta", + description: "Free, open source synchtube" } }; diff --git a/lib/web/jade.js b/lib/web/jade.js index f8080936..13477606 100644 --- a/lib/web/jade.js +++ b/lib/web/jade.js @@ -1,29 +1,21 @@ -/** - * web/jade.js - Provides functionality for rendering/serving jade templates - * - * @author Calvin Montgomery - */ - -var jade = require('jade'); -var fs = require('fs'); -var path = require('path'); -var templates = path.join(__dirname, '..', '..', 'templates'); +var jade = require("jade"); +var fs = require("fs"); +var path = require("path"); +var Config = require("../config"); +var templates = path.join(__dirname, "..", "..", "templates"); var cache = {}; /** * Merges locals with globals for jade rendering - * - * @param {Object} locals - The locals to merge - * @return {Object} an object containing globals and locals */ function merge(locals) { var _locals = { - siteTitle: 'CyTube Beta', - siteDescription: 'Free, open source synchtube', - siteAuthor: 'Calvin "calzoneman" "cyzon" Montgomery' + siteTitle: Config.get("html-template.title"), + siteDescription: Config.get("html-template.description"), + siteAuthor: "Calvin 'calzoneman' 'cyzon' Montgomery" }; - if (typeof locals !== 'object') { + if (typeof locals !== "object") { return _locals; } for (var key in locals) { @@ -34,14 +26,10 @@ function merge(locals) { /** * Renders and serves a jade template - * - * @param res - The HTTP response - * @param view - The view to render - * @param locals - The locals to pass to the renderer */ function sendJade(res, view, locals) { - if (!(view in cache) || process.env['DEBUG']) { - var file = path.join(templates, view + '.jade'); + if (!(view in cache) || process.env["DEBUG"]) { + var file = path.join(templates, view + ".jade"); var fn = jade.compile(fs.readFileSync(file), { filename: file, pretty: true diff --git a/templates/account-profile.jade b/templates/account-profile.jade index ef7025ea..2ae096f6 100644 --- a/templates/account-profile.jade +++ b/templates/account-profile.jade @@ -26,7 +26,7 @@ html(lang="en") .alert.alert-danger.center.messagebox strong Profile Error p= profileError - .profile-box(style="position: inherit") + .profile-box(style="position: inherit; z-index: auto;") img.profile-image(src=profileImage) strong= loginName p= profileText diff --git a/templates/nav.jade b/templates/nav.jade index 9a81e666..b75939d1 100644 --- a/templates/nav.jade +++ b/templates/nav.jade @@ -29,7 +29,7 @@ mixin navdefaultlinks(page) if loggedIn li: a(href="/logout?redirect=#{page}") Logout li.divider - li: a(href="/account/channels") My Channels + li: a(href="/account/channels") Channels li: a(href="/account/profile") Profile li: a(href="/account/edit") Change Password/Email else