• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    CSS
  • License
    BSD 3-Clause "New...
  • Created over 11 years ago
  • Updated almost 11 years ago

Reviews

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

Repository Details

Super simple live static blog generator in Go. Vraiment trofaf.

trofaf

trofaf is a super-simple live static blog engine.

Install using: go get github.com/PuerkitoBio/trofaf

Description

It generates a static website from markdown files and front matter, and requires only a simple 3-directories structure to get going. It favors simplicity over features.

To get started, create the 3 subdirectories (you can look at the example/ subdirectory for... an example):

  • posts
  • public
  • templates

trofaf only cares about *.md files in the posts directory, and about *.amber (Amber templates) or *.html (native Go templates) files in the templates directory. It will watch for changes, creates or deletes on those files in these directories, and will re-generate automatically the website when required. This is the live part.

All files in the public directory are exposed by the web server. Posts in markdown format get translated to static html files at the root of the public directory. The html file name is an URL-friendly slug generated from the original markdown file name. There is no extension, so the URL looks clean and, uh, modern?

An RSS feed is automatically generated from a number of recent posts, and saved as a static XML file in the public directory.

There is no special template for an index page, the most recent post (based on the publication date found in the front matter of the markdown files) is saved twice - once under its own html file, once under the index.html file, so that this is the page displayed when the root of the web server is requested.

When the site is (re-)generated, the public directory must be cleaned, because some posts may have been deleted. Subdirectories are left untouched (so that css/ or js/ directories can coexist peacefully), as well as hidden (dot) files, and some special files are also graced from the destruction (robots.txt, favicon.ico, etc., see gen.go).

It currently uses my fork of the amber package, in order to make a fmttime(t time.Time, fmt string) string function available in the templates. This function makes it possible to format the PubTime or ModTime fields in the same way that the stdlib's time.Format() works. This function is also made available to native Go templates (you can check the examples for usage).

Command-line Options

