refinerycms-announcements 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ module Admin
2
+ class AnnouncementsController < Admin::BaseController
3
+
4
+ crudify :announcement, :xhr_paging => true
5
+
6
+ end
7
+ end
@@ -0,0 +1,30 @@
1
+ class AnnouncementsController < ApplicationController
2
+
3
+ before_filter :find_all_announcements
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 @announcement in the line below:
9
+ present(@page)
10
+ end
11
+
12
+ def show
13
+ @announcement = Announcement.displayable.find(params[:id])
14
+
15
+ # you can use meta fields from your model instead (e.g. browser_title)
16
+ # by swapping @page for @announcement in the line below:
17
+ present(@page)
18
+ end
19
+
20
+ protected
21
+
22
+ def find_all_announcements
23
+ @announcements = Announcement.displayable.find(:all, :order => 'position ASC')
24
+ end
25
+
26
+ def find_page
27
+ @page = Page.where(:link_url => "/announcements").first
28
+ end
29
+
30
+ end
@@ -0,0 +1,10 @@
1
+ class Announcement < ActiveRecord::Base
2
+
3
+ acts_as_indexed :fields => [:title, :description]
4
+
5
+ validates :title, :presence => true
6
+
7
+ belongs_to :photo, :class_name => 'Image'
8
+
9
+ scope :displayable, :conditions => ["starts_at <= ? and ends_at >= ?", Time.now, Time.now]
10
+ end
@@ -0,0 +1,28 @@
1
+ <ul>
2
+ <% if Admin::AnnouncementsController.searchable? %>
3
+ <li>
4
+ <%= render :partial => "/shared/admin/search",
5
+ :locals => {
6
+ :url => admin_announcements_path
7
+ } %>
8
+ </li>
9
+ <% end %>
10
+ <li>
11
+ <%= link_to t('.create_new'), new_admin_announcement_path,
12
+ :class => "add_icon" %>
13
+ </li>
14
+ <% if !searching? and Admin::AnnouncementsController.sortable? and Announcement.count > 1 %>
15
+ <li>
16
+ <%= link_to t('.reorder', :what => "Announcements"),
17
+ admin_announcements_path,
18
+ :id => "reorder_action",
19
+ :class => "reorder_icon" %>
20
+
21
+ <%= link_to t('.reorder_done', :what => "Announcements"),
22
+ admin_announcements_path,
23
+ :id => "reorder_action_done",
24
+ :style => "display: none;",
25
+ :class => "reorder_icon" %>
26
+ </li>
27
+ <% end %>
28
+ </ul>
@@ -0,0 +1,18 @@
1
+ <li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(announcement) -%>">
2
+ <span class='title'>
3
+ <%= announcement.title %>
4
+ <span class="preview"><br><%= t(".from_to", :from => l(announcement.starts_at), :to => l(announcement.ends_at)) %></span>
5
+ </span>
6
+ <span class='actions'>
7
+ <%= link_to refinery_icon_tag("application_go.png"), announcement_path(announcement),
8
+ :title => t('.view_live_html'),
9
+ :target => "_blank" %>
10
+ <%= link_to refinery_icon_tag("application_edit.png"), edit_admin_announcement_path(announcement),
11
+ :title => t('.edit') %>
12
+ <%= link_to refinery_icon_tag("delete.png"), admin_announcement_path(announcement),
13
+ :class => "cancel confirm-delete",
14
+ :title => t('.delete'),
15
+ :confirm => t('message', :scope => 'shared.admin.delete', :title => announcement.title),
16
+ :method => :delete %>
17
+ </span>
18
+ </li>
@@ -0,0 +1,2 @@
1
+ <%= will_paginate @announcements %>
2
+ <%= render :partial => "sortable_list" %>
@@ -0,0 +1,66 @@
1
+ <%= form_for [:admin, @announcement] do |f| -%>
2
+ <%= render :partial => "/shared/admin/error_messages", :locals => {
3
+ :object => @announcement,
4
+ :include_object_name => true
5
+ } %>
6
+
7
+ <div class='field'>
8
+ <%= f.label :title -%>
9
+ <%= f.text_field :title, :class => 'larger widest' -%>
10
+ </div>
11
+
12
+ <div class='field'>
13
+ <%= f.label :starts_at -%>
14
+ <%= f.datetime_select :starts_at -%>
15
+ </div>
16
+
17
+ <div class='field'>
18
+ <%= f.label :ends_at -%>
19
+ <%= f.datetime_select :ends_at -%>
20
+ </div>
21
+
22
+ <div class='field'>
23
+ <%= f.label :photo -%>
24
+ <%= render :partial => "/shared/admin/image_picker", :locals => {
25
+ :f => f,
26
+ :field => :photo_id,
27
+ :image => @announcement.photo,
28
+ :toggle_image_display => false
29
+ } %>
30
+ </div>
31
+
32
+ <div class='field'>
33
+ <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
34
+ <ul id='page_parts'>
35
+ <% [:description].each_with_index do |part, part_index| %>
36
+ <li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'>
37
+ <%= link_to part.to_s.titleize, "##{part}" %>
38
+ </li>
39
+ <% end %>
40
+ </ul>
41
+
42
+ <div id='page_part_editors'>
43
+ <% [:description].each do |part| %>
44
+ <div class='page_part' id='<%= part %>'>
45
+ <%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
46
+ </div>
47
+ <% end %>
48
+ </div>
49
+ </div>
50
+ </div>
51
+
52
+ <%= render :partial => "/shared/admin/form_actions",
53
+ :locals => {
54
+ :f => f,
55
+ :continue_editing => false,
56
+ :delete_title => t('delete', :scope => 'admin.announcements.announcement'),
57
+ :delete_confirmation => t('message', :scope => 'shared.admin.delete', :title => @announcement.title)
58
+ } %>
59
+ <% end -%>
60
+ <% content_for :javascripts do %>
61
+ <script>
62
+ $(document).ready(function(){
63
+ page_options.init(false, '', '');
64
+ });
65
+ </script>
66
+ <% end %>
@@ -0,0 +1,18 @@
1
+ <% if searching? %>
2
+ <h2><%= t('results_for', :scope => 'shared.admin.search', :query => params[:search]) %></h2>
3
+ <% end %>
4
+ <% if @announcements.any? %>
5
+ <div class='pagination_container'>
6
+ <%= render :partial => 'announcements' %>
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 => 'announcement', :collection => @announcements %>
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::AnnouncementsController.sortable? and Announcement.count > 1 %>
@@ -0,0 +1 @@
1
+ <%= render :partial => "form" %>
@@ -0,0 +1,17 @@
1
+
2
+ <% content_for :body_content_right do %>
3
+ <h3><%= t("announcements.titles.other") %></h3>
4
+ <% if @announcements.size > 0 -%>
5
+ <ul id="announcements">
6
+ <% @announcements.each do |announcement| %>
7
+ <li>
8
+ <%= link_to announcement.title, announcement_path(announcement) %>
9
+ </li>
10
+ <% end %>
11
+ </ul>
12
+ <% else %>
13
+ <p class="no-data"><%= t("announcements.nodata") %></p>
14
+ <% end %>
15
+ <% end %>
16
+
17
+ <%= render :partial => "/shared/content_page" %>
@@ -0,0 +1,30 @@
1
+ <% content_for :body_content_title do %>
2
+ <%= @announcement.title %>
3
+ <% end %>
4
+
5
+ <% content_for :body_content_left do %>
6
+
7
+ <section>
8
+ <%= image_fu @announcement.photo, nil %>
9
+ <p>
10
+ <%=raw @announcement.description %>
11
+ </p>
12
+ </section>
13
+ <% end %>
14
+
15
+ <% content_for :body_content_right do %>
16
+ <% if @announcements.size > 0 -%>
17
+ <aside>
18
+ <h2><%= t('.other') %></h2>
19
+ <ul id="announcements">
20
+ <% @announcements.each do |announcement| %>
21
+ <li>
22
+ <%= link_to announcement.title, announcement_path(announcement) %>
23
+ </li>
24
+ <% end %>
25
+ </ul>
26
+ </aside>
27
+ <% end %>
28
+ <% end %>
29
+
30
+ <%= render :partial => "/shared/content_page" %>
@@ -0,0 +1,25 @@
1
+ en:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: image
6
+ plugins:
7
+ announcements:
8
+ title: Announcements
9
+ admin:
10
+ announcements:
11
+ actions:
12
+ create_new: Add New Announcement
13
+ reorder: Reorder Announcements
14
+ reorder_done: Done Reordering Announcements
15
+ records:
16
+ title: Announcements
17
+ sorry_no_results: Sorry! There are no results found.
18
+ no_items_yet: There are no Announcements yet. Click "Add New Announcement" to add your first announcement.
19
+ announcement:
20
+ view_live_html: View this announcement live <br/><em>(opens in a new window)</em>
21
+ edit: Edit this announcement
22
+ delete: Remove this announcement forever
23
+ announcements:
24
+ show:
25
+ other: Other Announcements
@@ -0,0 +1,29 @@
1
+ fr:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: image
6
+ plugins:
7
+ announcements:
8
+ title: Annonces
9
+ admin:
10
+ announcements:
11
+ actions:
12
+ create_new: Créer une nouvelle annonce
13
+ reorder: Réordonner les annonces
14
+ reorder_done: Fin de réordonnancement des annonces
15
+ records:
16
+ title: Annonces
17
+ sorry_no_results: "Désolé ! Aucun résultat."
18
+ no_items_yet: 'Il n''y a actuellement aucune Annonce. Cliquer sur "Créer une nouvelle annonce" pour créer votre première annonce.'
19
+ announcement:
20
+ view_live_html: Voir cette annonce <br/><em>(Ouvre une nouvelle fenêtre)</em>
21
+ edit: Modifier cette annonce
22
+ delete: Supprimer définitivement cette annonce
23
+ from_to: "Du %{from} au %{to}"
24
+ announcements:
25
+ show:
26
+ other: Autres annonces
27
+ titles:
28
+ other: Autres annonces
29
+ nodata: "Aucune annonce n'est disponible actuellement"
@@ -0,0 +1,25 @@
1
+ lolcat:
2
+ shared:
3
+ admin:
4
+ image_picker:
5
+ image: IMAGE
6
+ plugins:
7
+ announcements:
8
+ title: Announcements
9
+ admin:
10
+ announcements:
11
+ actions:
12
+ create_new: CREATE NEW Announcement
13
+ reorder: REORDR Announcements
14
+ reorder_done: DUN REORDERIN Announcements
15
+ records:
16
+ title: Announcements
17
+ sorry_no_results: SRY! THAR R NO RESULTS FINDZ.
18
+ no_items_yet: THAR R NO Announcements YET. CLICK "CREATE NEW Announcement" 2 ADD UR FURST announcement.
19
+ announcement:
20
+ view_live_html: VIEW DIS announcement LIV <BR/><EM>(OPENS IN NEW WINDOW)</EM>
21
+ edit: EDIT DIS announcement
22
+ delete: REMOOV DIS announcement FOREVR
23
+ announcements:
24
+ show:
25
+ other: OTHR Announcements
@@ -0,0 +1,21 @@
1
+ nb:
2
+ plugins:
3
+ announcements:
4
+ title: Announcements
5
+ admin:
6
+ announcements:
7
+ actions:
8
+ create_new: Lag en ny Announcement
9
+ reorder: Endre rekkefølgen på Announcements
10
+ reorder_done: Ferdig å endre rekkefølgen Announcements
11
+ records:
12
+ title: Announcements
13
+ sorry_no_results: Beklager! Vi fant ikke noen resultater.
14
+ no_items_yet: Det er ingen Announcements enda. Klikk på "Lag en ny Announcement" for å legge til din første announcement.
15
+ announcement:
16
+ view_live_html: Vis hvordan denne announcement ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
17
+ edit: Rediger denne announcement
18
+ delete: Fjern denne announcement permanent
19
+ announcements:
20
+ show:
21
+ other: Andre Announcements
@@ -0,0 +1,21 @@
1
+ nl:
2
+ plugins:
3
+ announcements:
4
+ title: Announcements
5
+ admin:
6
+ announcements:
7
+ actions:
8
+ create_new: Maak een nieuwe Announcement
9
+ reorder: Wijzig de volgorde van de Announcements
10
+ reorder_done: Klaar met het wijzingen van de volgorde van de Announcements
11
+ records:
12
+ title: Announcements
13
+ sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
14
+ no_items_yet: Er zijn nog geen Announcements. Druk op 'Maak een nieuwe Announcement' om de eerste aan te maken.
15
+ announcement:
16
+ view_live_html: Bekijk deze announcement op de website <br/><em>(opent een nieuw venster)</em>
17
+ edit: Bewerk deze announcement
18
+ delete: Verwijder deze announcement voor eeuwig
19
+ announcements:
20
+ show:
21
+ other: Andere Announcements
data/config/routes.rb ADDED
@@ -0,0 +1,11 @@
1
+ ::Refinery::Application.routes.draw do
2
+ resources :announcements, :only => [:index, :show]
3
+
4
+ scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
5
+ resources :announcements, :except => :show do
6
+ collection do
7
+ post :update_positions
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class RefinerycmsAnnouncements < Refinery::Generators::EngineInstaller
2
+
3
+ source_root File.expand_path('../../../', __FILE__)
4
+ engine_name "announcements"
5
+
6
+ end
@@ -0,0 +1,29 @@
1
+ require 'refinerycms-base'
2
+
3
+ module Refinery
4
+ module Announcements
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 = "announcements"
21
+ plugin.pathname = root
22
+ plugin.activity = {
23
+ :class => Announcement
24
+ }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :announcements do
4
+
5
+ # call this task my running: rake refinery:announcements: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,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-announcements
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ version: "1.0"
10
+ platform: ruby
11
+ authors:
12
+ - "C\xC3\xA9dric Bousmanne"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-11-28 00:00:00 Z
18
+ dependencies: []
19
+
20
+ description: Announcements is an engine for Refinery CMS to manage temporary announce. It can be used, for example, as an advertising system for your website.
21
+ email: cedric@studio-sept.be
22
+ executables: []
23
+
24
+ extensions: []
25
+
26
+ extra_rdoc_files: []
27
+
28
+ files:
29
+ - lib/generators/refinerycms_announcements_generator.rb
30
+ - lib/refinerycms-announcements.rb
31
+ - lib/tasks/announcements.rake
32
+ - config/locales/en.yml
33
+ - config/locales/fr.yml
34
+ - config/locales/lolcat.yml
35
+ - config/locales/nb.yml
36
+ - config/locales/nl.yml
37
+ - config/routes.rb
38
+ - app/controllers/admin/announcements_controller.rb
39
+ - app/controllers/announcements_controller.rb
40
+ - app/models/announcement.rb
41
+ - app/views/admin/announcements/_actions.html.erb
42
+ - app/views/admin/announcements/_announcement.html.erb
43
+ - app/views/admin/announcements/_announcements.html.erb
44
+ - app/views/admin/announcements/_form.html.erb
45
+ - app/views/admin/announcements/_records.html.erb
46
+ - app/views/admin/announcements/_sortable_list.html.erb
47
+ - app/views/admin/announcements/edit.html.erb
48
+ - app/views/admin/announcements/index.html.erb
49
+ - app/views/admin/announcements/new.html.erb
50
+ - app/views/announcements/index.html.erb
51
+ - app/views/announcements/show.html.erb
52
+ homepage: https://github.com/cedricbousmanne/refinerycms-announcements
53
+ licenses:
54
+ - MIT
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
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
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.11
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Announcements engine for Refinery CMS
85
+ test_files: []
86
+