Giter Club home page Giter Club logo

toto's Introduction

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.

toto's People

Contributors

cloudhead avatar divoxx avatar hyperbolist avatar jpluscplusm avatar mikedouglas avatar nixon avatar nogweii avatar sce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

toto's Issues

How would you create a dynamic set of pages?

If I wanted to respond to all routes in the form of 'tag/', how would I go about that? I would like to have all routes of 'tag/' forward to a given page that would then display the articles that have the given tag.

Same for categories.

Wordpress to Toto Converter

I'm pretty sure this isn't really the right place, but I've developed a little wordpress-WXR-to-Toto-articles converter. It's in Python and I'm guessing it might eventually be useful to someone. A pastie is here (http://pastie.org/876755).

Feed not showing up on localhost

Hmmm.. not sure what I'm doing wrong but the feed isn't showing up on my local dev machine. I'm getting a 404 error in console:

127.0.0.1 - - [07/May/2010 22:39:25] "GET /index.xml HTTP/1.1" 404 75 0.0898

Works fine on Heroku though, and I think it worked fine before. Any idea what I could be doing wrong?

10 second blog example can be compressed/improved a bit

See : http://cloudhead.io/toto

First, end users should probably be encouraged to create a fork of the dorothy repo before cloning their own fork. Otherwise they won't be able to store their repo with a git push, or issue pull requests to you easily for commits to dorothy that should be shared by others.

Instead of:

(implicit 'mkdir myblog' not mentioned)
$ cd myblog
$ git clone git://github.com/cloudhead/dorothy.git .
$ heroku create
$ git push heroku master

Better:

$ git clone git://github.com/cloudhead/dorothy.git myblog      ## no mkdir needed
$ heroku create <myblogname>      ## creates myblogname.heroku.com
$ git push heroku master

This approach does not allow for pushing changes easily back to github, where others can benefit from them. A git push would fail since its origin is cloudhead's account.

Best:

Fork the github dorothy repo from : http://github.com/cloudhead/dorothy
$ git clone git://github.com/YOUR-GITHUB-UNAME/dorothy.git myblog      ## no mkdir needed
$ heroku create <myblogname>      ## creates myblogname.heroku.com
$ git push heroku master
$ git push     ## pushes everything, including changes to be shared back to github 

question about development

First of all, are there specific "environments" that the app can be run in (e.g. dev, test, pro)? If there are, those should be better documented. Also, is there a way to turn off caching when running on a local system? The reason I ask is that I can only assume that caching is what is causing my bizarre issue: both of my test posts have the same date, even though the first one is the default post that comes with this app (dated 1900-05-17). When I load up the app in my browser, they both say February 5th 2010 and thus the first one (the 1900-05-17 one) has a broken link.

Confusion: Should :prefix include the leading slash?

Currently, if you do set :prefix, "blog" the string "blog" is literally appeneded, without the leading slash.

Personally, I was expecting "/blog/2010/..." but instead I got "blog/2010/...". Is this the intended behaviour? If so, perhaps it should be better documented?

UTF-8 issue

Hi all,
I encounter an issue about encoding. I covert all .rhtml page & .txt page as UTF-8 format and set charset as UTF-8. Everything works well except the page title. it can not display correct if contains chinese.

is there anyone can help me out?

Thanks in advance!
-Jay

When setting up using a sub folder like Blog the home URL doesn't work

When setting up using a sub folder like Blog the home URL doesn't work, so navigating to .../blog/ results in the toto 404 (so the app runs fine) only when you navigate to .../blog/index it works. Navigating to the different blog posts works fine as well. I used the description in the Wiki to make it run with rails, I'll be using Padrino but that doesn't really matter here.

I hope I have explained it correctly?

Cheers,

-Mark

Add support for metadata and description tags for SEO

Add tags to the header section of each article to support SEO metadata keywords and description.

Title: My blog post
Date: 11/02/2010
keywords: blog, post, toto, github, blah
description: How to set up a blog using toto and Heroku

More control over titles

Can we have an option to attach the site title to all the page titles. So default title would be "MySite" and then when you go to an article page it would be something like "MySite - Some Article Title". Is this possible now?

`article.url` does not include port number

Just as the title says, calling article.url includes the path, the domain, the protocol, but not the port.

Run rackup locally, and open your atom feed. (Presuming rack uses a non-standard port) If you look at the ID (that should be fixed, but w/e) or link, the port is not shown.

Failed to install Toto gem under Windows XP Professional SP3

Could some one help?

I tried the installation in both remote and local way, it kept throwing out error as below:

