Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 121 lines (79 sloc) 4.165 kb
42552c2 @5v3n added rdoc and fixed some renaming glitches
authored
1 # Karakuri
6987525 changed from classes to modules... seems more appropriate
5v3n authored
2
3 Having a closer look at ruby based blogging platforms like [serious](http://github.com/colszowka/serious) and [toto](http://cloudhead.io/toto), I missed some functionality.
4
9fd4375 @5v3n fixed typo
authored
5 This a a collection of tools usable in both platforms. The project was formerly known as blog_helper, but Karakuri is a far more suitable name & will be used from now on.
6987525 changed from classes to modules... seems more appropriate
5v3n authored
6
7fc9a17 changed README to README.md
5v3n authored
7 ## Features
6987525 changed from classes to modules... seems more appropriate
5v3n authored
8
9 - tag your posts
509019e working on the documentation...
5v3n authored
10 - use seo friendly page titles
6987525 changed from classes to modules... seems more appropriate
5v3n authored
11 - use the disqus comment counter
2345466 updated README.md
5v3n authored
12 - a workaround for serious allowing you to use generic yaml fields
c6ece92 Competing the docs...
5v3n authored
13
7fc9a17 changed README to README.md
5v3n authored
14 ## Installation
c6ece92 Competing the docs...
5v3n authored
15
f1f1c3a @5v3n removed toto --pre from readme and added Gemfile remark.
authored
16 It's a piece of cake: just install the gem. Simply add `gem 'karakuri'` to your Gemfile or use `sudo gem install karakuri` to get going.
c6ece92 Competing the docs...
5v3n authored
17
0bf9e7f @5v3n changed link to dorothy's sister
authored
18 For a default karakuri powered toto template, check out [dorothy's sister karathy](https://github.com/5v3n/karathy).
b9aeaac @5v3n added remark on karathy
authored
19
7fc9a17 changed README to README.md
5v3n authored
20 ## Usage
c6ece92 Competing the docs...
5v3n authored
21
0e20ef0 @5v3n migrating to new name
authored
22 Piece of cake, again: all you have to do is use `<% require 'karakuri'%>` in your .rhtml or .erb file and call the corresponding methods.
3ca2d11 added description for seo friendly page titles
5v3n authored
23
6d20ab5 updated README.md
5v3n authored
24 ### SEO friendly titles
3ca2d11 added description for seo friendly page titles
5v3n authored
25 For example, to use seo friendly titles, your layout.rhtml should be looking like this:
26
bd7d52a adjusted readme formatting...
5v3n authored
27
28 <!doctype html>
29 <html>
30 <head>
3927a42 @5v3n adjusted readme - still had some blog_helper require in there, darn\!
authored
31 <% require 'karakuri'
0e20ef0 @5v3n migrating to new name
authored
32 page_title = Karakuri::seo_friendly_title(@path, title, 'yourSitesTitle.com')
bd7d52a adjusted readme formatting...
5v3n authored
33 %>
34 <title><%= page_title %></title>
35 <link rel="alternate" type="application/atom+xml" title="<%= page_title %> - feed" href="/index.xml" />
36 .
37 .
38 .
5ad53aa added documenation & tag
5v3n authored
39
6d20ab5 updated README.md
5v3n authored
40 ### Tags
41 Adding the tagging feature requires the _toto_prerelease_ as mentioned above, since we need the http request to apply our little hack.
42
43 To add a list of tags to your article, just use a custom yaml attribute:
44
45 title: The Wonderful Wizard of Oz
46 author: Lyman Frank Baum
47 date: 1900/05/17
2345466 updated README.md
5v3n authored
48 tags: hacks, love, rock 'n' roll
6d20ab5 updated README.md
5v3n authored
49
50 Dorothy lived in the midst of the great Kansas prairies, with Uncle Henry,
51 who was a farmer, and Aunt Em, who was the farmer's wife.
52
53 Next, you need a place to show the tag links, for example the index.rhtml:
54
55 <section id="articles">
3927a42 @5v3n adjusted readme - still had some blog_helper require in there, darn\!
authored
56 <% require 'karakuri' %>
6d20ab5 updated README.md
5v3n authored
57 <% for article in articles[0...10] %>
58 <article class="post">
59 <header>
60 <h1><a href="<%= article.path %>"><%= article.title %></a></h1>
61 <span class="descr"><%= article.date %></span><% 10.times { %>&nbsp;<%}%>
2345466 updated README.md
5v3n authored
62 <span class="tags">
0e20ef0 @5v3n migrating to new name
authored
63 <%= Karakuri::tag_link_list(article[:tags]) %>
2345466 updated README.md
5v3n authored
64 </span><% 10.times { %>&nbsp;<%}%>
65 .
66 .
67 .
6d20ab5 updated README.md
5v3n authored
68
69
70
85327f2 @5v3n removed toto --pre from readme and added Gemfile remark.
authored
71 And again: piece of cake ;-). Now all we need to add is a page that displays articles belonging to a ceratin tag:
6d20ab5 updated README.md
5v3n authored
72
73 Create a page called `tagged.rhtml` in your `templates/pages` directory that looks like this:
74
5ad53aa added documenation & tag
5v3n authored
75
6d20ab5 updated README.md
5v3n authored
76 <%
3927a42 @5v3n adjusted readme - still had some blog_helper require in there, darn\!
authored
77 require 'karakuri'
0e20ef0 @5v3n migrating to new name
authored
78 desired_tag = Karakuri::desired_tag(env["QUERY_STRING"])
6d20ab5 updated README.md
5v3n authored
79 %>
80 <h1>Posts filed under '<%= desired_tag %>': </h1>
81 <ul>
82
0e20ef0 @5v3n migrating to new name
authored
83 <% Karakuri::desired_articles(@articles, desired_tag).each do |article| %>
6d20ab5 updated README.md
5v3n authored
84 <li>
85 <span class="descr"><a href="<%= article.path %>" alt="<%= article.title %>"><%= article.title %></a><br/></span>
86 </li>
87 <% end %>
88 </ul>
89 <br/>
90
91 Now, you did most likely implement a tag listing on your toto blog. Congrats!
92
2345466 updated README.md
5v3n authored
93
c747041 fixed typo
5v3n authored
94 ### short url (via bit.ly)
dc110cc Version 0.0.6 - url shortening (via bit.ly) introduced.
5v3n authored
95
57b1ebf fixed typo and shaprened url shortener's description
5v3n authored
96 To use a bit.ly shortened URL, just call the followin function inside a .rhtml file:
97
0e20ef0 @5v3n migrating to new name
authored
98 <%= Karakuri::short_url_bitly(<url>, <bit.ly login name>, <bit.ly api key>) %>
dc110cc Version 0.0.6 - url shortening (via bit.ly) introduced.
5v3n authored
99
100
2345466 updated README.md
5v3n authored
101 ### disqus comment counter
102
5ad53aa added documenation & tag
5v3n authored
103 Basically just adds the necessary java script to enable the disqus comment counter. For best performance, place it near the end of the page:
104
0e20ef0 @5v3n migrating to new name
authored
105 <%= Karakuri::disqus_comment_count_js(@config[:disqus]) %>
5ad53aa added documenation & tag
5v3n authored
106 </body>
107
108 </html>
109
110 Mind the usage of `@config[:disqus]`, this enables configuration via `config.ru`.
111
112 To access the comment count, use `#disqus_thread` at the end of the permalink to the post & it will be replaced with the disqus comment count:
113
c0c3d5b fixed typo
5v3n authored
114 <a href="<%= article.path %>#disqus_thread">&nbsp;</a>
5ad53aa added documenation & tag
5v3n authored
115
116 Will result in the number of comments of the article the permalink posts to.
2345466 updated README.md
5v3n authored
117
118 ### serious custom yaml field reader
119
85327f2 @5v3n removed toto --pre from readme and added Gemfile remark.
authored
120 I hacked serious' custom yaml field access (quite dirty hack) - but please refer to the source & ri for that, I don't use serious anymore.
Something went wrong with that request. Please try again.