Skip to content

Commit

Permalink
Generated by 6@6548833011
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 17, 2023
1 parent 47e69db commit f57f717
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
46 changes: 1 addition & 45 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,176 +20,132 @@
</nav>
<article>
<h1 id="s.s.-law">S.S. Law</h1>

<p>This is a lightweight system&#47;template for creating your own static website.</p>

<p>You create webpages in Markdown, in (your fork of) the repository (which you&#8217;ll have to commit and push if you&#8217;re using GitHub or GitLab as a host).
Afterwards they&#8217;re converted and &#8220;stapled&#8221; together with <a href="https://romanzolotarev.com/ssg.html">ssg</a> and <a href="https://kristaps.bsd.lv/lowdown/">lowdown</a>, then more advanced editing is done on them with <a href="#awk">AWK scripts</a> and finally everything is automatically &#8220;deployed&#8221;.
All of those operations are done by a couple of shell scripts.</p>

<p>It is based upon the setup for <a href="https://syndamia.com">my website</a>, so if you want to see a more advanced generation configuration, with some already created AWK scripts, <a href="https://gitlab.com/Syndamia/syndamiadotcom">click here</a>.</p>

<p>The goal of this template is to be as simple, understandable and expandable as possible.
You&#8217;re <strong>highly encouraged</strong> to figure out what everything does and to modify it according to your needs.
Everything that comes out of the box is just default configurations, remove what you don&#8217;t need and replace what you don&#8217;t like.</p>

<h2 id="contents">Contents</h2>

<ol>
<li><a href="#how-it-all-works-and-what-are-files-for">How it all works and what are files for</a>

<ol>
<li><a href="#scripts">Scripts</a></li>
<li><a href="#awk">AWK</a></li>
</ol></li>
<li><a href="#how-to-use">How to use</a>

<ol>
<li><a href="#configuring-generate-site">Configuring generate-site</a></li>
</ol></li>
<li><a href="#background">Background</a></li>
</ol>

<h2 id="how-it-all-works-and-what-are-files-for">How it all works and what are files for</h2>

<p>The main tools that power everything are ssg, lowdown and awk.
Essentially, ssg takes all of your website files, where</p>

<ul>
<li>Markdown pages are converted into <code>.html</code> files via lowdown, and then ssg inserts <code>_header.html</code> and <code>_footer.html</code> at the top and bottom of every such <code>.html</code> file</li>
<li>and all other files are taken as-is,</li>
</ul>

<p>and puts everything in a nice folder (<code>public</code>).
Afterwards, all AWK scripts are combined (which improves efficiency) into one and are ran on all <code>.html</code> files inside that folder.</p>

<h3 id="scripts">Scripts</h3>

<p>Inside the <code>generate-scripts</code> folder you&#8217;ll find the shell scripts, which automate the creation of your website.
The <code>get-</code> scripts download and &#8220;install&#8221; ssg and lowdown, while <code>generate-site.sh</code> does the actual site generation.</p>

<p><code>.gitlab-ci.yml</code> and <code>.github&#47;workflows&#47;github-ci.yml</code> are your pipeline configurations.
With them GitLab and GitHub (respectively) can generate your site automatically, with their servers, and host it for you too.
<code>deploy.sh</code> is a manual script which can be used to generate your site without GitHub or GitLab.
All three use the stuff in <code>generate-scripts</code>.
I&#8217;m encouraging you to remove the ones that you know you won&#8217;t need.</p>

<p><code>.ssgignore</code> has files and folder which will not be used for site generation.</p>

<h3 id="awk">AWK</h3>

<p>As mentioned, the preferred way to do special formatting to your generated (<code>html</code>) pages is via AWK scripts, because it&#8217;s decently simple and very powerful.
An AWK script goes through the file, line by line, and then matches text patterns, which can then be processed any way you want (including modifying the current line).</p>

<p>An example use case would be to add your own syntax, lets say you want to type <code>&#38;&#38;gb</code> in Markdown, and in the HTML page that should be replaced with some HTML code, containing the image of the British flag.
Or alternatively, what if you want to automatically insert an image next to every occurrence of a word, without having to specify it in the Markdown file.</p>

<p>Good resources for the language are</p>

<ul>
<li><a href="https://archive.org/details/pdfy-MgN0H1joIoDVoIC7">The AWK programming language</a></li>
<li><a href="https://www.researchgate.net/publication/2425273_Awk_---_A_Pattern_Scanning_and_Processing_Language_Second_Edition">Awk &#8211; A Pattern Scanning and Processing Language</a></li>
</ul>

<p>However, there are some caveats with the AWK scripts, in the context of this template:</p>

<ul>
<li><p>If every script printed the current line, you would get duplicated lines, so that is handled by <code>generate-site.sh</code>.
<em>Note:</em> If you don&#8217;t want to print a line, do <code>$0 = 0</code>.</p></li>
<li><p>For this reason, files in <code>awk-scripts</code> are managed by their first character:</p>

<ul>
<li>If it is <code>#</code>, then that script is a &#8220;library&#8221;, just a collection of custom AWK functions</li>
<li>If it is a capital latter, the script is ran before the line is printed</li>
<li>If it is a lowercase letter, the script is ran after the line is printed</li>
</ul>

<p>Do remember that any ordering between scripts with the same starting character isn&#8217;t guaranteed!</p></li>
<li><p>Running every script individually is inefficient, for every file, every script would have to open and close it, usually taking up about 100ms, which can stack up if you have a lot of content.
Additionally, you can&#8217;t share data from a pre-print script to a post-print script.
That is why all scripts are combined into one big script, in which first are the &#8220;libraries&#8221;, then the pre-print, the printing line and finally the post-print.
This means that:</p>

<ul>
<li>global variable names must be unique between all scripts</li>
<li><code>exit</code> cannot be used, instead have some sort of check in the &#8220;pattern&#8221; part of your rules (that need <code>exit</code>)</li>
</ul></li>
</ul>

<h2 id="how-to-use">How to use</h2>

<p>There are 3 provided ways to (easily) generate it, using pipelines and scripts:</p>

<ul>
<li>GitLab:

<ol>
<li>Fork the repository</li>
<li>Make sure <code>Pages</code> under <code>Settings&#47;General&#47;Visibility, project features, permissions&#47;Pages</code> and <code>CI&#47;CD</code> under <code>Settings&#47;General&#47;Visibility, project features, permissions&#47;Repository</code> are enabled.</li>
<li>Run the pipeline (needed only for the first time): go to <code>CI&#47;CD &#47; Pipelines</code> and press the <code>Run pipeline</code> from the top right corner, then on the new window press <code>Run pipeline</code> (no need to input anything).</li>
</ol>

<ul>
<li>After that, the pipeline will be ran automatically.
You can view your website link and change domain in <code>Deployments&#47;Pages</code></li>
</ul></li>
<li>GitHub:

<ol>
<li>Fork the <a href="https://github.com/Syndamia/ss-law">GitHub mirror</a></li>
<li>Create a <code>gh-pages</code> branch in your fork: on the top left, next to &#8220;branch&#8221;, press on <code>main</code>, then enter <code>gh-pages</code> and press below <code>Create branch: gh-pages</code></li>
<li>Inside <code>Settings&#47;Code and automation&#47;Pages</code>, you&#8217;ll need to select for <code>Source</code>, <code>Deploy from a branch</code> and for <code>Branch</code> select <code>gh-pages</code> and <code>&#47;(root)</code>.</li>
<li>Enable actions: go to <code>Actions</code>, then press <code>I understand my workflows, go ahead and enable them</code></li>
<li>Run the workflow (needed only for the first time): in the <code>Actions</code> page, to the left, press <code>Website on GitHub pages</code>, then in the blue rectangle, to the left, press <code>Run workflow</code>, and then again <code>Run workflow</code> in the pop-up</li>
</ol>

<ul>
<li>After that, the workflow will be ran automatically.
You can view your website link and change domain in <code>Settings&#47;Code and automation&#47;Pages</code>.</li>
</ul></li>
<li>Server&#47;locally (manually):

<ol>
<li>Fork the repository (either from GitLab or GitHub, whichever you prefer)

<ul>
<li>This step can be skipped, if you intend to edit the website directly where it is hosted.</li>
</ul></li>
<li>Clone it</li>
<li>Run the <code>deploy.sh</code> script</li>
</ol>

<ul>
<li>The website will be available inside the <code>public</code> folder.
You can directly just view and open the generated <code>.html</code> files, but it&#8217;s better to an HTTP server.</li>
You can directly just view and open the generated <code>.html</code> files, but it&#8217;s better to use an HTTP server.</li>
</ul></li>
</ul>

<h3 id="configuring-generate-site">Configuring generate-site</h3>

<p>There are a couple of variables which control how your website will be generated:</p>

<ul>
<li><code>SOURCE_FOLDER</code>: The directory where the pages for your website are located (relative to the repository).
By default it&#8217;s <code>.</code>, meaning exactly where all other repo files are.</li>
<li><code>AWK_FOLDER</code>: Location of your awk scripts (relative to the repository).</li>
<li><code>SSG_TITLE</code>: The title that will be included in all of your pages</li>
<li><code>SSG_BASE_URL</code>: The base URL (<code>https:&#47;&#47;website.com</code>) of your website</li>
</ul>

<p>Depending on how you generate the website, those variables will be available&#47;have to be modified either in:</p>

<ul>
<li><code>.github&#47;workflows&#47;github-ci.yml</code> (if using GitHub)</li>
<li><code>.gitlab-ci.yml</code> (if using GitLab)</li>
<li><code>deploy.sh</code> (if generating manually)</li>
</ul>

<h2 id="background">Background</h2>

<p>This template is pretty much my <a href="https://gitlab.com/Syndamia/syndamiadotcom">website</a> generation stack, extracted as a standalone template, with some pipelines and nice default configurations.
However, I was introduced to ssg and lowdown from <a href="https://www.youtube.com/channel/UCsnGwSIHyoYN0kiINAGUKxg">Wolfgang&#8217;s Channel</a> on YouTube, and more specifically, from his <a href="https://www.youtube.com/watch?v=N_ttw2Dihn8">tutorial</a>.</p>

<p>The name is a word-play on the main three technologies used: <strong>SS</strong>g, <strong>L</strong>owdown, <strong>aw</strong>k</p>
</article>
</body>
2 changes: 1 addition & 1 deletion sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>https://syndamia.gitlab.io/ss-law//index.html</loc><lastmod>2023-05-07</lastmod><priority>1.0</priority></url>
<url><loc>https://syndamia.gitlab.io/ss-law//index.html</loc><lastmod>2023-10-17</lastmod><priority>1.0</priority></url>
</urlset>

0 comments on commit f57f717

Please sign in to comment.