From: Ruben Beltran del Rio Date: Sun, 4 Feb 2024 21:34:05 +0000 (+0100) Subject: Add page.gmi X-Git-Url: https://git.r.bdr.sh/rbdr/r.bdr.sh/commitdiff_plain/7f4a6af94da673e9fe7294c93719878696deda2a Add page.gmi --- diff --git a/index.gmi b/index.gmi index 769cf3c..7bc49e1 100644 --- a/index.gmi +++ b/index.gmi @@ -47,6 +47,7 @@ A command line tool to manage and publish an (almost) ephemeral https blog with ### Page A command line tool to generate HTML and static gemini websites from .gmi files +=> /page.gmi ./page.gmi => https://git.unlimited.pizza/rbdr/page page source code ### Page diff --git a/page.gmi b/page.gmi new file mode 100644 index 0000000..e75f61b --- /dev/null +++ b/page.gmi @@ -0,0 +1,121 @@ +--- title: /page.html +--- description: Page is a command-line tool that can generate a static website from gemtext. +## Page + +Command line tool to generate a static website and gemini capsule from a directory with gemtext. Written in rust! + +=> https://git.unlimited.pizza/rbdr/page view source. + +## Install + +### Homebrew +You can install using homebrew. + +``` +% brew tap rbdr/apps git@git.sr.ht:~rbdr/homebrew-apps +% brew install rbdr/apps/page +``` + +### From Source +Make sure you have rust and Make installed. Clone the repository, and run: + +``` +% make -e profile=release +``` + +Then copy the file somewhere in your PATH + +``` +% cp ./target/release/page /usr/local/bin +``` + +## Usage + +Go to the directory that contains your site and run page + +``` +% cd ~/projects/my_cool_page +% page +``` + +It will create two directories at the parent directory, they will have the same name as the current one but appending _html and _gemini respectively. + +``` +% ls ~/projects +my_cool_page/ +my_cool_page_gemini/ +my_cool_page_html/ +``` + +These pages contain the static files ready to be uploaded with a tool like scp, rsync or however you move files. + +## The files. + +The website directory has some requirements for page to work correctly. + +### Gemtext + +Any file with ending .gmi is interpreted as gemtext and will be parsed as html with the following rules: + +* The first two lines are checked for front matter +* If the first or second line starts with "--- title:", the text following will be treated as the title of the page and the line will be removed from the output. +* If the first or second line starts with "--- description:", the text following will be treated as the description of the page and the line will be removed from the output. +* URLs that end with the extension ".gmi" will be replaced with ".html" unless the url begins with "gemini:" + +Example, this could be index.gmi. The first link will be converted to html but the second won't: + +``` +--- title: Home +--- description: Clemland is dedicated to all things sound + +# Welcome to Clemland + +My projects are located here: + +=> /projects.gmi Projects + +This is a good gemini page: + +=> gemini://gemini.unlimited.pizza/page.gmi +``` + +### The layout + +A file called _layout.html at the root of the element. It must be present. It should include the three following keywords: +* {{ title }} will get replaced with the front matter title of the gemtext file. +* {{ description }} will get replaced with the front matter description of the gemtext file. +* {{ content }} will get replaced with the body of the gemtext file. + +For example: + +``` + + + + + + + + + + Clemland {{ title }} + + + + +
+ {{ content }} +
+ + +``` + +### Static files + +Any file that isn't gemtext or the layout will be copied as-is. This includes hidden files! The only ones that are excluded are .git and .gitignore. + +## Changelog + +* 1.3.0 Adds support for specifying alt-text for preformatted text blocks. +* 1.2.0 Wraps headings in a div to make certain layout operations easier. +* 1.1.0 Adds front matter for title and description, generates gemini and http directories.