Commit 4c181a73 authored by yPhil's avatar yPhil

Sys: Yes, another rat

parent 3c713861
......@@ -626,13 +626,10 @@
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz",
"integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8="
},
"favicon": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/favicon/-/favicon-0.0.2.tgz",
"integrity": "sha1-WmUNHmaE0wCCLqj+Hx8u78tNP5E=",
"requires": {
"request": "2.83.0"
}
"favrat": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/favrat/-/favrat-0.0.1.tgz",
"integrity": "sha512-LCDdkqUR+Jb5e7G+z01FtJY+OBB9evvJN+VIaYvR/BnEM6sFW2/A+h6M9xZCoHuPV4TP/DbCUUY2ZQLtyi93BQ=="
},
"fclone": {
"version": "1.0.11",
......
......@@ -28,8 +28,8 @@
"bower": "1.8.2",
"ejs": "2.5.7",
"express": "4.16.2",
"favicon": "0.0.2",
"feedparser": "2.2.9",
"favrat": "0.0.1",
"feedrat": "latest",
"pm2": "2.8.0"
}
......
......@@ -3,7 +3,7 @@
"name" : "petrolette",
"script" : "./bin/www",
"watch" : true,
"ignore_watch" : ["favicons-cache"],
"ignore_watch" : ["*#", "favicons-cache"],
"log_date_format" : "YYYY-MM-DD HH:mm",
"env" : {
"PORT" : 8666,
......
......@@ -192,7 +192,8 @@ PTL.src = {
$feedIcon = $feed.find('.source-toggle > i');
var l = PTL.util.getLocation(feedUrl),
feedHost = l.protocol + '//' + l.hostname,
feedProtocol = l.protocol + '//' || '//',
feedHost = feedProtocol + l.hostname,
subdomain = l.hostname.substr(0, l.hostname.indexOf('.'));
if (subdomain === 'rss' || subdomain === 'feeds') {
......@@ -207,9 +208,10 @@ PTL.src = {
dataType: "json",
timeout: 2000
}, function(icon) {
// console.log('ICON: (%s)', icon);
// console.log('feedHost: %s (icon %s)', feedHost, icon);
}).done(function(icon) {
$feedToggle.css('background-image','url("' + icon + '")');
$feedIcon.removeClass('icon-rss');
$header.data('img',icon);
......@@ -220,13 +222,13 @@ PTL.src = {
img.src = icon;
img.onerror = function() {
$feedIcon.addClass('icon-rss');
$feedIcon.addClass('icon-rss yowza');
$feedToggle.css('background-image', 'none');
};
}).fail(function(err) {
console.log('err: %s (%s)', err.statusText, feedHost);
$feedIcon.addClass('icon-rss');
$feedIcon.addClass('icon-rss yowzo');
$feedToggle.css('background-image', 'none');
});
......@@ -315,6 +317,7 @@ PTL.src = {
var imageUrl;
var $imageLink = $('<a>').attr('target', '_blank'),
$itemLink = $('<a>').attr('target', '_blank'),
$soundLink = $('<a>').attr('target', '_blank'),
......@@ -406,6 +409,12 @@ PTL.src = {
.attr('data-fancybox-group', $panel.attr('id'))
.attr('data-caption', '<a class="ui-button ui-corner-all" href="' + item.link + '">' + item.title + '</a>');
var isAbsolutePath = new RegExp('^(?:[a-z]+:)?//', 'i');
if (!isAbsolutePath.test(imageUrl)) {
imageUrl = feedHost + imageUrl;
}
$image
.attr('src', imageUrl);
......@@ -423,6 +432,8 @@ PTL.src = {
$itemDiv.appendTo($sourceItem);
$sourceItem.appendTo($feedBody);
});
}).fail(function() {
......
......@@ -127,7 +127,6 @@ PTL.util = {
if (element.columns) isValid = true;
});
console.log('isValid : (%s)', isValid);
return isValid;
},
......
var express = require('express'),
router = express.Router(),
favicon = require('favicon'),
favrat = require('favrat'),
FeedParser = require('feedparser'),
request = require('request'),
feedrat = require('feedrat'),
Url = require('url'),
fs = require('fs'),
path = require('path'),
crypto = require('crypto'),
pjson = require('../package.json');
console.log(pjson.version);
// require('request').debug = true;
router.get('/', function(req, res) {
res.render('index', {
queryString:req.query.source,
......@@ -24,17 +20,6 @@ router.get('/about/javascript', function(req, res) {
res.render('javascript');
});
// router.use(function(req,res,next){
// var _send = res.send;
// var sent = false;
// res.send = function(data){
// if(sent) return;
// _send.bind(res)(data);
// sent = true;
// };
// next();
// });
function getFeed (urlfeed, callback) {
var options = {
......@@ -103,14 +88,9 @@ router.get('/feed', function(req, res) {
console.log('####### START');
// router.use('/favicon', function (req, res, next) {
// console.log('Request:', req.method);
// next();
// });
router.get('/favicon', function(req, res) {
favicon(req.query.url, function(err, iconUrl) {
favrat(req.query.url, function(err, iconUrl) {
if (iconUrl) {
......@@ -121,10 +101,14 @@ router.get('/favicon', function(req, res) {
console.log('# %s (%s)', iconUrl, fileName);
// res.send(iconUrl);
if (fs.existsSync(filePath)) {
console.log('File exists');
res.contentType(fileName);
res.contentType(filePath);
res.send('/favicons/' + fileName);
} else {
res.send(iconUrl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment