Project

blogish

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A tiny and powerful blogging engine, wrapped up in a Rubygem. Supports markdown-based posts, syntax highlighting, and RSS feeds.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

Blogish

Blogish is a neat and simple blogging engine, wrapped up in a Rubygem. It supports markdown-based entries and syntax highlighting.

It aims to provide the functions you need to create and display entries, but without dictating site layout or design. That makes it well suited for situations where you want to incorporate a simple blog into an pre-existing site.

Installation

Add this line to your application's Gemfile:

gem 'blogish'

And then execute:

$ bundle

Or install it yourself as:

$ gem install blogish

Usage

require 'blogish'

Creating new posts

Blogish reads entries stored in flat markdown files in a views/blog directory.

It relies on certain conventions to work. Each entry should be named using the date of the entry and the URL slug, separated by an underscore and with the .mkd extension.

<date>_<slug>.mkd

The first line of the each entry should contain its title, then three dashes to separate it from the main body of the entry. Putting it all together:

$ cat views/blog/2013-02-07_hello-world.mkd
Hello World!
---
This is the first paragraph.

This is the second paragraph. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic porro quae ea amet
dolores quibusdam magni illum harum unde tempore nisi totam adipisci quisquam aliquid quis ab necessitatibus?
Mollitia explicabo aperiam asperiores doloremque officiis ipsam. Animi distinctio a dolor consequuntur.

Displaying a post

You can display a single post based on it's slug using the fetch method. For example:

Blogish.fetch('hello-world')

If a matching entry is found, then a Hash with the contents of the post is returned. This Hash can then be passed to your view file, or wherever else you need to use the information.

{
  :title => 'Hello World',
  :date => #<Date: 2013-02-07 ((2456088j,0s,0n),+0s,2299161j)>,
  :slug => 'hello-world',
  :intro => '<p>This is the first paragraph</p>',
  :body => '<p>This is the first paragraph</p><p>This is the second paragraph. Lorem ipsum ...</p>'
}

If no entry with a matching slug is found, the method returns nil.

Displaying multiple posts

You can also display all entries using the fetch_all method. This returns an Array of all entries in the directory, sorted with the most recently dated first.

Blogish.fetch_all

This Array can then be passed to your view file, or wherever else you need to use it.

Using Syntax Highlighting

Syntax highlighting is supported out of the box thanks to Rouge. A list of supported languages is here. Simply wrap any code in your markdown files in fenced blocks, github style.

```ruby
# This is a comment
@foo = bar
```

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request