D:\02_RoR\ruby>gem install toto -v 0.4.6
Building native extensions. This could take a while...
ERROR: Error installing toto:
ERROR: Failed to build gem native extension.

D:/02_RoR/ruby/bin/ruby.exe extconf.rb
checking for random()... no
checking for srandom()... no
checking for rand()... no
checking for srand()... no
creating Makefile

nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.

Gem files will remain installed in D:/02_RoR/ruby/lib/ruby/gems/1.8/gems/rdiscou
nt-1.6.5 for inspection.
Results logged to D:/02_RoR/ruby/lib/ruby/gems/1.8/gems/rdiscount-1.6.5/ext/gem_
make.out

Is it an incompatible issue? Is there any windows-compatible verson of Toto?

Thanks a lot!

Call YAML-derived data from layout.rhtml

I've browsed through the source code and can't figure out how to call YAML-derived values from my layout page.

I want to optimize my blog's SEO and dynamically generate the description and keywords for every page. (I know, I know... keywords don't affect page rank. Still, I like being semi-semantic.)

I've tried calling <%= description %> from the template and nothing shows up! Right now, it falls back to a default description I define in config.ru (and call via @config[:description]), but I want individual descriptions for each page.

It looks like the standard tags (title, date, author) have explicit methods defining them in the source, methods that can be called from a template. But method_missing doesn't work from inside that template file.

(I realize there is a method_missing definition elsewhere in the source, but I think that's scoped so that it doesn't work within my layout.rhtml.)

Do I really need to patch in a new method for every YAML tag I'm going to call from the template?

Selective Page Cache

Hi!

I just realized that my "random page" works locally (thin), but not on toto. It seems like a page cache issue - the random page picker works, but the page is not rendered since it's cached.

Is there a way to invalidate the page cache for a single page, perhaps a flag in the template or something similar?

Cheers

5v3n

Reference-style links broken in summaries

Links using the reference-style formatting...

This is [a link][1].
... rest of article
[1]:http://thelink.com

...are broken on summary views because the bottom of the article is truncated before being processed by Markdown.

utf-8

Hi.

It seems like toto doesn't handle utf-8 correctly yet (at least it's broken for me ;). I did not look through the code yet, just to let you know about it.

Summaries can contain wrongly markdown'd content

A summary that has pertinent markdown syntax beyond :max (or :delim, but that's more the author's fault) can display wrongly formatted content on the index page.

The example I've found is the backtick (currently visible on http://jpluscplusm.com/blog/). If the opening backtick is before :max and the closing backtick is after :max, then

a) the backtick is included in the output and
b) it is ignored for formatting purposes.

Obviously the fix is to manually include a :delim character before :max in an appropriate place, but there might be something clever that could be done to make this a non-issue for articles without a :delim.

Something that came to mind was reversing the logic in def(summary) from markdown(truncated_body) to truncate(markdown(entire_body)). Unfortunately, I don't think this would work very well, probably resulting in a syntactically invalid summary when it's truncated halfway through an HTML tag.

Hosting on http://domain.tld/blog/

I can't quite see how to make stock toto/dorothy host on /blog/, where the path is virtual. Things that break include: the links to individual articles from the index page (as they use .path instead of any part of config[:url]), links inside index.xml, and links to the css on the article pages.

I've cloned both projects at http://github.com/jpluscplusm/(toto|dorothy) with minor changes that make this possible, and would appreciate either a merge, or a suggestion of how better to achieve it with the existing code&config.ru. Apologies if this isn't the recognised git-ish way of requesting/suggesting a merge - I'm using this project to learn git :-)

HTH,
Jonathan

rake task not working

Hello:

I'm running into issue trying to use the 'rake new' task. I am able to publish perfect fine by hand, but if i try to generate an article with rake, I run into the following issue:

{REMOVED}:myNewBlog {REMOVED}$ rake --trace new
(in {REMOVED}/myNewBlog)
rake aborted!
no such file to load -- toto
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
/Users/guy_montag_old/development/myNewBlog/Rakefile:1
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in load' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:inraw_load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in load_rakefile' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in load_rakefile' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:inrun'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19

render partials with haml

I would love to use partials within haml. However, when I try to render a partial, the to_html method fails. What do I need to add to the render call?

=render :partial=> "sidebar"

give's me an ArgumentError, wrong number of arguments (1 for 2)

/Library/Ruby/Gems/1.8/gems/toto-0.4.1/lib/toto.rb: in to_html

  1. def self.env= env
  2. ENV['RACK_ENV'] = env
  3. end
    29.
  4. module Template
  5. def to_html page, config, &blk
  6. path = ([:layout, :repo].include?(page) ? Paths[:templates] : Paths[:pages])
  7. config[:to_html].call(path, page, binding)...
  8. end
    35.
  9. def markdown text
  10. if (options = @config[:markdown])
  11. Markdown.new(text.to_s.strip, *(options.eql?(true) ? [] : options)).to_html
  12. else
  13. text.strip

