Fixed images inside euronews, and caching
This commit is contained in:
parent
595b2be1e3
commit
402682bdea
@ -105,6 +105,8 @@ function doGetArticle(guid = '') {
|
||||
|
||||
const ampURL = `${url[1]}amp/${url[2]}`;
|
||||
|
||||
logger.debug('ampURL', ampURL);
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
request(ampURL, function(err, resp, body) {
|
||||
if (err)
|
||||
|
@ -22,11 +22,19 @@ function reduceArticle(body = '') {
|
||||
|
||||
// stuff.children().each(function () {
|
||||
stuff.each(function () {
|
||||
html.push($(this).html());
|
||||
let line = $(this).html().replace('amp-img', 'img');
|
||||
|
||||
const symbol = /src=(['"])(http[s]?:\/\/)/.exec(line) || [];
|
||||
// logger.debug(symbol);
|
||||
|
||||
if (symbol.length !== 0)
|
||||
line = line.replace(/src=['"]http[s]?:\/\//, `src=${symbol[1]}https://image.silvrtree.co.uk/640,fit,q80/${symbol[2]}`);
|
||||
|
||||
html.push(line);
|
||||
});
|
||||
|
||||
html.push('<div class="endbumper"></div>');
|
||||
// const outputHTML = html.join('').replace(htmlTidy, '');
|
||||
// const outputHTML = html.join('').replace(htmlTidy, '');
|
||||
const outputHTML = html.join('');
|
||||
|
||||
obj.title = title;
|
||||
@ -37,3 +45,4 @@ function reduceArticle(body = '') {
|
||||
}
|
||||
|
||||
module.exports = { reduceArticle };
|
||||
|
||||
|
@ -425,6 +425,11 @@ li {
|
||||
max-width:100%;
|
||||
}
|
||||
|
||||
.newsarticle h1, .newsarticle h3, .newsarticle h3, .newsarticle h4 {
|
||||
font-family: "Roboto Condensed", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.tiny {
|
||||
font-size:1rem;
|
||||
}
|
||||
|
@ -1,9 +1,3 @@
|
||||
Roboto+Condensed
|
||||
Roboto+Condensed:300
|
||||
Roboto+Mono
|
||||
Roboto:100
|
||||
Roboto:300
|
||||
Roboto:400
|
||||
Roboto:500
|
||||
Roboto:700
|
||||
Roboto:900
|
||||
Roboto+Condensed:300,400,700
|
||||
Roboto:100,300,400,400i,500,700,700i,900
|
||||
|
@ -11,7 +11,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
const CACHE_VERSION = { 'version': '0.0.884' };
|
||||
const CACHE_VERSION = { 'version': '0.0.885' };
|
||||
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
|
||||
const RUNTIME = 'runtime';
|
||||
|
||||
@ -56,6 +56,8 @@ const PRECACHE_URLS = [
|
||||
'/fonts/fonts.css',
|
||||
'/fonts/fujicons.css',
|
||||
'/fonts/fujicons.ttf',
|
||||
'/fonts/Roboto-italic-400.woff',
|
||||
'/fonts/Roboto-italic-700.woff',
|
||||
'/fonts/Roboto-normal-100.woff',
|
||||
'/fonts/Roboto-normal-300.woff',
|
||||
'/fonts/Roboto-normal-400.woff',
|
||||
@ -63,7 +65,8 @@ const PRECACHE_URLS = [
|
||||
'/fonts/Roboto-normal-700.woff',
|
||||
'/fonts/Roboto-normal-900.woff',
|
||||
'/fonts/Roboto_Condensed-normal-300.woff',
|
||||
'/fonts/Roboto_Condensed-normal-400.woff'
|
||||
'/fonts/Roboto_Condensed-normal-400.woff',
|
||||
'/fonts/Roboto_Condensed-normal-700.woff'
|
||||
|
||||
];
|
||||
|
||||
@ -121,10 +124,11 @@ self.addEventListener('fetch', event => {
|
||||
);
|
||||
}*/
|
||||
|
||||
console.log('Req', event.request.url);
|
||||
if (event.request.url.startsWith(self.location.origin)) {
|
||||
console.log('One of our requests..');
|
||||
|
||||
event.respondWith(
|
||||
/* event.respondWith(
|
||||
caches.open(RUNTIME).then(function(cache) {
|
||||
return cache.match(event.request).then(function(response) {
|
||||
var fetchPromise = fetch(event.request).then(function(networkResponse) {
|
||||
@ -137,6 +141,18 @@ self.addEventListener('fetch', event => {
|
||||
return response || fetchPromise;
|
||||
});
|
||||
})
|
||||
);*/
|
||||
|
||||
event.respondWith(
|
||||
caches.open(RUNTIME).then(function(cache) {
|
||||
return cache.match(event.request).then(function (response) {
|
||||
return response || fetch(event.request).then(function(response) {
|
||||
cache.put(event.request, response.clone());
|
||||
|
||||
return response;
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@ -160,3 +176,18 @@ self.addEventListener('fetch', event => {
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
self.addEventListener('fetch', function(event) {
|
||||
event.respondWith(
|
||||
caches.open('mysite-dynamic').then(function(cache) {
|
||||
return cache.match(event.request).then(function (response) {
|
||||
return response || fetch(event.request).then(function(response) {
|
||||
cache.put(event.request, response.clone());
|
||||
return response;
|
||||
});
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
*/
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user