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