Commit 5d749092 authored by yPhil's avatar yPhil

Sys: Columns: newList

parent f6ab87a1
......@@ -3,6 +3,12 @@ var express = require('express'),
index = require('./routes/index'),
app = express();
// fs.exists(cacheDir, (exists) => {
// if (!exists) fs.mkdirSync(cacheDir);
// });
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.engine('html', require('ejs').renderFile);
......
......@@ -12,11 +12,11 @@
"url": "https://framagit.org/yphil/petrolette"
},
"scripts": {
"start": "pm2 start -f bin/www --log-date-format='YYYY-MM-DD HH:mm Z' --name PTL",
"start": "pm2 start -f bin/www --watch --log-date-format='YYYY-MM-DD HH:mm Z' --name PTL",
"stop": "pm2 stop PTL",
"build:pre": "uglifyjs public/js/PTL.main.js public/js/PTL.prefs.js public/js/PTL.i18n.js -m -o dist/js/PTL.pre.min.js",
"build:post": "uglifyjs public/js/PTL.utilities.js public/js/PTL.tab.js public/js/PTL.feed.js public/js/PTL.dialog.js public/js/PTL.sync.js public/js/PTL.menu.js -m -o dist/js/PTL.post.min.js",
"build:js": "mkdir -p dist/js && npm run build:pre && npm run build:post",
"build:js": "mkdir -p dist/js cache-favicons && npm run build:pre && npm run build:post",
"watch:js": "onchange 'public/js/*.js' -- npm run build:js",
"postinstall": "npm run build:js && bower install"
},
......@@ -32,5 +32,6 @@
"feedrat": "latest",
"favicon": "0.0.2",
"pm2": "2.8.0"
}
},
"cacheDirName": "favicon-cache"
}
......@@ -887,11 +887,6 @@ li.feed {
margin: 0 0 0 2px;
}
.feed * {
transition: all .1s linear;
}
.mobHeader > .feedToggle {
margin: 2px;
flex-basis: auto;
......@@ -1127,6 +1122,13 @@ div.introjs-helperLayer {
position: absolute;
top: 0;
z-index: 5;
}
div#logoTitle > .logoTitle > a:link,
div#logoTitle > .logoTitle > a:visited,
.topnav i,
#scrollToTop,
#scrollToTop i {
transition: all .3s linear;
}
......@@ -1154,7 +1156,6 @@ i.icon-petrolette {
font-size:24pt;
margin: 6px 12px 6px 6px;
color: var(--ui-color-pri);
transition: all .3s linear;
}
i.icon-petrolette:hover,
......@@ -1185,7 +1186,6 @@ div#logoTitle > .logoTitle {
div#logoTitle > .logoTitle > a:link,
div#logoTitle > .logoTitle > a:visited {
color: var(--ui-color-pri);
transition: all 0.3s linear;
}
div#logoTitle > .logoTitle > a:hover {
......@@ -1217,7 +1217,6 @@ div#logoTitle > .logoTitle > a:hover {
position: fixed;
right: 20px;
text-decoration: none;
transition: all 0.3s ease;
width: 50px;
}
......@@ -1228,7 +1227,6 @@ div#logoTitle > .logoTitle > a:hover {
margin: 0;
position: relative;
top: 13px;
transition: all 0.3s ease;
}
#scrollToTop:hover {
......
......@@ -2,6 +2,21 @@
PTL.prefs = (function() {
var newList = [
{"name":"News",
"feeds": [
{"url":"http://xkcd.com/rss.xml","type":"mixed","limit": 8},
{"url":"http://xkcd.com/rss.xml","type":"photo","limit": 4}
]
},
{"name":"Comics",
"feeds": [
{"url":"http://xkcd.com/rss.xml","type":"photo","limit": 8},
{"url":"http://superphazed.tumblr.com/rss","type":"photo","limit": 8}
]
}
];
var emptyTabList = [
{"name":"News",
"feeds": [
......@@ -46,6 +61,7 @@ PTL.prefs = (function() {
'columns': 3,
'lang': 'en',
'explicitLang': false,
'sources': JSON.stringify(newList),
'tabs': JSON.stringify(emptyTabList)
};
......
......@@ -179,7 +179,7 @@ PTL.tab = {
var tabIndex = $('ul#tabUl li.mobTab').length + 1;
if (!name) name = 'Group ' + tabIndex;
name = name || 'Group ' + tabIndex;
var $sortable = $('<ul>')
.attr('class', 'tabSort');
......
......@@ -3,6 +3,21 @@
PTL.utilities = {
isValidSourcesFile:function(sources) {
function checkElt(val) {
return val === 'news';
}
function has(object, key) {
return object ? hasOwnProperty.call(object, key) : false;
}
// console.log('sources', sources.find('name'));
console.log('feeds', sources.hasOwnProperty('name'));
console.log('sources: ', has(sources, 'feeds'));
// sources.find('name');
var isValid = false;
if (Object.prototype.toString.call(sources) === '[object Array]') {
isValid = sources.some(obj => Array.isArray(obj.feeds) && obj.feeds.some(feed => Object.prototype.hasOwnProperty.call(feed, 'url')));
......@@ -13,9 +28,6 @@ PTL.utilities = {
},
isImage:function(string) {
// return string.split('.').pop() === 'jpg';
return (['jpg', 'png'].indexOf(string.split('.').pop()) >= 0);
},
noSourcesButton:function() {
......@@ -26,15 +38,14 @@ PTL.utilities = {
var $noSourcesText = $('<div>').text('Loading sources');
var $noSourcesButton = $('<div>')
// .append('<span data-content="Whoops, no sources!" data-title="Whoops, no sources!" class="translate"> Whoops, no sources! </span> <br/> <span data-content="Click here to add some." data-title="Click here to add some." class="translate"> Click here to add some.</span>')
.append($loadingSpinner)
.append('<br>')
.append($noSourcesText);
.append($loadingSpinner)
.append('<br>')
.append($noSourcesText);
var $noSourcesButtonContainer = $('<div>')
.attr('id', 'noSourcesButton')
.attr('class', 'deadCenter')
.append($noSourcesButton);
var $noSourcesButtonContainer = $('<div>')
.attr('id', 'noSourcesButton')
.attr('class', 'deadCenter')
.append($noSourcesButton);
$('main').append($noSourcesButtonContainer);
......@@ -44,7 +55,7 @@ PTL.utilities = {
var vWidth = $(window).width(),
vW;
if(PTL.utilities.isMobile() || vWidth < 720 ) {
if (PTL.utilities.isMobile() || vWidth < 720 ) {
vW = vWidth - 8;
} else {
vW = vWidth - vWidth / 4;
......
var express = require('express');
var router = express.Router();
var favicon = require('favicon');
var FeedParser = require('feedparser');
var request = require('request');
var feedrat = require('feedrat');
var express = require('express'),
router = express.Router(),
favicon = require('favicon'),
FeedParser = require('feedparser'),
request = require('request'),
feedrat = require('feedrat'),
Url = require('url'),
fs = require('fs'),
path = require('path'),
packageJson = require('../package.json'),
cacheDir = path.join(__dirname, packageJson.cacheDirName);
// require('request').debug = true;
......@@ -16,14 +21,14 @@ router.get('/about/javascript', function(req, res) {
});
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();
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) {
......@@ -47,14 +52,14 @@ function getFeed (urlfeed, callback) {
stream.pipe (feedparser);
} else {
console.log ('getFeed: Content-type Error read %s (%s) .', urlfeed, res.headers['content-type']);
// console.log ('getFeed: Content-type Error read %s (%s) .', urlfeed, res.headers['content-type']);
callback (res.headers['content-type']);
return;
}
});
req.on ('error', function (res) {
console.log ('getFeed: Error read %s (%s) .', urlfeed, res);
// console.log ('getFeed: Error read %s (%s) .', urlfeed, res);
});
feedparser.on ('readable', function () {
......@@ -65,7 +70,7 @@ function getFeed (urlfeed, callback) {
}
}
catch (err) {
console.log ('getFeed: err.message == ' + err.message);
// console.log ('getFeed: err.message == ' + err.message);
}
}).on ('end', function () {
var meta = this.meta;
......@@ -94,15 +99,47 @@ router.get('/feed', function(req, res) {
router.get('/feedicon', function(req, res) {
favicon(req.query.url, function(err, u) {
// var p = Url.parse(req.query.url),
// fileName = p.host + "-" + p.path;
if (u) {
res.send(u);
} else {
res.status(500).send('No icon found');
}
// fs.exists(path.join(cacheDir, fileName), (exists) => {
// if (!exists) {
// console.log('path.join(cacheDir, fileName) does not exist');
// // fs.mkdirSync(cacheDir);
// }
// });
});
favicon(req.query.url, function(err, iconUrl) {
if (iconUrl) {
res.send(iconUrl);
var u = Url.parse(iconUrl);
var fileName = u.host + '.' + u.pathname.replace(/(^\/|\/$)/g,'');
console.log('(%s) is not in (%s)', fileName, cacheDir);
// console.log('icon! (%s) Name: %s', iconUrl, root);
// var s = fs.ReadStream(u);
// s.on('data', function(d) {
// shasum.update(d);
// });
// s.on('end', function() {
// var d = shasum.digest('hex');
// console.log('plop! ' + d + ' ' + u);
// });
} else {
res.status(500).send('No icon found');
}
});
});
router.get('/discover', function(req, res) {
......
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