タイトルの通り、Hrokuというサービスを利用してBotのプログラムと同時にhttpのリクエストを受け付けてnodeのプログラムで動作するWebページを制作したいなと考えております。
hubotが持っているexpressの機能を使いroutingの処理をしてみたりしているのですが、css、javascriptがどうしてもサイト上に反映されなくて困っております。
node該当コード
(function() { /* ==================== ■ Bot ==================== */ function Bot(object) { //class this.originalDate = object.originalDate; this.slack = object.slack; this.weather = object.weather; this.httpServer = object.httpServer; //method this.init(); console.log("bot running!!"); } Bot.prototype.init = function() { //init var self = this; module.exports = function(robot) { //yo //self.yo(robot); //weather //self.weather.getWeather(robot, 270000); //httpSever self.httpServer.routing(robot); }; }; Bot.prototype.yo = function(robot) { //yo var self = this; robot.messageRoom(this.slack.room, "♪(σ´ω`)σ\tyo!!\n今日は" + this.originalDate.getDate_All() + "だ\tyo!!"); }; /* ==================== ■ HTTPSever ==================== */ function HttpServer(object) { //class this.originalDate = object.originalDate; this.slack = object.slack; this.weather = object.weather; } HttpServer.prototype.routing = function(robot) { //routing var self = this; robot.router.get("/", function(err, res, body) { robot.messageRoom(self.slack.room, "♪(σ´ω`)σ\tyo!!\nサイトに訪問者がいる\tyo!!\nお茶出せ\tyo!!\n" + self.originalDate.getTime_All() + "だ\tyo!!"); robot.router.set("view engine", "ejs"); res.render("index"); }); //sheard(css) robot.router.get("/sheard/css/reset.css", function(err, res, body) { res.type("css"); res.send(); res.end(); }); robot.router.get("/sheard/css/common.css", function(err, res, body) { res.type("css"); res.send(); res.end(); }); //sheard(js) robot.router.get("/sheard/js/lib/jquery-1.11.3.min.js", function(err, res, body) { res.type("javascript"); res.send(); res.end(); }); robot.router.get("/sheard/js/lib/jquery.easing.1.3.js", function(err, res, body) { res.type("javascript"); res.send(); res.end(); }); robot.router.get("/sheard/js/lib/velocity.min.js", function(err, res, body) { res.type("javascript"); res.send(); res.end(); }); robot.router.get("/sheard/js/lib/TweenMax.min.js", function(err, res, body) { res.type("javascript"); res.send(); res.end(); }); robot.router.get("/sheard/js/lib/three.min.js", function(err, res, body) { res.type("javascript"); res.send(); res.end(); }); robot.router.get("/sheard/js/lincle.js", function(err, res, body) { res.type("javascript"); res.send(); res.end(); }); };
ejsコード
<% pageSetting = { siteTitle: "aaa", pageTitle: "", description: "", css: "", js: "" } ; %> <%- include("sheard/inc/_header") %> <div class="wrapper"> </div> <%- include("sheard/inc/_footer") %>
よろしくお願いいたします。
あなたの回答
tips
プレビュー