├── workers-site
├── .cargo-ok
├── .gitignore
├── package.json
├── package-lock.json
└── index.js
├── src
├── index.md
├── about.md
└── articles
│ ├── post1.md
│ └── post2.md
├── README.md
├── .gitignore
├── layouts
├── partials
│ └── navigation.hbt
├── about.hbs
├── article.hbs
└── index.hbs
├── wrangler.toml
├── .github
└── workflows
│ ├── integration.yml
│ └── deploy.yml
├── package.json
├── public
├── about
│ └── index.html
├── index.html
└── articles
│ ├── write-drunk-edit-sober
│ └── index.html
│ └── its-not-a-bug-its-an-undocumented-feature
│ └── index.html
└── dist
└── worker.js
/workers-site/.cargo-ok:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: index.hbs
3 | ---
--------------------------------------------------------------------------------
/workers-site/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | worker
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GithubCMS
2 | Code repository for how to use Github as a CMS
3 |
4 |
--------------------------------------------------------------------------------
/src/about.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: about.hbs
3 | ---
4 | Info about your cool project!
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Note: you may end up needing to comment out node_modules
2 | node_modules
3 |
--------------------------------------------------------------------------------
/layouts/partials/navigation.hbt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/wrangler.toml:
--------------------------------------------------------------------------------
1 | name = "buffalo-traceroute"
2 | type = "webpack"
3 | account_id = ""
4 | workers_dev = true
5 | # route = ""
6 | # zone_id = ""
7 |
8 | [site]
9 | bucket = "./public"
10 | entry-point = "workers-site"
11 |
--------------------------------------------------------------------------------
/workers-site/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "name": "worker",
4 | "version": "1.0.0",
5 | "description": "A template for kick starting a Cloudflare Workers project",
6 | "main": "index.js",
7 | "author": "Ashley Lewis ",
8 | "license": "MIT",
9 | "dependencies": {
10 | "@cloudflare/kv-asset-handler": "^0.0.5"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/.github/workflows/integration.yml:
--------------------------------------------------------------------------------
1 | name: Integration
2 |
3 | on:
4 | pull_request:
5 | branches: [ master ]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | strategy:
11 | matrix:
12 | node-version: [10.x, 12.x]
13 | steps:
14 | - uses: actions/checkout@v2
15 | - name: Use Node.js ${{ matrix.node-version }}
16 | uses: actions/setup-node@v1
17 | with:
18 | node-version: ${{ matrix.node-version }}
19 | - run: npm ci
20 | - run: npm run build --if-present
21 | - run: npm test
22 | env:
23 | CI: true
24 |
--------------------------------------------------------------------------------
/src/articles/post1.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'Write drunk, edit sober'
3 | layout: article.hbs
4 | ---
5 |
6 | ## Some Amazing Drinking Quotes
7 | * "I like to have a martini, two at the very most. After three I’m under the table, after four I’m under my host." (Dorothy Parker)
8 | * "I distrust camels, and anyone else who can go a week without a drink." (Joe E Ellis)
9 | * "Work is the curse of the drinking classes." (Oscar Wilde)
10 | * "A woman drove me to drink, and I hadn’t even the courtesy to thank her." (W.C. Fields)
11 | * "I have taken more out of alcohol than alcohol has taken out of me." (Winston Churchill)
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "buffaloTraceRoute",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "build": "node build.js",
8 | "test": "echo \"No Tests Yet!\" "
9 | },
10 | "keywords": [],
11 | "author": "",
12 | "license": "ISC",
13 | "devDependencies": {
14 | "handlebars": "^4.7.3",
15 | "jstransformer-handlebars": "^1.1.0",
16 | "metalsmith": "^2.3.0",
17 | "metalsmith-collections": "^0.9.0",
18 | "metalsmith-layouts": "^2.3.1",
19 | "metalsmith-markdown": "^1.3.0",
20 | "metalsmith-permalinks": "^2.2.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/articles/post2.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 'Its not a bug its an undocumented feature'
3 | layout: article.hbs
4 | ---
5 |
6 | ## Some Amazing Programming Quotes
7 | * "A user interface is like a joke. If you have to explain it, it’s not that good."
8 | * "Measuring programming progress by lines of code is like measuring aircraft building progress by weight." (Bill Gates)
9 | * "One man’s crappy software is another man’s full time job" (Jessica Gaston)
10 | * "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." (Martin Golding)
11 | * "Programming is like sex. One mistake and you have to support it for the rest of your life." (Michael Sinz)
--------------------------------------------------------------------------------
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: Deploy
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | deploy:
10 | runs-on: ubuntu-latest
11 | name: Deploy
12 | strategy:
13 | matrix:
14 | node-version: [10.x]
15 |
16 | steps:
17 | - uses: actions/checkout@v2
18 | - name: Use Node.js ${{ matrix.node-version }}
19 | uses: actions/setup-node@v1
20 | with:
21 | node-version: ${{ matrix.node-version }}
22 | - run: npm install
23 | - uses: actions/checkout@master
24 | - name: Build site
25 | run: "npm run build"
26 | - name: Publish
27 | uses: cloudflare/wrangler-action@1.1.0
28 | with:
29 | apiToken: ${{ secrets.CF_API_TOKEN }}
30 |
--------------------------------------------------------------------------------
/workers-site/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "worker",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@cloudflare/kv-asset-handler": {
8 | "version": "0.0.5",
9 | "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.0.5.tgz",
10 | "integrity": "sha512-7yLMAUZD1XQNKzmktYCcUUPB+wXmQENv1MMi8QEMs0rzL01e0XEyCUUDauRXHzxi7dBbSUGA5RS23h890ncKog==",
11 | "requires": {
12 | "mime": "^2.4.4"
13 | }
14 | },
15 | "mime": {
16 | "version": "2.4.4",
17 | "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz",
18 | "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA=="
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/layouts/about.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 |
28 | {{>navigation }}
29 |
30 | {{{contents}}}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/layouts/article.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 |
28 | {{>navigation }}
29 |
30 | {{{contents}}}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/layouts/index.hbs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 |
28 | {{>navigation }}
29 |
30 | {{#each articles }}
31 |
{{ title }}
32 |
{{ description }}
33 | {{/each }}
34 |
35 |
36 |
--------------------------------------------------------------------------------
/public/about/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 |
28 |
34 |
Info about your cool project!
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 |
28 |
39 |
40 |
--------------------------------------------------------------------------------
/public/articles/write-drunk-edit-sober/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 |
28 |
34 |
Some Amazing Drinking Quotes
35 |
36 | - "I like to have a martini, two at the very most. After three I’m under the table, after four I’m under my host." (Dorothy Parker)
37 | - "I distrust camels, and anyone else who can go a week without a drink." (Joe E Ellis)
38 | - "Work is the curse of the drinking classes." (Oscar Wilde)
39 | - "A woman drove me to drink, and I hadn’t even the courtesy to thank her." (W.C. Fields)
40 | - "I have taken more out of alcohol than alcohol has taken out of me." (Winston Churchill)
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/public/articles/its-not-a-bug-its-an-undocumented-feature/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
27 |
28 |
34 |
Some Amazing Programming Quotes
35 |
36 | - "A user interface is like a joke. If you have to explain it, it’s not that good."
37 | - "Measuring programming progress by lines of code is like measuring aircraft building progress by weight." (Bill Gates)
38 | - "One man’s crappy software is another man’s full time job" (Jessica Gaston)
39 | - "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." (Martin Golding)
40 | - "Programming is like sex. One mistake and you have to support it for the rest of your life." (Michael Sinz)
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/workers-site/index.js:
--------------------------------------------------------------------------------
1 | import { getAssetFromKV, mapRequestToAsset } from '@cloudflare/kv-asset-handler'
2 |
3 | /**
4 | * The DEBUG flag will do two things that help during development:
5 | * 1. we will skip caching on the edge, which makes it easier to
6 | * debug.
7 | * 2. we will return an error message on exception in your Response rather
8 | * than the default 404.html page.
9 | */
10 | const DEBUG = false
11 |
12 | addEventListener('fetch', event => {
13 | try {
14 | event.respondWith(handleEvent(event))
15 | } catch (e) {
16 | if (DEBUG) {
17 | return event.respondWith(
18 | new Response(e.message || e.toString(), {
19 | status: 500,
20 | }),
21 | )
22 | }
23 | event.respondWith(new Response('Internal Error', { status: 500 }))
24 | }
25 | })
26 |
27 | async function handleEvent(event) {
28 | const url = new URL(event.request.url)
29 | let options = {}
30 |
31 | /**
32 | * You can add custom logic to how we fetch your assets
33 | * by configuring the function `mapRequestToAsset`
34 | */
35 | // options.mapRequestToAsset = handlePrefix(/^\/docs/)
36 |
37 | try {
38 | if (DEBUG) {
39 | // customize caching
40 | options.cacheControl = {
41 | bypassCache: true,
42 | }
43 | }
44 | return await getAssetFromKV(event, options)
45 | } catch (e) {
46 | // if an error is thrown try to serve the asset at 404.html
47 | if (!DEBUG) {
48 | try {
49 | let notFoundResponse = await getAssetFromKV(event, {
50 | mapRequestToAsset: req => new Request(`${new URL(req.url).origin}/404.html`, req),
51 | })
52 |
53 | return new Response(notFoundResponse.body, { ...notFoundResponse, status: 404 })
54 | } catch (e) {}
55 | }
56 |
57 | return new Response(e.message || e.toString(), { status: 500 })
58 | }
59 | }
60 |
61 | /**
62 | * Here's one example of how to modify a request to
63 | * remove a specific prefix, in this case `/docs` from
64 | * the url. This can be useful if you are deploying to a
65 | * route on a zone, or if you only want your static content
66 | * to exist at a specific path.
67 | */
68 | function handlePrefix(prefix) {
69 | return request => {
70 | // compute the default (e.g. / -> index.html)
71 | let defaultAssetKey = mapRequestToAsset(request)
72 | let url = new URL(defaultAssetKey.url)
73 |
74 | // strip the prefix from the path for lookup
75 | url.pathname = url.pathname.replace(prefix, '/')
76 |
77 | // inherit all other props from the default request
78 | return new Request(url.toString(), defaultAssetKey)
79 | }
80 | }
--------------------------------------------------------------------------------
/dist/worker.js:
--------------------------------------------------------------------------------
1 | !function(a){var i={};function p(t){if(i[t])return i[t].exports;var n=i[t]={i:t,l:!1,exports:{}};return a[t].call(n.exports,n,n.exports,p),n.l=!0,n.exports}p.m=a,p.c=i,p.d=function(a,i,t){p.o(a,i)||Object.defineProperty(a,i,{enumerable:!0,get:t})},p.r=function(a){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},p.t=function(a,i){if(1&i&&(a=p(a)),8&i)return a;if(4&i&&"object"==typeof a&&a&&a.__esModule)return a;var t=Object.create(null);if(p.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:a}),2&i&&"string"!=typeof a)for(var n in a)p.d(t,n,function(i){return a[i]}.bind(null,n));return t},p.n=function(a){var i=a&&a.__esModule?function(){return a.default}:function(){return a};return p.d(i,"a",i),i},p.o=function(a,i){return Object.prototype.hasOwnProperty.call(a,i)},p.p="",p(p.s=4)}([function(a,i,p){"use strict";var t=p(1);a.exports=new t(p(2),p(3))},function(a,i,p){"use strict";function t(){this._types=Object.create(null),this._extensions=Object.create(null);for(var a=0;a{const i=new URL(a.url);let p=i.pathname;return p.endsWith("/")?p=p.concat("index.html"):n.a.getType(p)||(p=p.concat("/index.html")),i.pathname=p,new Request(i,a)},e={browserTTL:0,edgeTTL:864e4,bypassCache:!1},c=async(a,i)=>{i=Object.assign({ASSET_NAMESPACE:__STATIC_CONTENT,ASSET_MANIFEST:__STATIC_CONTENT_MANIFEST,mapRequestToAsset:o,cacheControl:e},i);const p=a.request,t=i.ASSET_NAMESPACE,c=i.ASSET_MANIFEST;if(!["GET","HEAD"].includes(p.method))throw new Error(`${p.method} is not a valid request method`);if(void 0===t)throw new Error(`there is no ${t} namespace bound to the script`);const l=i.mapRequestToAsset(p),d=new URL(l.url);let s=d.pathname.replace(/^\/+/,"");const m=caches.default,r=n.a.getType(s)||"text/plain";let v=!1;void 0!==c&&JSON.parse(c)[s]&&(s=JSON.parse(c)[s],v=!0);const x=`${d.origin}/${s}`,f=(()=>{switch(typeof i.cacheControl){case"function":return i.cacheControl(p);case"object":return i.cacheControl;default:return e}})();i.cacheControl=Object.assign({},e,f),i.cacheControl.bypassCache&&(v=!1);let u=null;if(v&&(u=await m.match(x)),u){let a=new Headers(u.headers);a.set("CF-Cache-Status","HIT"),u=new Response(u.body,{headers:a})}else{const p=await __STATIC_CONTENT.get(s,"arrayBuffer");if(null===p)throw new Error(`could not find ${s} in your content namespace`);u=new Response(p),v&&(u.headers.set("CF-Cache-Status","MISS"),u.headers.set("Cache-Control",`max-age=${i.cacheControl.edgeTTL}`),a.waitUntil(m.put(x,u.clone())),u.headers.delete("Cache-Control"))}return u.headers.set("Content-Type",r),i.cacheControl.browserTTL&&u.headers.set("Cache-Control",`max-age=${i.cacheControl.browserTTL}`),u};addEventListener("fetch",a=>{try{a.respondWith(async function(a){new URL(a.request.url);let i={};try{return await c(a,i)}catch(i){try{let i=await c(a,{mapRequestToAsset:a=>new Request(`${new URL(a.url).origin}/404.html`,a)});return new Response(i.body,{...i,status:404})}catch(a){}return new Response(i.message||i.toString(),{status:500})}}(a))}catch(i){0,a.respondWith(new Response("Internal Error",{status:500}))}})}]);
--------------------------------------------------------------------------------