From 05b91caf6c325d9e036b35e49f7ecfac3a2362a6 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 14 Jun 2013 13:01:24 -0400 Subject: [PATCH] noscript for home and category view (although it's not quite working for category view yet) --- app.js | 2 +- public/css/noscript.less | 49 ++++++++++++++++++++++---- public/src/modules/composer.js | 10 +++--- public/templates/category.tpl | 2 +- public/templates/noscript/category.tpl | 18 ++++++++++ public/templates/noscript/header.tpl | 8 +++++ public/templates/noscript/home.tpl | 10 ++++++ public/templates/noscript/topic.tpl | 8 ----- src/webserver.js | 25 +++++++++++-- 9 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 public/templates/noscript/category.tpl create mode 100644 public/templates/noscript/header.tpl create mode 100644 public/templates/noscript/home.tpl diff --git a/app.js b/app.js index 7d4f854087..64973f2ccb 100644 --- a/app.js +++ b/app.js @@ -51,7 +51,7 @@ fs.readFile(path.join(__dirname, 'config.json'), function(err, data) { 'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext', 'emails/header', 'emails/footer', 'install/header', 'install/footer', 'install/redis', - 'noscript/topic' + 'noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic' ]); templates.ready(function() { diff --git a/public/css/noscript.less b/public/css/noscript.less index 0c9ddd3ebb..3e5508e560 100644 --- a/public/css/noscript.less +++ b/public/css/noscript.less @@ -1,15 +1,50 @@ @import "mixins"; noscript { - .posts { - li { - list-style-type: none; - padding: 1em; - margin-bottom: 1em; + .default { + list-style-type: none; + padding: 1em; + margin-bottom: 1em; - &:nth-child(even) { - background: rgba(192,192,192,0.2); + &:nth-child(even) { + background: rgba(191,191,191,0.2); + } + + &:nth-child(odd) { + background: rgba(223,223,223,0.2); + } + } + + .categories { + li { + .default; + + .icon { + float: left; + margin-right: 1em; + } + + a { + font-size: 20px; } } } + + .topics { + li { + .default; + } + + .teaser { + img { + float: left; + } + } + } + + .posts { + li { + .default; + } + } } \ No newline at end of file diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index 50a2673fe5..459a3269cf 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -19,7 +19,7 @@ define(function() { composer.postContainer = document.createElement('div'); composer.postContainer.className = 'post-window row-fluid'; composer.postContainer.innerHTML = '
' + - '' + + '' + '
' + '
' + '' + @@ -28,12 +28,12 @@ define(function() { '' + '
' + '
' + - '' + - '' + - '' + + '' + + '' + + '' + '
' + '
' + - '' + + '' + '
'; composer.listEl = composer.btnContainer.querySelector('ul'); diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 38fa7a059f..b43c11cf62 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -24,7 +24,7 @@
- +

{topics.teaser_username}: {topics.teaser_text}

posted {topics.teaser_timestamp} ago
diff --git a/public/templates/noscript/category.tpl b/public/templates/noscript/category.tpl new file mode 100644 index 0000000000..00728916b0 --- /dev/null +++ b/public/templates/noscript/category.tpl @@ -0,0 +1,18 @@ + +
    + +
  • + {topics.title} +
    + +

    + {topics.teaser_text} — {topics.teaser_timestamp} ago +

    +
    +
  • + +
\ No newline at end of file diff --git a/public/templates/noscript/header.tpl b/public/templates/noscript/header.tpl new file mode 100644 index 0000000000..83be5b0fbc --- /dev/null +++ b/public/templates/noscript/header.tpl @@ -0,0 +1,8 @@ +
+

+ Your browser does not seem to support javascript. As a result, your viewing experience will be diminished. +

+

+ Please download a browser that supports javascript, or enable it, if it disabled (i.e. NoScript). +

+
diff --git a/public/templates/noscript/home.tpl b/public/templates/noscript/home.tpl new file mode 100644 index 0000000000..9a307c8583 --- /dev/null +++ b/public/templates/noscript/home.tpl @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/public/templates/noscript/topic.tpl b/public/templates/noscript/topic.tpl index a5d6743af8..b1581ddbe6 100644 --- a/public/templates/noscript/topic.tpl +++ b/public/templates/noscript/topic.tpl @@ -1,11 +1,3 @@ -
-

- Your browser does not seem to support javascript. As a result, your viewing experience will be diminished. -

-

- Please download a browser that supports javascript, or enable it, if it disabled (i.e. NoScript). -

-
  • diff --git a/src/webserver.js b/src/webserver.js index bde5fa480c..a4f9592d2b 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -78,7 +78,7 @@ var express = require('express'), // Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section) (function() { - var routes = ['', 'login', 'register', 'account', 'latest', 'popular', 'active', '403', '404']; + var routes = ['login', 'register', 'account', 'latest', 'popular', 'active', '403', '404']; for (var i=0, ii=routes.length; i\n' + templates['noscript/header'] + templates['noscript/home'].parse(returnData) + '\n\t' + + app.create_route('') + + templates['footer'] + ); + }, 0); + }); + app.get('/topic/:topic_id/:slug?', function(req, res) { var tid = req.params.topic_id; if (tid.match('.rss')) { @@ -117,7 +128,7 @@ var express = require('express'), topics.getTopicById(tid, ((req.user) ? req.user.uid : 0), function(topic) { res.send( build_header() + - '\n\t' + + '\n\t' + '\n\t' + templates['footer'] ); @@ -141,7 +152,15 @@ var express = require('express'), } var category_url = cid + (req.params.slug ? '/' + req.params.slug : ''); - res.send(build_header() + '' + templates['footer']); + categories.getCategoryById(cid, 0, function(returnData) { + console.log(returnData); + res.send( + build_header() + + '\n\t' + + '\n\t' + + templates['footer'] + ); + }); }); app.get('/confirm/:code', function(req, res) {