diff --git a/README.md b/README.md index 9d42b2c..7bd014d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This ends up being specially useful for communities, in order to follow the work # How to deploy -First you need to have [wrangler]() correctly setup on your machine. Then: +First you need to have [wrangler](https://github.com/cloudflare/wrangler) correctly setup on your machine. Then: 1. Clone this repository 2. Create a `wrangler.toml` file based on the existing `wrangler.toml.example` diff --git a/index.js b/index.js index 4266b5f..1b1676d 100644 --- a/index.js +++ b/index.js @@ -27,16 +27,22 @@ async function handleRequest(request) { if (path === '/') { let content = await WORKER_PLANET_STORE.get('html') response = new Response(content, { - headers: { 'content-type': 'text/html;charset=UTF-8' }, + headers: { + 'content-type': 'text/html;charset=UTF-8', + 'Cache-Control': 'max-age=3600', + }, }) } else if (path === '/rss') { let content = await WORKER_PLANET_STORE.get('rss') response = new Response(content, { - headers: { 'content-type': 'application/rss+xml' } + headers: { + 'content-type': 'application/rss+xml', + 'Cache-Control': 'max-age=3600', + }, }) - // } else if (path === '/atom') { - // let content = await WORKER_PLANET_STORE.get('atom') - // response = new Response(content) + // } else if (path === '/atom') { + // let content = await WORKER_PLANET_STORE.get('atom') + // response = new Response(content) } else { return new Response('', { status: 404 }) } diff --git a/templates/list_posts.precompiled.js b/templates/list_posts.precompiled.js index e9ef4d1..f0d53bb 100644 --- a/templates/list_posts.precompiled.js +++ b/templates/list_posts.precompiled.js @@ -1,38 +1,234 @@ -var Handlebars = require("handlebars/runtime"); var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; -templates['list_posts'] = template({"1":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) { - if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { - return parent[propertyName]; +var Handlebars = require('handlebars/runtime') +var template = Handlebars.template, + templates = (Handlebars.templates = Handlebars.templates || {}) +templates['list_posts'] = template({ + '1': function(container, depth0, helpers, partials, data) { + var stack1, + helper, + alias1 = depth0 != null ? depth0 : container.nullContext || {}, + alias2 = container.hooks.helperMissing, + alias3 = 'function', + alias4 = container.escapeExpression, + lookupProperty = + container.lookupProperty || + function(parent, propertyName) { + if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { + return parent[propertyName] + } + return undefined } - return undefined - }; - return "
\n

" - + alias4(((helper = (helper = lookupProperty(helpers,"title") || (depth0 != null ? lookupProperty(depth0,"title") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"title","hash":{},"data":data,"loc":{"start":{"line":24,"column":31},"end":{"line":24,"column":40}}}) : helper))) - + "

\n

\n Date: " - + alias4(((helper = (helper = lookupProperty(helpers,"pubDate") || (depth0 != null ? lookupProperty(depth0,"pubDate") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"pubDate","hash":{},"data":data,"loc":{"start":{"line":26,"column":23},"end":{"line":26,"column":34}}}) : helper))) - + "
\n Source: " - + alias4(((helper = (helper = lookupProperty(helpers,"source_title") || (depth0 != null ? lookupProperty(depth0,"source_title") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"source_title","hash":{},"data":data,"loc":{"start":{"line":27,"column":51},"end":{"line":27,"column":67}}}) : helper))) - + "\n

