karakuri 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/README.md +12 -6
  2. data/Rakefile +1 -1
  3. data/lib/karakuri.rb +24 -2
  4. metadata +6 -6
data/README.md CHANGED
@@ -13,11 +13,9 @@ This a a collection of tools usable in both platforms. The project was formerly
13
13
 
14
14
  ## Installation
15
15
 
16
- It's a piece of cake: just use the `gem` tool to get going with the _Karakuri_: `sudo gem install karakuri`
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.
17
17
 
18
- If you want to use features that rely on accessing the http requests like the _tag_ feature, you'll need to use the [_toto_prerelease_](http://github.com/5v3n/toto).
19
-
20
- Please follow the instrucions there to do so.
18
+ For a default karakuri powered toto template, check out [dorothy's sister karathy](https://github.com/5v3n/karathy).
21
19
 
22
20
  ## Usage
23
21
 
@@ -70,7 +68,7 @@ Next, you need a place to show the tag links, for example the index.rhtml:
70
68
 
71
69
 
72
70
 
73
- And again: piece of caked ;-). Now all we need to add is a page that displays articles belonging to a ceratin tag:
71
+ And again: piece of cake ;-). Now all we need to add is a page that displays articles belonging to a ceratin tag:
74
72
 
75
73
  Create a page called `tagged.rhtml` in your `templates/pages` directory that looks like this:
76
74
 
@@ -92,6 +90,14 @@ Create a page called `tagged.rhtml` in your `templates/pages` directory that loo
92
90
 
93
91
  Now, you did most likely implement a tag listing on your toto blog. Congrats!
94
92
 
93
+ ### Tag Cloud
94
+
95
+ Example usage:
96
+
97
+ <h1>Tags</h1>
98
+ <% Karakuri::tag_cloud(@articles).each do |tag, freq| %>
99
+ <%= %|<a href="/tagged?tag=#{tag}" alt="articles concerning #{tag}" style="font-size: #{10 * freq}px">#{tag}</a>| %>
100
+ <% end %>
95
101
 
96
102
  ### short url (via bit.ly)
97
103
 
@@ -119,4 +125,4 @@ Will result in the number of comments of the article the permalink posts to.
119
125
 
120
126
  ### serious custom yaml field reader
121
127
 
122
- 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.
128
+ 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.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'karakuri'
15
- s.version = '0.1.2'
15
+ s.version = '0.1.3'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README.md', 'LICENSE']
18
18
  s.summary = 'Some handy helpers for toto and the likes...'
@@ -103,5 +103,27 @@ module Karakuri
103
103
  end
104
104
  end
105
105
  end
106
-
107
- end
106
+
107
+ #
108
+ # Tag cloud, return a hash of tags and their frequency
109
+ #
110
+ def Karakuri.tag_cloud(articles)
111
+ tag_cloud = {}
112
+ if(articles)
113
+ articles.select do |article|
114
+ if tags = csv_to_array(article[:tags])
115
+ tags.each do |tag|
116
+ if tag_cloud.has_key? tag
117
+ tag_cloud[tag] += 1
118
+ else
119
+ tag_cloud[tag] = 1
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ tag_cloud
126
+ end
127
+
128
+ end
129
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: karakuri
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
4
+ hash: 29
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sven Kraeuter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-04 00:00:00 +01:00
18
+ date: 2012-03-24 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements: []
65
65
 
66
66
  rubyforge_project:
67
- rubygems_version: 1.3.7
67
+ rubygems_version: 1.6.2
68
68
  signing_key:
69
69
  specification_version: 3
70
70
  summary: Some handy helpers for toto and the likes...