From 17b2cc7bf218982bbd66f8d490024870bd3975ba Mon Sep 17 00:00:00 2001 From: aisk Date: Mon, 23 Jul 2012 22:23:38 +0800 Subject: [PATCH] Add tag topic list page's background image css. --- controllers/tag.js | 24 +++++++++++++++++++++--- views/layout.html | 5 +++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/controllers/tag.js b/controllers/tag.js index 1a17638..f88af59 100644 --- a/controllers/tag.js +++ b/controllers/tag.js @@ -31,8 +31,23 @@ exports.list_topic = function(req,res,next){ } } } - res.render('tag/list_topic',{tag:tag,topics:topics,current_page:page,list_topic_count:limit,in_collection:collection, - hot_topics:hot_topics,no_reply_topics:no_reply_topics,pages:pages}); + + if (tag.background=='') { + var style = null; + } else { + var style = '#wrapper {background-image: url("'+tag.background+'")}'; + } + + res.render('tag/list_topic',{ + tag:tag,topics:topics, + current_page:page, + list_topic_count:limit, + in_collection:collection, + hot_topics:hot_topics, + no_reply_topics:no_reply_topics, + pages:pages, + extra_style:style + }); }); } @@ -110,7 +125,7 @@ exports.add = function(req,res,next){ var description = sanitize(req.body.description).trim(); description = sanitize(description).xss(); var background = sanitize(req.body.background).trim(); - background = sanitize(description).xss(); + background = sanitize(background).xss(); var order = req.body.order; if(name == ''){ @@ -162,6 +177,8 @@ exports.edit = function(req,res,next){ var name = sanitize(req.body.name).trim(); name = sanitize(name).xss(); var order = req.body.order; + var background = sanitize(req.body.background).trim(); + background = sanitize(background).xss(); var description = sanitize(req.body.description).trim(); description = sanitize(description).xss(); if(name == ''){ @@ -170,6 +187,7 @@ exports.edit = function(req,res,next){ } tag.name = name; tag.order = order; + tag.background = background; tag.description = description; tag.save(function(err){ if(err) return next(err); diff --git a/views/layout.html b/views/layout.html index 1703e6e..26b39d6 100644 --- a/views/layout.html +++ b/views/layout.html @@ -15,6 +15,11 @@ + <% if (locals.extra_style) { %> + + <% } %>