public
Description: This contains various plugins for Feather
Clone URL: git://github.com/eldiablo/feather-plugins.git
Search Repo:
Click here to lend your support to: feather-plugins and make a donation at www.pledgie.com !
* changed after_save event for tagging so that it uses the model hooks 
provided
* added styling to tag cloud
* few fixes for tagging plugin
* updated manifest for tagging plugin
eldiablo (author)
Fri Apr 11 04:34:55 -0700 2008
commit  fab1720c02443565bc9fdba2a8f3f7ad1f265063
tree    7a5a18d9c740752765291a6a6b77612105a9bbb9
parent  c4485d05a2a61e8089eeeb25b393e8224615564d
...
6
7
8
9
10
11
...
6
7
8
 
9
10
0
@@ -6,5 +6,4 @@ class Tags < Application
0
     @tag = Tag.first(:name => id)
0
     display @tag
0
   end
0
-
0
 end
0
\ No newline at end of file
...
17
18
19
 
 
 
 
20
21
22
23
24
 
25
26
27
...
17
18
19
20
21
22
23
24
25
26
27
 
28
29
30
31
0
@@ -17,10 +17,14 @@ Merb::Router.prepend do |r|
0
   r.match('/tags/:id').to(:controller => 'tags', :action =>'show').name(:tag)
0
 end
0
 
0
+Hooks::Events.register_event(:after_save_article) do |args|
0
+ args.first.create_tags
0
+end
0
+
0
 Hooks::View.register_view do
0
   [
0
     { :name => "article_form_fields", :partial => "tag_field" },
0
     { :name => "meta_section", :partial => "tag_list" },
0
- { :name => "sidebar", :partial => "tag_could" }
0
+ { :name => "sidebar", :partial => "tag_cloud" }
0
   ]
0
 end
0
\ No newline at end of file
...
20
21
22
23
 
24
25
26
27
28
29
30
31
32
33
34
35
...
20
21
22
 
23
24
25
26
27
28
 
 
 
 
29
30
31
0
@@ -20,16 +20,12 @@ class Article
0
     @tag_list.split(",").each do |t|
0
       unless t.empty?
0
         # Hmm, can we do transactions with DM? I'm sure there's a way.
0
- tag = Tag.create(:name => t.strip)
0
+ tag = Tag.find_or_create(:name => t.strip)
0
         Tagging.create(:article_id => self.id, :tag_id => tag.id)
0
       end
0
     end
0
   end
0
   
0
- after_save do |article|
0
- article.create_tags
0
- end
0
-
0
   # This is probably slower than habtm, but that's not working as stated above.
0
   def tags
0
     taggings.map { |tagging| tagging.tag.name }.join(", ")
...
1
2
3
 
4
 
5
6
7
8
 
 
9
10
11
12
 
13
14
15
16
17
18
...
1
 
 
2
3
4
5
6
 
 
7
8
9
10
11
 
12
13
14
15
 
16
17
0
@@ -1,17 +1,16 @@
0
 module Merb
0
- module GlobalHelpers
0
-
0
+ module GlobalHelpers
0
     def tag_cloud(tags, classes)
0
+ return "" if tags.nil? || tags.length == 0
0
       max, min = 0, 0
0
       tags.each do |t|
0
- max = t.count.to_i if t.count.to_i > max
0
- min = t.count.to_i if t.count.to_i < min
0
+ max = t.taggings.count.to_i if t.taggings.count.to_i > max
0
+ min = t.taggings.count.to_i if t.taggings.count.to_i < min
0
       end
0
       divisor = ((max - min) / classes.size) + 1
0
       tags.each do |t|
0
- yield t.name, classes[(t.count.to_i - min) / divisor]
0
+ yield t.name, classes[(t.taggings.count.to_i - min) / divisor]
0
       end
0
     end
0
   end
0
-
0
 end
0
\ No newline at end of file
...
10
11
12
 
 
 
 
13
14
15
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
...
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -10,7 +10,25 @@ plugin:
0
         controllers:
0
             .:
0
                 - tags.rb
0
+ lib:
0
+ .:
0
+ - article.rb
0
+ - global_helpers.rb
0
         models:
0
             .:
0
                 - tag.rb
0
                 - tagging.rb
0
+ views:
0
+ .:
0
+ article_form_fields:
0
+ .:
0
+ - _tag_field.html.erb
0
+ meta_section:
0
+ .:
0
+ - _tag_list.html.erb
0
+ sidebar:
0
+ .:
0
+ - _tag_cloud.html.erb
0
+ tags:
0
+ .:
0
+ - show.html.erb
0
\ No newline at end of file
...
9
10
11
12
13
 
14
15
...
9
10
11
 
 
12
13
14
0
@@ -9,6 +9,5 @@ class Tag < DataMapper::Base
0
   
0
   def to_param
0
     name
0
- end
0
-
0
+ end
0
 end
0
\ No newline at end of file
...
1
 
 
 
 
 
 
 
 
 
2
3
4
 
 
5
...
 
1
2
3
4
5
6
7
8
9
10
 
 
11
12
13
0
@@ -1,4 +1,12 @@
0
-<!-- We need a way to get these classes in the style sheet. -->
0
+<style>
0
+ .tag1 { font-size: 12px; }
0
+ .tag2 { font-size: 14px; }
0
+ .tag3 { font-size: 16px; }
0
+ .tag4 { font-size: 18px; }
0
+ .tag5 { font-size: 20px; }
0
+</style>
0
+
0
+<% @tags = Tag.all %>
0
 <% tag_cloud @tags, %w(tag1 tag2 tag3 tag4 tag5) do |name, css_class| %>
0
- <%= link_to(name, tag_path(name), :class => css_class) %>
0
-<% end %>
0
+ <%= link_to(name, url(:tag, :id => name), :class => css_class) %>
0
+<% end %>
0
\ No newline at end of file

Comments

    No one has commented yet.