Init
This commit is contained in:
commit
9f2f494f3c
|
@ -0,0 +1,12 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[{Makefile,*.go}]
|
||||
indent_style = tab
|
|
@ -0,0 +1,3 @@
|
|||
*.ico filter=lfs diff=lfs merge=lfs -text
|
||||
*.woff filter=lfs diff=lfs merge=lfs -text
|
||||
*.woff2 filter=lfs diff=lfs merge=lfs -text
|
|
@ -0,0 +1 @@
|
|||
/out
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
default:
|
||||
interruptible: true
|
||||
tags:
|
||||
- docker
|
||||
- linux
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
build:generate_html:
|
||||
stage: build
|
||||
artifacts:
|
||||
expire_in: 1 hour
|
||||
paths:
|
||||
- out/
|
||||
image: golang:1.20-alpine
|
||||
script:
|
||||
- apk --no-cache add minify make
|
||||
- make
|
||||
|
||||
deploy:cloudflare_pages:
|
||||
stage: deploy
|
||||
image:
|
||||
name: node:20-alpine
|
||||
entrypoint: ['']
|
||||
script: |
|
||||
npx wrangler pages deploy \
|
||||
--project-name=folliehiyuki-cdn \
|
||||
--branch="$CI_COMMIT_REF_NAME" \
|
||||
out/
|
||||
dependencies:
|
||||
- build:generate_html
|
|
@ -0,0 +1,7 @@
|
|||
Copyright © 2023 Hoang Nguyen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,21 @@
|
|||
.DEFAULT_GOAL := bundle
|
||||
|
||||
OUTPUT_DIR ?= out
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(OUTPUT_DIR)
|
||||
|
||||
.PHONY: gen
|
||||
gen:
|
||||
@mkdir -p $(OUTPUT_DIR)
|
||||
@cp -rf src/* $(OUTPUT_DIR)
|
||||
@OUTPUT_DIR=$(OUTPUT_DIR) \
|
||||
find ./$(OUTPUT_DIR) -mindepth 1 -type d -print -exec go run ./tools/update_html.go {} \;
|
||||
|
||||
.PHONY: minify
|
||||
minify:
|
||||
@minify -r ./$(OUTPUT_DIR) -o .
|
||||
|
||||
.PHONY: bundle
|
||||
bundle: clean gen minify
|
|
@ -0,0 +1,45 @@
|
|||
# FollieHiyuki's CDN
|
||||
|
||||
This is a small website, acting like a centralized source for all of my web assets. Most of them are vendored fonts and small CSS files.
|
||||
|
||||
The website is deployed to Cloudflare Pages and is available at <https://cdn.folliehiyuki.com>.
|
||||
|
||||
## FAQ
|
||||
|
||||
> Why not `<link href="url-to-original-source">`?
|
||||
|
||||
I like being in control of my own stuff. Also, it's because my websites have a strict `Content-Security-Policy` header value (see [_headers](./src/_headers) file for an example).
|
||||
|
||||
> Why not using Chrome or Nginx directory listing?
|
||||
|
||||
I like some theming and little directory/file icons. Also, CloudFlare Pages (where I deploy this project to) isn't a VM hosting platform but a [FaaS](https://en.wikipedia.org/wiki/Function_as_a_Service) provider.
|
||||
|
||||
> Why not using `tree(1)`?
|
||||
|
||||
```bash
|
||||
$ find ./out/ -mindepth 1 -type d -print -exec sh -c 'tree "$0" \
|
||||
-a \
|
||||
-i \
|
||||
-F \
|
||||
-H "." \
|
||||
-I "index.html" \
|
||||
-T "$0" \
|
||||
-L 1 \
|
||||
-o "$0/index.html" \
|
||||
--noreport \
|
||||
--dirsfirst \
|
||||
--charset utf-8 \
|
||||
--ignore-case' {} \;
|
||||
```
|
||||
|
||||
Meh?
|
||||
|
||||
Also, `tree` injects its metadata, CSS and copyright notice into the `index.html` file. Yes, I can yank them out with something like [htmlq](https://github.com/mgdm/htmlq), but I also want to insert my own styling and stuff.
|
||||
|
||||
> Why not using [minify](https://github.com/tdewolff/minify)'s library but its CLI?
|
||||
|
||||
Using the CLI is much easier. And, I don't want a dedicated Go module for this small project with external dependencies.
|
||||
|
||||
## License
|
||||
|
||||
All the vendored files use to their original licenses. Other are licensed under MIT.
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
X-Frame-Options: DENY
|
||||
X-Content-Type-Options: nosniff
|
||||
X-DNS-Prefetch-Control: off
|
||||
Referrer-Policy: no-referrer
|
||||
Permissions-Policy: interest-cohort=(), geolocation=(), camera=(), microphone=(), display-capture=(), web-share=()
|
||||
Content-Security-Policy: default-src 'self'; script-src 'none'; frame-ancestors 'none'; child-src 'none'; base-uri 'self'
|
|
@ -0,0 +1,349 @@
|
|||
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
||||
|
||||
/* Document
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Correct the line height in all browsers.
|
||||
* 2. Prevent adjustments of font size after orientation changes in iOS.
|
||||
*/
|
||||
|
||||
html {
|
||||
line-height: 1.15; /* 1 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/* Sections
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the margin in all browsers.
|
||||
*/
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the `main` element consistently in IE.
|
||||
*/
|
||||
|
||||
main {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the font size and margin on `h1` elements within `section` and
|
||||
* `article` contexts in Chrome, Firefox, and Safari.
|
||||
*/
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
margin: 0.67em 0;
|
||||
}
|
||||
|
||||
/* Grouping content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in Firefox.
|
||||
* 2. Show the overflow in Edge and IE.
|
||||
*/
|
||||
|
||||
hr {
|
||||
box-sizing: content-box; /* 1 */
|
||||
height: 0; /* 1 */
|
||||
overflow: visible; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
pre {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/* Text-level semantics
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the gray background on active links in IE 10.
|
||||
*/
|
||||
|
||||
a {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Remove the bottom border in Chrome 57-
|
||||
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
|
||||
*/
|
||||
|
||||
abbr[title] {
|
||||
border-bottom: none; /* 1 */
|
||||
text-decoration: underline; /* 2 */
|
||||
text-decoration: underline dotted; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font weight in Chrome, Edge, and Safari.
|
||||
*/
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inheritance and scaling of font size in all browsers.
|
||||
* 2. Correct the odd `em` font sizing in all browsers.
|
||||
*/
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: monospace, monospace; /* 1 */
|
||||
font-size: 1em; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct font size in all browsers.
|
||||
*/
|
||||
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent `sub` and `sup` elements from affecting the line height in
|
||||
* all browsers.
|
||||
*/
|
||||
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
/* Embedded content
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Remove the border on images inside links in IE 10.
|
||||
*/
|
||||
|
||||
img {
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
/* Forms
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* 1. Change the font styles in all browsers.
|
||||
* 2. Remove the margin in Firefox and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
font-family: inherit; /* 1 */
|
||||
font-size: 100%; /* 1 */
|
||||
line-height: 1.15; /* 1 */
|
||||
margin: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the overflow in IE.
|
||||
* 1. Show the overflow in Edge.
|
||||
*/
|
||||
|
||||
button,
|
||||
input { /* 1 */
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inheritance of text transform in Edge, Firefox, and IE.
|
||||
* 1. Remove the inheritance of text transform in Firefox.
|
||||
*/
|
||||
|
||||
button,
|
||||
select { /* 1 */
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the inability to style clickable types in iOS and Safari.
|
||||
*/
|
||||
|
||||
button,
|
||||
[type="button"],
|
||||
[type="reset"],
|
||||
[type="submit"] {
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner border and padding in Firefox.
|
||||
*/
|
||||
|
||||
button::-moz-focus-inner,
|
||||
[type="button"]::-moz-focus-inner,
|
||||
[type="reset"]::-moz-focus-inner,
|
||||
[type="submit"]::-moz-focus-inner {
|
||||
border-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the focus styles unset by the previous rule.
|
||||
*/
|
||||
|
||||
button:-moz-focusring,
|
||||
[type="button"]:-moz-focusring,
|
||||
[type="reset"]:-moz-focusring,
|
||||
[type="submit"]:-moz-focusring {
|
||||
outline: 1px dotted ButtonText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the padding in Firefox.
|
||||
*/
|
||||
|
||||
fieldset {
|
||||
padding: 0.35em 0.75em 0.625em;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the text wrapping in Edge and IE.
|
||||
* 2. Correct the color inheritance from `fieldset` elements in IE.
|
||||
* 3. Remove the padding so developers are not caught out when they zero out
|
||||
* `fieldset` elements in all browsers.
|
||||
*/
|
||||
|
||||
legend {
|
||||
box-sizing: border-box; /* 1 */
|
||||
color: inherit; /* 2 */
|
||||
display: table; /* 1 */
|
||||
max-width: 100%; /* 1 */
|
||||
padding: 0; /* 3 */
|
||||
white-space: normal; /* 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
|
||||
*/
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the default vertical scrollbar in IE 10+.
|
||||
*/
|
||||
|
||||
textarea {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Add the correct box sizing in IE 10.
|
||||
* 2. Remove the padding in IE 10.
|
||||
*/
|
||||
|
||||
[type="checkbox"],
|
||||
[type="radio"] {
|
||||
box-sizing: border-box; /* 1 */
|
||||
padding: 0; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Correct the cursor style of increment and decrement buttons in Chrome.
|
||||
*/
|
||||
|
||||
[type="number"]::-webkit-inner-spin-button,
|
||||
[type="number"]::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the odd appearance in Chrome and Safari.
|
||||
* 2. Correct the outline style in Safari.
|
||||
*/
|
||||
|
||||
[type="search"] {
|
||||
-webkit-appearance: textfield; /* 1 */
|
||||
outline-offset: -2px; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the inner padding in Chrome and Safari on macOS.
|
||||
*/
|
||||
|
||||
[type="search"]::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Correct the inability to style clickable types in iOS and Safari.
|
||||
* 2. Change font properties to `inherit` in Safari.
|
||||
*/
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button; /* 1 */
|
||||
font: inherit; /* 2 */
|
||||
}
|
||||
|
||||
/* Interactive
|
||||
========================================================================== */
|
||||
|
||||
/*
|
||||
* Add the correct display in Edge, IE 10+, and Firefox.
|
||||
*/
|
||||
|
||||
details {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the correct display in all browsers.
|
||||
*/
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/* Misc
|
||||
========================================================================== */
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10+.
|
||||
*/
|
||||
|
||||
template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the correct display in IE 10.
|
||||
*/
|
||||
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
:root {
|
||||
--color-bg: #f2f4f8;
|
||||
--color-fg: #3b4252;
|
||||
--color-blue: #5e81ac;
|
||||
--color-cyan: #88c0d0;
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
--color-bg: #3b4252;
|
||||
--color-fg: #eceff4;
|
||||
--color-blue: #81a1c1;
|
||||
}
|
||||
}
|
||||
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body {
|
||||
box-sizing: border-box;
|
||||
font-family: "Iosevka Aile Web", sans-serif;
|
||||
line-height: 1.5;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: var(--color-fg);
|
||||
background: var(--color-bg);
|
||||
}
|
||||
|
||||
main {
|
||||
margin: auto;
|
||||
max-width: 48rem;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--color-blue);
|
||||
text-decoration: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: var(--color-cyan);
|
||||
border-bottom: 0.1rem solid var(--color-cyan);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.fa-solid {
|
||||
font-family: "Font Awesome 6 Free";
|
||||
font-size: 1rem;
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
@font-face {
|
||||
font-family: "devicon";
|
||||
font-display: block;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
src: url("devicon.woff") format("woff");
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
@font-face {
|
||||
font-family: "Font Awesome 6 Brands";
|
||||
font-display: block;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
src: url("fa-brands-400.woff2") format("woff2");
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
@font-face {
|
||||
font-family: "Font Awesome 6 Free";
|
||||
font-display: block;
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
src: url("fa-solid-900.woff2") format("woff2");
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
@font-face {
|
||||
font-family: "font-logos";
|
||||
font-display: block;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
src: url("font-logos.woff2") format("woff2");
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,35 @@
|
|||
@font-face {
|
||||
font-family: "Iosevka Aile Web";
|
||||
font-display: swap;
|
||||
font-weight: 400;
|
||||
font-stretch: normal;
|
||||
font-style: normal;
|
||||
src: url("iosevka-aile-regular.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Iosevka Aile Web";
|
||||
font-display: swap;
|
||||
font-weight: 400;
|
||||
font-stretch: normal;
|
||||
font-style: italic;
|
||||
src: url("iosevka-aile-italic.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Iosevka Aile Web";
|
||||
font-display: swap;
|
||||
font-weight: 700;
|
||||
font-stretch: normal;
|
||||
font-style: normal;
|
||||
src: url("iosevka-aile-bold.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Iosevka Aile Web";
|
||||
font-display: swap;
|
||||
font-weight: 700;
|
||||
font-stretch: normal;
|
||||
font-style: italic;
|
||||
src: url("iosevka-aile-bolditalic.woff2") format("woff2");
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,35 @@
|
|||
@font-face {
|
||||
font-family: "Iosevka Web";
|
||||
font-display: swap;
|
||||
font-weight: 400;
|
||||
font-stretch: normal;
|
||||
font-style: normal;
|
||||
src: url("iosevka-regular.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Iosevka Web";
|
||||
font-display: swap;
|
||||
font-weight: 400;
|
||||
font-stretch: normal;
|
||||
font-style: italic;
|
||||
src: url("iosevka-italic.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Iosevka Web";
|
||||
font-display: swap;
|
||||
font-weight: 700;
|
||||
font-stretch: normal;
|
||||
font-style: normal;
|
||||
src: url("iosevka-bold.woff2") format("woff2");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Iosevka Web";
|
||||
font-display: swap;
|
||||
font-weight: 700;
|
||||
font-stretch: normal;
|
||||
font-style: italic;
|
||||
src: url("iosevka-bolditalic.woff2") format("woff2");
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<title>FollieCDN</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="FollieCDN">
|
||||
|
||||
<link rel="stylesheet" href="/css/normalize.css">
|
||||
<link rel="stylesheet" href="/css/self.css">
|
||||
<link rel="stylesheet" href="/fonts/iosevka/iosevka-aile.css">
|
||||
<link rel="stylesheet" href="/fonts/font-awesome/solid.css">
|
||||
|
||||
<link rel="canonical" href="https://cdn.folliehiyuki.com">
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-bolditalic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>FollieHiyuki's personal web assets</h1>
|
||||
<p>
|
||||
Hi! Welcome to my "Content Delivery Network" <s>running</s> freeloading on Cloudflare. The files served here are used to power my websites, including
|
||||
<a href="https://www.folliehiyuki.com" rel="author noopener">folliehiyuki.com</a> and
|
||||
<a href="https://docs.folliehiyuki.com" rel="noopener">docs.folliehiyuki.com</a>. The source code is avaliable to see on
|
||||
<a href="https://gitlab.com/FollieHiyuki/cdn" rel="noreferrer nofollow">GitLab</a>.
|
||||
</p>
|
||||
<h2>Packages</h2>
|
||||
<p>
|
||||
<span class="fa-solid"></span> <a href="./fonts/">fonts</a> - Various 3rd-party fonts I use everywhere<br>
|
||||
<span class="fa-solid"></span> <a href="./css/">css</a> - Some minimal, opinionated CSS settings<br>
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-us">
|
||||
<head>
|
||||
<title>{{ .Path }} | FollieCDN</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="{{ .Path }} | FollieCDN">
|
||||
|
||||
<link rel="stylesheet" href="/css/normalize.css">
|
||||
<link rel="stylesheet" href="/css/self.css">
|
||||
<link rel="stylesheet" href="/fonts/iosevka/iosevka-aile.css">
|
||||
<link rel="stylesheet" href="/fonts/font-awesome/solid.css">
|
||||
|
||||
<link rel="canonical" href="https://cdn.folliehiyuki.com/{{ .Path }}">
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-bolditalic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
<link rel="preload" href="/fonts/iosevka/iosevka-aile-regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>{{ .Path }}</h1>
|
||||
<p>
|
||||
<span class="fa-solid"></span> <a href="../">../</a><br>
|
||||
{{ range .Entries }}
|
||||
<span class="fa-solid">{{ if .IsDir }}{{ else }} {{ end }}</span>
|
||||
<a href="./{{ .Name }}">{{ .Name }}</a><br>
|
||||
{{ end }}
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,85 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"html/template"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// A struct based on fs.DirEntry
|
||||
type Entry struct {
|
||||
Name string
|
||||
IsDir bool
|
||||
}
|
||||
|
||||
var destPrefix = os.Getenv("OUTPUT_DIR")
|
||||
|
||||
//go:embed index.html.tmpl
|
||||
var indexTemplate string
|
||||
|
||||
// Return the list of entries inside a specified directory
|
||||
func getEntries(dirPath string) ([]Entry, error) {
|
||||
dirEntries, err := os.ReadDir(dirPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
entryList := []Entry{}
|
||||
for _, entry := range dirEntries {
|
||||
// Of course we want to ignore index.html file in the directory listing
|
||||
if entry.Name() != "index.html" {
|
||||
entryName := entry.Name()
|
||||
if entry.IsDir() {
|
||||
entryName = entryName + "/"
|
||||
}
|
||||
entryList = append(entryList, Entry{Name: entryName, IsDir: entry.IsDir()})
|
||||
}
|
||||
}
|
||||
|
||||
return entryList, nil
|
||||
}
|
||||
|
||||
// Output an index.html file listing entries to a specified destination
|
||||
func renderIndexHTML(entries []Entry, dest string) error {
|
||||
tmpl, err := template.New("index.html").Parse(indexTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Get rid of ./out/ prefix from find(1) result
|
||||
re := regexp.MustCompile(`^\.\/` + destPrefix + `\/`)
|
||||
dirPath := re.ReplaceAllString(dest, "")
|
||||
|
||||
data := struct {
|
||||
Path string
|
||||
Entries []Entry
|
||||
}{Path: dirPath, Entries: entries}
|
||||
|
||||
// Open the destination index.html file
|
||||
destFile, err := os.Create(path.Join(dest, "index.html"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tmpl.Execute(destFile, data)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
log.Fatalln("Requires exactly 1 argument (a directory path to evaluate).")
|
||||
}
|
||||
|
||||
dirPath := os.Args[1]
|
||||
entries, err := getEntries(dirPath)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
err = renderIndexHTML(entries, dirPath)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue