Command line tool to author and manage a semi-ephemeral™ blog with a gemini archive.
-=> https://git.r.bdr.sh/rbdr/blog view source @ git.r.bdr.sh
-=> https://git.sr.ht/~rbdr/blog source mirror @ sourcehut
+=> https://git.r.bdr.sh/rbdr/blog ⧇ source
+=> https://git.sr.ht/~rbdr/blog ⧉ mirror
## Install
-At the moment only installation from source is available. Clone this repository and run:
+### Homebrew
+
+You can install using homebrew.
+
+```
+% brew tap rbdr/apps git@git.sr.ht:~rbdr/homebrew-apps
+% brew install rbdr/apps/blog
+```
+
+### Prebuilt Packages
+You can find pre-built packages for linux @ build.r.bdr.sh. There you can
+find a `.tar.gz` that includes only the binary, or `.rpm` and `.deb`
+distributions for fedora and debian that include a manpage.
+
+Binaries are provided for x86_64 and aarch64.
+
+Unstable releases are built directly from the main branch, while tagged
+versions have their own release and can be considered more stable.
+
+=> gemini://build.r.bdr.sh/blog blog pre-built releases @ gemini
+=> https://build.r.bdr.sh/blog blog pre-built releases @ https
+
+### From Source
+
+Make sure you have rust and Make installed. Clone the repository, and run:
```
-pnpm install -g .
+% make -e profile=release
```
-This will add the `blog` command to your shell.
+Then copy the file somewhere in your PATH
+
+```
+% cp ./target/release/blog /usr/local/bin
+```
## Usage I: Authoring
You can add this to the blog using the following command:
```
-blog --add path/to/blog_post.gmi
+blog add path/to/blog_post.gmi
```
This it will shift all posts and remove the oldest one if the limit of posts is reached (defualts to 3). This will also regenerate the static files.
If you need to make corrections to the latest post, use:
```
-blog --update path/to/blog_post.gmi
+blog update path/to/blog_post.gmi
```
This will replace the latest with the contents of the `path` without shifting the existing entries. It will also regenerate files.
Adding and updating posts regenerates the blog and archive, but you can always regenerate manually (eg. if you updated your static assets or templates):
```
-blog --generate
+blog generate
```
## Usage II: Publishing
You can publish to any valid `rsync` target (eg. ruben@coolserver.local:blog)
```
-blog --publish <remote_server>
+blog publish <remote_server>
```
This publishes the static files, including the html index, rss feed and plaintext version of the ephemeral blog.
You can also publish the archive of posts as a gemlog by passing a valid rsync target
```
-blog --publish-archive <remote_server>
+blog publish-archive <remote_server>
```
This will include *all the posts* in gemtext format.
Blog supports saving snapshots of the blog in git, and you can add and remove remotes with the following commands:
```
-blog --add-remote <git_url>
-blog --remove-remote
+blog add-remote <git_url>
+blog remove-remote
```
If a remote is present, it will be pulled before adding or updating, and pushed after it finishes. You can manually trigger this by calling
```
-blog --sync-up
-blog --sync-down
+blog sync-up
+blog sync-down
```
The blog will always sync down before adding to avoid going out of sync.
For the ephemeral blog you can create `feed.xml`, `index.html`, and `index.txt` inside of `templates`. These files are then parsed with [dot][dot] and passed the following variables:
```
-it.posts <Array<Post>>
+posts <Array<Post>> // The array of posts
+has_posts <Boolean> // Whether the posts array has any posts or not
+posts_length <Integer> // The number of posts in the posts array
+
+Post
+ +id <String> // The id of the post
+ +created_on <String> // The numerical timestamp when the blog post was added
+ +created_on_utc <String> // The RFC-2822 String of post creation date
+ +title <String> // The title of the post
+ +raw <String> // The raw gemini text of the template
+ +html <String> // The parsed html generated from the gemini
+ +escaped_html <String> // Same as html, but escaped for inclusion in XML
+```
+
+To customize your gemini and gopher archives you can provide an `index.gmi` and `index.gph` files that will be used as templates for the archive. However the data structure is different:
+
+```
+posts <Array<ArchivePost>> // The array of posts
+archive_length <Integer> // The number of archive posts in the posts array
Post
- +id <String> // The numerical timestamp when the blog post was added.
- +createdOn <String> // The UTC String of post creation date. (only feed.xml)
- +title <String> // The title of the post. (only feed.xml)
- +raw <String> // The raw gemini text of the template.
- +html <String> // The parsed html generated from the gemini.
+ +id <String> // The id of the post
+ +slug <String> // The slug of the post (used to generate URLs)
+ +title <String> // The title of the post
+```
+
+### The Template Syntax
+
+The template is a subset of DoT. You can print values, iterate over arrays, or check conditionals. The template does not allow expressions. You can only reference keys in the structure above.
+
+You can print values
+
+```
+{{= posts.raw }}
+```
+
+You can iterate over collections. With the format COLLECTION: MEMBER, where MEMBER will become part of the template below, and the template will be repeated for each member of COLLECTION.
+
+```
+{{~ posts: post }}
+{{= post.html}}
+{{~}}
```
-To customize your gemini archive you can provide an `index.gmi` file that will be used as a template for the archive. However the data structure is different, as it's just the gemini URL strings:
+Finally, you can do conditionals. To negate a conditional you can prepend !.
```
-it.posts <Array<String>>
+{{# !has_posts }}
+<p> There are no posts </p>
+{{#}}
```
+=> https://olado.github.io/doT/index.html DoT template language.
+
### Using Static Files
Any files inside the `static` directory of your blog data root (`$XDG_DATA_HOME/blog`) will be copied as is. This is useful for any images, javascript files or stylesheets that you use in your posts or templates.
## Changelog
+* 7.0.0 Rewritten in rust, supports gopher (geomyidae format).
* 6.0.0 Use custom templates, use XDG directories.
+
+=> ./blog_6.0.0.gmi Deprecated documentation for blog 6.0.0
+
* 5.0.2 Internal template changes
* 5.0.1 Dependency update
* 5.0.0 Publish using rsync instead of s3