kisipar

package module
v0.0.0-...-cf5c4a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 4 Imported by: 0

README

Kisipar: An UNFINISHED (and abandoned) Markdown-centric web server for small sites.

This was a fun project and I rewrote it several times -- twice in Perl, thrice in Go, and even once in Javascript/nodejs. But in the end, I never quite got it where I wanted it, and other things solved my own problems better. These days I use Zola.

Still, there are some useful bits of code and ideas in here, so I keep it around for reference, and you are welcome to use any of it subject to the MIT LICENSE.


LATEST IDEAS - 10 MAY 2016

Site Layout

    config.yaml / config.json (as you prefer)
    static/
    pages/
    templates/

TheDot
    Site
        Name
        Description
        Domain
        Owner
        BaseURL
        Pageset -- all pages for the site
        Config  -- your full config; handle with care!
        StaticInfo(path) -> FileInfo
        StaticList(prefix,suffix,extension) --> []FileInfo
    Page -- the current page if applicable, not present for created index
    Pageset -- the pageset if applicable (current level down)
    Static  -- interface to lookup static files, if desired.

PAGE FINDING HIERARCHY

    1. STATIC (so you can override on disk)
    2. VIRTUAL
    3. REGULAR FULL MATCH
    4. REGULAR INDEX MATCH


STATIC ASSET HANDLING

Exact match in static dir (configurable, or "static") trumps all else,
and is never cached.  No approximate matches are attempted.

No auto-indexing of static pages, for instance.  If you want to store
things in /static and

INDEX HANDLING

Specific page trumps index, so for `/foo` a match on `/foo.md` will always
beat `/foo/index.md` and will *not* result in a Pageset automatically
present for the Dot.

    IF exact static match THEN serve that file
    ELSE IF exact md THEN serve that as Page
    ELSE IF index THEN serve that as Page with Pageset for dir
    ELSE IF dir matches THEN serve generic Index with Pageset for dir
    ELSE serve not-found

TEMPLATE SELECTION

Templates can e overridden in the config, or in the individual file's
meta.  Config overrides are either specific by cleaned URL, or general
covering a partial match; in the latter case, the most complete match
is used, i.e. `/foo/bar/baz` matches `/foo/bar` before `/foo`.
Config templates take precedence over file-meta templates.
Regexp template overrides are not (yet) supported, but might be a good
idea.

If a specified template is not found, a 500 error results.

    IF match for
    IF exact match for clean URL in config THEN use that
    ELSE IF set in file meta THEN use that
    ELSE IF partial match in config THEN use that
First: any page-specific override
First: template specified in the file, if available (500 if not).
Second: any override template specified in config
USE CASES
    /foo
    /foo/index.html

"Kisipar" is Hungarian for "Kleingewerbe," which is German for small business.

Kisipar is also an opinionated, Markdown-centric web server written in the Go language.

WORK IN PROGRESS

CAVEAT LECTOR! This is a work in early progress and may change radically at any moment. Do not try to use it before it at least reaches version 1.0. Thank you.

CURRENT VERSION: 0.0.0 (i.e. just getting started here folks...)

