refinerycms-forms 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/lib/generators/refinery/form/USAGE +20 -0
  3. data/lib/generators/refinery/form/form_generator.rb +34 -0
  4. data/lib/generators/refinery/form/templates/.gitignore +2 -0
  5. data/lib/generators/refinery/form/templates/.gitkeep +0 -0
  6. data/lib/generators/refinery/form/templates/Gemfile +44 -0
  7. data/lib/generators/refinery/form/templates/Rakefile +19 -0
  8. data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb +65 -0
  9. data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb +53 -0
  10. data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/plural_name_controller.rb.erb +63 -0
  11. data/lib/generators/refinery/form/templates/app/mailers/refinery/namespace/mailer.rb.erb +22 -0
  12. data/lib/generators/refinery/form/templates/app/models/refinery/namespace/setting.rb.erb +40 -0
  13. data/lib/generators/refinery/form/templates/app/models/refinery/namespace/singular_name.rb.erb +53 -0
  14. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +23 -0
  15. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_singular_name.html.erb +25 -0
  16. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_submenu.html.erb +29 -0
  17. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/index.html.erb +4 -0
  18. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/show.html.erb +52 -0
  19. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/spam.html.erb +27 -0
  20. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/_confirmation_email_form.html.erb +50 -0
  21. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/_notification_recipients_form.html.erb +21 -0
  22. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/edit.html.erb +5 -0
  23. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/mailer/confirmation.html.erb +1 -0
  24. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/mailer/notification.html.erb +17 -0
  25. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/plural_name/new.html.erb +43 -0
  26. data/lib/generators/refinery/form/templates/app/views/refinery/namespace/plural_name/thank_you.html.erb +1 -0
  27. data/lib/generators/refinery/form/templates/config/locales/cs.yml +78 -0
  28. data/lib/generators/refinery/form/templates/config/locales/da.yml +60 -0
  29. data/lib/generators/refinery/form/templates/config/locales/de.yml +78 -0
  30. data/lib/generators/refinery/form/templates/config/locales/en.yml +78 -0
  31. data/lib/generators/refinery/form/templates/config/locales/es.yml +60 -0
  32. data/lib/generators/refinery/form/templates/config/locales/fr.yml +78 -0
  33. data/lib/generators/refinery/form/templates/config/locales/it.yml +60 -0
  34. data/lib/generators/refinery/form/templates/config/locales/lv.yml +77 -0
  35. data/lib/generators/refinery/form/templates/config/locales/nb.yml +69 -0
  36. data/lib/generators/refinery/form/templates/config/locales/nl.yml +78 -0
  37. data/lib/generators/refinery/form/templates/config/locales/pt-BR.yml +78 -0
  38. data/lib/generators/refinery/form/templates/config/locales/ru.yml +71 -0
  39. data/lib/generators/refinery/form/templates/config/locales/sk.yml +78 -0
  40. data/lib/generators/refinery/form/templates/config/locales/sl.yml +61 -0
  41. data/lib/generators/refinery/form/templates/config/locales/tr.yml +78 -0
  42. data/lib/generators/refinery/form/templates/config/locales/zh-CN.yml +78 -0
  43. data/lib/generators/refinery/form/templates/config/routes.rb.erb +30 -0
  44. data/lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb +29 -0
  45. data/lib/generators/refinery/form/templates/db/seeds.rb.erb +39 -0
  46. data/lib/generators/refinery/form/templates/lib/generators/refinery/plural_name_generator.rb.erb +20 -0
  47. data/lib/generators/refinery/form/templates/lib/refinery/plural_name/engine.rb.erb +23 -0
  48. data/lib/generators/refinery/form/templates/lib/refinery/plural_name.rb.erb +18 -0
  49. data/lib/generators/refinery/form/templates/lib/refinerycms-plural_name.rb.erb +1 -0
  50. data/lib/generators/refinery/form/templates/readme.md +10 -0
  51. data/lib/generators/refinery/form/templates/refinerycms-plural_name.gemspec +22 -0
  52. data/lib/generators/refinery/form/templates/script/rails +10 -0
  53. data/lib/generators/refinery/form/templates/spec/controllers/refinery/plural_name/plural_name_controller_spec.rb +75 -0
  54. data/lib/generators/refinery/form/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb +166 -0
  55. data/lib/generators/refinery/form/templates/spec/features/refinery/namespace/admin/settings_spec.rb.erb +54 -0
  56. data/lib/generators/refinery/form/templates/spec/features/refinery/namespace/singular_name_spec.rb.erb +34 -0
  57. data/lib/generators/refinery/form/templates/spec/models/refinery/namespace/setting_spec.rb +34 -0
  58. data/lib/generators/refinery/form/templates/spec/requests/refinery/plural_name/plural_name_requests_spec.rb +32 -0
  59. data/lib/generators/refinery/form/templates/spec/routing/refinery/plural_name/admin/plural_name_routing_spec.rb +51 -0
  60. data/lib/generators/refinery/form/templates/spec/routing/refinery/plural_name/plural_name_routing_spec.rb +63 -0
  61. data/lib/generators/refinery/form/templates/spec/spec_helper.rb +30 -0
  62. data/lib/generators/refinery/form/templates/spec/support/factories/refinery/plural_name.rb.erb +7 -0
  63. data/lib/generators/refinery/form/templates/tasks/rspec.rake +6 -0
  64. data/lib/generators/refinery/form/templates/tasks/testing.rake +8 -0
  65. data/lib/refinery/forms/engine.rb +22 -0
  66. data/lib/refinery/forms.rb +1 -0
  67. data/lib/refinerycms-forms.rb +1 -0
  68. metadata +137 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01ff4e9ec14ee2315d2f88d34cef10924b08a9ff