The following options can be set at the command-line:

  • Port (-p) : the port number for the web server, defaults to 9000.
  • GenOnly (-g) : generate the static site and exit.
  • NoGen (-G) : prevents watching and live-generating the site. This is equivalent to running the static public directory.
  • SiteName (-n) : the name of the web site, passed to the template.
  • TagLine (-t) : a tag line for the web site, passed to the template.
  • RecentPostsCount (-r) : the number of posts in the recent posts list, passed to the template and used for the RSS feed.
  • BaseURL (-b) : the base URL of the web site, most likely the host name (i.e. http://www.mysite.com).

Front matter

Like many static blog generators, trofaf uses YAML front matter to get metadata for a post. This is a complicated way to say that you have to add blocks of text like this at the start of your posts:

---
Title: My title
Description: My short-ish description of the post.
Author: Me
Date: 2013-07-14
Lang: en
---

# Here is my post!

Etc.

The three dashes delimit the front matter. It must be there, beginning and end. Between the dashes, the part before the colon : is the key, and after is the value. Simple as that. Title, Description, Author, Date and Lang are recognized. Valid date formats are 2006-01-02, 2006-01-02 15h (or 2006-01-02 8h), 2006-01-02 15:04 (or 2006-01-02 8:17) or the RCF3339 format (2013-08-06T17:48:01-05:00).

License

The BSD 3-Clause License.

More Repositories

1

pigeon

Command pigeon generates parsers in Go from a PEG grammar.
Go
837
star
2

agora

a dynamically typed, garbage collected, embeddable programming language built with Go
Go
326
star
3

martini-api-example

An example RESTful API application built with Martini.
Go
272
star
4

redisc

A Go redis cluster client built on top of redigo.
Go
228
star
5

express-boilerplate

Basic structure of a node.js web application with Express. Started out as a blog post about how to structure code in an Express web app (in French, see the URL below).
JavaScript
64
star
6

juggler

Juggler: a websocket-based, redis-backed RPC and pub-sub server.
Go
62
star
7

gocostmodel

Benchmarks of common basic operations for the Go language.
Go
61
star
8

specter

a (tiny) VM project built with Go
Go
59
star
9

ghost

Lego blocks for web servers.
Go
52
star
10

lune

A pure Go implementation of the Lua virtual machine.
Go
44
star
11

advice

Advice functional mixin based on Twitter's Angus Croll presentation (How we learned to stop worrying and love Javascript).
JavaScript
39
star
12

upstashdis

A Go client and a compatible server for local testing for the Upstash Redis REST API interface.
Go
22
star
13

gred

A pure Go concurrent implementation of the Redis server
Go
20
star
14

implement.js

Strong type-checking for dependency injection and method arguments.
JavaScript
20
star
15

Networking

Low-level Swift package for POSIX sockets and Epoll/Kqueue.
Swift
19
star
16

luashell

A small Lua module to help write what would be shell scripts in Lua. (mirror)
Lua
12
star
17

gocoro

Lua coroutine implementation in Go
Go
7
star
18

angular-gtd

An example app for Getting Things Done built with AngularJS.
JavaScript
6
star
19

tulip

Lua web framework based on lua-http and PostgreSQL. (mirror)
Lua
6
star
20

algo

Fundamental algorithms and data structures using Go generics.
Go
6
star
21

mainer

Package mainer defines types relevant to flag parsing and command entrypoint implementation.
Go
5
star
22

assnatapi

API pour exploiter les données de l'Assemblée nationale du Québec.
JavaScript
5
star
23

starstruct

Starlark to Go struct converter.
Go
4
star
24

assnat

Extracteur des données du site de l'Assemblée Nationale du Québec, pour nourrir assnatapi.
JavaScript
4
star
25

swiftodo

iOS ToDo list tutorial in Swift
Swift
4
star
26

httpcmw

Package httpcmw supports creating middleware chains for HTTP clients.
Go
3
star
27

runes

Command to print Unicode code point information.
Go
3
star
28

myvim

my vim setup
Vim Script
2
star
29

zzterm

Zero-allocation terminal input key and mouse decoder in Go (mirror).
Go
2
star
30

nitfind

ack-style finder in Nit, mostly to experiment with the language
Nit
2
star
31

setupjs

Personal setup for javascript frontend projects.
JavaScript
2
star
32

see-no-evil

Tiny callback cleaner library for node.js, so that error management gets out of the way.
JavaScript
2
star
33

httpmw

Package httpmw is a collection of bite-sized middleware with chaining support.
Go
2
star
34

bench_go_scripting

Small benchmarks comparing the Tengo and Risor scripting languages
Shell
2
star
35

luafn

Functional programming fundamentals for Lua. (mirror)
Lua
1
star
36

sendkeys

Simulate sending user input in a terminal (mirror).
Go
1
star
37

luasock99

Lua module for the socket99 C library. (mirror)
C
1
star
38

nenuphar

wip
Go
1
star
39

bookify

Make a book out of URLs, basically. Exploring node.js, express and socket.io along the way!
JavaScript
1
star
40

tcheck

Simple Lua module of sanity-checks for types (mirror)
Lua
1
star
41

Provok.in-issues

Issues repository for the Provok.in website.
1
star
42

exp

Go
1
star
43

xpgsql

Lua module providing a straightforward API to the luapgsql library. (mirror)
Lua
1
star
44

feedbuilder

JavaScript
1
star
45

mna.dev

Mirror of git.sr.ht/~mna/mna.dev
Go
1
star
46

vim-trefle

Vim syntax highlighting, filetype detection and indentation for trefle.
Vim Script
1
star
47

0value

files for my 0value.com blog
HTML
1
star
48

zzcsi

Control Sequence Introducer (CSI) functions for xterm-compatible terminals. (mirror)
Go
1
star
49

httpparms

Package httpparms provides helper functions and mechanisms to load the content of an HTTP request into a Go struct.
Go
1
star
50

ungeekenorbite

Blog exploratoire d'un geek qui découvre avec stupeur et tremblements le merveilleux monde des nouvelles technologies.
JavaScript
1
star