NOTE: now a private repo until it does something useful (but it might go public before 1.0.0, just not while it's this embarrassingly raw).

Motivation

I want an off-the-shelf web server for my content-based projects, with a minimum of configuration required for the simplest use cases. I want it to be easily expandable to handle more complicated sites. I want the textual content itself to be written in Markdown.

Since others might reasonably want the same thing, let's make it an Open Source project!

Goals

  • Zero-config serving of simple sites.
    • kisipar /path/to/your/site
  • High performance.
  • Minimum number of dependencies outside the standard library.
  • Easy/obvious way to extend (in code) for new routes.
  • Flexible, within reasonable use cases.
  • Support multiple languages.
  • Placeholder sites just run the binary w/ cli args for config.
  • Basic "real" sites just run the binary but w/various customizations.
  • More complicated sites import "kisipar" and go from there.
Stretc (or 2.0) Goals
  • Run multiple sites from one executable.
  • Sane multilingual options.
  • SSL (normally you'd let Nginx do this for you).

NOTES TO SELF

  • Caching rendered content defeats the purpose of greater control in templates.
    • You can't cache the request object, and it may be meaningful.
    • If you want real caching for performance reasons then do it in Nginx etc.
  • Follow blackfriday example for packaging: https://github.com/russross/blackfriday
    • Except we want an executable, so I guess it needs a main package.
  • https://travis-ci.org
  • docopt in main
  • vendor in deps or what?
  • frosted markdown as option (once ready); otherwise just regular
    • then extract title via node parsing or what?
    • first line is title?
  • what to do for config?
  • Use the executable, or fork and customize
  • What about using one instance of kisipar to serve a bunch of sites?
    • Shared static content for example...

Features

  • Content can be Markdown, text, or HTML.
  • Content is rendered in the browser.
  • Uses Frosted Markdown for defining metadata.
  • Templates are used.
  • Zero config option: can use command-line or env.
  • Contact Form available (simple mail sender).
    • Or not? Security risk?
  • MAYBE SSL?

Site Layout:

config.toml
templates/
    wrapper.html
    ...anything else you want, it's within the templates...
static/
    js/
    css/

    (anything)
content/

Order of checking:

  1. static (trumps all else; not cached)
  2. cached, rendered (respect TTL)
  3. content directory: md,txt,html as fragments; others served straight.
  4. special URLs, eg "contact" and "rss"

Anything not found this way is 404.

Documentation

Overview

Package kisipar provides an opinionated web server for small(ish) Markdown-based sites. The API presented here allows for a standard server to be run via the command subpackage cmd/kisipar, or through a custom application. Much deeper customization is possible using the subpackages.

It is STRONGLY recommended that you run any public-facing kisipar servers behind a reverse-proxy web server such as Nginx: https://www.nginx.com

For more information see https://github.com/biztos/kisipar

Building the Server

The standard server should be sufficient for most intended purposes.

go get github.com/biztos/kisipar
go build github.com/biztos/kisipar/cmd/kisipar
./kisipar --help

You may of course build a custom server in order to expand -- or contract -- the Kisipar functionality.

Site Configuration

The configuration file is in YAML format, must be named "config.yaml" and lives at the top of the site directory.

Site Layout

A standard Kisipar site is contained in a directory, with a YAML configuration file and three subdirectories:

config.yaml
pages/
static/
templates/

Static assets override pages. Templates are go-style (html/template).

Index

Constants

This section is empty.

Variables

View Source
var LAUNCH_SERVERS = true

LAUNCH_SERVERS controls whether to actually launch the site servers; set to false for testing without spawning listeners.

Functions

This section is empty.

Types

type Kisipar

type Kisipar struct {
	Sites []*site.Site
}

Kisipar represents a set of one or more Sites to serve.

func Load

func Load(paths ...string) (*Kisipar, error)

Load initializes a Kisipar struct with sites loaded from the directories located at the given paths. Each site must have its own config file.

func (*Kisipar) Serve

func (k *Kisipar) Serve()

Serve launches listen-and-serve routines for all Sites, with or without TLS as per the configuration. The last site in the list will block until it is finished.

Directories

Path Synopsis
Package app defines the Kisipar web server application.
Package app defines the Kisipar web server application.
cmd
kisipar
The kisipar program loads and serves Kisipar web sites.
The kisipar program loads and serves Kisipar web sites.
Package frostedmd implements Frosted Markdown: standard Markdown to HTML conversion with a meta map and a default title.
Package frostedmd implements Frosted Markdown: standard Markdown to HTML conversion with a meta map and a default title.
Package funcmap provides functions useful to html templates, and a standard html.FuncMap of them.
Package funcmap provides functions useful to html templates, and a standard html.FuncMap of them.
Package page defines a single page in a Kisipar web site.
Package page defines a single page in a Kisipar web site.
Package pageset defines a set of pages in a Kisipar web site.
Package pageset defines a set of pages in a Kisipar web site.
Package site defines a Kisipar web site, and contains most of its actual server logic.
Package site defines a Kisipar web site, and contains most of its actual server logic.
assets
Package assets provides embedded asset data for the Kisipar site package.
Package assets provides embedded asset data for the Kisipar site package.
Package utli assembles various utility functions useful in and around the Kisipar web-server project.
Package utli assembles various utility functions useful in and around the Kisipar web-server project.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL