Giter Site home page Giter Site logo

someodd / burrow Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 1.27 MB

Static gopherhole generator.

Home Page: https://www.someodd.zip/showcase/burrow/

License: GNU General Public License v3.0

Haskell 93.17% Makefile 0.88% Shell 4.39% Dockerfile 1.57%
atom gopher-protocol markdown static-site-generator

burrow's Introduction

Burrow: Make Gopherholes

Burrow is to gopherholes as static site builders are to websites.

Burrow is a static site generator, but for gopherholes. A gopherhole is a place in gopherspace accessed through the Gopher protocol).

I made my gopherhole with burrow, so it's an example:

  • gopher://gopher.someodd.zip:7071/
  • https://github.com/someodd/personal-gopherhole
  • This functional example uses this repo's Docker config, allow me to push to the above repo, and the repo that is used to build my gopherhole (Docker setup is a git + gopher server)

There's a .deb (Ubuntu, Debian) available in the releases.

Written in Haskell. If you're looking for very similar software, with coincidentally the exact same name, please check out James Tomasino's Burrow.

Quick Start

There's an example gopherhole (in burrowsrc/, with a default config in data/gopherhole.ini) you can build with these command and then visit localhost:7070 in gopher:

burrow build --spacecookie
cd built
spacecookie ../data/spacecookie.json

The --spacecookie flag parses index.menu.md files to .gophermap files, I think?

Features

Front matter

Jekyll-like front matter support. You can tag posts for a phlog, control the rendering process for the file, and more, all through the front matter of the file.

Here's an example of various front matter entries specifically supported by Burrow:

---
published: 2021-06-01T05:44
updated: June 13th at 10pm
author: Some Author's Name
type: post
variables: {"someVariable": "Some text to replace someVariable.", "foo": "bar"}
skipMustache: false
skipMarkdown: false
parentTemplate: post
renderAs: menu
---

Here's the content of my post that supports Markdown and Mustache.

Mustache

Use Mustache for templating.

