refinerycms-testimonials 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ class Admin::TestimonialsController < Admin::BaseController
2
+
3
+ crudify :testimonial, :title_attribute => :flash_name
4
+
5
+ end
@@ -0,0 +1,16 @@
1
+ class TestimonialsController < ApplicationController
2
+
3
+ before_filter :find_page
4
+
5
+ def index
6
+ @testimonials = Testimonial.paginate(:all, :order => "position ASC", :page => params[:page], :per_page => RefinerySetting.find_or_set(:testimonials_per_page, 10))
7
+ present(@page)
8
+ end
9
+
10
+ protected
11
+
12
+ def find_page
13
+ @page = Page.find_by_link_url("/testimonials")
14
+ end
15
+
16
+ end
@@ -0,0 +1,37 @@
1
+ module TestimonialsHelper
2
+
3
+ # Helper method to be included in the page layout
4
+ def display_page_testimonial_if_setup
5
+ if @page.show_a_testimonial? && (random_testimonial = Testimonial.random)
6
+ content_for :head, stylesheet_link_tag('testimonials')
7
+ render :partial => '/testimonials/testimonial', :locals => {:testimonial => random_testimonial}
8
+ end
9
+ end
10
+
11
+ # Based on the fields filled in by the user display the
12
+ # citation in our desired format:
13
+ #
14
+ # Name: JobTitle, Company/Website (Company is a link to website if possible)
15
+ def citation_line(t)
16
+ [
17
+ content_tag(:b, h(t.name)),
18
+ h(t.job_title),
19
+ website_or_company(t)
20
+ ].reject(&:blank?).join(", ").sub(/,\s/, ": ")
21
+ end
22
+
23
+ # Method to setup the end of the citation line
24
+ # Returns:
25
+ #
26
+ # The company name as a link is both are set
27
+ # The company name with a link
28
+ # Or
29
+ # Just a link if the name isn't set
30
+ def website_or_company(t)
31
+ if t.website.blank?
32
+ h(t.company)
33
+ else
34
+ content_tag(:a, h(t.company.blank? ? t.website : t.company), :href => h(t.website))
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,16 @@
1
+ class Testimonial < ActiveRecord::Base
2
+
3
+ acts_as_indexed :fields => [:quote, :name, :company, :job_title, :website],
4
+ :index_file => [Rails.root.to_s,"tmp","index"]
5
+
6
+ validates_presence_of :quote
7
+ validates_presence_of :name
8
+
9
+ def flash_name
10
+ "Quote by #{self.name}"
11
+ end
12
+
13
+ def self.random
14
+ self.find :first, :offset => ( Testimonial.count * rand ).to_i
15
+ end
16
+ end
@@ -0,0 +1,35 @@
1
+ <%= error_messages_for :testimonial -%>
2
+ <% form_for [:admin, @testimonial] do |f| -%>
3
+
4
+ <div class='field'>
5
+ <%= f.label :quote, "Quote <em>*</em>" -%>
6
+ <%= f.text_area :quote, :rows => 5, :cols => 140 -%>
7
+ </div>
8
+
9
+ <div class='field'>
10
+ <%= f.label :name, "Name <em>*</em>" -%>
11
+ <%= f.text_field :name -%>
12
+ </div>
13
+
14
+ <div class='field'>
15
+ <%= f.label :company -%>
16
+ <%= f.text_field :company -%>
17
+ </div>
18
+
19
+ <div class='field'>
20
+ <%= f.label :job_title -%>
21
+ <%= f.text_field :job_title -%>
22
+ </div>
23
+
24
+ <div class='field'>
25
+ <%= f.label :website -%>
26
+ <%= f.text_field :website -%>
27
+ </div>
28
+
29
+ <div class='field'>
30
+ <%= f.label :quoted_on -%>
31
+ <%= f.date_select :quoted_on, :order => [:day, :month, :year] -%>
32
+ </div>
33
+
34
+ <%= render :partial => "/shared/admin/form_actions", :locals => {:f => f, :continue_editing => false} %>
35
+ <% end -%>
@@ -0,0 +1,2 @@
1
+ <%= render :partial => 'testimonial', :collection => @testimonials %>
2
+ <%= render :partial => "/shared/admin/sortable_list" %>
@@ -0,0 +1,20 @@
1
+ <li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(testimonial) -%>">
2
+ <span class='title'>
3
+ <span class='actions'>
4
+ <%= link_to refinery_icon_tag("eye.png"), '#',
5
+ :title => 'Toggle the display of this quote',
6
+ :style => 'display:none;',
7
+ :class => 'toggle_quote' %>
8
+ <%= link_to refinery_icon_tag("application_edit.png"), edit_admin_testimonial_path(testimonial),
9
+ :title => 'Edit this testimonial' %>
10
+ <%= link_to refinery_icon_tag("delete.png"), admin_testimonial_path(testimonial),
11
+ :confirm => 'Are you sure you want to remove this testimonial forever?',
12
+ :class => "cancel", :method => :delete,
13
+ :title => 'Remove this testimonial forever' %>
14
+ </span>
15
+
16
+ <%= [content_tag(:b, h(testimonial.name)), h(testimonial.job_title), h(testimonial.company)].reject(&:blank?).join(", ") %>
17
+ <span class="preview">&nbsp;</span>
18
+ <p style="display:none;"><%= h(testimonial.quote) %></p>
19
+ </span>
20
+ </li>
@@ -0,0 +1,2 @@
1
+ <%= will_paginate @testimonials %>
2
+ <%= render :partial => "sortable_list" %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,54 @@
1
+ <% content_for :head do %>
2
+ <script type="text/javascript">
3
+ $(document).ready(function(){
4
+ $('.toggle_quote').show().click(function(){
5
+ $(this).parent().parent().find('p:last').toggle();
6
+ return false;
7
+ });
8
+ });
9
+ </script>
10
+ <% end %>
11
+
12
+ <div id='actions'>
13
+ <ul>
14
+ <li>
15
+ <%= render :partial => "/shared/admin/search", :locals => {:url => admin_testimonials_url} %>
16
+ </li>
17
+ <li>
18
+ <%= link_to "Create New Testimonial", new_admin_testimonial_url, :class => "add_icon" %>
19
+ </li>
20
+ <% if !searching? and Testimonial.count > 1 %>
21
+ <li>
22
+ <%= link_to "Reorder Testimonials", admin_testimonials_url, :id => "reorder_action", :class => "reorder_icon" %>
23
+ <%= link_to "Done Reordering Testimonials", admin_testimonials_url, :id => "reorder_action_done", :style => "display: none;", :class => "reorder_icon" %>
24
+ </li>
25
+ <% end %>
26
+ </ul>
27
+ </div>
28
+
29
+ <div id='records'>
30
+ <% if searching? %>
31
+ <h2>Search Results for "<%= params[:search] %>"</h2>
32
+ <% if @testimonials.size > 0 %>
33
+ <%= render :partial => "testimonial", :collection => @testimonials %>
34
+ <% else %>
35
+ <p>Sorry, no results found.</p>
36
+ <% end %>
37
+ <% else %>
38
+ <% if @testimonials.size > 0 %>
39
+ <%= will_paginate @testimonials, :previous_label => '&laquo;', :next_label => '&raquo;' %>
40
+ <ul id='sortable_list'>
41
+ <%= render :partial => "sortable_list" %>
42
+ </ul>
43
+ <%= will_paginate @testimonials, :previous_label => '&laquo;', :next_label => '&raquo;' %>
44
+ <% else %>
45
+ <p>
46
+ <strong>
47
+ There are no testimonials yet.
48
+ Click "Create New Testimonial" to add your first testimonial.
49
+ </strong>
50
+ </p>
51
+ <% end %>
52
+ <% end %>
53
+ </div>
54
+ <%= render :partial => "/shared/admin/make_sortable", :locals => {:tree => false } if !searching? and Testimonial.count > 1 %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,6 @@
1
+ <div class="testimonial">
2
+ <blockquote>
3
+ <p><%= testimonial.quote %></p>
4
+ <p><cite><%= citation_line(testimonial) %></cite></p>
5
+ </blockquote>
6
+ </div>
@@ -0,0 +1,19 @@
1
+ <% content_for :head, stylesheet_link_tag('testimonials') %>
2
+
3
+ <% content_for :body_content_left do %>
4
+ <%= @page[:body] %>
5
+
6
+ <%= will_paginate @testimonials %>
7
+
8
+ <div class="testimonials">
9
+ <%= render :partial => 'testimonial', :collection => @testimonials %>
10
+ </div>
11
+
12
+ <%= will_paginate @testimonials %>
13
+ <% end %>
14
+
15
+ <% content_for :body_content_right do %>
16
+ <%= @page[:side_body] %>
17
+ <% end %>
18
+
19
+ <%= render :partial => "/shared/content_page" %>
@@ -0,0 +1,27 @@
1
+ <% content_for :body_content_title do %>
2
+ <%= @testimonial.title %>
3
+ <% end %>
4
+
5
+ <% content_for :body_content_left do %>
6
+ <section>
7
+ <h1>Date</h1>
8
+ <p>
9
+ <%=raw @testimonial.date %>
10
+ </p>
11
+ </section>
12
+ <% end %>
13
+
14
+ <% content_for :body_content_right do %>
15
+ <aside>
16
+ <h2><%= t('.other') %></h2>
17
+ <ul id="testimonials">
18
+ <% @testimonials.each do |testimonial| %>
19
+ <li>
20
+ <%= link_to testimonial.title, testimonial_url(testimonial) %>
21
+ </li>
22
+ <% end %>
23
+ </ul>
24
+ </aside>
25
+ <% end %>
26
+
27
+ <%= render :partial => "/shared/content_page" %>
@@ -0,0 +1,24 @@
1
+ en:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: image
6
+ plugins:
7
+ testimonials:
8
+ title: Testimonials
9
+ admin:
10
+ testimonials:
11
+ index:
12
+ title: Testimonials
13
+ create_new: Add New Testimonial
14
+ reorder: Reorder Testimonials
15
+ reorder_done: Done Reordering Testimonials
16
+ sorry_no_results: Sorry! There are no results found.
17
+ no_items_yet: There are no Testimonials yet. Click "Add New Testimonial" to add your first testimonial.
18
+ testimonial:
19
+ view_live_html: View this testimonial live <br/><em>(opens in a new window)</em>
20
+ edit: Edit this testimonial
21
+ delete: Remove this testimonial forever
22
+ testimonials:
23
+ show:
24
+ other: Other Testimonials
@@ -0,0 +1,24 @@
1
+ lolcat:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: IMAGE
6
+ plugins:
7
+ testimonials:
8
+ title: Testimonials
9
+ admin:
10
+ testimonials:
11
+ index:
12
+ title: Testimonials
13
+ create_new: CREATE NEW Testimonial
14
+ reorder: REORDR Testimonials
15
+ reorder_done: DUN REORDERIN Testimonials
16
+ sorry_no_results: SRY! THAR R NO RESULTS FINDZ.
17
+ no_items_yet: THAR R NO Testimonials YET. CLICK "CREATE NEW Testimonial" 2 ADD UR FURST testimonial.
18
+ testimonial:
19
+ view_live_html: VIEW DIS testimonial LIV <BR/><EM>(OPENS IN NEW WINDOW)</EM>
20
+ edit: EDIT DIS testimonial
21
+ delete: REMOOV DIS testimonial FOREVR
22
+ testimonials:
23
+ show:
24
+ other: OTHR Testimonials
@@ -0,0 +1,20 @@
1
+ nb:
2
+ plugins:
3
+ testimonials:
4
+ title: Testimonials
5
+ admin:
6
+ testimonials:
7
+ index:
8
+ title: Testimonials
9
+ create_new: Lag en ny Testimonial
10
+ reorder: Endre rekkefølgen på Testimonials
11
+ reorder_done: Ferdig å endre rekkefølgen Testimonials
12
+ sorry_no_results: Beklager! Vi fant ikke noen resultater.
13
+ no_items_yet: Det er ingen Testimonials enda. Klikk på "Lag en ny Testimonial" for å legge til din første testimonial.
14
+ testimonial:
15
+ view_live_html: Vis hvordan denne testimonial ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
16
+ edit: Rediger denne testimonial
17
+ delete: Fjern denne testimonial permanent
18
+ testimonials:
19
+ show:
20
+ other: Andre Testimonials
@@ -0,0 +1,20 @@
1
+ nl:
2
+ plugins:
3
+ testimonials:
4
+ title: Testimonials
5
+ admin:
6
+ testimonials:
7
+ index:
8
+ title: Testimonials
9
+ create_new: Maak een nieuwe Testimonial
10
+ reorder: Wijzig de volgorde van de Testimonials
11
+ reorder_done: Klaar met het wijzingen van de volgorde van de Testimonials
12
+ sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
13
+ no_items_yet: Er zijn nog geen Testimonials. Druk op 'Maak een nieuwe Testimonial' om de eerste aan te maken.
14
+ testimonial:
15
+ view_live_html: Bekijk deze testimonial op de website <br/><em>(opent een nieuw venster)</em>
16
+ edit: Bewerk deze testimonial
17
+ delete: Verwijder deze testimonial voor eeuwig
18
+ testimonials:
19
+ show:
20
+ other: Andere Testimonials
data/config/routes.rb ADDED
@@ -0,0 +1,11 @@
1
+ Refinery::Application.routes.draw do
2
+ resources :testimonials, :only => [:index, :show]
3
+
4
+ scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
5
+ resources :testimonials, :except => :show do
6
+ collection do
7
+ post :update_positions
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class RefinerycmsTestimonials < Refinery::Generators::EngineInstaller
2
+
3
+ source_root File.expand_path('../../../', __FILE__)
4
+ engine_name "testimonials"
5
+
6
+ end
@@ -0,0 +1,19 @@
1
+ require 'refinery'
2
+
3
+ module Refinery
4
+ module Testimonials
5
+ class Engine < Rails::Engine
6
+ initializer "static assets" do |app|
7
+ app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
8
+ end
9
+
10
+ config.after_initialize do
11
+ Refinery::Plugin.register do |plugin|
12
+ plugin.name = "testimonials"
13
+ plugin.activity = {
14
+ :class => Testimonial}
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :testimonials do
4
+
5
+ # call this task my running: rake refinery:testimonials:my_task
6
+ # desc "Description of my task below"
7
+ # task :my_task => :environment do
8
+ # # add your logic here
9
+ # end
10
+
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-testimonials
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 9
9
+ version: 0.0.9
10
+ platform: ruby
11
+ authors: []
12
+
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-07 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Ruby on Rails Testimonials engine for Refinery CMS
22
+ email:
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/generators/refinerycms_testimonials_generator.rb
31
+ - lib/refinerycms-testimonials.rb
32
+ - lib/tasks/testimonials.rake
33
+ - config/locales/en.yml
34
+ - config/locales/lolcat.yml
35
+ - config/locales/nb.yml
36
+ - config/locales/nl.yml
37
+ - config/routes.rb
38
+ - app/controllers/admin/testimonials_controller.rb
39
+ - app/controllers/testimonials_controller.rb
40
+ - app/helpers/testimonials_helper.rb
41
+ - app/models/testimonial.rb
42
+ - app/views/admin/testimonials/_form.html.erb
43
+ - app/views/admin/testimonials/_sortable_list.html.erb
44
+ - app/views/admin/testimonials/_testimonial.html.erb
45
+ - app/views/admin/testimonials/_testimonials.html.erb
46
+ - app/views/admin/testimonials/edit.html.erb
47
+ - app/views/admin/testimonials/index.html.erb
48
+ - app/views/admin/testimonials/new.html.erb
49
+ - app/views/testimonials/_testimonial.html.erb
50
+ - app/views/testimonials/index.html.erb
51
+ - app/views/testimonials/show.html.erb
52
+ has_rdoc: true
53
+ homepage:
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ requirements: []
78
+
79
+ rubyforge_project:
80
+ rubygems_version: 1.3.7
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: Testimonials engine for Refinery CMS
84
+ test_files: []
85
+