Add a default config.ru file

The file isn't in the source, but nor is it in .gitignore. Was it simply omitted or was there a reason for not versioning/sharing the file?

Not heroku installation problems

I think this might be pointed out that if you install on your own server and want to push there from your local machine you have to use a bare git repo on the server. But toto needs a working directory obviously. And you cannot push to a repo with a working directory. So if you use your own server you will have to make all your editing directly on the server or you'll have to #git reset --hard; git checkout -f on the server after any push.

I wonder how does heroko work around this issue? Maybe I can utilize their solution on my own server?

Atom Feed ID should not be the article.url

Atom Feed ID should not be the article.url

Using the post url as the atom id is not really the best practice. If the permalink changes (e.g. due to a typo) then the atom id will also change resulting in this post showing up again in feed readers (and other issues).

Once set, the ID should never, ever change no matter what.

Perhaps when your rake task generates the post, you can generate an appropriate (e.g. uuid) atom id in stuff it into the metadata of the post (and teach the user to never change this id).

See :

http://diveintomark.org/archives/2004/05/28/howto-atom-id
http://www.hesido.com/web.php?page=atomidtimestamp

Request: Custom permalinks

It seems that sant0sk1 already got it working. You (cloudhead) commented on it already, and you mentioned that go() needs to be patched. He did - sant0sk1/toto@ae4d7a0db960ac33df1200e94d3629ae3247f606 -, so I think it's ready, though, there probably will be a conflict with the newer code base.

Categories/tags?

I'd like to switch a Wordpress blog with about 200 posts to Toto - but in order to do that, I would need to be able to categorize and tag my posts. I'm not a Ruby guy - I've been trying to wrap my head around how to make the chances I'm thinking of, but so far I haven't had any luck.

Are these features planned additions to Toto, or are they outside of Toto's scope?

Let archives list be available in all sub pages

I'd like to have the archives list be in the layout.rhtml file so that I can have a sidebar with all of the archives when you are on any page. But if I do that and navigate to the about page I get a rack exception saying that the archives variable is empty.

Feed should only show the latest few articles, not all articles

Feedburner just stopped working for my blog because the feed is too large since it's loading all the blog's articles. Feed is there to show latest updates, not archives, so should only load up a few latest posts. Modifying the feed builder with the following to fetch the last 10 articles:

articles[-10, 10].each do |article|

Still waiting for Feedburner to refresh, will let you know if this works.

Problems with embedding Toto in Rails

Hi,

Using the wiki article contributed by markyl to embed Toto inside a rails app, I am running into the problem whereby toto has a problem parsing the request sent to it. The gist git://gist.github.com/299200.git gist-299200 shows the config.ru I am using.

The exception thrown is:

NoMethodError at /blog
You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.split

Ruby /home/foo/.gem/ruby/1.8/gems/toto-0.2.8/lib/toto.rb: in call, line 291

So it seems path is nil at this point and no route is set. The ENV shows path_info is set to /blog.

Is there something that can done in Toto do debug why the route is not being picked up properly as per a default install of toto? I have been unable to figure out this little glitch.

Thanks!

Too many open files

I imported 80 articles from my old blog and after clicking around from the index to an article and back again I get:

Errno::EMFILE at / Too many open files

It seems you need to find a safe place to call File#close after reading in each file's content.

summary defaults have changed

It looks like the default for article summaries is the whole article , and the :max summary option has changed to :length.

Is this correct?

Config's "ext" not being honored by the Rakefile

Changed "set :ext" to "markdown", so Textmate picks up on the formatting when opening files. But the task "new" still uses ".txt" after changing "config.ru" (toto itself is correctly using .markdown).

doesn't point to the post url

Hello everyone, this is a kinda weird issue. I create a new .txt file in /articles and add to git, commit and push it, then I go to the blog home page, and the description of the new post is there, but when I click to see the entire post in Chrome it says "Oops! This link appears to be broken." and Firefox gives me a 404 error (toto, we're not in Kansas anymore (404)), what is this?

P.S: The blog http://neorubyist.heroku.com/

Thanks :-)

Custom template engines

I would love to us toto for my small corporate site, I tried to build the blog index page inside a "blog" page. This does not work, seems that only index has access to the articles variable?

So my goal is to have a blog on http://127.0.0.1/blog/

How could I achieve that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.