refinerycms-pdf_newsletters 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/newsletters_controller.rb +8 -0
- data/app/controllers/newsletters_controller.rb +30 -0
- data/app/models/newsletter.rb +27 -0
- data/app/views/admin/newsletters/_actions.html.erb +28 -0
- data/app/views/admin/newsletters/_form.html.erb +43 -0
- data/app/views/admin/newsletters/_newsletter.html.erb +18 -0
- data/app/views/admin/newsletters/_newsletters.html.erb +2 -0
- data/app/views/admin/newsletters/_records.html.erb +18 -0
- data/app/views/admin/newsletters/_sortable_list.html.erb +7 -0
- data/app/views/admin/newsletters/edit.html.erb +1 -0
- data/app/views/admin/newsletters/index.html.erb +10 -0
- data/app/views/admin/newsletters/new.html.erb +1 -0
- data/app/views/newsletters/_list_by_year.html.erb +17 -0
- data/app/views/newsletters/_newsletter.html.erb +2 -0
- data/app/views/newsletters/index.html.erb +5 -0
- data/config/locales/en.yml +25 -0
- data/config/locales/fr.yml +25 -0
- data/config/locales/lolcat.yml +25 -0
- data/config/locales/nb.yml +21 -0
- data/config/locales/nl.yml +21 -0
- data/config/routes.rb +11 -0
- data/lib/generators/refinerycms_pdf_newsletters_generator.rb +6 -0
- data/lib/refinerycms-pdf_newsletters.rb +30 -0
- data/lib/tasks/pdf_newsletters.rake +13 -0
- metadata +77 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
class NewslettersController < ApplicationController
|
2
|
+
|
3
|
+
before_filter :find_all_newsletters
|
4
|
+
before_filter :find_page
|
5
|
+
|
6
|
+
def index
|
7
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
8
|
+
# by swapping @page for @newsletter in the line below:
|
9
|
+
present(@page)
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
@newsletter = Newsletter.find(params[:id])
|
14
|
+
|
15
|
+
# you can use meta fields from your model instead (e.g. browser_title)
|
16
|
+
# by swapping @page for @newsletter in the line below:
|
17
|
+
present(@page)
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def find_all_newsletters
|
23
|
+
@newsletters = Newsletter.recent
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_page
|
27
|
+
@page = Page.where(:link_url => "/newsletters").first
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Newsletter < ActiveRecord::Base
|
2
|
+
|
3
|
+
acts_as_indexed :fields => [:volume, :issue]
|
4
|
+
|
5
|
+
validates :volume, :presence => true
|
6
|
+
validates :issue, :presence => true
|
7
|
+
validates :pdf, :presence => true
|
8
|
+
|
9
|
+
belongs_to :pdf, :class_name => 'Resource'
|
10
|
+
|
11
|
+
def month
|
12
|
+
self.publish_on.strftime("%B")
|
13
|
+
end
|
14
|
+
|
15
|
+
def year
|
16
|
+
self.publish_on.year
|
17
|
+
end
|
18
|
+
scope :published, lambda {
|
19
|
+
where("newsletters.publish_on IS NOT NULL AND newsletters.publish_on <= ?", Time.zone.now)
|
20
|
+
}
|
21
|
+
|
22
|
+
scope :recent, published.order("newsletters.publish_on DESC")
|
23
|
+
|
24
|
+
def self.current
|
25
|
+
self.recent.first
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<ul>
|
2
|
+
<% if Admin::NewslettersController.searchable? %>
|
3
|
+
<li>
|
4
|
+
<%= render :partial => "/shared/admin/search",
|
5
|
+
:locals => {
|
6
|
+
:url => admin_newsletters_path
|
7
|
+
} %>
|
8
|
+
</li>
|
9
|
+
<% end %>
|
10
|
+
<li>
|
11
|
+
<%= link_to t('.create_new'), new_admin_newsletter_path,
|
12
|
+
:class => "add_icon" %>
|
13
|
+
</li>
|
14
|
+
<% if !searching? and Admin::NewslettersController.sortable? and Newsletter.count > 1 %>
|
15
|
+
<li>
|
16
|
+
<%= link_to t('.reorder', :what => "Newsletters"),
|
17
|
+
admin_newsletters_path,
|
18
|
+
:id => "reorder_action",
|
19
|
+
:class => "reorder_icon" %>
|
20
|
+
|
21
|
+
<%= link_to t('.reorder_done', :what => "Newsletters"),
|
22
|
+
admin_newsletters_path,
|
23
|
+
:id => "reorder_action_done",
|
24
|
+
:style => "display: none;",
|
25
|
+
:class => "reorder_icon" %>
|
26
|
+
</li>
|
27
|
+
<% end %>
|
28
|
+
</ul>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<%= form_for [:admin, @newsletter] do |f| -%>
|
2
|
+
<%= render :partial => "/shared/admin/error_messages", :locals => {
|
3
|
+
:object => @newsletter,
|
4
|
+
:include_object_name => true
|
5
|
+
} %>
|
6
|
+
|
7
|
+
<div class='field'>
|
8
|
+
<%= f.label :publish_on -%>
|
9
|
+
<%= f.date_select :publish_on -%>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<div class='field'>
|
13
|
+
<%= f.label :pdf -%>
|
14
|
+
<%= render :partial => "/shared/admin/resource_picker", :locals => {
|
15
|
+
:f => f,
|
16
|
+
:field => :pdf_id,
|
17
|
+
:resource => @newsletter.pdf,
|
18
|
+
} %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class='field'>
|
22
|
+
<%= f.label :volume -%>
|
23
|
+
<%= f.text_field :volume -%>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class='field'>
|
27
|
+
<%= f.label :issue -%>
|
28
|
+
<%= f.text_field :issue -%>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div class='field'>
|
32
|
+
<%= f.label :editor -%>
|
33
|
+
<%= f.text_field :editor -%>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<%= render :partial => "/shared/admin/form_actions",
|
37
|
+
:locals => {
|
38
|
+
:f => f,
|
39
|
+
:continue_editing => false,
|
40
|
+
:delete_title => t('delete', :scope => 'admin.newsletters.newsletter'),
|
41
|
+
:delete_confirmation => t('message', :scope => 'shared.admin.delete', :title => @newsletter.volume)
|
42
|
+
} %>
|
43
|
+
<% end -%>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(newsletter) -%>">
|
2
|
+
<span class='title'>
|
3
|
+
<%= "Volume #{newsletter.volume}, Issue #{newsletter.issue} - #{newsletter.month} #{newsletter.year}" %>
|
4
|
+
<span class="preview"> </span>
|
5
|
+
</span>
|
6
|
+
<span class='actions'>
|
7
|
+
<%= link_to refinery_icon_tag("application_go.png"), newsletter_path(newsletter),
|
8
|
+
:title => t('.view_live_html'),
|
9
|
+
:target => "_blank" %>
|
10
|
+
<%= link_to refinery_icon_tag("application_edit.png"), edit_admin_newsletter_path(newsletter),
|
11
|
+
:title => t('.edit') %>
|
12
|
+
<%= link_to refinery_icon_tag("delete.png"), admin_newsletter_path(newsletter),
|
13
|
+
:class => "cancel confirm-delete",
|
14
|
+
:title => t('.delete'),
|
15
|
+
:confirm => t('message', :scope => 'shared.admin.delete', :title => newsletter.volume),
|
16
|
+
:method => :delete %>
|
17
|
+
</span>
|
18
|
+
</li>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if searching? %>
|
2
|
+
<h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
|
3
|
+
<% end %>
|
4
|
+
<% if @newsletters.any? %>
|
5
|
+
<div class='pagination_container'>
|
6
|
+
<%= render :partial => 'newsletters' %>
|
7
|
+
</div>
|
8
|
+
<% else %>
|
9
|
+
<p>
|
10
|
+
<% unless searching? %>
|
11
|
+
<strong>
|
12
|
+
<%= t('.no_items_yet') %>
|
13
|
+
</strong>
|
14
|
+
<% else %>
|
15
|
+
<%= t('no_results', :scope => 'shared.admin.search') %>
|
16
|
+
<% end %>
|
17
|
+
</p>
|
18
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<ul id='sortable_list'>
|
2
|
+
<%= render :partial => 'newsletter', :collection => @newsletters %>
|
3
|
+
</ul>
|
4
|
+
<%= render :partial => "/shared/admin/sortable_list",
|
5
|
+
:locals => {
|
6
|
+
:continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true
|
7
|
+
} %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<section id='records'>
|
2
|
+
<%= render :partial => 'records' %>
|
3
|
+
</section>
|
4
|
+
<aside id='actions'>
|
5
|
+
<%= render :partial => 'actions' %>
|
6
|
+
</aside>
|
7
|
+
<%= render :partial => '/shared/admin/make_sortable',
|
8
|
+
:locals => {
|
9
|
+
:tree => false
|
10
|
+
} if !searching? and Admin::NewslettersController.sortable? and Newsletter.count > 1 %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => "form" %>
|
@@ -0,0 +1,17 @@
|
|
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>
|
7
|
+
<% 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 %>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
en:
|
2
|
+
shared:
|
3
|
+
admin:
|
4
|
+
image_picker:
|
5
|
+
image: image
|
6
|
+
plugins:
|
7
|
+
newsletters:
|
8
|
+
title: Newsletters
|
9
|
+
admin:
|
10
|
+
newsletters:
|
11
|
+
actions:
|
12
|
+
create_new: Add New Newsletter
|
13
|
+
reorder: Reorder Newsletters
|
14
|
+
reorder_done: Done Reordering Newsletters
|
15
|
+
records:
|
16
|
+
title: Newsletters
|
17
|
+
sorry_no_results: Sorry! There are no results found.
|
18
|
+
no_items_yet: There are no Newsletters yet. Click "Add New Newsletter" to add your first newsletter.
|
19
|
+
newsletter:
|
20
|
+
view_live_html: View this newsletter live <br/><em>(opens in a new window)</em>
|
21
|
+
edit: Edit this newsletter
|
22
|
+
delete: Remove this newsletter forever
|
23
|
+
newsletters:
|
24
|
+
show:
|
25
|
+
other: Other Newsletters
|
@@ -0,0 +1,25 @@
|
|
1
|
+
fr:
|
2
|
+
shared:
|
3
|
+
admin:
|
4
|
+
image_picker:
|
5
|
+
image: image
|
6
|
+
plugins:
|
7
|
+
newsletters:
|
8
|
+
title: Newsletters
|
9
|
+
admin:
|
10
|
+
newsletters:
|
11
|
+
actions:
|
12
|
+
create_new: Créer un(e) nouve(au/l/lle) Newsletter
|
13
|
+
reorder: Réordonner les Newsletters
|
14
|
+
reorder_done: Fin de réordonnancement des Newsletters
|
15
|
+
records:
|
16
|
+
title: Newsletters
|
17
|
+
sorry_no_results: "Désolé ! Aucun résultat."
|
18
|
+
no_items_yet: 'Il n''y a actuellement aucun(e) Newsletter. Cliquer sur "Créer un(e) nouve(au/l/lle) Newsletter" pour créer votre premi(er/ère) newsletter.'
|
19
|
+
newsletter:
|
20
|
+
view_live_html: Voir ce(t/tte) newsletter <br/><em>(Ouvre une nouvelle fenêtre)</em>
|
21
|
+
edit: Modifier ce(t/tte) newsletter
|
22
|
+
delete: Supprimer définitivement ce(t/tte) newsletter
|
23
|
+
newsletters:
|
24
|
+
show:
|
25
|
+
other: Autres Newsletters
|
@@ -0,0 +1,25 @@
|
|
1
|
+
lolcat:
|
2
|
+
shared:
|
3
|
+
admin:
|
4
|
+
image_picker:
|
5
|
+
image: IMAGE
|
6
|
+
plugins:
|
7
|
+
newsletters:
|
8
|
+
title: Newsletters
|
9
|
+
admin:
|
10
|
+
newsletters:
|
11
|
+
actions:
|
12
|
+
create_new: CREATE NEW Newsletter
|
13
|
+
reorder: REORDR Newsletters
|
14
|
+
reorder_done: DUN REORDERIN Newsletters
|
15
|
+
records:
|
16
|
+
title: Newsletters
|
17
|
+
sorry_no_results: SRY! THAR R NO RESULTS FINDZ.
|
18
|
+
no_items_yet: THAR R NO Newsletters YET. CLICK "CREATE NEW Newsletter" 2 ADD UR FURST newsletter.
|
19
|
+
newsletter:
|
20
|
+
view_live_html: VIEW DIS newsletter LIV <BR/><EM>(OPENS IN NEW WINDOW)</EM>
|
21
|
+
edit: EDIT DIS newsletter
|
22
|
+
delete: REMOOV DIS newsletter FOREVR
|
23
|
+
newsletters:
|
24
|
+
show:
|
25
|
+
other: OTHR Newsletters
|
@@ -0,0 +1,21 @@
|
|
1
|
+
nb:
|
2
|
+
plugins:
|
3
|
+
newsletters:
|
4
|
+
title: Newsletters
|
5
|
+
admin:
|
6
|
+
newsletters:
|
7
|
+
actions:
|
8
|
+
create_new: Lag en ny Newsletter
|
9
|
+
reorder: Endre rekkefølgen på Newsletters
|
10
|
+
reorder_done: Ferdig å endre rekkefølgen Newsletters
|
11
|
+
records:
|
12
|
+
title: Newsletters
|
13
|
+
sorry_no_results: Beklager! Vi fant ikke noen resultater.
|
14
|
+
no_items_yet: Det er ingen Newsletters enda. Klikk på "Lag en ny Newsletter" for å legge til din første newsletter.
|
15
|
+
newsletter:
|
16
|
+
view_live_html: Vis hvordan denne newsletter ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
|
17
|
+
edit: Rediger denne newsletter
|
18
|
+
delete: Fjern denne newsletter permanent
|
19
|
+
newsletters:
|
20
|
+
show:
|
21
|
+
other: Andre Newsletters
|
@@ -0,0 +1,21 @@
|
|
1
|
+
nl:
|
2
|
+
plugins:
|
3
|
+
newsletters:
|
4
|
+
title: Newsletters
|
5
|
+
admin:
|
6
|
+
newsletters:
|
7
|
+
actions:
|
8
|
+
create_new: Maak een nieuwe Newsletter
|
9
|
+
reorder: Wijzig de volgorde van de Newsletters
|
10
|
+
reorder_done: Klaar met het wijzingen van de volgorde van de Newsletters
|
11
|
+
records:
|
12
|
+
title: Newsletters
|
13
|
+
sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
|
14
|
+
no_items_yet: Er zijn nog geen Newsletters. Druk op 'Maak een nieuwe Newsletter' om de eerste aan te maken.
|
15
|
+
newsletter:
|
16
|
+
view_live_html: Bekijk deze newsletter op de website <br/><em>(opent een nieuw venster)</em>
|
17
|
+
edit: Bewerk deze newsletter
|
18
|
+
delete: Verwijder deze newsletter voor eeuwig
|
19
|
+
newsletters:
|
20
|
+
show:
|
21
|
+
other: Andere Newsletters
|
data/config/routes.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
::Refinery::Application.routes.draw do
|
2
|
+
resources :newsletters, :only => [:index, :show]
|
3
|
+
|
4
|
+
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
|
5
|
+
resources :newsletters, :except => :show do
|
6
|
+
collection do
|
7
|
+
post :update_positions
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'refinerycms-base'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Newsletters
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :root
|
8
|
+
def root
|
9
|
+
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Engine < Rails::Engine
|
14
|
+
initializer "static assets" do |app|
|
15
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do
|
19
|
+
Refinery::Plugin.register do |plugin|
|
20
|
+
plugin.name = "pdf_newsletters"
|
21
|
+
plugin.pathname = root
|
22
|
+
plugin.activity = {
|
23
|
+
:class => Newsletter,
|
24
|
+
:title => 'volume'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: refinerycms-pdf_newsletters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: "0.8"
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Doug Bradbury <doug@8thlight.com>
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-08-16 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Ruby on Rails Pdf Newsletters engine for Refinery CMS
|
17
|
+
email:
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/generators/refinerycms_pdf_newsletters_generator.rb
|
26
|
+
- lib/refinerycms-pdf_newsletters.rb
|
27
|
+
- lib/tasks/pdf_newsletters.rake
|
28
|
+
- config/locales/en.yml
|
29
|
+
- config/locales/fr.yml
|
30
|
+
- config/locales/lolcat.yml
|
31
|
+
- config/locales/nb.yml
|
32
|
+
- config/locales/nl.yml
|
33
|
+
- config/routes.rb
|
34
|
+
- app/controllers/admin/newsletters_controller.rb
|
35
|
+
- app/controllers/newsletters_controller.rb
|
36
|
+
- app/models/newsletter.rb
|
37
|
+
- app/views/admin/newsletters/_actions.html.erb
|
38
|
+
- app/views/admin/newsletters/_form.html.erb
|
39
|
+
- app/views/admin/newsletters/_newsletter.html.erb
|
40
|
+
- app/views/admin/newsletters/_newsletters.html.erb
|
41
|
+
- app/views/admin/newsletters/_records.html.erb
|
42
|
+
- app/views/admin/newsletters/_sortable_list.html.erb
|
43
|
+
- app/views/admin/newsletters/edit.html.erb
|
44
|
+
- app/views/admin/newsletters/index.html.erb
|
45
|
+
- app/views/admin/newsletters/new.html.erb
|
46
|
+
- app/views/newsletters/_list_by_year.html.erb
|
47
|
+
- app/views/newsletters/_newsletter.html.erb
|
48
|
+
- app/views/newsletters/index.html.erb
|
49
|
+
homepage: https://github.com/dougbradbury/refinerycms-newsletters
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.8.8
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Pdf Newsletters engine for Refinery CMS
|
76
|
+
test_files: []
|
77
|
+
|