4
+ data.tar.gz: 50a6696160cab6749dc312abbe3772590fa85d7e
5
+ SHA512:
6
+ metadata.gz: 03c516c13112b857fb45633e63c777da62aa4b0b82ce0a3788ab39de3b0e277283c5b9da6fe01d5628a6cc4bae455c70c9168c135d3793e2affb919d860c3cf3
7
+ data.tar.gz: 4babed715d148d2b26aa271668f88f3a1fab450dd1b3244e072eeed055007f076126980906da8536bb0595e175cafe9db5b340136db01782de2a8fb4f53b8ee6
@@ -0,0 +1,20 @@
1
+ Description:
2
+ Generates a custom forms based extension for Refinery automatically.
3
+ It works very similarly to the Refinery Engine generator.
4
+
5
+ The first string attribute should always be the one which is the title or
6
+ name field in your model.
7
+
8
+ There must be at least one attribute.
9
+
10
+ Additional Supported Field Types
11
+
12
+ All field types that are supported by the Refinery Engine generator are supported
13
+ with the addition of these form specific ones:
14
+
15
+ radio - creates a set of radio buttons based off Model::FIELD_NAMES
16
+ checkbox - creates a checkbox for true/false values.
17
+ select - creates a select list with options using Model::FIELD_NAMES
18
+
19
+ Example:
20
+ rails generate refinery:form job_inquiry name:string message:text job_type:radio brochure:checkbox qualification:select
@@ -0,0 +1,34 @@
1
+ require 'refinery/extension_generation'
2
+ require 'refinery/generators/named_base'
3
+
4
+ module Refinery
5
+ class FormGenerator < Refinery::Generators::NamedBase
6
+ source_root Pathname.new(File.expand_path('../templates', __FILE__))
7
+
8
+ include Refinery::ExtensionGeneration
9
+
10
+ class_option :include_spam,
11
+ :desc => 'Generate extension with spam filtering',
12
+ :type => :boolean,
13
+ :default => false,
14
+ :required => false
15
+
16
+ def include_spam?
17
+ options[:include_spam]
18
+ end
19
+
20
+ def description
21
+ "Generates an extension which is set up for frontend form submissions like a contact page."
22
+ end
23
+
24
+ def generate
25
+ default_generate!
26
+ end
27
+
28
+ protected
29
+
30
+ def generator_command
31
+ 'rails generate refinery:form'
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,2 @@
1
+ # Ignore dummy applications.
2
+ spec/dummy
File without changes
@@ -0,0 +1,44 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ git 'https://github.com/refinery/refinerycms.git', :branch => 'master' do
6
+ gem 'refinerycms'
7
+
8
+ group :development, :test do
9
+ gem 'refinerycms-testing'
10
+ end
11
+ end
12
+
13
+ # Database Configuration
14
+ platforms :jruby do
15
+ gem 'activerecord-jdbcsqlite3-adapter'
16
+ gem 'activerecord-jdbcmysql-adapter'
17
+ gem 'activerecord-jdbcpostgresql-adapter'
18
+ gem 'jruby-openssl'
19
+ end
20
+
21
+ platforms :ruby do
22
+ gem 'sqlite3'
23
+ gem 'mysql2'
24
+ gem 'pg'
25
+ end
26
+
27
+ group :development, :test do
28
+ gem 'rspec-its' # for the model's validation tests.
29
+ gem 'selenium-webdriver'
30
+ platforms :ruby do
31
+ require 'rbconfig'
32
+ if RbConfig::CONFIG['target_os'] =~ /linux/i
33
+ gem 'therubyracer', '~> 0.11.4'
34
+ end
35
+ end
36
+ end
37
+
38
+ # Gems used only for assets and not required
39
+ # in production environments by default.
40
+ group :assets do
41
+ gem 'sass-rails'
42
+ gem 'coffee-rails'
43
+ gem 'uglifier'
44
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ ENGINE_PATH = File.dirname(__FILE__)
9
+ APP_RAKEFILE = File.expand_path "../spec/dummy/Rakefile", __FILE__
10
+
11
+ if File.exists? APP_RAKEFILE
12
+ load 'rails/tasks/engine.rake'
13
+ end
14
+
15
+ require "refinerycms-testing"
16
+ Refinery::Testing::Railtie.load_dummy_tasks ENGINE_PATH
17
+
18
+ load File.expand_path('../tasks/testing.rake', __FILE__)
19
+ load File.expand_path('../tasks/rspec.rake', __FILE__)
@@ -0,0 +1,65 @@
1
+ module Refinery
2
+ module <%= namespacing %>
3
+ module Admin
4
+ class <%= class_name.pluralize %>Controller < Refinery::AdminController
5
+
6
+ crudify :'refinery/<%= namespacing.underscore %>/<%= singular_name %>', <% if (title = attributes.detect { |a| a.refinery_type.to_s == "string" }).present? %>
7
+ :title_attribute => "<%= title.name %>", <% end %>
8
+ :order => "created_at DESC"
9
+ <% if include_spam? -%>
10
+
11
+ before_action :get_spam_count, :only => [:index, :spam]
12
+
13
+ def index
14
+ @<%= plural_name %> = find_all_<%= plural_name %>.ham
15
+ @<%= plural_name %> = @<%= plural_name %>.with_query(params[:search]) if searching?
16
+
17
+ @grouped_<%= plural_name %> = group_by_date(@<%= plural_name %>)
18
+ end
19
+
20
+ def spam
21
+ @<%= plural_name %> = find_all_<%= plural_name %>.spam
22
+ @<%= plural_name %> = @<%= plural_name %>.with_query(params[:search]) if searching?
23
+
24
+ @grouped_<%= plural_name %> = group_by_date(@<%= plural_name %>)
25
+ end
26
+
27
+ def toggle_spam
28
+ find_<%= singular_name %>
29
+ @<%= singular_name %>.toggle!(:spam)
30
+
31
+ redirect_to :back
32
+ end
33
+
34
+ protected
35
+
36
+ def get_spam_count
37
+ @spam_count = <%= class_name %>.count(:conditions => {:spam => true})
38
+ end
39
+ <% else %>
40
+ def index
41
+ if searching?
42
+ search_all_<%= plural_name %>
43
+ else
44
+ find_all_<%= plural_name %>
45
+ end
46
+
47
+ @grouped_<%= plural_name %> = group_by_date(@<%= plural_name %>)
48
+ end
49
+
50
+ <% end -%>
51
+
52
+ private
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def <%= "#{singular_table_name}_params" %>
56
+ <%- if attributes_names.empty? -%>
57
+ params[:<%= singular_table_name %>]
58
+ <%- else -%>
59
+ params.require(:<%= singular_table_name %>).permit(<%= attributes.map { |attr| ":#{attr.column_name}" }.join(', ') %>)
60
+ <%- end -%>
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,53 @@
1
+ module Refinery
2
+ module <%= class_name.pluralize %>
3
+ module Admin
4
+ class SettingsController < Refinery::AdminController
5
+
6
+ before_action :find_setting, :only => [:edit, :update]
7
+ after_action :save_subject_for_confirmation, :save_message_for_confirmation, :save_notification_recipients, :only => :update
8
+
9
+ def edit
10
+ end
11
+
12
+ def update
13
+ flash[:notice] = t('refinery.crudify.updated', :what => @setting.name.gsub("<%= singular_name %>_", "").titleize)
14
+
15
+ if request.xhr? or from_dialog?
16
+ render :text => "<script type='text/javascript'>parent.window.location = '#{refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path}';</script>"
17
+ else
18
+ redirect_back_or_default(refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path)
19
+ end
20
+ end
21
+
22
+ protected
23
+ def find_setting
24
+ setting = params[:id].gsub("<%= singular_name %>_", "")
25
+
26
+ Refinery::<%= namespacing %>::Setting.send(setting) if Refinery::<%= namespacing %>::Setting.respond_to?(setting)
27
+
28
+ @setting = Refinery::Setting.friendly.find(params[:id])
29
+ end
30
+
31
+ def save_notification_recipients
32
+ Refinery::<%= namespacing %>::Setting.notification_recipients = setting_params[:value] if setting_params.include?('value')
33
+ end
34
+
35
+ def save_subject_for_confirmation
36
+ Refinery::<%= namespacing %>::Setting.confirmation_subject = setting_params[:subject] if setting_params.include?('subject')
37
+ end
38
+
39
+ def save_message_for_confirmation
40
+ Refinery::<%= namespacing %>::Setting.confirmation_message = setting_params[:message] if setting_params.include?('message')
41
+ end
42
+
43
+ private
44
+
45
+ def setting_params
46
+ params.require(:setting).permit(:value,
47
+ subject: Refinery::I18n.frontend_locales,
48
+ message: Refinery::I18n.frontend_locales)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,63 @@
1
+ module Refinery
2
+ module <%= class_name.pluralize %>
3
+ class <%= class_name.pluralize %>Controller < ::ApplicationController
4
+
5
+ before_action :find_page, :only => [:create, :new]
6
+
7
+ def index
8
+ redirect_to refinery.new_<%= plural_name %>_<%= singular_name %>_path
9
+ end
10
+
11
+ def thank_you
12
+ @page = Refinery::Page.where(link_url: "/<%= plural_name %>/thank_you").first
13
+ end
14
+
15
+ def new
16
+ @<%= singular_name %> = <%= class_name %>.new
17
+ end
18
+
19
+ def create
20
+ @<%= singular_name %> = <%= class_name %>.new(<%= singular_name %>_params)
21
+
22
+ if @<%= singular_name %>.save
23
+ begin
24
+ Mailer.notification(@<%= singular_name %>, request).deliver
25
+ rescue => e
26
+ logger.warn "There was an error delivering the <%= singular_name %> notification.\n#{e.message}\n"
27
+ end<% if include_spam? %> if @<%= singular_name %>.ham?<% end %>
28
+
29
+ if <%= class_name %>.column_names.map(&:to_s).include?('email')
30
+ begin
31
+ Mailer.confirmation(@<%= singular_name %>, request).deliver
32
+ rescue => e
33
+ logger.warn "There was an error delivering the <%= singular_name %> confirmation:\n#{e.message}\n"
34
+ end<% if include_spam? %> if @<%= singular_name %>.ham?<% end %>
35
+ else
36
+ logger.warn "Please add an 'email' field to <%= class_name %> if you wish to send confirmation emails when forms are submitted."
37
+ end
38
+
39
+ redirect_to refinery.thank_you_<%= namespacing.underscore %>_<%= plural_name %>_path
40
+ else
41
+ render :action => 'new'
42
+ end
43
+ end
44
+
45
+ protected
46
+
47
+ def find_page
48
+ @page = Refinery::Page.where(link_url: "/<%= plural_name %>/new").first
49
+ end
50
+
51
+ private
52
+
53
+ # Only allow a trusted parameter "white list" through.
54
+ def <%= "#{singular_table_name}_params" %>
55
+ <%- if attributes_names.empty? -%>
56
+ params[:<%= singular_table_name %>]
57
+ <%- else -%>
58
+ params.require(:<%= singular_table_name %>).permit(<%= attributes.map { |attr| ":#{attr.column_name}" }.join(', ') %>)
59
+ <%- end -%>
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,22 @@
1
+ module Refinery
2
+ module <%= namespacing %>
3
+ class Mailer < ::ActionMailer::Base
4
+
5
+ def confirmation(<%= singular_name %>, request)
6
+ @<%= singular_name %> = <%= singular_name %>
7
+ mail :subject => Refinery::<%= namespacing %>::Setting.confirmation_subject,
8
+ :to => <%= singular_name %>.email,
9
+ :from => "\"#{Refinery::Core.site_name}\" <no-reply@#{request.domain}>",
10
+ :reply_to => Refinery::<%= namespacing %>::Setting.notification_recipients.split(',').first
11
+ end
12
+
13
+ def notification(<%= singular_name %>, request)
14
+ @<%= singular_name %> = <%= singular_name %>
15
+ mail :subject => Refinery::<%= namespacing %>::Setting.notification_subject,
16
+ :to => Refinery::<%= namespacing %>::Setting.notification_recipients,
17
+ :from => "\"#{Refinery::Core.site_name}\" <no-reply@#{request.domain}>"
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,40 @@
1
+ module Refinery
2
+ module <%= namespacing %>
3
+ class Setting
4
+ class << self
5
+ def confirmation_message
6
+ Refinery::Setting.find_or_set(:<%= singular_name %>_confirmation_message,
7
+ "Thank you for your <%= singular_name.humanize.downcase %> %name%,\n\nThis email is a receipt to confirm we have received your <%= singular_name.humanize.downcase %> and we'll be in touch shortly.\n\nThanks."
8
+ )
9
+ end
10
+
11
+ def confirmation_subject
12
+ Refinery::Setting.find_or_set(:<%= singular_name %>_confirmation_subject,
13
+ "Thank you for your <%= singular_name.humanize.downcase %>")
14
+ end
15
+
16
+ def notification_recipients
17
+ Refinery::Setting.find_or_set(:<%= singular_name %>_notification_recipients,
18
+ "you@example.com")
19
+ end
20
+
21
+ def notification_subject
22
+ Refinery::Setting.find_or_set(:<%= singular_name %>_notification_subject,
23
+ "New <%= singular_name.humanize.downcase %> from your website")
24
+ end
25
+
26
+ def confirmation_message=(value)
27
+ Refinery::Setting.set(:<%= singular_name %>_confirmation_message, value)
28
+ end
29
+
30
+ def confirmation_subject=(value)
31
+ Refinery::Setting.set(:<%= singular_name %>_confirmation_subject, value)
32
+ end
33
+
34
+ def notification_recipients=(value)
35
+ Refinery::Setting.set(:<%= singular_name %>_notification_recipients, value)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,53 @@
1
+ <% if include_spam? %>
2
+ require 'filters_spam'
3
+ <% end %>
4
+ module Refinery
5
+ module <%= class_name.pluralize %>
6
+ class <%= class_name %> < Refinery::Core::BaseModel
7
+ <% if table_name == namespacing.underscore.pluralize -%>
8
+ self.table_name = 'refinery_<%= plural_name %>'
9
+ <% end -%>
10
+ <% if include_spam? %>
11
+ filters_spam author_field: :name
12
+ <% end %>
13
+
14
+ <% if (text_fields = attributes.map { |a| a.name if a.refinery_type == :text }.compact.uniq).any? && text_fields.detect{ |a| a.to_s == 'message' }.nil? -%>
15
+ alias_attribute :message, :<%= text_fields.first %>
16
+ <% elsif text_fields.empty? -%>
17
+
18
+ # def message was created automatically because you didn't specify a text field
19
+ # when you ran the refinery:form generator. <3 <3 Refinery CMS.
20
+ def message
21
+ "Override def message in vendor/extensions/<%= namespacing.underscore %>/app/models/refinery/<%= namespacing.underscore %>/<%= singular_name %>.rb"
22
+ end
23
+ <% end -%>
24
+ <% unless (string_fields = attributes.map { |a| a.name if a.refinery_type == :string }.compact.uniq).empty? || string_fields.detect { |f| f.to_s == 'name' } -%>
25
+
26
+ alias_attribute :name, :<%= string_fields.first %>
27
+ <% end -%>
28
+
29
+ # Add some validation here if you want to validate the user's input
30
+ <% if string_fields.any? -%>
31
+ # We have validated the first string field for you.
32
+ validates :<%= string_fields.first %>, :presence => true
33
+ <% else %>
34
+ # def name was created automatically because you didn't specify a string field
35
+ # when you ran the refinery:form generator. <3 <3 Refinery CMS.
36
+ def name
37
+ "Override def name in vendor/extensions/<%= namespacing.underscore %>/app/models/refinery/<%= namespacing.underscore %>/<%= singular_name %>.rb"
38
+ end
39
+ <% end -%>
40
+ <% image_attributes.each do |a| -%>
41
+
42
+ belongs_to :<%= a.name -%>, :class_name => 'Refinery::Image'
43
+ <% end -%>
44
+ <% resource_attributes.each do |a| -%>
45
+
46
+ belongs_to :<%= a.name %>, :class_name => 'Refinery::Resource'
47
+ <% end -%>
48
+ <% attributes.select{ |a| /radio|select/ === a.refinery_type.to_s }.uniq.each do |a| %>
49
+ <%= a.name.pluralize.upcase %> = []
50
+ <% end -%>
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,23 @@
1
+ <%%= render 'refinery/admin/search_header', :url => refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path %>
2
+ <%% if searching? %>
3
+ <%% if @<%= plural_name %>.any? %>
4
+ <ul>
5
+ <%%= render :partial => '<%= singular_name %>', :collection => @<%= plural_name %> %>
6
+ </ul>
7
+ <%% else %>
8
+ <p><%%= t('no_results', :scope => 'refinery.admin.search') %></p>
9
+ <%% end %>
10
+ <%% else %>
11
+ <%% if @grouped_<%= plural_name %>.any? -%>
12
+ <%% @grouped_<%= plural_name %>.each do |container| %>
13
+ <h3><%%= l((<%= singular_name %>_group = container.last).first.created_at, :format => :short) %></h3>
14
+ <ul>
15
+ <%%= render :partial => '<%= singular_name %>', :collection => <%= singular_name %>_group %>
16
+ </ul>
17
+ <%% end %>
18
+ <%% else -%>
19
+ <p>
20
+ <strong><%%= t('no_<%= plural_name %>', :scope => 'refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.index') %></strong>
21
+ </p>
22
+ <%% end -%>
23
+ <%% end %>
@@ -0,0 +1,25 @@
1
+ <li class='clearfix record <%%= cycle("on", "on-hover") %>'>
2
+ <span class='title'>
3
+ <%%= link_to <%= singular_name %>.name, refinery.<%= namespacing.underscore %>_admin_<%= singular_name %>_path(<%= singular_name %>) %> <%%= t('.said') %>
4
+ <span class="preview"><%%= truncate(strip_tags(sanitize(<%= singular_name %>.message)), :length => 60) -%></span>
5
+ </span>
6
+ <span class='actions'>
7
+ <%%= link_to refinery_icon_tag('delete.png'), refinery.<%= namespacing.underscore %>_admin_<%= singular_name %>_path(<%= singular_name %>),
8
+ :class => "cancel confirm-delete",
9
+ :title => t('.delete_<%= singular_name %>'),
10
+ :'data-confirm' => t('shared.admin.delete.message', :title => <%= singular_name %>.name),
11
+ :'data-method' => "delete" -%>
12
+
13
+ <%%= link_to refinery_icon_tag('zoom.png'), refinery.<%= namespacing.underscore %>_admin_<%= singular_name %>_path(<%= singular_name %>),
14
+ :title => t('.read_<%= singular_name %>') -%>
15
+ <% if include_spam? %>
16
+ <%% if <%= singular_name %>.spam? %>
17
+ <%%= link_to refinery_icon_tag('email.png'), refinery.toggle_spam_<%= namespacing.underscore %>_admin_<%= singular_name %>_path(<%= singular_name %>),
18
+ :title => t('.mark_as_ham') -%>
19
+ <%% else %>
20
+ <%%= link_to refinery_icon_tag('bin_closed.png'), refinery.toggle_spam_<%= namespacing.underscore %>_admin_<%= singular_name %>_path(<%= singular_name %>),
21
+ :title => t('.mark_as_spam') -%>
22
+ <%% end %>
23
+ <% end -%>
24
+ </span>
25
+ </li>
@@ -0,0 +1,29 @@
1
+ <div id='actions'>
2
+ <ul>
3
+ <%% if ::Refinery::<%= namespacing %>::Admin::<%= class_name.pluralize %>Controller.searchable? %>
4
+ <li>
5
+ <%%= render '/refinery/admin/search', :url => refinery.<%= namespacing.underscore %>_admin_<%= plural_name %><%= "_index" if plural_name == singular_name%>_path %>
6
+ </li>
7
+ <%% end %>
8
+ <li <%%= "class='selected'" if params[:action] == "index" %>>
9
+ <%%= link_to t('.inbox'), refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path, :class => "email_icon" %>
10
+ </li><% if include_spam? %>
11
+ <li <%%= "class='selected'" if params[:action] == "spam" %>>
12
+ <%% if @spam_count > 0 %>
13
+ <%%= link_to "#{t('.spam')} (#{@spam_count})", refinery.spam_<%= namespacing.underscore %>_admin_<%= plural_name %>_path, :class => "spam_icon" %>
14
+ <%% else %>
15
+ <%%= link_to t('.spam'), refinery.spam_<%= namespacing.underscore %>_admin_<%= plural_name %>_path, :class => "spam_empty_icon" %>
16
+ <%% end %>
17
+ </li><% end %>
18
+ <li>
19
+ <%%= link_to t('.update_notified'),
20
+ refinery.edit_<%= namespacing.underscore %>_admin_setting_path(:<%= singular_name %>_notification_recipients, :dialog => true, :height => 300),
21
+ :class => "user_comment_icon" %>
22
+ </li>
23
+ <li>
24
+ <%%= link_to t('.edit_confirmation_email'),
25
+ refinery.edit_<%= namespacing.underscore %>_admin_setting_path(:<%= singular_name %>_confirmation_message, :dialog => true),
26
+ :class => "edit_email_icon" %>
27
+ </li>
28
+ </ul>
29
+ </div>
@@ -0,0 +1,4 @@
1
+ <%%= render 'submenu' %>
2
+ <section id='records'>
3
+ <%%= render 'records' %>
4
+ </section>
@@ -0,0 +1,52 @@
1
+ <div id='records'>
2
+ <h2><%%= t('.<%= singular_name %>') %></h2>
3
+ <table id='<%= singular_name %>' class='<%= singular_name %>'>
4
+ <% attributes.each do |attribute| -%>
5
+ <tr>
6
+ <td<%= " valign='top'" if attribute.type.to_s == 'text' %>>
7
+ <strong>
8
+ <%%= t('.<%= attribute.name %>', :default => t('activerecord.attributes.<%= singular_name %>.<%= attribute.name %>')) %>
9
+ </strong>
10
+ </td>
11
+ <td>
12
+ <% if attribute.type.to_s == 'text' -%>
13
+ <p style='margin-top: 0px'>
14
+ <%% @<%= singular_name %>.message.to_s.gsub("\r\n\r\n", "\r\n").split("\r\n").each_with_index do |sentence, index| %>
15
+ <%%=raw "</p><p>" unless index == 0 %>
16
+ <%%= sentence %>
17
+ <%% end %>
18
+ </p>
19
+ <% else -%>
20
+ <%%= @<%= singular_name %>.<%= attribute.name %> %>
21
+ <% end -%>
22
+ </td>
23
+ </tr>
24
+ <% end -%>
25
+ </table>
26
+ </div>
27
+ <div id='actions'>
28
+ <h2><%%= t('.details')%></h2>
29
+ <p>
30
+ <strong><%%= t('.age') %>:</strong> <%%= time_ago_in_words(@<%= singular_name %>.created_at) %>
31
+ </p><% if include_spam? %>
32
+ <%% if @<%= singular_name %>.spam? %>
33
+ <p>
34
+ <strong><%%= t('.spam') %>:</strong> <%%= t('.spam_yes') %>
35
+ </p>
36
+ <%% end %><% end %>
37
+ <h2><%%= t('.actions') %></h2>
38
+ <ul>
39
+ <li>
40
+ <%%= link_to t('.back_to_all_<%= plural_name %>'), refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path,
41
+ :class => "back_icon" %>
42
+ </li>
43
+ <li>
44
+ <%%= link_to t('delete_<%= singular_name %>', :scope => 'refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.<%= singular_name %>'),
45
+ refinery.<%= namespacing.underscore %>_admin_<%= singular_name %>_path(@<%= singular_name %>),
46
+ :class => 'delete_icon no-tooltip confirm-delete',
47
+ :title => t('delete_<%= singular_name %>', :scope => 'refinery.<%= namespacing.underscore %>.admin.<%= plural_name %>.<%= singular_name %>'),
48
+ :'data-confirm' => t('message', :scope => 'refinery.admin.delete', :title => @<%= singular_name %>.name),
49
+ :'data-method' => "delete" %>
50
+ </li>
51
+ </ul>
52
+ </div>
@@ -0,0 +1,27 @@
1
+ <%%= render 'submenu' %>
2
+ <div id='records'>
3
+ <%% if searching? %>
4
+ <%%= link_to t('cancel_search', :scope => 'refinery.admin.search'), refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path, :class => "cancel-search" %>
5
+ <h2><%%= t('results_for_html', :scope => 'refinery.admin.search', :query => h(params[:search])).html_safe %></h2>
6
+ <%% if @<%= plural_name %>.any? %>
7
+ <ul>
8
+ <%%= render :partial => '<%= singular_name %>', :collection => @<%= plural_name %> %>
9
+ </ul>
10
+ <%% else %>
11
+ <p><%%= t('no_results', :scope => 'refinery.admin.search') %></p>
12
+ <%% end %>
13
+ <%% else %>
14
+ <%% if @grouped_<%= plural_name %>.any? -%>
15
+ <%% @grouped_<%= plural_name %>.each do |container| %>
16
+ <h3><%%= l((<%= singular_name %>_group = container.last).first.created_at) %></h3>
17
+ <ul>
18
+ <%%= render :partial => '<%= singular_name %>', :collection => <%= singular_name %>_group %>
19
+ </ul>
20
+ <%% end %>
21
+ <%% else -%>
22
+ <p>
23
+ <strong><%%= t('.no_spam') %></strong>
24
+ </p>
25
+ <%% end -%>
26
+ <%% end %>
27
+ </div>
@@ -0,0 +1,50 @@
1
+ <%%= form_for @setting, :url => refinery.<%= namespacing.underscore %>_admin_setting_path(@setting) do |f| %>
2
+
3
+ <p>
4
+ <%%= t('.explanation') %>
5
+ </p>
6
+ <p>
7
+ <%%= t('.below_edit_email_sent') %>
8
+ </p>
9
+ <table id='<%= singular_name %>'>
10
+ <tr>
11
+ <td>
12
+ <label class='stripped'><%%= t('.to') %></label>
13
+ </td>
14
+ <td>
15
+ <%%= t('.the_customer_making_<%= singular_name %>') %>
16
+ </td>
17
+ </tr>
18
+ <tr>
19
+ <td>
20
+ <label class='stripped'><%%= t('.from') %></label>
21
+ </td>
22
+ <td>
23
+ <%%= "#{Refinery::Core.site_name} &lt;no-reply@#{request.domain}&gt;".html_safe %>
24
+ </td>
25
+ </tr>
26
+ <tr>
27
+ <td>
28
+ <%%= label_tag "setting[subject[#{locale.to_s}]]", t('.subject'), :class => 'stripped' %>
29
+ </td>
30
+ <td>
31
+ <%%= text_field_tag "setting[subject[#{locale.to_s}]]", Refinery::<%= namespacing %>::Setting.confirmation_subject, :class => 'widest' %>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <td valign='top'>
36
+ <%%= label_tag "setting[message[#{locale.to_s}]]", t('.message'), :class => 'stripped' %>
37
+ </td>
38
+ <td>
39
+ <%%= text_area_tag "setting[message[#{locale.to_s}]]", Refinery::<%= namespacing %>::Setting.confirmation_message, :rows => "7", :class => 'widest' %>
40
+ <br/>
41
+ <em><%%= t('.note') %></em>
42
+ </td>
43
+ </tr>
44
+ </table>
45
+
46
+ <%%= render '/refinery/admin/form_actions', :f => f,
47
+ :continue_editing => false,
48
+ :cancel_url => refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_url,
49
+ :hide_delete => true %>
50
+ <%% end %>