Commit 7fc44ed9 authored by yPhil's avatar yPhil

Cache: Promise fulfilled :)

parent 6d899ec8
......@@ -4,6 +4,10 @@ var express = require('express'),
fs = require('fs'),
app = express();
var bodyParser = require('body-parser');
if (!fs.existsSync(path.join(__dirname, process.env.FAVICONS_CACHE_DIR))){
fs.mkdirSync(path.join(__dirname, process.env.FAVICONS_CACHE_DIR));
}
......@@ -18,4 +22,7 @@ app.use('/static', express.static(path.join(__dirname, 'public')));
app.use('/bower', express.static(path.join(__dirname, 'bower_components')));
app.use('/', index);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
module.exports = app;
......@@ -23,7 +23,6 @@
"fancybox": "3.2.5",
"intro.js": "2.7.0",
"remotestorage": "rs#1.0.2",
"rs-widget": "1.3.0",
"jquery.hotkeys": "jQuery.Hotkeys#0.2.0"
"rs-widget": "1.3.0"
}
}
......@@ -616,15 +616,6 @@
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
},
"favrat": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/favrat/-/favrat-0.0.7.tgz",
"integrity": "sha512-Ipdjs+hYAqe+A9EtWjRGVlkWNgrDFHGsY+kDzXL9SxdPzJgvvKCCuuQcsY5ghwg4+b2L5ZhheQKMaSodq35gMQ==",
"requires": {
"cheerio": "1.0.0-rc.2",
"request": "2.85.0"
}
},
"fclone": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/fclone/-/fclone-1.0.11.tgz",
......
......@@ -20,7 +20,6 @@
"bower": "1.8.2",
"ejs": "2.5.7",
"express": "4.16.2",
"favrat": "0.0.7",
"feedparser": "2.2.9",
"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,
......
@font-face {
font-family: 'fontello';
src: url('../font/fontello.eot?83680137');
src: url('../font/fontello.eot?83680137#iefix') format('embedded-opentype'),
url('../font/fontello.woff2?83680137') format('woff2'),
url('../font/fontello.woff?83680137') format('woff'),
url('../font/fontello.ttf?83680137') format('truetype'),
url('../font/fontello.svg?83680137#fontello') format('svg');
src: url('../font/fontello.eot?70380129');
src: url('../font/fontello.eot?70380129#iefix') format('embedded-opentype'),
url('../font/fontello.woff2?70380129') format('woff2'),
url('../font/fontello.woff?70380129') format('woff'),
url('../font/fontello.ttf?70380129') format('truetype'),
url('../font/fontello.svg?70380129#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
......@@ -15,7 +15,7 @@
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'fontello';
src: url('../font/fontello.svg?83680137#fontello') format('svg');
src: url('../font/fontello.svg?70380129#fontello') format('svg');
}
}
*/
......@@ -82,5 +82,5 @@
.icon-left-open:before { content: '\f007'; } /* '' */
.icon-export:before { content: '\f02e'; } /* '' */
.icon-uncheck:before { content: '\f096'; } /* '' */
.icon-rss:before { content: '\f143'; } /* '' */
.icon-rzz:before { content: '\f143'; } /* '' */
.icon-bomb:before { content: '\f1e2'; } /* '' */
\ No newline at end of file
......@@ -1092,11 +1092,11 @@ li.feed {
color: var(--color-ui-pri) !important;
}
.icon-rss {
.icon-rzz {
color: var(--color-ui-rss) !important;
}
.icon-rss {
.icon-rzz {
color: var(--color-ui-rss) !important;
}
......@@ -1279,8 +1279,8 @@ div.introjs-helperLayer {
div#logo-title > .logo-title > a:link,
div#logo-title > .logo-title > a:visited,
.topnav i,
#scroll-top,
#scroll-top i {
#backtop,
#backtop i {
transition: all .3s linear;
}
......@@ -1361,7 +1361,7 @@ div#logo-title > .logo-title > a:hover {
top: 22px;
}
#scroll-top {
#backtop {
z-index: 2;
background: var(--color-ui-qua);
border-radius: 35px;
......@@ -1377,7 +1377,7 @@ div#logo-title > .logo-title > a:hover {
width: 50px;
}
#scroll-top i {
#backtop i {
color: var(--color-ui-pri);
font-size: 19px;
left: 18px;
......@@ -1386,11 +1386,11 @@ div#logo-title > .logo-title > a:hover {
top: 13px;
}
#scroll-top:hover {
#backtop:hover {
opacity: 1;
}
#scroll-top:hover i {
#backtop:hover i {
color: var(--color-ui-sec);
top: 5px;
}
......
No preview for this file type
......@@ -60,7 +60,7 @@
<glyph glyph-name="uncheck" unicode="&#xf096;" d="M625 707h-464q-37 0-63-26t-27-63v-464q0-37 27-63t63-27h464q37 0 63 27t26 63v464q0 37-26 63t-63 26z m161-89v-464q0-67-47-114t-114-47h-464q-67 0-114 47t-47 114v464q0 66 47 113t114 48h464q66 0 114-48t47-113z" horiz-adv-x="785.7" />
<glyph glyph-name="rss" unicode="&#xf143;" d="M286 136q0 29-21 50t-51 21-50-21-21-50 21-51 50-21 51 21 21 51z m196-53q-8 130-99 222t-221 98q-8 1-14-5t-5-13v-71q0-7 5-12t12-6q86-6 147-68t67-147q1-7 6-12t12-5h72q7 0 13 6t5 13z m214 0q-3 86-31 166t-78 145-115 114-145 78-166 31q-7 1-13-5-5-5-5-13v-71q0-7 5-12t12-6q114-4 211-62t156-155 62-211q0-8 5-13t13-5h71q7 0 13 6 6 5 5 13z m161 535v-536q0-66-47-113t-114-48h-535q-67 0-114 48t-47 113v536q0 66 47 113t114 48h535q67 0 114-48t47-113z" horiz-adv-x="857.1" />
<glyph glyph-name="rzz" unicode="&#xf143;" d="M286 136q0 29-21 50t-51 21-50-21-21-50 21-51 50-21 51 21 21 51z m196-53q-8 130-99 222t-221 98q-8 1-14-5t-5-13v-71q0-7 5-12t12-6q86-6 147-68t67-147q1-7 6-12t12-5h72q7 0 13 6t5 13z m214 0q-3 86-31 166t-78 145-115 114-145 78-166 31q-7 1-13-5-5-5-5-13v-71q0-7 5-12t12-6q114-4 211-62t156-155 62-211q0-8 5-13t13-5h71q7 0 13 6 6 5 5 13z m161 535v-536q0-66-47-113t-114-48h-535q-67 0-114 48t-47 113v536q0 66 47 113t114 48h535q67 0 114-48t47-113z" horiz-adv-x="857.1" />
<glyph glyph-name="bomb" unicode="&#xf1e2;" d="M319 521q-6 14-19 20t-28 0q-60-25-106-71t-71-107q-6-14 0-27t19-19q8-3 14-3 23 0 33 23 19 47 55 83t83 54q14 7 20 20t0 27z m525 199l26-26-136-135 38-38q10-11 10-26t-10-25l-36-36q50-90 50-191 0-80-31-153t-84-125-125-84-153-31-153 31-125 84-84 125-31 153 31 153 84 125 125 84 153 31q101 0 191-50l36 36q11 10 25 10t26-10l38-38z m5 31q-6-5-12-5-8 0-13 5l-51 51q-5 5-5 12t5 13q6 5 13 5t13-5l50-51q5-5 5-12t-5-13z m128-128q-6-5-13-5t-12 5l-51 51q-5 5-5 12t5 13q5 5 13 5t12-5l51-50q5-6 5-13t-5-13z m23 102q0-8-5-13t-13-5h-53q-8 0-13 5t-5 13 5 13 13 5h53q8 0 13-5t5-13z m-107 107v-53q0-8-5-13t-13-5-13 5-5 13v53q0 8 5 13t13 5 13-5 5-13z m84-30l-51-51q-5-5-12-5-7 0-13 5-5 5-5 13t5 12l51 51q5 5 12 5t13-5q5-5 5-13t-5-12z" horiz-adv-x="1000" />
</font>
......
No preview for this file type
......@@ -515,7 +515,7 @@ PTL.dialog = {
isUrl = false,
h1, h2;
$icon.addClass('icon-rss');
$icon.addClass('icon-rzz');
// console.log('There is %s cols in the %s panel', nbOfColumnsInTab, $panel.attr('id'));
......
......@@ -8,6 +8,8 @@ var PTL = (function() {
language: 'en',
start : function() {
var $menu = $('nav#side-menu'),
$overlay = $('#overlay'),
$sourceCodeButton = $('button#sourceCode'),
......
......@@ -7,7 +7,7 @@ PTL.src = {
var feedIndex = $('#tabs').find('.feed').length;
var $feedIcon = $('<i>')
.attr('class', 'source-control feedIcon icon-rss rotate translate')
.attr('class', 'source-control feedIcon icon-rzz rotate translate')
.data('title', 'Fold / unfold this source (%1)', url)
.attr('title', PTL.tr('Fold / unfold this source (%1)', url));
......@@ -116,7 +116,7 @@ PTL.src = {
$feedToggle.css('background-image', 'none');
$feedIcon.addClass('icon-down-big');
$feedIcon.removeClass('icon-rss');
$feedIcon.removeClass('icon-rzz');
$(this).data('img', iconImg);
......@@ -129,7 +129,7 @@ PTL.src = {
if ($(this).data('img') !== 'none') {
$feedToggle.css('background-image', $(this).data('img'));
} else {
$feedIcon.addClass('icon-rss');
$feedIcon.addClass('icon-rzz');
}
});
......@@ -212,7 +212,7 @@ PTL.src = {
$feedToggle.css('background-image','url("' + icon + '")');
$feedIcon.removeClass('icon-rss');
$feedIcon.removeClass('icon-rzz');
$header.data('img',icon);
// var img = new Image();
......@@ -220,13 +220,13 @@ PTL.src = {
// img.src = icon;
// img.onerror = function() {
// $feedIcon.addClass('icon-rss yowza');
// $feedIcon.addClass('icon-rzz yowza');
// $feedToggle.css('background-image', 'none');
// };
}).fail(function(err) {
// console.log('err: %s (%s)', err.statusText, feedHost);
$feedIcon.addClass('icon-rss yowzo');
$feedIcon.addClass('icon-rzz yowzo');
$feedToggle.css('background-image', 'none');
});
......@@ -361,7 +361,7 @@ PTL.src = {
if (typeof item.enclosures[0] !== 'undefined' && item.enclosures[0].url) {
imageUrl = item.enclosures[0].url;
// imageUrl = item.enclosures[0].url;
if (item.enclosures[0].url.match(/\.(ogg|mp3)$/)) {
......
......@@ -50,13 +50,13 @@ PTL.tab = {
$(window).scroll(function() {
if ($(this).scrollTop() >= 50) {
$('#scroll-top').fadeIn(200);
$('#backtop').fadeIn(200);
} else {
$('#scroll-top').fadeOut(200);
$('#backtop').fadeOut(200);
}
});
$('#scroll-top').click(function() {
$('#backtop').click(function() {
$('body,html').animate({
scrollTop : 0
}, 500);
......
......@@ -192,7 +192,7 @@ PTL.util = {
},
{
element: 'li.feed',
intro: PTL.tr('This is a source. ') + '<a class="ui-button ui-corner-all icon-rss" href="https://' + PTL.language + '.wikipedia.org/wiki/RSS">' + PTL.tr('More info') + '</a>'
intro: PTL.tr('This is a source. ') + '<a class="ui-button ui-corner-all icon-rzz" href="https://' + PTL.language + '.wikipedia.org/wiki/RSS">' + PTL.tr('More info') + '</a>'
},
{
element: 'div#newSourceButton',
......
......@@ -156,7 +156,7 @@
<span class="translate"
data-content="Pétrolette uses a time-tested technology">
Pétrolette uses a time-tested technology
</span>: <a class="ui-button help-button icon-rss help-rss" href="https://wikipedia.org/wiki/RSS">RSS</a>.
</span>: <a class="ui-button help-button icon-rzz help-rss" href="https://wikipedia.org/wiki/RSS">RSS</a>.
<span class="translate"
data-content="Create sources and organize them into groups.">
......
......@@ -103,16 +103,18 @@ router.get('/favicon', function(req, res) {
var fileName = hash + '.favicon';
var filePath = path.join(process.env.FAVICONS_CACHE_DIR, fileName);
res.send(iconUrl);
// if (fs.existsSync(filePath)) {
// res.send('/favicons/' + fileName);
// } else {
// res.send(iconUrl);
// request.get(iconUrl).pipe(fs.createWriteStream(filePath));
// }
if (fs.existsSync(filePath)) {
res.send('/favicons/' + fileName);
} else {
var p = new Promise(resolve => request(iconUrl)
.pipe(fs.createWriteStream(filePath, {'Content-Type': 'image/x-icon'}))
.on('finish', resolve({filePath, iconUrl})));
p.then(function(r) {
console.log('Finished copying %s (%s)', r.filePath, r.iconUrl);
res.send('/favicons/' + fileName);
});
}
} else {
res.status(500).send('No icon found');
......@@ -124,13 +126,13 @@ router.get('/discover', function(req, res) {
feedrat(req.query.url, function(err, feed) {
if (feed) {
res.send(feed);
} else {
res.status(500).send('No feed found');
}
if (feed) {
res.send(feed);
} else {
res.status(500).send('No feed found');
}
});
});
});
......
......@@ -368,7 +368,7 @@
<div id="dialogs"></div>
<span id="scroll-top">
<span id="backtop">
<i class="icon-up"></i>
</span>
......
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