Skip to content
The code behind https://markdownshare.com/
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
data
.gitignore
LICENSE
Makefile
README.md
cmd_ips.go
cmd_serve.go
cmd_serve_test.go
cmd_version.go
cmd_version_test.go
db.go
db_test.go
go.mod
go.sum
main.go
static.go
static_includes.go
static_test.go

README.md

Go Report Card license Release gocover store

markdownshare

Markdownshare is the code which is behind markdownshare.com, which is essentially a pastebin site which happens to transform markdown into a HTML.

Installation

There are two ways to install this project from source, which depend on the version of the go version you're using.

If you prefer you can fetch a binary from our release page.

Build without Go Modules (Go before 1.11)

go get -u github.com/skx/markdownshare

Build with Go Modules (Go 1.11 or higher)

git clone https://github.com/skx/markdownshare ;# make sure to clone outside of GOPATH
cd markdownshare
go install

Usage

Once installed like this you'll should find a markdownshare application. The application has several modes, implemented via sub-commands, run with no-arguments to see a list.

To launch the server for real you'll want to run:

 $ markdownshare serve [-host 127.0.0.1] [-port 3737]

Storage

Initially all user-data was stored in a local Redis database, but over time I've started to prefer to use redis only for transient/session-data - so the contents were moved to a local SQLite database.

Due to issues with embedding SQLite in golang I've now moved to storing data upon the filesystem, beneath a common prefix, which is slightly less efficient but still good enough for the volume of users I see.

Rate-Limiting

The server has support for rate-limiting, you can enable this by passing the address of a redis server to the binary:

  $ markdownshare  serve -redis=127.0.0.1:6379

If this flag is not present then rate-limiting will be disabled. If a client makes too many requests they will be returned a HTTP 429 status-code. Each request made will return a series of headers prefixed with X-RateLimit to allow clients to see how many requests they

Notes

The generated HTML views are stored inside the compiled binary to ease deployment, along with a couple of the bundled markdown files. If you wish to tweak the look & feel by editing them then you're more then welcome.

The raw HTML-templates are located beneath data/, and you can edit them then rebuild the compiled versions via the implant tool.

If you don't already have implant installed please install, following the instructions here:

Using implant you can regenerate the compiled version(s) of the templates and rebuild the binary to make your changes:

implant -input data/ -output static.go
go build .

(A simple make should do the correct thing upon a GNU/Linux host.)

Github Setup

This repository is configured to run tests upon every commit, and when pull-requests are created/updated. The testing is carried out via .github/run-tests.sh which is used by the github-action-tester action.

Releases are automated in a similar fashion via .github/build, and the github-action-publish-binaries action.

Steve

You can’t perform that action at this time.