There are built in lambdas for your convenience:

  • {{#columnate2}}this text will be justified and broken up like a newspaper{{/columnate2}}

Markdown

Commonmark parser is used.

Phlogging features

Indexes will be generated as gophermaps for posts which are tagged and have all the required front matter (like published, title, and type: post).

Atom feeds will be generated for each index (tag indexes, the main feed, and tag summaries).

Change a lot of the behavior through an INI

Be sure to look at data/gopherhole.ini in order to control and customize the builder!

Other notes

This software has primarily been tested with spacecookie (Gopher server). You may want to look at my spacecookie Docker repo. Currently, Burrow relies heavily on the .gophermap behavior outlined in these documents:

Other good things to read about and know:

Font system

The font system is primarily used by the markdown parser for headings.

Headings are parsed in a way which creates fancy ASCII art headings. You can specify which ASCII art font to use in data/gopherhole.ini.

The font spec is simple: on one line is a character you wish to represent, followed by the ASCII art for the character. Each line for the character must be of the same length. Each character in the font must be of the same number of lines. Separate character definitions with blank lines.

For more info please see data/fonts/.

Example

Turn this:

---
title: Example phlog post
published: 2021-06-12
updated: June 13th, 2021 at 10pm
author: someodd
type: post
tags: foo bar
variables: {"someVariable": "Some text to replace someVariable.", "foo": "bar"}
parentTemplate: post.txt
renderAs: menu
---

This is an example phlog post.

{{ someVariable }}

## Columnate Example

{{#columnate2}}
The Gopher protocol /ˈɡoʊfər/ is a communications protocol designed for distributing, searching, and retrieving documents in Internet Protocol networks. The design of the Gopher protocol and user interface is menu-driven, and presented an alternative to the World Wide Web in its early stages, but ultimately fell into disfavor, yielding to the Hypertext Transfer Protocol (HTTP) The Gopher ecosystem is often regarded as the effective predecessor of the World Wide Web.[1]
The protocol was invented by a team led by Mark P. McCahill[2] at the University of Minnesota. It offers some features not natively supported by the Web and imposes a much stronger hierarchy on the documents it stores. Its text menu interface is well-suited to computing environments that rely heavily on remote text-oriented computer terminals, which were still common at the time of its creation in 1991, and the simplicity of its protocol facilitated a wide variety of client implementations. More recent Gopher revisions and graphical clients added support for multimedia.[citation needed] Gopher was preferred by many network administrators for using fewer network resources than Web services.[3]
Gopher's hierarchical structure provided a platform for the first large-scale electronic library connections.[4] The Gopher protocol is still in use by enthusiasts, and although it has been almost entirely supplanted by the Web, a small population of actively-maintained servers remains. 
{{/columnate2}}

[some link](/some-menu)

Into this:

══════════════════════════════════════════════════════════════════════════════════════════
██████████████████████████████████████████████████████████████████████████████████████████
█   ██ █ ██▀ ▀██ █ ██  ▀██ ████   ███████  ▀██ █ ██ ████▀ ▀██▀  ███████  ▀██▀ ▀██▀  ██   █
█ ████ █ ██ █ ██   ██ █ ██ ████ █████████ █ ██ █ ██ ████ █ ██ █████████ █ ██ █ ██ █████ ██
█   ███ ███ ▄ ██   ██  ▄██ ████   ███████  ▄██   ██ ████ █ ██ █\███████  ▄██ █ ██  ▀███ ██
█ ████ █ ██ █ ██ █ ██ ████ ████ █████████ ████ █ ██ ████ █ ██ █ ███████ ████ █ ████ ███ ██
█   ██ █ ██ █ ██ █ ██ ████   ██   ███████ ████ █ ██   ██▄ ▄██▄  ███████ ████▄ ▄██  ▄███ ██
██████████████████████████████████████████████████████████████████████████████████████████
══════════════════════════════════════════════════════════════════════════════════════════

Posted: 2021-06-12
Updated: 2021-06-13
Author: someodd
Tags: foo, bar

This is an example phlog post.

Some text to replace someVariable

═════════════════════════════════════════════════════════════════════════════════════
█████████████████████████████████████████████████████████████████████████████████████
█   ██▀ ▀██ ████ █ ██ █ ██ ████▀ ▀██   ██   ███████   ██ █ ██▀ ▀██ █ ██  ▀██ ████   █
█ ████ █ ██ ████ █ ██   ██  ▀██ █ ███ ███ █████████ ████ █ ██ █ ██   ██ █ ██ ████ ███
█ ████ █ ██ ████ █ ██   ██ █ ██ ▄ ███ ███   ███████   ███ ███ ▄ ██   ██  ▄██ ████   █
█ ████ █ ██ ████ █ ██ █ ██ █ ██ █ ███ ███ █████████ ████ █ ██ █ ██ █ ██ ████ ████ ███
█   ██▄ ▄██   ██   ██ █ ██ █ ██ █ ███ ███   ███████   ██ █ ██ █ ██ █ ██ ████   ██   █
█████████████████████████████████████████████████████████████████████████████████████
═════════════════════════════════════════════════════════════════════════════════════

The  Gopher protocol  /ˈɡoʊfər/  is  a │ interface  is well-suited to computing
communications  protocol designed  for │ environments   that  rely  heavily  on
distributing,      searching,      and │ remote      text-oriented     computer
retrieving   documents   in   Internet │ terminals,  which were still common at
Protocol  networks. The  design of the │ the  time of its creation in 1991, and
Gopher  protocol and user interface is │ the   simplicity   of   its   protocol
menu-driven,    and    presented    an │ facilitated  a wide  variety of client
alternative  to the  World Wide Web in │ implementations.  More  recent  Gopher
its  early stages, but ultimately fell │ revisions  and graphical clients added
into   disfavor,   yielding   to   the │ support    for    multimedia.[citation
Hypertext Transfer Protocol (HTTP) The │ needed]  Gopher was  preferred by many
Gopher  ecosystem is often regarded as │ network administrators for using fewer
the effective predecessor of the World │ network     resources     than     Web
Wide Web.[1] The protocol was invented │ services.[3]   Gopher's   hierarchical
by  a team  led by Mark P. McCahill[2] │ structure  provided a platform for the
at  the University  of  Minnesota.  It │ first  large-scale electronic  library
offers   some  features  not  natively │ connections.[4] The Gopher protocol is
supported  by the  Web and  imposes  a │ still   in  use  by  enthusiasts,  and
much   stronger   hierarchy   on   the │ although  it has  been almost entirely
documents  it stores.  Its  text  menu │ supplanted   by  the   Web,  a   small

population    of   actively-maintained
servers remains.

0some link      /some-menu

bar

burrow's People

Contributors

github-actions[bot] avatar someodd avatar sternenseemann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

morrowm

burrow's Issues

command to list all tags found

Along with how many posts per tag. This would be nice for keeping tags nice and organized, among other purposes (like if someone wanted to pipe it into some tagcloud app).

Turns out, it's not impossible

➜  gopherhole-new-someodd git:(master) git push origin master
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.32 KiB | 1.32 MiB/s, done.
Total 5 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Cloning into '/tmp/gopherhole-clone'...
remote: done.
remote: burrow: this should be impossible!
remote: CallStack (from HasCallStack):
remote:   error, called at src/Markdown.hs:342:16 in burrow-0.1.14.0-inplace:Markdown
To gopherhole:/srv/git/gopherhole.git
   4a3560a..a64ee5b  master -> master

cli to add blog posts

would be nice because it would add frontmatter with correct timestamp and all that

nix build only works in develop environment?

➜  burrow git:(master) nix run .#burrow -- build
burrow: data/fonts/basicthorpe.bmf: hGetContents: invalid argument (invalid byte sequence)
➜  burrow git:(master) nix run .#burrow -- build
➜  burrow git:(master) vim data/
➜  burrow git:(master) nix develop
tilde@framework:~/Projects/burrow$ nix run .#burrow -- build
tilde@framework:~/Projects/burrow$ ls
app           burrowsrc      data           flake.nix  README.md  templates
built         cabal.project  dist-newstyle  LICENSE    result
burrow.cabal  CHANGELOG.md   flake.lock     Makefile   src
tilde@framework:~/Projects/burrow$ 

more configuration settings

  • list bullet styles configuration and their spacing
  • Option to generate spacecookie.json from gopherhole.ini (can also derive optoins form the spacecookie.json). Is it necessary to include a spacecookie.json at all? Maybe you shouldn't.

better testing features

Thinking of this because I want to have a testing and prod config.

be able to specify .ini config with --config for build

docker able to build local dev version?

More CLI options

Need to add some features for the CLI:

  • define source and destination directories (see: #25)
  • define a config file path

font spec: first line should be list of flags, other changes

Such as uppercase only or lowercase only, but done in a comma-delimited list like:

upercase only, monospaced.

This would be a good time to implement support for non-monospaced fonts, too.

Should rename the extension then from bmf (burrow monospaced font) to baaf (burrow ascii art font).

More mustache lambdas

Ideas:

  • Image to ASCII art
  • "Floating" ASCII art blocks to the right (so text surrounds it?)
  • Support arguments for lambdas

docker hgetfilecontents error

When using the docker setup, the docker locale needs to be set up for hGetFileContents to work specifically for the fonts (bmf), I have no idea what's up with that.

https://stackoverflow.com/questions/30421845/haskell-quotefile-fails-on-text-file-with-invalid-byte-sequence-on-unicode-ch

This worked (in the Docker container, note i disabled deleting /tmp/gopherhole-clone in the post-receive git hook so i could do this build command cd to the tmp version):

cd /tmp/gopherhole-clone
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
export LANG=en_US.UTF8 burrow build
edit the file /etc/locale.gen, append new line en_US.UTF-8 UTF-8
invoke locale-gen to generate locales.
export LANG variable.

Link bug: gopher:// links

there's an error in the link parser for gopher:// links. It needs to tokenize the URI so it can create a valid gopher link to external resources.

better errors--more of them!

Implement descriptive and helpful error messages for the end user:

  • pairToPostMeta if one of the required bits that are of the type Maybe a turns out to be Nothing.
  • better error for when call partial no exist/better error for when template file called to from frontmatter (parentTemplate) which doesn't exist.

ToGopherMenu complexity

Now that prefixing each non-linking line in a gophermap/menu with i is no longer required (see: #1) is src/Markdown/ToGopherMenu.hs needlessly complex?

Could the exact same desired result be achieved with the ToTextFile version, except a different way of handling links?

Are there some advantages to keeping the abstraction this way? If not, save maintenance time and number of lines by simply sharing, mostly, the same code for both Markdown parsers (could be placed in src/Markdown/Common.hs), with the exception of the link parser.

Bug encountered when trying to port jekyll posts

➜  gopherhole-new-someodd git:(master) git push origin master
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 11.41 KiB | 11.41 MiB/s, done.
Total 7 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Cloning into '/tmp/gopherhole-clone'...
remote: done.
remote: burrow: this should be impossible!
remote: CallStack (from HasCallStack):
remote:   error, called at src/Markdown.hs:342:16 in burrow-0.1.14.0-inplace:Markdown
To gopherhole:/srv/git/gopherhole.git

Relevant line:

lineToText _ = error "this should be impossible!" -- FIXME

CLI-defined input and output paths

Ignoring the path variable from the CLI and just using the INI to get the output directory and input directory.

Need to either drop CLI support for defining the input and output path and compeltely rely on the ini file, or completely implement support for the CLi args.

This may also go hand-in-hand with adding a config abstraction, because then the config abstraction could have its output/input entries changed early on before it's passed around. Related: #20

testing

doctests, quickcheck, conventional tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.