beef-articles 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/app/helpers/articles_helper.rb +18 -17
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.4.3
@@ -1,19 +1,19 @@
1
1
  module ArticlesHelper
2
-
2
+
3
3
  def article_categories
4
4
  tabs = Category.with( :articles ).collect do |category|
5
5
  content_tag :li, link_to( h(category.title), category_articles_path(category.permalink) )
6
6
  end
7
7
  content_tag( :h2, 'Categories' ) + content_tag( :ul, tabs.join, :class => "categories" ) if tabs.any?
8
8
  end
9
-
9
+
10
10
  def article_authors
11
11
  tabs = Article.published.all(:select => 'users.name, users.permalink', :group => 'created_by_id', :joins => :created_by ).collect do |user|
12
12
  content_tag :li, link_to( user.name, articles_authored_path(user.permalink) )
13
13
  end
14
14
  content_tag( :h2, 'Authors' ) + content_tag( :ul, tabs.join, :class => "authors" ) if tabs.any?
15
15
  end
16
-
16
+
17
17
  def comments_link(article)
18
18
  if(article.comments.count!=0)
19
19
  "|  #{link_to('Comment'.pluralize, [article, {:anchor => 'comments'}])} (#{article.comments.count.to_s})"
@@ -29,31 +29,31 @@ module ArticlesHelper
29
29
  def delicious_link(options, html_options = {})
30
30
  link_to 'delicious', "http://del.icio.us/post?url=#{server_url_for(options)}", html_options.reverse_merge(:class => 'share-link', :id => 'delicious-submit', :title => 'Save to delicious')
31
31
  end
32
-
32
+
33
33
  def facebook_link(options, html_options = {})
34
34
  link_to 'Facebook', "http://www.facebook.com/sharer.php?u=#{server_url_for(options)}", html_options.reverse_merge(:class => 'share-link', :id => 'facebook-submit', :title => 'Share on Facebook')
35
35
  end
36
-
36
+
37
37
  def stumble_link(options, html_options = {})
38
38
  link_to 'Stumble Upon', "http://www.stumbleupon.com/submit?url=#{server_url_for(options)}", html_options.reverse_merge(:class => 'share-link', :id => 'stumble-submit', :title => 'Stumble on this')
39
39
  end
40
-
40
+
41
41
  def mail_link(options, html_options = {})
42
42
  mail_to nil, "Email", html_options.reverse_merge( :body => server_url_for(options), :class => 'share-link', :id => 'mail-link', :title => 'Email this to a friend')
43
43
  end
44
-
44
+
45
45
  def twitter_link(options, html_options = {})
46
46
  link_to 'Twitter', "http://twitter.com/home?status=#{server_url_for(options)}}", html_options.reverse_merge(:class => 'share-link', :id => 'twitter-submit', :title => 'Tweet this')
47
47
  end
48
-
48
+
49
49
  def reddit_link(options, html_options = {})
50
50
  link_to 'Reddit', "http://www.reddit.com/submit?url=#{server_url_for(options)}", html_options.reverse_merge(:class => 'share-link', :id => 'reddit-submit', :title => 'Reddit this!')
51
51
  end
52
-
52
+
53
53
  def technorati_link(options, html_options = {})
54
54
  link_to 'Technorati', "http://technorati.com/faves/?add=#{server_url_for(options)}", html_options.reverse_merge(:class => 'share-link', :id => 'technorati-submit', :title => 'Technorati this!')
55
55
  end
56
-
56
+
57
57
  def server_url_for(options = {})
58
58
  options ||= {}
59
59
  url = case options
@@ -68,17 +68,18 @@ module ArticlesHelper
68
68
 
69
69
  escape ? escape_once(url) : url
70
70
  end
71
-
71
+
72
72
  def archive(conditions = nil, html_options = {})
73
73
  this_year = params[:year] || Time.now.year
74
74
  html = ''
75
75
  all_articles = Article.published.all(:conditions => conditions, :select => 'published_at')
76
76
  grouped_by_year = all_articles.group_by{ |a| a.published_at.year }.sort.reverse
77
77
  grouped_by_year.each do |year, articles|
78
- html << '<li>'
78
+ current = this_year.to_i == year
79
+ html << "<li#{' class="current"' if current}>"
79
80
  html << link_to("#{year}", {:controller => 'articles', :action => 'index', :year => year, :month => nil, :day => nil})
80
81
  html << (" (#{articles.size})")
81
- if this_year.to_i == year
82
+ if current
82
83
  grouped_by_month = articles.group_by{ |a| a.published_at.month }.sort.reverse
83
84
  html << '<ul>'
84
85
  grouped_by_month.each do |month, articles|
@@ -93,7 +94,7 @@ module ArticlesHelper
93
94
  end
94
95
  content_tag :ul, html, html_options.reverse_merge!( :class => 'archive' ) unless html.empty?
95
96
  end
96
-
97
+
97
98
  def related_articles(taggable, &block)
98
99
  articles = Article.published.all(taggable.related_search_options(:tags, Article, :limit => 3))
99
100
  return if articles.empty?
@@ -103,7 +104,7 @@ module ArticlesHelper
103
104
  content_tag(:div, content_tag( :h2, 'Related' ) + articles_list(articles), :class => "related")
104
105
  end
105
106
  end
106
-
107
+
107
108
  def recent_articles(options = {}, &block)
108
109
  options.reverse_merge!(:limit => 3)
109
110
  articles = Article.published.all(options)
@@ -113,11 +114,11 @@ module ArticlesHelper
113
114
  articles_list(articles)
114
115
  end
115
116
  end
116
-
117
+
117
118
  def articles_list(articles)
118
119
  return if articles.empty?
119
120
  articles.collect! { |article| content_tag( 'li', "#{link_to(article.title, article)} #{article.published_at.to_formatted_s(:short_dot)}") }
120
121
  content_tag( 'ul', articles.join, :class => 'article-list' )
121
122
  end
122
-
123
+
123
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beef-articles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve England
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-22 00:00:00 +00:00
12
+ date: 2010-01-19 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency