Skip to content

Node.js based forum software built for the modern web

adding noscript parsing for a topic, if accessed by a browser without javascript

Julian Lamc0b018cdf4b3
diff --git a/public/css/nodebb.less b/public/css/nodebb.less
index c9423a17b8..78c464f8b4 100644
--- a/public/css/nodebb.less
+++ b/public/css/nodebb.less
@@ -2,3 +2,4 @@
@import "topic";
@import "category";
+@import "noscript";
\ No newline at end of file
diff --git a/public/css/noscript.less b/public/css/noscript.less
new file mode 100644
index 0000000000..0c9ddd3ebb
--- /dev/null
+++ b/public/css/noscript.less
@@ -0,0 +1,15 @@
+@import "mixins";
+
+noscript {
+ .posts {
+ li {
+ list-style-type: none;
+ padding: 1em;
+ margin-bottom: 1em;
+
+ &:nth-child(even) {
+ background: rgba(192,192,192,0.2);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/public/templates/noscript/topic.tpl b/public/templates/noscript/topic.tpl
index 6e5684ea4d..a5d6743af8 100644
--- a/public/templates/noscript/topic.tpl
+++ b/public/templates/noscript/topic.tpl
@@ -1,15 +1,37 @@
-<div class="alert alert-error">
- <p>
- Your browser does not seem to support javascript. As a result, your viewing experience will be diminished.
- </p>
- <p>
- Please download a browser that supports javascript, or enable it, if it disabled (i.e. NoScript).
- </p>
-</div>
-<ul>
- <!-- BEGIN posts -->
- <li>
- Foo: {posts.foo}
- </li>
- <!-- END posts -->
-</ul>
\ No newline at end of file
+ <div class="alert alert-error">
+ <p>
+ Your browser does not seem to support javascript. As a result, your viewing experience will be diminished.
+ </p>
+ <p>
+ Please download a browser that supports javascript, or enable it, if it disabled (i.e. NoScript).
+ </p>
+ </div>
+ <ul class="posts">
+ <!-- BEGIN main_posts -->
+ <li>
+ <div class="row-fluid">
+ <div class="span2">
+ <img src="{main_posts.gravatar}" /><br />
+ {main_posts.username}
+ </div>
+ <div class="span10">
+ {main_posts.content}
+ </div>
+ </div>
+ </li>
+ <!-- END main_posts -->
+ <!-- BEGIN posts -->
+ <li>
+ <div class="row-fluid">
+ <div class="span2">
+ <img src="{posts.gravatar}" /><br />
+ {posts.username}
+ </div>
+ <div class="span10">
+ {posts.content}
+ </div>
+ <div class="clear"></div>
+ </div>
+ </li>
+ <!-- END posts -->
+ </ul>
\ No newline at end of file
diff --git a/src/topics.js b/src/topics.js
index 7a9d5f5923..3819c86494 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -184,16 +184,6 @@ marked.setOptions({
});
}
- Topics.get_posts_noscript = function(tid, current_user, callback) {
- // Topics.get_topic(tid, current_user, function() {
- callback([
- {
- foo: 'bar'
- }
- ]);
- // });
- }
-
Topics.get_cid_by_tid = function(tid, callback) {
RDB.get(schema.topics(tid).cid, function(err, cid) {
if (cid && parseInt(cid) > 0) {
diff --git a/src/webserver.js b/src/webserver.js
index ec03efe542..bde5fa480c 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -114,11 +114,10 @@ var express = require('express'),
var topic_url = tid + (req.params.slug ? '/' + req.params.slug : '');
- topics.get_posts_noscript(tid, ((req.user) ? req.user.uid : 0), function(posts) {
- console.log(posts);
+ topics.getTopicById(tid, ((req.user) ? req.user.uid : 0), function(topic) {
res.send(
build_header() +
- '\n\t<noscript>\n\t\t' + templates['noscript/topic'].parse({ posts: posts }) + '\n\t</noscript>' +
+ '\n\t<noscript>\n' + templates['noscript/topic'].parse(topic) + '\n\t</noscript>' +
'\n\t<script>templates.ready(function(){ajaxify.go("topic/' + topic_url + '");});</script>' +
templates['footer']
);