pansite: Pansite: a simple web site management tool

[ library, mit, program, web ] [ Propose Tags ] [ Report a vulnerability ]

Pansite is a Pandoc-based web site management tool. Please see README.md


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0
Dependencies aeson, base (>=4.7 && <5), blaze-html, bytestring, data-default, directory, filepath, http-types, MissingH, optparse-applicative, pandoc, pandoc-types, pansite, shake, split, template-haskell, text, time, unordered-containers, vcs-revision, vector, wai, wai-logger, warp, yaml [details]
License MIT
Copyright 2017-2018 Richard Cook
Author Richard Cook
Maintainer rcook@rcook.org
Category Web
Home page https://github.com/rcook/pansite#readme
Source repo head: git clone https://github.com/rcook/pansite.git
Uploaded by rcook at 2018-04-28T19:22:36Z
Distributions
Executables pansite
Downloads 1367 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-04-28 [all 1 reports]

Readme for pansite-0.2.0.0

[back to package description]

Pansite: a simple web site management tool

Development

This project uses Stack, Pandoc, Warp and Shake

Why are you doing this?

I want a Hakyll-like static web site generator that can be easily used in conjunction with a dynamic site built with Yesod. I want it to use Pandoc so that I can build rich content, possibly with embedded mathematics. I also want it to be responsive, so that when I make changes to the underlying Markdown files, I can view the updated output in my browser quickly instead of having to wait thirty seconds for the Hakyll build to complete. There are probably tools that already do this (probably Hakyll itself can be made to do this), but I love reinventing the wheel. So, that's what I'm going to do.

The system is intended to be extensible in the future, so I will put some thought into how to extract its core functionality into a library.

Work in progress

This project is a prototype and, therefore, should not be used for any real work yet!

Current features

  • Uses Pandoc to render Markdown into HTML (and, also, Microsoft Word documents)
  • Supports static resources such as CSS
  • Supports dynamic refresh of routes
  • Shake-based build ensure that outputs are correctly maintained as long as dependencies are fully specified

The vision

Currently Pansite is a trivial web app built on top of Warp. Routes are defined in a .pansite.yaml file using the following schema:

# $(@D) is an automatic variable meaning "the output directory" (a la GNU Make)
# All other paths are resolved relative to this directory containing this file

routes:
- path: ""
  target: $(@D)/index.html
- path: page1
  target: $(@D)/page1.html
- path: page2
  target: $(@D)/page2.html
- path: css/buttondown.css
  target: buttondown.css

targets:
- path: $(@D)/index.html
  tool: pandoc
  tool-settings:
    number-sections: false
  inputs:
  - index.md
  dependencies:
  - .pansite.yaml
- path: $(@D)/page1.html
  tool: pandoc
  tool-settings:
    number-sections: false
  inputs:
  - page1.md
  dependencies:
  - .pansite.yaml
- path: $(@D)/page2.html
  tool: pandoc
  tool-settings:
    mathjax: true
  inputs:
  - page2.md
  dependencies:
  - .pansite.yaml

tool-settings:
  pandoc:
    number-sections: true
    template-path: template.html
    vars:
    - [css, css/buttondown.css]

Each path entry defines a route that the web app will respond to. The target key defines the cached content file to return in response to this route.

The cached content files are currently built using Shake using rules generated from the .pansite.yaml file. Thus, the app itself defines how to build the cached content files using a simple declarative format. There is a silly test site defined under _app, specifically in _app/.pansite.yaml that demonstrates the idea. I do not want to allow the app's content itself to provide a Shake build script since I do not want to allow the user-provided content to run arbitrary commands on my server. Instead, the simple declarative rules in .pansite.yaml constrain what the build system can do while still keeping it useful.

Currently this prototype demonstrates the use of a single build tool, namely Pandoc. I intend to refactor the code to make it straightforward to specify additional build tools: some will be embedded directly, like Pandoc, others can use the Shake's cmd function to invoke external processes.

Build tools currently supported:

  • Pandoc (pandoc): Process input files using Pandoc
  • Copy (copy): Copy input file to output

How to run it

Build it:

stack build

Run the example site:

cd _app/
stack exec -- pansite --port 3000

In your web browser, navigate to a route defined in .pansite.yaml, e.g. http://localhost:3000/page2.

Command-line options

$ stack exec -- pansite --help
Pansite development server 0.1.0.0.772a2d5 (locally modified)

Usage: pansite ([-p|--port PORT] [-c|--config CONFIG]
                   [-o|--output-dir OUTPUTDIR] | [-v|--version])
  Run Pansite development server

Available options:
  -h,--help                Show this help text
  -p,--port PORT           Port
  -c,--config CONFIG       Path to YAML application configuration file
  -o,--output-dir OUTPUTDIR
                           Output directory
  -v,--version             Show version

Licence

Released under MIT License

Copyright © 2017—2018 Richard Cook