Authored by xuqi

获取相关资讯模板

@@ -14,4 +14,5 @@ module.exports = function(app) { @@ -14,4 +14,5 @@ module.exports = function(app) {
14 app.get('/tag', tag.show); //标签页 14 app.get('/tag', tag.show); //标签页
15 15
16 app.get('/ps', ps.show); //plus + star 16 app.get('/ps', ps.show); //plus + star
  17 + app.get('/ps/readTpl', ps.readTpl); //获取相关资讯模板
17 }; 18 };
@@ -3,7 +3,10 @@ @@ -3,7 +3,10 @@
3 * @author: xuqi(qi.xu@yoho.cn) 3 * @author: xuqi(qi.xu@yoho.cn)
4 * @date: 2015/4/15 4 * @date: 2015/4/15
5 */ 5 */
6 -var data = require('../../public/js/data')('ps'); 6 +var data = require('../../public/js/data')('ps'),
  7 + path = require('path'),
  8 + fs = require('fs'),
  9 + tplPath = path.normalize(path.join(__dirname, '../partials/ps/info-item.html'));
7 10
8 exports.show = function(req, res) { 11 exports.show = function(req, res) {
9 res.render('pages/ps', { 12 res.render('pages/ps', {
@@ -12,4 +15,16 @@ exports.show = function(req, res) { @@ -12,4 +15,16 @@ exports.show = function(req, res) {
12 css: '../css/ps.css', 15 css: '../css/ps.css',
13 usejs: 'ps/footer' 16 usejs: 'ps/footer'
14 }); 17 });
  18 +};
  19 +
  20 +exports.readTpl = function(req, res) {
  21 + fs.readFile(tplPath, 'utf8', function(err, data) {
  22 + if (err) {
  23 + res.send({success: false})
  24 + }
  25 + res.send({
  26 + success: true,
  27 + data: data
  28 + });
  29 + });
15 }; 30 };