Commit 053bde1d26
Verified · cmc
Layout: unified · split
README.org +59 −63
| @@ -15,14 +15,13 @@ The main site components are: | ||
| 15 | 15 | |
| 16 | 16 | - Org source files in =content/=, containing blog posts and pages. That directory |
| 17 | 17 | is the site's URL root: =content/blog/post.org= publishes at =/blog/post.html=. |
| 18 | - A configuration file (=content/orgo.toml=) that specifies the base | |
| 19 | URL, navigation, templates, and the generated pages (home, blog and | |
| 20 | garden indexes, tags, and the RSS feed). | |
| 18 | - A configuration file (=content/orgo.toml=) that specifies the base URL, | |
| 19 | navigation, templates, and the generated pages (home, blog and garden indexes, | |
| 20 | tags, and the RSS feed). | |
| 21 | 21 | - HTML templates in =content/templates/=. |
| 22 | - Assets such as images and style sheets, located in designated | |
| 23 | subdirectories. =theme/static/= is published at =/=. | |
| 24 | - Utility scripts (e.g., =build.py=) to facilitate building and | |
| 25 | deployment. | |
| 22 | - Assets such as images and style sheets, located in designated subdirectories. | |
| 23 | =theme/static/= is published at =/=. | |
| 24 | - Utility scripts (e.g., =build.py=) to facilitate building and deployment. | |
| 26 | 25 | |
| 27 | 26 | ** Dependencies |
| 28 | 27 | |
| @@ -35,22 +34,22 @@ The publishing system depends on: | ||
| 35 | 34 | |
| 36 | 35 | ** Configuration |
| 37 | 36 | |
| 38 | You can customize site settings within the =content/orgo.toml= file. | |
| 39 | This file establishes key variables such as: | |
| 37 | You can customize site settings within the =content/orgo.toml= file. This file | |
| 38 | establishes key variables such as: | |
| 40 | 39 | |
| 41 | 40 | - The base URL for links. |
| 42 | 41 | - Which pages appear in the navigation, and in what order. |
| 43 | 42 | - Per-directory template rules. |
| 44 | 43 | - The collections that generate the indexes, tag pages, and feed. |
| 45 | 44 | |
| 46 | Users intending to modify site parameters should review and edit this | |
| 47 | file accordingly. The orgo documentation contains extensive details on | |
| 48 | configuration options and expected formats. | |
| 45 | Users intending to modify site parameters should review and edit this file | |
| 46 | accordingly. The orgo documentation contains extensive details on configuration | |
| 47 | options and expected formats. | |
| 49 | 48 | |
| 50 | 49 | ** Setup Instructions |
| 51 | 50 | |
| 52 | To obtain a working copy of this repository, execute the following | |
| 53 | commands within a shell environment or Emacs shell interface: | |
| 51 | To obtain a working copy of this repository, execute the following commands | |
| 52 | within a shell environment or Emacs shell interface: | |
| 54 | 53 | |
| 55 | 54 | #+begin_src shell |
| 56 | 55 | git clone https://gitbay.org/cmc/cleberg.net |
| @@ -58,35 +57,35 @@ cd cleberg.net | ||
| 58 | 57 | emacs -nw |
| 59 | 58 | #+end_src |
| 60 | 59 | |
| 61 | For users employing Doom Emacs, open any repository Org file using | |
| 62 | =SPC f f= to access the content. | |
| 60 | For users employing Doom Emacs, open any repository Org file using =SPC f f= to | |
| 61 | access the content. | |
| 63 | 62 | |
| 64 | 63 | ** Building and Publishing the Site |
| 65 | 64 | |
| 66 | The =build.py= script wraps the build: it runs orgo, rewrites the footer's | |
| 67 | orgo version to match the orgo that ran, and then either deploys the result | |
| 68 | or serves it locally. | |
| 65 | The =build.py= script wraps the build: it runs orgo, rewrites the footer's orgo | |
| 66 | version to match the orgo that ran, and then either deploys the result or serves | |
| 67 | it locally. | |
| 69 | 68 | |
| 70 | 69 | Environment variables control what it does, and all default to off: |
| 71 | 70 | |
| 72 | 71 | - =BUILD=true= performs the build. |
| 73 | - =DEPLOY=true= deploys in production, or starts a development server | |
| 74 | on port 8000 otherwise. | |
| 75 | - =ENV=prod= selects production: image URLs are rewritten to be | |
| 76 | root-relative (see Deployment below) and the =ruff= pass is skipped. | |
| 77 | Anything else builds for development. | |
| 78 | - =DRY_RUN=true= turns a production deploy into a report. Production | |
| 79 | only; ignored everywhere else. | |
| 72 | - =DEPLOY=true= deploys in production, or starts a development server on port 8000 | |
| 73 | otherwise. | |
| 74 | - =ENV=prod= selects production: image URLs are rewritten to be root-relative (see | |
| 75 | Deployment below) and the =ruff= pass is skipped. Anything else builds for | |
| 76 | development. | |
| 77 | - =DRY_RUN=true= turns a production deploy into a report. Production only; ignored | |
| 78 | everywhere else. | |
| 80 | 79 | |
| 81 | 80 | Exactly one combination writes to the server: |
| 82 | 81 | |
| 83 | | =ENV= | =BUILD= | =DEPLOY= | =DRY_RUN= | What happens | Output | Server | | |
| 84 | |--------+---------+----------+-----------+---------------------------------------+--------------+-------------------| | |
| 85 | | unset | =true= | — | — | Development build, =ruff= first | =.build-dev/=| Untouched | | |
| 86 | | unset | =true= | =true= | — | Development build, then serve on :8000| =.build-dev/=| Untouched | | |
| 87 | | =prod= | =true= | — | — | Production build and image rewrite | =.build/= | Untouched | | |
| 88 | | =prod= | — | =true= | =true= | Reports what a deploy would change | — | Read only | | |
| 89 | | =prod= | =true= | =true= | — | Production build, then deploy | =.build/= | *Overwritten* | | |
| 82 | | =ENV= | =BUILD= | =DEPLOY= | =DRY_RUN= | What happens | Output | Server | | |
| 83 | |-------+-------+--------+---------+----------------------------------------+-------------+-------------| | |
| 84 | | unset | =true= | — | — | Development build, =ruff= first | =.build-dev/= | Untouched | | |
| 85 | | unset | =true= | =true= | — | Development build, then serve on :8000 | =.build-dev/= | Untouched | | |
| 86 | | =prod= | =true= | — | — | Production build and image rewrite | =.build/= | Untouched | | |
| 87 | | =prod= | — | =true= | =true= | Reports what a deploy would change | — | Read only | | |
| 88 | | =prod= | =true= | =true= | — | Production build, then deploy | =.build/= | *Overwritten* | | |
| 90 | 89 | |
| 91 | 90 | #+begin_src shell |
| 92 | 91 | # Development build: |
| @@ -105,20 +104,19 @@ ENV=prod DEPLOY=true DRY_RUN=true uv run build.py | ||
| 105 | 104 | ENV=prod BUILD=true DEPLOY=true uv run build.py |
| 106 | 105 | #+end_src |
| 107 | 106 | |
| 108 | Generated site files reside in =.build/= for production and | |
| 109 | =.build-dev/= for development. | |
| 107 | Generated site files reside in =.build/= for production and =.build-dev/= for | |
| 108 | development. | |
| 110 | 109 | |
| 111 | The deploy is =rsync --delete-before=, so files the build no longer | |
| 112 | produces are removed from the server. That is what makes the dry run | |
| 113 | worth having: a build that silently produced fewer pages would quietly | |
| 114 | delete the rest. Lines beginning =*deleting= in the dry-run output are | |
| 115 | what the real deploy would remove. | |
| 110 | The deploy is =rsync --delete-before=, so files the build no longer produces are | |
| 111 | removed from the server. That is what makes the dry run worth having: a build | |
| 112 | that silently produced fewer pages would quietly delete the rest. Lines | |
| 113 | beginning =*deleting= in the dry-run output are what the real deploy would remove. | |
| 116 | 114 | |
| 117 | Builds are incremental: orgo keeps an =.orgo-cache.json= inside the | |
| 118 | output directory and re-renders only what changed, so the directory is | |
| 119 | left in place between runs. Delete it for a clean build. The two | |
| 120 | environments use separate directories because production rewrites image | |
| 121 | URLs in the output and development does not. | |
| 115 | Builds are incremental: orgo keeps an =.orgo-cache.json= inside the output | |
| 116 | directory and re-renders only what changed, so the directory is left in place | |
| 117 | between runs. Delete it for a clean build. The two environments use separate | |
| 118 | directories because production rewrites image URLs in the output and development | |
| 119 | does not. | |
| 122 | 120 | |
| 123 | 121 | orgo can also build and preview on its own, without =build.py=: |
| 124 | 122 | |
| @@ -128,28 +126,27 @@ orgo serve content -o /tmp/preview | ||
| 128 | 126 | |
| 129 | 127 | ** Deployment |
| 130 | 128 | |
| 131 | Production builds rewrite image URLs to root-relative ones | |
| 132 | (=/img/blog/...=) instead of absolute =https://img.cleberg.net/= ones so | |
| 133 | the site renders standalone on the onion service without fetching assets | |
| 134 | off-onion. The stylesheet is already same-origin. | |
| 129 | Production builds rewrite image URLs to root-relative ones (=/img/blog/...=) | |
| 130 | instead of absolute =https://img.cleberg.net/= ones so the site renders standalone | |
| 131 | on the onion service without fetching assets off-onion. The stylesheet is | |
| 132 | already same-origin. | |
| 135 | 133 | |
| 136 | This means the web server must serve the image store at =/img/= on the | |
| 137 | =cleberg.net= vhost. The images live at =/var/www/img/= (their own host, | |
| 138 | =img.cleberg.net=); expose them under =cleberg.net/img/= with a symlink: | |
| 134 | This means the web server must serve the image store at =/img/= on the =cleberg.net= | |
| 135 | vhost. The images live at =/var/www/img/= (their own host, =img.cleberg.net=); | |
| 136 | expose them under =cleberg.net/img/= with a symlink: | |
| 139 | 137 | |
| 140 | 138 | #+begin_src shell |
| 141 | 139 | ln -s /var/www/img /var/www/cleberg.net/img |
| 142 | 140 | #+end_src |
| 143 | 141 | |
| 144 | Without this, images 404 in production. Development builds keep the | |
| 145 | absolute =img.cleberg.net= URLs, so local previews load images from the | |
| 146 | live host and need no symlink. | |
| 142 | Without this, images 404 in production. Development builds keep the absolute | |
| 143 | =img.cleberg.net= URLs, so local previews load images from the live host and need | |
| 144 | no symlink. | |
| 147 | 145 | |
| 148 | Once assets are same-origin, the vhost CSP can tighten =img-src=, | |
| 149 | =style-src=, and =font-src= back to ='self'=, and drop =bubbles.town= | |
| 150 | from =script-src=/=connect-src= (the vote widget was removed; only a | |
| 151 | plain link to Bubbles remains). After deploying, purge the Cloudflare | |
| 152 | cache (responses carry a 31-day =max-age=). | |
| 146 | Once assets are same-origin, the vhost CSP can tighten =img-src=, =style-src=, and | |
| 147 | =font-src= back to ='self'=, and drop =bubbles.town= from =script-src=/=connect-src= | |
| 148 | (the vote widget was removed; only a plain link to Bubbles remains). After | |
| 149 | deploying, purge the Cloudflare cache (responses carry a 31-day =max-age=). | |
| 153 | 150 | |
| 154 | 151 | ** Creating New Blog Posts |
| 155 | 152 | |
| @@ -157,8 +154,7 @@ To add new blog content, follow this procedure within Emacs: | ||
| 157 | 154 | |
| 158 | 155 | 1. Open a new Org file (via =C-x C-f= or Doom\'s =SPC f f=). |
| 159 | 156 | 2. Insert the contents of the post template with =C-x i=, sourcing from |
| 160 | =utils/template.org=. | |
| 157 | =utils/template.org=. | |
| 161 | 158 | 3. Modify the new file as needed to add post content and metadata. |
| 162 | 159 | |
| 163 | This method streamlines content creation by reusing a preformatted | |
| 164 | template. | |
| 160 | This method streamlines content creation by reusing a preformatted template. | |