• This repository has been archived on 03/Jan/2021
  • Stars
    star
    161
  • Rank 233,470 (Top 5 %)
  • Language
    JavaScript
  • License
    Do What The F*ck ...
  • Created over 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple markdown editor for static files (Hugo, Nexo, Jekyll, MkDocs, ...)

Pendulum

A simple editor for markdown/txt files. Supports saving changes into git repositories hosted anywhere (git add, git commit).

Docker image and built binaries are provided. Written by @TitPetric and licensed under the permissive WTFPL.

Codeship Status for titpetric/pendulum

Running it in docker

To run it in Docker:

docker run -d --name pendulum \
	--restart=always \
	-p 8080:8080 \
	-v $(pwd):/app/contents \
	titpetric/pendulum

This will expose your current directory to Pendulum for editing. You can open the interface on http://localhost:8080/ and start editing those files right away.

Download executable

There are binaries for 64bit Linux and Windows available on the releases page. Usage is simple. Download the .tgz file, unpack the binary and run it with any options like this:

# ./pendulum -?
flag provided but not defined: -?
Usage of pendulum:
  -addr string
        Address for server (default ":8080")
  -contents string
        Folder for display (default ".")

If you want to serve contents of a test folder on port 8081 you would run it as:

./pendulum -addr :8081 -contents test

It's also supported to pass the contents folder as a normal argument. This is the shortest way of starting pendulum serving a custom folder: ./pendulum folder.

Screenshot

As you write or scroll either the textarea or the preview pane, the scroll positions are synchronised based on percentage. In case of images in the text, accuracy can be quite off, but it's possible to improve this behaviour in the future.

Most of the development is basically related with the preview of whatever it is you're editing. The editor itself doesn't care about anything other than the contents of the text file you're opening and trying to save.

Thanks

If you want to thank me, please consider buying a book or three:

This project exists only because of the last book on the list.

Why did I make this?

There's a distinct lack of friendly solutions that just let you point to a folder and edit a bunch of text or markdown files. I wrote about three books on Leanpub (see above), and it was useful to provide me with a way to review those markdown files. I'm also blogging with Hugo, used to blog with Hexo, have some Jekyll files for my GitHub page, and I tend to write documentation with MkDocs. That's about five systems which I actively write content into and those are just the public ones.

How is it made?

There's a very simple API that powers the editor. The API provides exactly three calls:

  1. /api/list - lists folders and files for navigation,
  2. /api/read - reads a single file for editing,
  3. /api/store - stores a single file contents (can create new files)

It operates exclusively on the contents folder and the files you provide in there. The editor doesn't care what kind of files you put there, currently only files starting with a dot are excluded, ie, .git, .gitignore,...

Go server + API

A full HTTP server is implemented with Go. By default it listens on port 8080, but it's trivial to change this, just by passing the -addr option when you run it.

go run *.go -addr :80

Note: Pendulum supports git versioning. It does require you to set git config for user.name and user.email. Without those, Pendulum will not add/commit files, regardless if a git repository is present or not.

Special syntax

Software Type Syntax Support
Leanpub Citation A> Note Yes
Leanpub Pagebreak {pagebreak} Yes
Hugo Pagebreak <!--more--> Yes
Hexo Image asset_img Yes

I'm trying to add new features here. Feel free to submit a PR if there's a syntax you'd like to support, with the appropriate tests under front/src/markdown/*.

Status

  • Full API for list, read and store,
  • Navigation of folders and files on the front-end,
  • Editor component with synchronised scrolling with preview,
  • Marked preview,
  • (partially done) Add support for some of Leanpub syntax (A>, page break,...),
  • Add support for some of Hugo syntax (<!--more-->, metadata, ...),
  • Actually save the contents that are being edited (client-side ajax),
  • Check if git has user.name && user.email set before commiting with git
  • Add git support to Go API
  • Add option for HTTP auth
  • Deprecate/remove PHP API
  • Support images with relative links in rendering
  • Display images from preview markdown pane
  • More markdown styling (done: blockquote, code, image, needs: tables,...)
  • Docker image for delivery
  • Go server for delivery
  • Git support from Go / Docker
  • Codeship CI,
  • Semver (sort of),
  • Pack public_html data into release binary
  • Downloadable builds on GitHub
  • Windows build
  • Create new files over front-end interface

I guess unit testing should be somewhere on the list, if this thing ever gets any traction.

More Repositories

1

netdata

Dockerfile for building netdata
Shell
238
star
2

books

Samples from my published works
Go
160
star
3

docker-proxy-acl

A docker unix socket proxy which resticts endpoint usage to allowed sections
Go
65
star
4

task-ui

Task UI - a web based runner for Taskfile.yml
Go
51
star
5

iso-country-flags-svg-collection

ISO code country flag icons SVG collection
Shell
41
star
6

docker-chaos-monkey

A Chaos Monkey system for Docker and Docker Swarm
Shell
33
star
7

wowza-geoip

GeoIP module for Wowza Media Server 2.1.0+
Java
21
star
8

secretsmanager

Secrets management that allows you to store your secrets encrypted in git
Go
19
star
9

nginx-lesscss

CSS
18
star
10

PeerLive

Hybrid CDN/P2P Architecture for Live Video broadcast (HLS, WebRTC, Online Video, peer-to-peer)
JavaScript
12
star
11

minitpl

Miniature fully featured PHP template engine
PHP
12
star
12

microservice

DevOPS/Docker/Go Advent of Code 2019
Go
9
star
13

sonyflake

A ID generation service exposed over HTTP
Shell
9
star
14

factory

Go factories for some common things which I use
Go
9
star
15

saas

Various components for building your own SaaS
Vue
5
star
16

research-projects

Patches, tests, experiments, stuff
Assembly
5
star
17

wowza-virtualstreams

Virtual stream provider for Wowza Media Server
Java
4
star
18

binary

A helper to decode binary data into structures, with bit-size accuracy
Go
4
star
19

go-web-crontab

A crontab-like executor with a web front-end
Go
4
star
20

serve-vue

Serve a built vue-js project folder
Go
4
star
21

git_hooks

Common git hooks to be used with git-hooks and git submodules across several projects
PHP
2
star
22

smartcrop

Using the wonderful golang smartcrop to give crop sizes for common ratios
Go
2
star
23

drone-plain

A plain-JSON global secrets provider for Drone CI
Go
2
star
24

git-misc

Enhanced git commands for working with multiple checkouts/submodules
PHP
2
star
25

undock

Install a server with your Dockerfile
Shell
2
star
26

sql-as-an-api

Go
2
star
27

dockerfiles

Various Dockerfiles for building anything I need
Shell
1
star
28

composer-sentinel

A quick composer/packagist repository generator
PHP
1
star
29

vuejs-saas

A VueJS starter pack with a landing page and a simple back-end page, usable for SaaS projects
1
star