Permalink
Browse files

moved test templates. added routes. fixed README.

  • Loading branch information...
1 parent e690e2e commit ce8a3a5c01b839942dc9afc1b945d8e1aaf0f4d2 @georgi committed Jan 7, 2009
View
@@ -1,3 +1,4 @@
*~
doc/*
pkg/*
+test/repo
View
@@ -1,19 +1,23 @@
-Shinmun, the git-based blog engine
+Shinmun - a git-based blog engine
==========================================
-Shinmun is a **minimalist blog engine**. You just write posts as text
-files and serve your blog straight from a git repository. You write
-posts in your favorite editor like Emacs or VI and deploy via
-`git push`.
+Shinmun is a small git-based blog engine. Write posts in your favorite
+editor, git-push it and serve your blog straight from a
+repository.
+
### Features
+* Posts are text files formatted with [Markdown][8], [Textile][9] or [HTML][10]
+* Runs on [Rack][6], [Kontrol][3] and [GitStore][7]
+* Deploy via [git-push][11]
* Index, category and archive listings
* RSS feeds
* Flickr and Delicious aggregations
-* Runs on Rack via [Kontrol][3]
-* Syntax highlighting provided by CodeRay
+* Syntax highlighting provided by [CodeRay][4]
* AJAX comment system with Markdown preview
+* Web frontend using [WMD Editor][12]
+
### Quickstart
@@ -55,7 +59,8 @@ your new article.
### Post Format
Each blog post is just a text file with a YAML header and a body. The
-YAML header is surrounded with 2 lines of 3 dashes.
+YAML header is surrounded with 2 lines of 3 dashes. This format is
+compatible with [Jekyll][13] and [Github Pages][14].
The YAML header has following attributes:
@@ -150,24 +155,24 @@ Inside `config/blog.yml` you set the properties of your blog:
* url: used for RSS
* categories: a list of categories
+
### Assets
-By default Shinmun serves asset files from your assets directory. If
-you want some other behaviour, you can tweak the `map.rb` file in your
-blog folder, which contains all routes.
+Shinmun serves asset files from your assets directory. Files in the
+directories `assets/stylesheets` and `assets/javascripts` will be
+served as one file each under the URLs `assets/stylesheets.css` and
+`assets/javascripts.css`. You have to name them accordingly like
+`1-reset.css` and `2-typo.css` to define the order.
-If you set the variables `javascripts_files` or `stylesheets_files` in
-`config/asstes.yml`, Shinmun will serve the javascripts as
-`assets/javascripts.js` and stylesheets as `assets/stylesheets.css`
-automatically. Both variables should be arrays of the filenames
-without extension.
### Templates
Layout and templates are rendered by *ERB*. The layout is defined in
`templates/layout.rhtml`. The content will be provided in the variable
`@content`. A minimal example:
+ @@rhtml
+
<html>
<head>
<title><%= @blog.title %></title>
@@ -181,6 +186,8 @@ Layout and templates are rendered by *ERB*. The layout is defined in
The attributes of a post are accessible as instance variables in a
template:
+ @@rhtml
+
<div class="article">
<div class="date">
<%= date @date %>
@@ -200,6 +207,7 @@ post>`. So administration of comments is possible by editing the YAML
file, which can be done on your local machine, as you can just pull
the comments from your live server.
+
### Deployment
Shinmun can server the blog straight from the git repository. So on
@@ -230,6 +238,7 @@ just write, commit and finally push a post by:
$ git commit -a -m 'new post'
$ git push live
+
### Phusion Passenger
Shinmun is compatible with [Phusion Passenger][5]. Install Phusion
@@ -238,6 +247,8 @@ Passenger as described in my [blog post][2].
Assuming that you are on a Debian or Ubuntu system, you can create a
file named `/etc/apache2/sites-available/blog`:
+ @@xml
+
<VirtualHost *:80>
ServerName myblog.com
DocumentRoot /var/www/blog/public
@@ -255,13 +266,11 @@ domain:
### Web Frontend
-The example blog has a builtin web frontend. To activate you have to
-create a file named `password` with a single password inside. Now
-browse to `/admin` and login using some arbitrary username and your
-password.
+The example blog has a builtin web frontend. Currently it only works
+on localhost:9292.
The frontend allows you to create, edit, read or delete posts or
-pages. Editing a post shows up a form with the [wmd editor][6]. You
+pages. Editing a post shows up a form with the [wmd editor][12]. You
have to look yourself for a correct YAML header, otherwise you will
get incorrect results.
@@ -271,7 +280,7 @@ single commit overview, where you can inspect changes introduced by
this particular commit.
-### Download
+### GitHub Project
Download or fork the package at my [github repository][1]
@@ -281,4 +290,12 @@ Download or fork the package at my [github repository][1]
[3]: http://github.com/georgi/kontrol
[4]: http://coderay.rubychan.de/
[5]: http://www.modrails.com/
-[6]: http://wmd-editor.com/
+[6]: http://github.com/rack/rack
+[7]: http://github.com/georgi/git_store
+[8]: http://daringfireball.net/projects/markdown/
+[9]: http://textile.thresholdstate.com/
+[10]: http://en.wikipedia.org/wiki/Html
+[11]: http://www.kernel.org/pub/software/scm/git/docs/git-push.html
+[12]: http://wmd-editor.com/
+[13]: http://github.com/mojombo/jekyll
+[14]: http://github.com/blog/272-github-pages
View
@@ -5,6 +5,7 @@
require 'coderay'
require 'kontrol'
require 'git_store'
+require 'grit'
begin; require 'redcloth'; rescue LoadError; end
View
@@ -6,7 +6,7 @@ class Blog < Kontrol::Application
include Helpers
- attr_reader :aggregations, :categories, :comments
+ attr_reader :aggregations, :categories, :comments, :repo
%w[ assets comments config posts pages ].each do |name|
define_method(name) { store.root.tree(name) }
@@ -21,6 +21,7 @@ def initialize(path)
super
@aggregations = {}
+ @repo = Grit::Repo.new(path)
Thread.start do
loop do
@@ -45,13 +46,17 @@ def load_aggregations
end
end
+ def posts_by_date
+ posts.sort_by { |post| post.date.to_s }.reverse
+ end
+
def recent_posts
- posts.sort_by { |post| post.date.to_s }.reverse[0, 20]
+ posts_by_date[0, 20]
end
# Return all posts for a given month.
def posts_for_month(year, month)
- posts.select { |p| p.year == year and p.month == month }.sort_by { |p| p.date.to_s }
+ posts_by_date.select { |p| p.year == year and p.month == month }
end
# Return all posts with any of given tags.
@@ -142,6 +147,11 @@ def write(file, template, vars={})
def render(name, vars = {})
super(name, vars.merge(:blog => self))
end
+
+ def call(env)
+ templates['helpers.rb']
+ super
+ end
end
View
@@ -22,11 +22,11 @@
end
post '/comments' do
- if params['preview']
+ if params['preview'] == 'true'
render '_comments.rhtml', :comments => [Shinmun::Comment.new(params)]
else
post_comment(params['path'], params)
- render '_comments.rhtml', :comments => comments_for(path)
+ render '_comments.rhtml', :comments => comments_for(params['path'])
end
end
@@ -46,12 +46,18 @@
end
map '/admin' do
- use Rack::Auth::Basic do |username, password|
- File.read(File.join(File.dirname(__FILE__), "password")).chomp("\n") == password
- end
+ use(Class.new do
+ def initialize(app); @app = app; end
+ def call(env)
+ if env['HTTP_HOST'] == 'localhost:9292'
+ @app.call(env)
+ else
+ [401, {}, '<h1>Not Allowed</h1>']
+ end
+ end
+ end)
get '/posts/(.*)' do |page|
- session[:admin] = true
render 'admin/posts.rhtml', :posts => posts_by_date, :page => page.to_i, :page_size => 10
end
Oops, something went wrong. Retry.

0 comments on commit ce8a3a5

Please sign in to comment.