Coder Social home page Coder Social logo

likki's Introduction

likki

Wiki generator written in Lua

I'm learning Lua (again), and I'm building a simple wiki generator to do so.

Installation

Requires Lua, probably 5.4? The script is executable, so you just need to clone it and run it.

git clone [email protected]:gakimball/likki

Usage

Run the script to build the wiki once:

./likki.lua

Relative to your current working directory, likki is looking for a site directory containing:

  • _template.html, the site template
  • _navigation.txt, a navigation template
  • Files with the .gmi extension, which are your wiki pages

The finished site will be output to a build directory adjacent to site.

To make the development process more fluid, try adding watchexec to recompile the site as you write. Here's a slice of a justfile:

watch:
  watchexec --watch site -- just build

build:
  ./likki/likki.lua

Formatting

likki parses pages as Gemtext, with some additions:

Lines starting with a pipe (|) are table rows. The first row is assumed to be the header. Cells only containing hyphens are ignored, and can be used to visually separate the header from the body in your markup.

| Ingredient | Quantity |
| ---------- | -------- |
| Flour      | 225g     |
| Salt       | 2.5g     |
| Olive oil  | 15ml     |
| Water      | 180ml    |

Within a plain text line or a list item line, you can insert internal links to other wiki pages. You can either reference the page directly:

Last month, I visited {Iceland}.

Or with an alias:

Last month, I visisted {iceland|a new country}.

Spaces are converted to hyphens to construct the hyperlink.

Functions

Functions allow you to inject content into a page via an external process.

They're defined as Lua functions at the path functions/*.lua. The Lua file should be executable:

#!/usr/bin/env lua

-- functions/zombo.lua

io.stdout:write('=> https://html5zombo.com')

Invoke a function with ->:

Hello world

-> zombo

The output of the process will be inserted into the page:

Hello world

=> https://html5zombo.com

Templating

The file site/_template.html holds your HTML template. Use these template variables to construct the page:

  • {{ title }}: page title (derived from the filename)
  • {{ body }}: page contents
  • {{ outline }}: table of contents with links to each heading
  • {{ backlinks }}: list of other pages that link to this one
  • {{ navigation }}: main site navigation

The infixed spaces are necessary, by the way!

Navigation

The file site/_navigation.txt holds a template for use as the main site navigation. Each line starting with a hyphen is an internal link; all other lines are section titles. Like with internal links, the text of the link can be changed by adding a pipe and the link text.

section 1
- page 1
- page 2

section 2
- page 3
- page 4|Page four

Hidden pages

To hide a page, prefix its filename with an underscore. It will still be built and accessible, but its outgoing links are not tracked, and it's not shown in the directory. The filename of the built page removes the underscore.

Backlinks

likki tracks internal links between pages; you can insert a page's backlinks into your HTML template. On build, likki will print to the console any page that isn't linked to by another page or by the site navigation. Unlisted pages are excluded from this check.

Directory

A special page called /directory is created automatically, which lists every page in your wiki.

License

MIT © Geoff Kimball

likki's People

Contributors

gakimball avatar

Watchers

James Cloos avatar  avatar  avatar

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.