项目作者: kamaln7

项目描述 :
a Markdown middleware HTTP server
高级语言: Go
项目地址: git://github.com/kamaln7/mdmw.git
创建时间: 2018-04-12T05:56:28Z
项目社区:https://github.com/kamaln7/mdmw

开源协议:MIT License

下载



mdmw logo

mdmw is a Markdown middleware HTTP server. It renders Markdown files and serves them back as HTML. It’s not meant to be your sole www-facing webserver as it cannot serve non-markdown files.

You can use mdmw to host a micro-blog, quickly share documents, host documentation, etc.

mdmw supports two storage drivers (i.e. where it pulls markdown files from):

  • filesystem uses the OS filesystem to look up files
  • spaces uses DigitalOcean Spaces to look up files

mdmw exposes an HTTP server and uses the URI as the path for the markdown files.

Table of Contents generated with DocToc

installation

  1. pull the latest docker image
  1. docker pull kamaln7/mdmw:latest

use a pre-built mdmw binary

  1. download a binary suitable for your OS from the releases page
  2. place said binary in /usr/local/bin or wherever you would like

usage

mdmw listens on localhost:4000 by default. Refer to the options section below for details on how to change that. If you are using the docker image, you will need to expose port 4000

See the options section below on how to configure mdmw. You can run docker run -p 4000 kamaln7/mdmw (use -e or --env-file to pass configuration options) or run mdmw directly if you chose to not use Docker.

options

  1. Usage:
  2. mdmw [flags]
  3. Flags:
  4. --config string config file (default is ./.mdmw.yaml)
  5. --filesystem.path string path to markdown files (default "./files")
  6. -h, --help help for mdmw
  7. --listenaddress string address to listen on (default "localhost:4000")
  8. --outputtemplate string path to HTML output template
  9. --spaces.auth.access string DigitalOcean Spaces access key
  10. --spaces.auth.secret string DigitalOcean Spaces secret key
  11. --spaces.cache string DigitalOcean Spaces cache time (default "0")
  12. --spaces.path string DigitalOcean Spaces files path (default "/")
  13. --spaces.region string DigitalOcean Spaces region
  14. --spaces.space string DigitalOcean Spaces space name
  15. --storage string storage driver to use (default "filesystem")
  16. --validateextension validate that files have a markdown extension (default true)

There are three ways to configure mdmw. examples for each can be found below

  1. use a config file (yaml, toml, json, etc.) and pass -config ./path/to/config
    • options become nested objects, see the example below
  2. pass cli flags as described above
  3. use environment variables
    • options become uppercase with periods replaced by underscores, see the example below

configuration examples

  • listen on 0.0.0.0:8080
  • serve files from a Space in AMS3
as a yaml config file
  1. listenaddress: 0.0.0.0:8080
  2. storage: spaces
  3. spaces:
  4. auth:
  5. access: ACCESS KEY GOES HERE
  6. secret: SECRET KEY GOES HERE
  7. region: ams3
  8. space: SPACE NAME GOES HERE
as cli flags
  1. mdmw \
  2. --listenaddress 0.0.0.0:8000 \
  3. --storage spaces \
  4. --spaces.auth.access "ACCESS KEY GOES HERE" \
  5. --spaces.auth.secret "SECRET KEY GOES HERE" \
  6. --spaces.region ams3 \
  7. --spaces.space "SPACE NAME GOES HERE"
as environment variables
  1. LISTENADDRESS=0.0.0.0:8000 \
  2. STORAGE=spaces \
  3. SPACES_AUTH_ACCESS=ACCESS KEY GOES HERE \
  4. SPACES_AUTH_SECRET=SECRET KEY GOES HERE \
  5. SPACES_REGION=ams3 \
  6. SPACES_SPACE=SPACE NAME GOES HERE \
  7. mdmw

license

MIT. see LICENSE