refinerycms-resource-downloads 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ module Refinery
2
+ module Downloads
3
+ module Admin
4
+ class DownloadsController < ::Refinery::AdminController
5
+
6
+ crudify :'refinery/downloads/download',
7
+ :title_attribute => 'name', :xhr_paging => true
8
+
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Refinery
2
+ module Downloads
3
+ class Download < Refinery::Core::BaseModel
4
+ self.table_name = 'refinery_downloads'
5
+
6
+ attr_accessible :page_id, :name, :position, :preview_id, :file_id
7
+
8
+ acts_as_indexed :fields => [:name]
9
+
10
+ validates :name, :presence => true, :uniqueness => true
11
+
12
+ belongs_to :preview, :class_name => '::Refinery::Image'
13
+ belongs_to :file, :class_name => '::Refinery::Resource'
14
+ belongs_to :page, :class_name => '::Refinery::Page'
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ <ul>
2
+ <% if ::Refinery::Downloads::Admin::DownloadsController.searchable? %>
3
+ <li>
4
+ <%= render '/refinery/admin/search', :url => refinery.downloads_admin_downloads_path %>
5
+ </li>
6
+ <% end %>
7
+ <li>
8
+ <%= link_to t('.create_new'), refinery.new_downloads_admin_download_path,
9
+ :class => "add_icon" %>
10
+ </li>
11
+ <% if !searching? && ::Refinery::Downloads::Admin::DownloadsController.sortable? && ::Refinery::Downloads::Download.any? %>
12
+ <li>
13
+ <%= link_to t('.reorder', :what => "Downloads"),
14
+ refinery.downloads_admin_downloads_path,
15
+ :id => "reorder_action",
16
+ :class => "reorder_icon" %>
17
+
18
+ <%= link_to t('.reorder_done', :what => "Downloads"),
19
+ refinery.downloads_admin_downloads_path,
20
+ :id => "reorder_action_done",
21
+ :style => "display: none;",
22
+ :class => "reorder_icon" %>
23
+ </li>
24
+ <% end %>
25
+ </ul>
@@ -0,0 +1,16 @@
1
+ <li class='clearfix record <%= cycle("on", "on-hover") %>' id="<%= dom_id(download) -%>">
2
+ <span class='title'>
3
+ <%= download.name %>
4
+
5
+ </span>
6
+ <span class='actions'>
7
+
8
+ <%= link_to refinery_icon_tag("application_edit.png"), refinery.edit_downloads_admin_download_path(download),
9
+ :title => t('.edit') %>
10
+ <%= link_to refinery_icon_tag("delete.png"), refinery.downloads_admin_download_path(download),
11
+ :class => "cancel confirm-delete",
12
+ :title => t('.delete'),
13
+ :confirm => t('message', :scope => 'refinery.admin.delete', :title => download.name),
14
+ :method => :delete %>
15
+ </span>
16
+ </li>
@@ -0,0 +1,2 @@
1
+ <%= will_paginate @downloads if Refinery::Downloads::Admin::DownloadsController.pageable? %>
2
+ <%= render 'sortable_list' %>
@@ -0,0 +1,36 @@
1
+ <%= form_for [refinery, :downloads_admin, @download] do |f| -%>
2
+ <%= render '/refinery/admin/error_messages',
3
+ :object => @download,
4
+ :include_object_name => true %>
5
+
6
+
7
+ <div class='field'>
8
+ <%= f.label :name -%>
9
+ <%= f.text_field :name, :class => 'larger widest' -%>
10
+
11
+ </div>
12
+
13
+ <div class='field'>
14
+ <%= f.label :preview -%>
15
+ <%= render '/refinery/admin/image_picker',
16
+ :f => f,
17
+ :field => :preview_id,
18
+ :image => @download.preview,
19
+ :toggle_image_display => false %>
20
+
21
+ </div>
22
+
23
+ <div class='field'>
24
+ <%= f.label :file -%>
25
+ <%= render '/refinery/admin/resource_picker',
26
+ :f => f,
27
+ :field => :file_id,
28
+ :resource => @download.file %>
29
+
30
+ </div>
31
+
32
+ <%= render '/refinery/admin/form_actions', :f => f,
33
+ :continue_editing => false,
34
+ :delete_title => t('delete', :scope => 'refinery.downloads.admin.downloads.download'),
35
+ :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @download.name) %>
36
+ <% end -%>
@@ -0,0 +1,18 @@
1
+ <% if searching? %>
2
+ <h2><%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
3
+ <% end %>
4
+ <div class='pagination_container'>
5
+ <% if @downloads.any? %>
6
+ <%= render 'downloads' %>
7
+ <% else %>
8
+ <p>
9
+ <% unless searching? %>
10
+ <strong>
11
+ <%= t('.no_items_yet') %>
12
+ </strong>
13
+ <% else %>
14
+ <%= t('no_results', :scope => 'refinery.admin.search') %>
15
+ <% end %>
16
+ </p>
17
+ <% end %>
18
+ </div>
@@ -0,0 +1,5 @@
1
+ <ul id='sortable_list'>
2
+ <%= render :partial => 'download', :collection => @downloads %>
3
+ </ul>
4
+ <%= render '/refinery/admin/sortable_list',
5
+ :continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,7 @@
1
+ <section id='records'>
2
+ <%= render 'records' %>
3
+ </section>
4
+ <aside id='actions'>
5
+ <%= render 'actions' %>
6
+ </aside>
7
+ <%= render '/refinery/admin/make_sortable', :tree => false if !searching? and ::Refinery::Downloads::Admin::DownloadsController.sortable? and ::Refinery::Downloads::Download.count > 1 %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,35 @@
1
+ en:
2
+ refinery:
3
+ admin:
4
+ pages:
5
+ tabs:
6
+ downloads:
7
+ add: Add Download
8
+ plugins:
9
+ downloads:
10
+ title: Downloads
11
+ downloads:
12
+ admin:
13
+ downloads:
14
+ actions:
15
+ create_new: Add New Download
16
+ reorder: Reorder Downloads
17
+ reorder_done: Done Reordering Downloads
18
+ records:
19
+ title: Downloads
20
+ sorry_no_results: Sorry! There are no results found.
21
+ no_items_yet: There are no Downloads yet. Click "Add New Download" to add your first download.
22
+ download:
23
+ view_live_html: View this download live <br/><em>(opens in a new window)</em>
24
+ edit: Edit this download
25
+ delete: Remove this download forever
26
+ downloads:
27
+ show:
28
+ other: Other Downloads
29
+ activerecord:
30
+ attributes:
31
+ 'refinery/downloads/download':
32
+ name: Name
33
+ page_id: Page
34
+ preview: Preview
35
+ file: File
@@ -0,0 +1,31 @@
1
+ es:
2
+ refinery:
3
+ plugins:
4
+ downloads:
5
+ title: Downloads
6
+ # article: masculino/femenino
7
+ downloads:
8
+ admin:
9
+ downloads:
10
+ actions:
11
+ create_new: Crear nuevo download
12
+ reorder: Reordenar downloads
13
+ reorder_done: Reordenación de downloads completada
14
+ records:
15
+ title: Downloads
16
+ sorry_no_results: Lo siento, no hay resultados
17
+ no_items_yet: No hay downloads todavía. Pulsa en "Crear nuevo Download" para crear tu primer download.
18
+ download:
19
+ view_live_html: Ver este download como abierto al público <br/><em>(abre en ventana nueva)</em>
20
+ edit: Editar este download
21
+ delete: Borrar este download para siempre
22
+ downloads:
23
+ show:
24
+ other: Otros downloads
25
+ activerecord:
26
+ attributes:
27
+ 'refinery/downloads/download':
28
+ name: Name
29
+ page_id: Page
30
+ preview: Preview
31
+ file: File
@@ -0,0 +1,30 @@
1
+ fr:
2
+ refinery:
3
+ plugins:
4
+ downloads:
5
+ title: Downloads
6
+ downloads:
7
+ admin:
8
+ downloads:
9
+ actions:
10
+ create_new: Créer un(e) nouve(au/l/lle) Download
11
+ reorder: Réordonner les Downloads
12
+ reorder_done: Fin de réordonnancement des Downloads
13
+ records:
14
+ title: Downloads
15
+ sorry_no_results: "Désolé ! Aucun résultat."
16
+ no_items_yet: 'Il n''y a actuellement aucun(e) Download. Cliquer sur "Créer un(e) nouve(au/l/lle) Download" pour créer votre premi(er/ère) download.'
17
+ download:
18
+ view_live_html: Voir ce(t/tte) download <br/><em>(Ouvre une nouvelle fenêtre)</em>
19
+ edit: Modifier ce(t/tte) download
20
+ delete: Supprimer définitivement ce(t/tte) download
21
+ downloads:
22
+ show:
23
+ other: Autres Downloads
24
+ activerecord:
25
+ attributes:
26
+ 'refinery/downloads/download':
27
+ name: Name
28
+ page_id: Page
29
+ preview: Preview
30
+ file: File
@@ -0,0 +1,30 @@
1
+ nb:
2
+ refinery:
3
+ plugins:
4
+ downloads:
5
+ title: Downloads
6
+ downloads:
7
+ admin:
8
+ downloads:
9
+ actions:
10
+ create_new: Lag en ny Download
11
+ reorder: Endre rekkefølgen på Downloads
12
+ reorder_done: Ferdig å endre rekkefølgen Downloads
13
+ records:
14
+ title: Downloads
15
+ sorry_no_results: Beklager! Vi fant ikke noen resultater.
16
+ no_items_yet: Det er ingen Downloads enda. Klikk på "Lag en ny Download" for å legge til din første download.
17
+ download:
18
+ view_live_html: Vis hvordan denne download ser ut offentlig <br/><em>(åpner i et nytt vindu)</em>
19
+ edit: Rediger denne download
20
+ delete: Fjern denne download permanent
21
+ downloads:
22
+ show:
23
+ other: Andre Downloads
24
+ activerecord:
25
+ attributes:
26
+ 'refinery/downloads/download':
27
+ name: Name
28
+ page_id: Page
29
+ preview: Preview
30
+ file: File
@@ -0,0 +1,30 @@
1
+ nl:
2
+ refinery:
3
+ plugins:
4
+ downloads:
5
+ title: Downloads
6
+ downloads:
7
+ admin:
8
+ downloads:
9
+ actions:
10
+ create_new: Maak een nieuwe Download
11
+ reorder: Wijzig de volgorde van de Downloads
12
+ reorder_done: Klaar met het wijzingen van de volgorde van de Downloads
13
+ records:
14
+ title: Downloads
15
+ sorry_no_results: Helaas! Er zijn geen resultaten gevonden.
16
+ no_items_yet: Er zijn nog geen Downloads. Druk op 'Maak een nieuwe Download' om de eerste aan te maken.
17
+ download:
18
+ view_live_html: Bekijk deze download op de website <br/><em>(opent een nieuw venster)</em>
19
+ edit: Bewerk deze download
20
+ delete: Verwijder deze download voor eeuwig
21
+ downloads:
22
+ show:
23
+ other: Andere Downloads
24
+ activerecord:
25
+ attributes:
26
+ 'refinery/downloads/download':
27
+ name: Name
28
+ page_id: Page
29
+ preview: Preview
30
+ file: File
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ Refinery::Core::Engine.routes.append do
2
+
3
+ # Admin routes
4
+ namespace :downloads, :path => '' do
5
+ namespace :admin, :path => 'refinery' do
6
+ resources :downloads, :except => :show do
7
+ collection do
8
+ post :update_positions
9
+ end
10
+ end
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,23 @@
1
+ class CreateDownloadsDownloads < ActiveRecord::Migration
2
+
3
+ def up
4
+ create_table :refinery_downloads do |t|
5
+ t.string :name
6
+ t.integer :preview_id
7
+ t.integer :file_id
8
+ t.integer :position
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+
14
+ def down
15
+ if defined?(::Refinery::UserPlugin)
16
+ ::Refinery::UserPlugin.destroy_all({:name => "refinerycms-downloads"})
17
+ end
18
+
19
+ drop_table :refinery_downloads
20
+
21
+ end
22
+
23
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,10 @@
1
+ if defined?(::Refinery::User)
2
+ ::Refinery::User.all.each do |user|
3
+ if user.plugins.where(:name => 'refinerycms-downloads').blank?
4
+ user.plugins.create(:name => 'refinerycms-downloads',
5
+ :position => (user.plugins.maximum(:position) || -1) +1)
6
+ end
7
+ end
8
+ end
9
+
10
+
@@ -0,0 +1,18 @@
1
+ module Refinery
2
+ class DownloadsGenerator < Rails::Generators::Base
3
+
4
+ def rake_db
5
+ rake("refinery_downloads:install:migrations")
6
+ end
7
+
8
+ def append_load_seed_data
9
+ create_file 'db/seeds.rb' unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
10
+ append_file 'db/seeds.rb', :verbose => true do
11
+ <<-EOH
12
+
13
+ Refinery::Downloads::Engine.load_seed
14
+ EOH
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ require 'refinerycms-core'
2
+
3
+ module Refinery
4
+ autoload :DownloadsGenerator, 'generators/refinery/downloads_generator'
5
+
6
+ module Downloads
7
+ require 'refinery/downloads/engine'
8
+
9
+ class << self
10
+ attr_writer :root
11
+
12
+ def root
13
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
14
+ end
15
+
16
+ def factory_paths
17
+ @factory_paths ||= [ root.join('spec', 'factories').to_s ]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module Refinery
2
+ module Downloads
3
+ class Engine < Rails::Engine
4
+ include Refinery::Engine
5
+ isolate_namespace Refinery::Downloads
6
+
7
+ engine_name :refinery_downloads
8
+
9
+ initializer "register refinerycms_downloads plugin" do
10
+ Refinery::Plugin.register do |plugin|
11
+ plugin.name = "downloads"
12
+ plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.downloads_admin_downloads_path }
13
+ plugin.pathname = root
14
+ plugin.activity = {
15
+ :class_name => :'refinery/downloads/download',
16
+ :title => 'name'
17
+ }
18
+
19
+ end
20
+ end
21
+
22
+ config.after_initialize do
23
+ Refinery.register_extension(Refinery::Downloads)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1 @@
1
+ require 'refinery/downloads'
@@ -0,0 +1,13 @@
1
+ namespace :refinery do
2
+
3
+ namespace :downloads do
4
+
5
+ # call this task by running: rake refinery:downloads: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
data/readme.md ADDED
@@ -0,0 +1,10 @@
1
+ # Downloads extension for Refinery CMS.
2
+
3
+ ## How to build this extension as a gem
4
+
5
+ cd vendor/extensions/downloads
6
+ gem build refinerycms-downloads.gemspec
7
+ gem install refinerycms-downloads.gem
8
+
9
+ # Sign up for a http://rubygems.org/ account and publish the gem
10
+ gem push refinerycms-downloads.gem
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: refinerycms-resource-downloads
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stas Ladonenko
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: refinerycms-core
16
+ requirement: &70338512640140 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70338512640140
25
+ - !ruby/object:Gem::Dependency
26
+ name: refinerycms-testing
27
+ requirement: &70338512639660 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.2
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70338512639660
36
+ description: Ruby on Rails Downloads extension for Refinery CMS
37
+ email:
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - app/controllers/refinery/downloads/admin/downloads_controller.rb
43
+ - app/models/refinery/downloads/download.rb
44
+ - app/views/refinery/downloads/admin/downloads/_actions.html.erb
45
+ - app/views/refinery/downloads/admin/downloads/_download.html.erb
46
+ - app/views/refinery/downloads/admin/downloads/_downloads.html.erb
47
+ - app/views/refinery/downloads/admin/downloads/_form.html.erb
48
+ - app/views/refinery/downloads/admin/downloads/_records.html.erb
49
+ - app/views/refinery/downloads/admin/downloads/_sortable_list.html.erb
50
+ - app/views/refinery/downloads/admin/downloads/edit.html.erb
51
+ - app/views/refinery/downloads/admin/downloads/index.html.erb
52
+ - app/views/refinery/downloads/admin/downloads/new.html.erb
53
+ - config/locales/en.yml
54
+ - config/locales/es.yml
55
+ - config/locales/fr.yml
56
+ - config/locales/nb.yml
57
+ - config/locales/nl.yml
58
+ - config/routes.rb
59
+ - db/migrate/1_create_downloads_downloads.rb
60
+ - db/seeds.rb
61
+ - lib/generators/refinery/downloads_generator.rb
62
+ - lib/refinery/downloads/engine.rb
63
+ - lib/refinery/downloads.rb
64
+ - lib/refinerycms-downloads.rb
65
+ - lib/tasks/refinery/downloads.rake
66
+ - readme.md
67
+ homepage: http://github.com/stasl/refinerycms-resource-downloads
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.10
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Downloads extension for Refinery CMS
91
+ test_files: []