Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit b56b65e

Browse files
author
Maxime Vaillancourt
committed
added sass, cleaned styling, cleaned views, revamped header, fixed dates
1 parent 8a65db9 commit b56b65e

16 files changed

+428
-248
lines changed

app.js

+22-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*---------------------------------------------------------------------
1+
/**********************************************************************
22
Dependencies
3-
---------------------------------------------------------------------*/
3+
**********************************************************************/
44
var express = require('express');
55
var path = require('path');
66
var favicon = require('serve-favicon');
@@ -9,13 +9,13 @@ var session = require('express-session');
99
var cookieParser = require('cookie-parser');
1010
var bodyParser = require('body-parser');
1111
var flash = require("express-flash");
12-
var Promise = require("bluebird");
1312
var compression = require('compression');
1413
var helmet = require('helmet')
14+
var sassMiddleware = require('node-sass-middleware')
1515

16-
/*---------------------------------------------------------------------
16+
/**********************************************************************
1717
App Setup
18-
---------------------------------------------------------------------*/
18+
**********************************************************************/
1919
var app = express();
2020

2121
var sessionStore = new session.MemoryStore;
@@ -25,10 +25,9 @@ app.locals.moment = require('moment');
2525
app.set('views', path.join(__dirname, 'views'));
2626
app.set('view engine', 'pug');
2727

28-
/*---------------------------------------------------------------------
28+
/**********************************************************************
2929
Middleware
30-
---------------------------------------------------------------------*/
31-
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
30+
**********************************************************************/
3231
app.use(compression())
3332
app.use(helmet())
3433
app.use(cookieParser('secret'));
@@ -43,18 +42,25 @@ app.use(logger('dev'));
4342
app.use(bodyParser.json());
4443
app.use(bodyParser.urlencoded({ extended: false }));
4544
app.use(cookieParser('secret'));
46-
app.use(express.static(path.join(__dirname, 'public')));
4745
app.use(flash());
46+
app.use(sassMiddleware({
47+
src: path.join(__dirname, 'sass'),
48+
dest: path.join(__dirname, 'public/css'),
49+
debug: true,
50+
outputStyle: 'compressed',
51+
prefix: '/css',
52+
}), express.static(path.join(__dirname, 'public')));
53+
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
4854

49-
/*---------------------------------------------------------------------
55+
/**********************************************************************
5056
Routes
51-
---------------------------------------------------------------------*/
57+
**********************************************************************/
5258
app.use('/', require('./routes/index'));
5359
app.use('/feed', require('./routes/feed'));
5460

55-
/*---------------------------------------------------------------------
56-
Error handlers
57-
---------------------------------------------------------------------*/
61+
/**********************************************************************
62+
Error Handlers
63+
**********************************************************************/
5864
// catch 404 and forward to error handler
5965
app.use(function(req, res, next) {
6066
var err = new Error('Not Found');
@@ -73,7 +79,7 @@ app.use(function(err, req, res, next) {
7379
res.render('error');
7480
});
7581

76-
/*---------------------------------------------------------------------
82+
/**********************************************************************
7783
Exports
78-
---------------------------------------------------------------------*/
84+
**********************************************************************/
7985
module.exports = app;

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"helmet": "^3.6.1",
1919
"moment": "^2.18.1",
2020
"morgan": "~1.7.0",
21+
"node-sass": "^4.5.3",
22+
"node-sass-middleware": "^0.11.0",
2123
"pug": "~2.0.0-beta10",
2224
"redis": "^2.7.1",
2325
"request": "^2.81.0",

public/css/main.css

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/styles.css

-49
This file was deleted.

public/img/curlybraces.svg

+57
Loading

routes/feed.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
/*---------------------------------------------------------------------
1+
/**********************************************************************
22
Dependencies
3-
---------------------------------------------------------------------*/
3+
**********************************************************************/
44
var express = require('express');
55
var router = express.Router();
66
var request = require("request");
77
var utils = require("../helpers/utils")
88
var redisCache = require('redis').createClient(process.env.REDIS_URL);
99

10-
/*---------------------------------------------------------------------
11-
Feed Display GET
12-
---------------------------------------------------------------------*/
10+
/**********************************************************************
11+
Feed Display (GET)
12+
**********************************************************************/
1313
router.get('/',
1414

1515
function ajaxRequest(req, res, next) {
@@ -34,20 +34,19 @@ router.get('/',
3434
}
3535
})
3636

37-
3837
if(feedType == "json"){
3938

4039
var parsedJson;
4140

4241
res.locals.feedType = "json"
4342

4443
try {
45-
parsedJson = JSON.parse(rawData);
44+
parsedJson = JSON.parse(rawData);
4645
} catch(e) {
4746
req.flash("error", "Error while parsing the JSON feed.")
4847
return res.redirect("/");
4948
}
50-
var parsedJson = JSON.parse(rawData);
49+
5150
if(parsedJson.hasOwnProperty('err')){
5251
req.flash("error", "There was an error while preparing the feed to be displayed.")
5352
return res.redirect("/");
@@ -90,7 +89,7 @@ router.get('/',
9089
var parsedConvertedJson;
9190

9291
try {
93-
parsedConvertedJson = JSON.parse(converterRawData);
92+
parsedConvertedJson = JSON.parse(converterRawData);
9493
} catch(e) {
9594
req.flash("error", "Error while parsing the converted feed.")
9695
return res.redirect("/");
@@ -107,7 +106,6 @@ router.get('/',
107106
parsedConvertedJson.feed_url = req.query.url.toLowerCase().trim()
108107
}
109108
res.locals.data = parsedConvertedJson;
110-
console.log(parsedConvertedJson)
111109

112110
// push data to the redis cache (expires after 72 hours)
113111
redisCache.setex(encodeURIComponent(req.query.url.toLowerCase().trim()), 60*60*72, JSON.stringify(parsedConvertedJson), function(){
@@ -129,7 +127,7 @@ router.get('/',
129127
});
130128
}
131129
else{
132-
// not json, nor xml or atom
130+
// not json, nor xml
133131
req.flash("error", "Unexpected MIME type. Please make sure you are entering a JSON, RSS, or Atom feed URL.")
134132
return res.redirect("/");
135133
}
@@ -155,7 +153,7 @@ router.get('/',
155153

156154
);
157155

158-
/*---------------------------------------------------------------------
156+
/**********************************************************************
159157
Exports
160-
---------------------------------------------------------------------*/
158+
**********************************************************************/
161159
module.exports = router;

0 commit comments

Comments
 (0)