\n\n " - + ((stack1 = ((helper = (helper = lookupProperty(helpers,"content") || (depth0 != null ? lookupProperty(depth0,"content") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"content","hash":{},"data":data,"loc":{"start":{"line":30,"column":8},"end":{"line":30,"column":21}}}) : helper))) != null ? stack1 : "") - + "\n
\n"; -},"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) { - var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) { - if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { - return parent[propertyName]; + return ( + '
\n

' + + alias4( + ((helper = + (helper = + lookupProperty(helpers, 'title') || + (depth0 != null ? lookupProperty(depth0, 'title') : depth0)) != null + ? helper + : alias2), + typeof helper === alias3 + ? helper.call(alias1, { + name: 'title', + hash: {}, + data: data, + loc: { + start: { line: 24, column: 31 }, + end: { line: 24, column: 40 }, + }, + }) + : helper), + ) + + '

\n

\n Date: ' + + alias4( + ((helper = + (helper = + lookupProperty(helpers, 'pubDate') || + (depth0 != null ? lookupProperty(depth0, 'pubDate') : depth0)) != + null + ? helper + : alias2), + typeof helper === alias3 + ? helper.call(alias1, { + name: 'pubDate', + hash: {}, + data: data, + loc: { + start: { line: 26, column: 23 }, + end: { line: 26, column: 34 }, + }, + }) + : helper), + ) + + '
\n Source: ' + + alias4( + ((helper = + (helper = + lookupProperty(helpers, 'source_title') || + (depth0 != null + ? lookupProperty(depth0, 'source_title') + : depth0)) != null + ? helper + : alias2), + typeof helper === alias3 + ? helper.call(alias1, { + name: 'source_title', + hash: {}, + data: data, + loc: { + start: { line: 27, column: 51 }, + end: { line: 27, column: 67 }, + }, + }) + : helper), + ) + + '\n

\n\n ' + + ((stack1 = + ((helper = + (helper = + lookupProperty(helpers, 'content') || + (depth0 != null ? lookupProperty(depth0, 'content') : depth0)) != + null + ? helper + : alias2), + typeof helper === alias3 + ? helper.call(alias1, { + name: 'content', + hash: {}, + data: data, + loc: { + start: { line: 30, column: 8 }, + end: { line: 30, column: 21 }, + }, + }) + : helper)) != null + ? stack1 + : '') + + '\n
\n' + ) + }, + compiler: [8, '>= 4.3.0'], + main: function(container, depth0, helpers, partials, data) { + var stack1, + helper, + alias1 = depth0 != null ? depth0 : container.nullContext || {}, + alias2 = container.hooks.helperMissing, + alias3 = 'function', + alias4 = container.escapeExpression, + lookupProperty = + container.lookupProperty || + function(parent, propertyName) { + if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { + return parent[propertyName] + } + return undefined } - return undefined - }; - return "\n\n\n\n \n \n \n " - + alias4(((helper = (helper = lookupProperty(helpers,"page_title") || (depth0 != null ? lookupProperty(depth0,"page_title") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"page_title","hash":{},"data":data,"loc":{"start":{"line":8,"column":9},"end":{"line":8,"column":23}}}) : helper))) - + "\n\n \n\n\n\n \n
\n
\n" - + ((stack1 = lookupProperty(helpers,"each").call(alias1,(depth0 != null ? lookupProperty(depth0,"items") : depth0),{"name":"each","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":22,"column":6},"end":{"line":32,"column":15}}})) != null ? stack1 : "") - + "
\n
\n \n\n\n\n"; -},"useData":true}); + return ( + '\n\n\n\n \n \n \n ' + + alias4( + ((helper = + (helper = + lookupProperty(helpers, 'page_title') || + (depth0 != null ? lookupProperty(depth0, 'page_title') : depth0)) != + null + ? helper + : alias2), + typeof helper === alias3 + ? helper.call(alias1, { + name: 'page_title', + hash: {}, + data: data, + loc: { + start: { line: 8, column: 9 }, + end: { line: 8, column: 23 }, + }, + }) + : helper), + ) + + '\n\n \n\n\n\n \n
\n
\n' + + ((stack1 = lookupProperty(helpers, 'each').call( + alias1, + depth0 != null ? lookupProperty(depth0, 'items') : depth0, + { + name: 'each', + hash: {}, + fn: container.program(1, data, 0), + inverse: container.noop, + data: data, + loc: { + start: { line: 22, column: 6 }, + end: { line: 32, column: 15 }, + }, + }, + )) != null + ? stack1 + : '') + + '
\n
\n \n\n\n\n' + ) + }, + useData: true, +})