refinerycms-pdf_newsletters 1.2 → 1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  class PdfNewslettersController < ApplicationController
2
2
 
3
+ helper :pdf_newsletters
3
4
  before_filter :find_all_newsletters
4
5
  before_filter :find_page
5
6
 
@@ -0,0 +1,19 @@
1
+ module PdfNewslettersHelper
2
+ def newsletter_description(newsletter)
3
+ "Volume #{newsletter.volume} Issue #{newsletter.issue} - #{newsletter.month} #{newsletter.year}"
4
+ end
5
+
6
+ def each_year(newsletters)
7
+ newsletters_list = newsletters
8
+ newsletter = newsletters_list.shift
9
+ while newsletter.present?
10
+ year_list = []
11
+ @year = newsletter.year
12
+ while newsletter && newsletter.year == @year
13
+ year_list << newsletter
14
+ newsletter = newsletters_list.shift
15
+ end
16
+ yield year_list
17
+ end
18
+ end
19
+ end
@@ -1,17 +1,11 @@
1
- <% newsletters_list = newsletters%>
2
- <% newsletter = newsletters_list.shift %>
3
- <% while newsletter.present? %>
4
- <h1 class="title"><%=newsletter.year-%></h1>
5
- <% unless newsletter.editor.blank? %>
6
- <p>(By Editor <%=newsletter.editor%>)</p>
1
+ <% each_year(newsletters) do |year_list| %>
2
+ <h2><%=year_list.first.year-%> Newsletters</h2>
3
+ <% unless year_list.first.editor.blank? %>
4
+ <p>(By Editor <%=year_list.first.editor%>)</p>
7
5
  <% end %>
8
- <% @year = newsletter.year %>
9
- <ul id="newsletters">
10
- <%while newsletter && newsletter.year == @year%>
11
- <li>
12
- <%= render :partial => 'newsletter', :object => newsletter %>
13
- </li>
14
- <% newsletter = newsletters_list.shift %>
6
+ <ul>
7
+ <% year_list.each do |newsletter| %>
8
+ <li><%= render :partial => 'newsletter', :object => newsletter %></li>
15
9
  <% end %>
16
10
  </ul>
17
11
  <% end %>
@@ -1,2 +1 @@
1
- <%= link_to "Volume #{newsletter.volume}, Issue #{newsletter.issue} - #{newsletter.month} #{newsletter.year}",
2
- newsletter.pdf.url %>
1
+ <%= link_to newsletter_description(newsletter), newsletter.pdf.url %>
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: refinerycms-pdf_newsletters
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "1.2"
5
+ version: "1.3"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Doug Bradbury <doug@8thlight.com>
@@ -33,6 +33,7 @@ files:
33
33
  - config/routes.rb
34
34
  - app/controllers/admin/pdf_newsletters_controller.rb
35
35
  - app/controllers/pdf_newsletters_controller.rb
36
+ - app/helpers/pdf_newsletters_helper.rb
36
37
  - app/models/pdf_newsletter.rb
37
38
  - app/views/admin/pdf_newsletters/_actions.html.erb
38
39
  - app/views/admin/pdf_newsletters/_form.html.erb