• Stars
    star
    1,473
  • Rank 31,917 (Top 0.7 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 15 years ago
  • Updated about 9 years ago

Reviews

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

Repository Details

the 10 second blog-engine for hackers

toto

the tiniest blogging engine in Oz!

introduction

toto is a git-powered, minimalist blog engine for the hackers of Oz. The engine weighs around ~300 sloc at its worse. There is no toto client, at least for now; everything goes through git.

blog in 10 seconds

$ git clone git://github.com/cloudhead/dorothy.git myblog
$ cd myblog
$ heroku create myblog
$ git push heroku master

philosophy

Everything that can be done better with another tool should be, but one should not have too much pie to stay fit. In other words, toto does away with web frameworks or DSLs such as sinatra, and is built right on top of rack. There is no database or ORM either, we use plain text files.

Toto was designed to be used with a reverse-proxy cache, such as Varnish. This makes it an ideal candidate for heroku.

Oh, and everything that can be done with git, is.

how it works

  • content is entirely managed through git; you get full fledged version control for free.
  • articles are stored as .txt files, with embedded metadata (in yaml format).
  • articles are processed through a markdown converter (rdiscount) by default.
  • templating is done through ERB.
  • toto is built right on top of Rack.
  • toto was built to take advantage of HTTP caching.
  • toto was built with heroku in mind.
  • comments are handled by disqus
  • individual articles can be accessed through urls such as /2009/11/21/blogging-with-toto
  • the archives can be accessed by year, month or day, with the same format as above.
  • arbitrary metadata can be included in articles files, and accessed from the templates.
  • summaries are generated intelligently by toto, following the :max setting you give it.
  • you can also define how long your summary is, by adding ~ at the end of it (:delim).

dorothy

Dorothy is toto's default template, you can get it at http://github.com/cloudhead/dorothy. It comes with a very minimalistic but functional template, and a config.ru file to get you started. It also includes a .gems file, for heroku.

synopsis

One would start by installing toto, with sudo gem install toto, and then forking or cloning the dorothy repo, to get a basic skeleton:

$ git clone git://github.com/cloudhead/dorothy.git weblog
$ cd weblog/

One would then edit the template at will, it has the following structure:

templates/
|
+- layout.rhtml      # the main site layout, shared by all pages
|
+- index.builder     # the builder template for the atom feed
|
+- pages/            # pages, such as home, about, etc go here
   |
   +- index.rhtml    # the default page loaded from `/`, it displays the list of articles
   |
   +- article.rhtml  # the article (post) partial and page
   |
   +- about.rhtml

One could then create a .txt article file in the articles/ folder, and make sure it has the following format:

title: The Wonderful Wizard of Oz
author: Lyman Frank Baum
date: 1900/05/17

Dorothy lived in the midst of the great Kansas prairies, with Uncle Henry,
who was a farmer, and Aunt Em, who was the farmer's wife.

If one is familiar with webby or aerial, this shouldn't look funny. Basically the top of the file is in YAML format, and the rest of it is the blog post. They are delimited by an empty line /\n\n/, as you can see above. None of the information is compulsory, but it's strongly encouraged you specify it. Note that one can also use rake to create an article stub, with rake new.

Once he finishes writing his beautiful tale, one can push to the git repo, as usual:

$ git add articles/wizard-of-oz.txt
$ git commit -m 'wrote the wizard of oz.'
$ git push remote master

Where remote is the name of your remote git repository. The article is now published.

deployment

Toto is built on top of Rack, and hence has a rackup file: config.ru.

on your own server

Once you have created the remote git repo, and pushed your changes to it, you can run toto with any Rack compliant web server, such as thin, mongrel or unicorn.

With thin, you would do something like:

$ thin start -R config.ru

With unicorn, you can just do:

$ unicorn

on heroku

Toto was designed to work well with heroku, it makes the most out of it's state-of-the-art caching, by setting the Cache-Control and Etag HTTP headers. Deploying on Heroku is really easy, just get the heroku gem, create a heroku app with heroku create, and push with git push heroku master.

$ heroku create weblog
$ git push heroku master
$ heroku open

configuration

You can configure toto, by modifying the config.ru file. For example, if you want to set the blog author to 'John Galt', you could add set :author, 'John Galt' inside the Toto::Server.new block. Here are the defaults, to get you started:

set :author,      ENV['USER']                               # blog author
set :title,       Dir.pwd.split('/').last                   # site title
set :url,         'http://example.com'                      # site root URL
set :prefix,      ''                                        # common path prefix for all pages
set :root,        "index"                                   # page to load on /
set :date,        lambda {|now| now.strftime("%d/%m/%Y") }  # date format for articles
set :markdown,    :smart                                    # use markdown + smart-mode
set :disqus,      false                                     # disqus id, or false
set :summary,     :max => 150, :delim => /~\n/              # length of article summary and delimiter
set :ext,         'txt'                                     # file extension for articles
set :cache,       28800                                     # cache site for 8 hours

set :to_html   do |path, page, ctx|                         # returns an html, from a path & context
  ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
end

set :error     do |code|                                    # The HTML for your error page
  "<font style='font-size:300%'>toto, we're not in Kansas anymore (#{code})</font>"
end

thanks

To heroku for making this easy as pie. To adam wiggins, as I stole a couple of ideas from Scanty. To the developers of Rack, for making such an awesome platform.

Copyright (c) 2009-2010 cloudhead. See LICENSE for details.

More Repositories

1

rx

๐Ÿ‘พ Modern and minimalist pixel editor
Rust
2,920
star
2

node-static

rfc 2616 compliant HTTP static-file server module, with built-in caching.
JavaScript
2,171
star
3

http-console

simple, intuitive HTTP REPL โ€” Speak HTTP like a local.
JavaScript
1,358
star
4

eyes.js

a customizable value inspector for node.js
JavaScript
342
star
5

journey

liberal JSON-only HTTP request routing for node.
JavaScript
321
star
6

nakamoto

Privacy-preserving Bitcoin light-client implementation in Rust
Rust
303
star
7

thingler

The amazingly simple-to-use, real-time, collaborative todo list!
JavaScript
296
star
8

dorothy

a basic template for toto, the blogging engine
Ruby
244
star
9

hijs

simple & fast javascript syntax highlighting for the browser
JavaScript
240
star
10

rgx.legacy

Modern mid-level 2D graphics library
Rust
194
star
11

popol

Minimal non-blocking I/O for Rust
Rust
157
star
12

neovim-fuzzy

Minimalistic fuzzy file finding for neovim
Vim Script
111
star
13

dotfiles

~cloudhead
Vim Script
100
star
14

mutter

the tiny command-line interface library with lots of style~
Ruby
80
star
15

resourcer

a resource-oriented object-relational mapper for document databases
JavaScript
58
star
16

pixelog

simple pixel tracking server
Go
56
star
17

node-syslog

a syslog-ng TCP client, with basic fault-tolerance.
JavaScript
32
star
18

koi

minimal task management for hackers
Ruby
31
star
19

nonempty

Correct by construction non-empty list
Rust
30
star
20

px

Superseded by `rx`
C
30
star
21

erlapp.template

minimal erlang/OTP rebar template
Erlang
29
star
22

styleguide

style-guide for various languages
27
star
23

shady.vim

Shady vim color-scheme for late night hacking
Vim Script
23
star
24

vargs

practical variable argument handling in node.js
JavaScript
22
star
25

neovim-ghcid

Provides instant haskell error feedback inside of neovim, via ghcid.
Vim Script
21
star
26

microserde

miniserde minus the dependencies
Rust
18
star
27

pilgrim

a JSON consuming JavaScript XHR client for the browser
JavaScript
15
star
28

nimbus

nimble, durable, document store
JavaScript
14
star
29

spell-correct

ruby implementation of Norvig's spell corrector
Ruby
12
star
30

node-crawler

http crawler โ€” (project under development)
JavaScript
12
star
31

arbre

a dynamic functional programming language experiment
C
10
star
32

rig.js

temporally extend an object's capabilities.
JavaScript
9
star
33

mrchat

micro chat client for the console, in c, with some tasteful ncurses
C
9
star
34

talker-plugins

A bunch of plugins for Talker (http://talkerapp.com)
JavaScript
9
star
35

node-provider

Manage HTTP content providers. It's 'Accept'-based routing, folks!
JavaScript
9
star
36

proto.js

prototype & other core extensions
JavaScript
8
star
37

github-unwatcher

Unwatch github repos
JavaScript
8
star
38

memoir

Self-describing, reflective parser combinators
Rust
7
star
39

spinsv

a stateless service runner inspired by runit
Haskell
7
star
40

avl-auth

An authenticated AVL+ tree implementation in Haskell
Haskell
6
star
41

bloomy

Bloom filter implementation in Rust
Rust
6
star
42

gogol

a bitmap drawing & animation library for Go
Go
6
star
43

cloudhead.io

This is my website.
CSS
5
star
44

prose

lightweight text to html parser, combining the best of Markdown with a hint of Textile
Ruby
5
star
45

s3web

scripts for publishing static sites to S3
Ruby
4
star
46

github-recommend

recommendation engine for github's 2009 contest
C
4
star
47

monsv

a service runner inspired by runsv
Go
3
star
48

diffraction

even stocks can be diffracted!
Ruby
3
star
49

melon

hybrid javascript/ruby micro app engine
Ruby
3
star
50

node-intro

intro to node.js presentation for montreal.js
JavaScript
3
star
51

cryptocurrency

Cryptocurrency library for Haskell
Haskell
2
star
52

golem

pre-forking HTTP server for node (old)
JavaScript
2
star
53

ghoul

your (node) deployment minion - a work in progress.
PHP
2
star
54

rx.cloudhead.io

CSS
2
star
55

birth

graceful linux system birthing
Vim Script
2
star
56

extender

handy extensions to keep your code cleanโ„ข
Ruby
2
star
57

sokol-gfx-rs

C
1
star
58

iohk-challenge

IOHK Haskell test
Haskell
1
star
59

a-file-uploader

JavaScript
1
star
60

rgx

2D Graphics Toolkit for Rust
Rust
1
star