Skip to content

APoniatowski/zehd-frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zero Effort Hosting Daemon

Introducing ZEHD

ZEHD is a static site generator that streamlines the process of converting markdown, org-mode, and gohtml/html files to HTML. Similar to Hugo, ZEHD allows users to automatically create paths and parse their files. The difference is that ZEHD removes the extra steps required to convert markdown to HTML, as it can do this automatically.

ZEHD has four main features:

  • It can build gohtml/html files.
  • It can convert org-mode files to HTML.
  • It can convert markdown to HTML.
  • It does caching to eliminate the need to restart the service.

Building Gohtml/HTML files

ZEHD supports Go templates with the .gohtml extension, and standard HTML files with the .html extension. These templates can include Go template language constructs such as control structures, loops, and functions, and can be used to generate dynamic content.

Converting Org-mode files to HTML

In addition to markdown, ZEHD can also convert org-mode files to HTML. Org-mode is a powerful markup language that supports outlining, notes, lists, tables, and other advanced features.

Converting Markdown to HTML

Like other static site generators, ZEHD can also convert markdown files to HTML. The conversion is handled by the Blackfriday Markdown processor.

Caching

One of the key benefits of ZEHD is its caching functionality. This eliminates the need to restart the service when new content is added or updated, and ensures that content is delivered quickly to users.

Here is an example of a simple Go template:

<!DOCTYPE html>
<html>
    <head>
        <title>{{template title}}</title>
    </head>
    <body>
        {{template templatePart}}
    </body>
</html>
{{define "title"}}
<h1>
    The name of my Title
</h1>
{{end}}

{{define "templatePart"}}
<div>
    <p>
        Whatever HTML you want to have displayed
    </p>
</div>
{{end}}

Kubernetes and hybrid setup ready:

Adjust your frontend setup with environment variables (`PORT`,`TEMPLATEDIRECTORY`,`TEMPLATETYPE`,`REFRESHCACHE`, there will probably be more in the future)

  • `PORT` : Specify a different port if you’d like (or need to)
  • `TEMPLATEDIRECTORY` : Specify a different directory (default is `/var/frontend/templates/`) to check for your templates (maybe a NFS volume, or other mounted volume like Longhorn)
  • `TEMPLATETYPE` : Specify which type of template format you’d like to use (default is gohtml). You can use any file extension you want (this was untested, of course)
  • `REFRESHCACHE` : Specify a different refresh cycle (default is 60 seconds)
  • `PROFILER` : Specify `True` to enable the profiler to print the time it took to run a function. I will add additional funtionality to this,to be able to use it in templates

To try or run it on docker:

docker pull zehd/zehd:latest

Here is the backend service, if you plan on collecting data on people visiting your site.

I am still working on a worker/agent to be able to dynamically ban IP’s/hostnames/etc, in the future I will implement calls from the frontend to the backend, to check if the IP/etc has been banned or not.