mechui

package
v0.0.0-...-d2f86d0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2023 License: CC0-1.0 Imports: 7 Imported by: 2

README

Package mechui

import "gitlab.com/fospathi/mechane/mechui"

Go package mechui provides:

  • the web directory: the root directory of the HTTP server's filesystem with the various HTML, CSS, font, and JS files needed by a Mechane server to display the browser based UI;

  • Go package asciidoc: an asciidoc to HTML converter which depends on Asciidoctor.js.

The Elm and Typescript integrants

The web directory has a few sibling directories among which are the elm and typescript siblings.

The Mechane browser based UI is composed of two interdependent integrants: an Elm language integrant and a Typescript language integrant.

The integrants are compiled to JS which is placed in the script directory under web.

Compilation

Assuming global installations of the Elm compiler (elm), the Typescript compiler (tsc), and the Node Package Manager (npm), then the commands to compile the integrants and replace the JS files in the script directory are as follows:

From the (web sibling) elm directory:

elm make src/Main.elm --output ../web/script/elm-integrant.js

Followed by, from the (web sibling) typescript directory:

npm ci
npm run build

Go package asciidoc

Automate the process of converting asciidoc files to HTML files which can then be incorporated into a Mechane world.

Package asciidoc recognises files as asciidoc if they use the .asciidoc filename extension.

Go generate

Package asciidoc can be combined with the go generate command to convert all of a world's asciidoc anywhere in its filesystem hierarchy to HTML. For example, add a doc directory to the world's root directory which contains the following two files:

  • a2h.go

    This file performs the asciidoc to HTML conversions:

    //go:build ignore
    
    package main // Convert asciidoc files to HTML.
    
    import (
        "log"
    
        "gitlab.com/fospathi/mechane/mechui/asciidoc"
    )
    
    const rootDir = "../" // Convert asciidoc files in the filesystem rooted here.
    
    func main() {
        if cnv, err := asciidoc.NewConverter(log.Default()); err != nil {
            log.Fatalln(err)
        } else if err := asciidoc.Convert(cnv, rootDir); err != nil {
            log.Fatalln(err)
        }
    }
    
  • doc.go

    This file enables the use of go generate to convert the asciidoc:

    package doc
    
    import _ "gitlab.com/fospathi/mechane/mechui/asciidoc"
    
    //go:generate go run a2h.go
    

    Run it from either:

    • the world's root directory (or any directory above it) with go generate ./...;
    • the doc directory with go generate.

Documentation

Overview

Package mechui provides the HTML, JS, and other such files needed by a Mechane server to display the browser based UI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUIDeps

func NewUIDeps() (ElmDeps, TypescriptDeps, error)

NewUIDeps returns the imported packages of the Elm and Typescript integrants.

func Root

func Root() (http.FileSystem, error)

Root file system of a Mechane server with the web directory as the root directory. Can be supplied to a Mechane server as the root file system.

Types

type ElmDeps

type ElmDeps struct {
	Dependencies struct {
		Direct   map[string]string
		Indirect map[string]string
	}
}

ElmDeps contains the dependencies of the Elm integrant.

Keys are package paths and values are versions.

type TypescriptDeps

type TypescriptDeps struct {
	Dependencies    map[string]string
	DevDependencies map[string]string
}

TypescriptDeps contains the dependencies of the Typescript integrant.

Keys are package paths and values are versions.

Directories

Path Synopsis
Package asciidoc converts AsciiDoc to HTML by sending the AsciiDoc to a Node.js process that uses the Asciidoctor.js Processor API.
Package asciidoc converts AsciiDoc to HTML by sending the AsciiDoc to a Node.js process that uses the Asciidoctor.js Processor API.
Download the default fonts used by Asciidoctor and create a modified stylesheet with the fonts' local URLs.
Download the default fonts used by Asciidoctor and create a modified stylesheet with the fonts' local URLs.
Generate the index.html file under the web directory.
Generate the index.html file under the web directory.

Jump to

Keyboard shortcuts

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