forge-cli 0.0.18 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +106 -0
  3. data/bin/cucumber +16 -0
  4. data/bin/erubis +16 -0
  5. data/bin/htmldiff +16 -0
  6. data/bin/ldiff +16 -0
  7. data/bin/rackup +16 -0
  8. data/bin/rake +16 -0
  9. data/bin/rdoc +16 -0
  10. data/bin/ri +16 -0
  11. data/bin/sprockets +16 -0
  12. data/bin/thor +16 -0
  13. data/bin/tilt +16 -0
  14. data/bin/tt +16 -0
  15. data/lib/forge-cli.rb +1 -0
  16. data/lib/forge-cli/application_creator.rb +25 -6
  17. data/lib/forge-cli/controller_module_includer.rb +43 -0
  18. data/lib/forge-cli/module_installer.rb +18 -13
  19. data/lib/forge-cli/modules/banners/routes.rb +1 -1
  20. data/lib/forge-cli/modules/base/forge_routes.rb +4 -4
  21. data/lib/forge-cli/modules/base/manifest.yml +9 -4
  22. data/lib/forge-cli/modules/base/post_hooks.rb +9 -2
  23. data/lib/forge-cli/modules/base/routes.rb +4 -4
  24. data/lib/forge-cli/modules/dispatches/forge_routes.rb +2 -2
  25. data/lib/forge-cli/modules/dispatches/manifest.yml +2 -1
  26. data/lib/forge-cli/modules/ecommerce/manifest.yml +5 -1
  27. data/lib/forge-cli/modules/ecommerce/post_hooks.rb +13 -21
  28. data/lib/forge-cli/modules/events/routes.rb +1 -1
  29. data/lib/forge-cli/modules/posts/manifest.yml +4 -1
  30. data/lib/forge-cli/modules/posts/post_hooks.rb +9 -17
  31. data/lib/forge-cli/modules/posts/routes.rb +1 -1
  32. data/lib/forge-cli/modules/videos/routes.rb +1 -1
  33. data/lib/forge-cli/version.rb +2 -2
  34. data/lib/forge/Gemfile +3 -9
  35. data/lib/forge/Gemfile.lock +214 -210
  36. data/lib/forge/app/controllers/forge/help_topics_controller.rb +2 -2
  37. data/lib/forge/app/controllers/forge/posts_controller.rb +1 -0
  38. data/lib/forge/app/controllers/forge/products_controller.rb +0 -4
  39. data/lib/forge/app/controllers/forge/users_controller.rb +0 -1
  40. data/lib/forge/app/controllers/forge_controller.rb +7 -6
  41. data/lib/forge/app/controllers/posts_controller.rb +0 -2
  42. data/lib/forge/app/controllers/sessions_controller.rb +2 -3
  43. data/lib/forge/app/helpers/forge_helper.rb +2 -2
  44. data/lib/forge/app/models/address.rb +3 -0
  45. data/lib/forge/app/models/asset.rb +9 -10
  46. data/lib/forge/app/models/banner.rb +3 -1
  47. data/lib/forge/app/models/comment.rb +17 -2
  48. data/lib/forge/app/models/comment_subscriber.rb +3 -0
  49. data/lib/forge/app/models/contact.rb +3 -0
  50. data/lib/forge/app/models/country.rb +5 -2
  51. data/lib/forge/app/models/dispatch.rb +5 -2
  52. data/lib/forge/app/models/dispatch_bounce.rb +3 -0
  53. data/lib/forge/app/models/dispatch_link.rb +4 -1
  54. data/lib/forge/app/models/dispatch_link_click.rb +4 -0
  55. data/lib/forge/app/models/dispatch_open.rb +5 -1
  56. data/lib/forge/app/models/dispatch_unsubscribe.rb +4 -0
  57. data/lib/forge/app/models/event.rb +3 -1
  58. data/lib/forge/app/models/gallery.rb +4 -1
  59. data/lib/forge/app/models/help_topic.rb +4 -1
  60. data/lib/forge/app/models/line_item.rb +2 -2
  61. data/lib/forge/app/models/order.rb +1 -1
  62. data/lib/forge/app/models/order_transaction.rb +3 -0
  63. data/lib/forge/app/models/page.rb +5 -5
  64. data/lib/forge/app/models/photo.rb +5 -1
  65. data/lib/forge/app/models/post.rb +3 -1
  66. data/lib/forge/app/models/post_category.rb +4 -0
  67. data/lib/forge/app/models/product.rb +4 -2
  68. data/lib/forge/app/models/product_category.rb +4 -1
  69. data/lib/forge/app/models/product_image.rb +4 -0
  70. data/lib/forge/app/models/province.rb +4 -1
  71. data/lib/forge/app/models/queued_dispatch.rb +7 -4
  72. data/lib/forge/app/models/role.rb +3 -0
  73. data/lib/forge/app/models/sale.rb +2 -0
  74. data/lib/forge/app/models/subscriber.rb +4 -0
  75. data/lib/forge/app/models/subscriber_group.rb +4 -0
  76. data/lib/forge/app/models/subscriber_group_member.rb +4 -0
  77. data/lib/forge/app/models/tax_rate.rb +5 -2
  78. data/lib/forge/app/models/user.rb +1 -2
  79. data/lib/forge/app/models/video.rb +2 -0
  80. data/lib/forge/app/models/video_feed.rb +2 -2
  81. data/lib/forge/app/views/forge/assets/_asset.html.haml +1 -1
  82. data/lib/forge/app/views/forge/posts/_post.html.haml +5 -2
  83. data/lib/forge/app/views/forge/settings/_ecommerce.html.haml +4 -0
  84. data/lib/forge/app/views/forge/subscribers/_subscriber.html.haml +2 -2
  85. data/lib/forge/app/views/user_mailer/approved.html.haml +1 -1
  86. data/lib/forge/config/application.rb +3 -9
  87. data/lib/forge/config/database.yml.template +30 -0
  88. data/lib/forge/config/environments/development.rb +3 -7
  89. data/lib/forge/config/environments/production.rb +6 -0
  90. data/lib/forge/config/environments/test.rb +5 -3
  91. data/lib/forge/config/initializers/ckeditor.rb +15 -143
  92. data/lib/forge/config/initializers/devise.rb +12 -2
  93. data/lib/forge/config/initializers/ecommerce.rb +1 -1
  94. data/lib/forge/config/initializers/secret_token.rb +1 -10
  95. data/lib/forge/config/routes.rb +7 -11
  96. data/lib/forge/config/settings.yml +82 -5
  97. data/lib/forge/config/sitemap.yml +3 -1
  98. data/lib/forge/db/migrate/20130405172031_create_products_tax_rates.rb +15 -0
  99. data/lib/forge/db/migrate/{20130405172040_create_subscribers copy.rb → 20130405172040_create_subscribers.rb} +0 -0
  100. data/lib/forge/db/seeds.rb +304 -298
  101. data/lib/forge/doc/update_to_rails4_notes.md +15 -0
  102. data/lib/forge/lib/assets/javascripts/forge/features/help.js.erb +5 -4
  103. data/lib/forge/lib/assets/javascripts/forge/forge_manifest.js.erb +2 -2
  104. data/lib/forge/lib/assets/stylesheets/forge/forge.ui.css.scss +4 -3
  105. data/lib/forge/lib/forge/can_use_asset.rb +5 -7
  106. data/lib/forge/lib/forge/config/ecommerce.rb +3 -3
  107. data/lib/forge/lib/forge/shared_controller_methods/ecommerce.rb +3 -3
  108. data/lib/forge/lib/generators/forge/scaffold/USAGE +1 -1
  109. data/lib/forge/lib/tasks/forge.rake +5 -10
  110. data/lib/forge/public/500.html +1 -0
  111. data/lib/forge/public/javascripts/ckeditor/config.js +0 -1
  112. metadata +39 -39
  113. data/README.rdoc +0 -4
  114. data/lib/forge/app/models/comment_observer.rb +0 -9
  115. data/lib/forge/app/sweepers/page_sweeper.rb +0 -11
@@ -1,4 +1,8 @@
1
1
  class PostCategory < ActiveRecord::Base
2
2
  has_and_belongs_to_many :posts
3
3
  validates_uniqueness_of :title
4
+
5
+ # open up everything for mass assignment
6
+ attr_protected
7
+
4
8
  end
@@ -1,8 +1,8 @@
1
1
  class Product < ActiveRecord::Base
2
2
  # Scopes and Inclusions
3
3
  include Forge::Reorderable
4
- default_scope :order => 'products.list_order ASC'
5
- scope :published, :conditions => ["published = ?", true]
4
+ default_scope { order('products.list_order ASC') }
5
+ scope :published, -> { where(published: true) }
6
6
 
7
7
  # Relationships
8
8
  has_many :images, :class_name => "ProductImage"
@@ -17,6 +17,8 @@ class Product < ActiveRecord::Base
17
17
  validates_presence_of :short_description, :description, :if => :published
18
18
  validates_numericality_of :price, :flat_rate_shipping, :weight, :width, :height, :depth, :greater_than_or_equal_to => 0.00
19
19
 
20
+ # open up everything for mass assignment
21
+ attr_protected
20
22
 
21
23
  # for when the product is used in the cart or in an order hash
22
24
  def quantity
@@ -1,6 +1,6 @@
1
1
  class ProductCategory < ActiveRecord::Base
2
2
  include Forge::Reorderable
3
- default_scope :order => 'product_categories.list_order'
3
+ default_scope { order('product_categories.list_order') }
4
4
  before_destroy :validate_destroy
5
5
  has_many :products
6
6
  belongs_to :sale
@@ -9,6 +9,9 @@ class ProductCategory < ActiveRecord::Base
9
9
 
10
10
  validates_presence_of :title
11
11
 
12
+ # open up everything for mass assignment
13
+ attr_protected
14
+
12
15
  def validate_destroy
13
16
  products.count < 1
14
17
  end
@@ -4,4 +4,8 @@ class ProductImage < ActiveRecord::Base
4
4
 
5
5
  validates_attachment_presence :image
6
6
  validates_attachment_content_type :image, :content_type => ['image/gif', 'image/png', 'image/jpeg', 'image/jpg', 'image/pjpeg']
7
+
8
+ # open up everything for mass assignment
9
+ attr_protected
10
+
7
11
  end
@@ -1,6 +1,6 @@
1
1
  class Province < ActiveRecord::Base
2
2
  # Scopes, Attrs, Etc.
3
- default_scope order("title ASC")
3
+ default_scope { order("title ASC") }
4
4
 
5
5
  # Relationships
6
6
  belongs_to :country
@@ -10,6 +10,9 @@ class Province < ActiveRecord::Base
10
10
  # Validations
11
11
  validates_presence_of :title, :code
12
12
  validates_uniqueness_of :title, :code
13
+
14
+ # open up everything for mass assignment
15
+ attr_protected
13
16
 
14
17
  def self.options_for_select(options={})
15
18
  options[:add_blank] ||= false
@@ -4,10 +4,13 @@ class QueuedDispatch < ActiveRecord::Base
4
4
  belongs_to :subscriber
5
5
 
6
6
  # Scopes
7
- scope :queued, where('sent_at IS NULL')
8
- scope :sent, where("sent_at IS NOT NULL")
9
- scope :failed, where("failed_attempts > ?", 0)
10
- scope :opened, where("opened_at IS NOT NULL")
7
+ scope :queued, -> { where('sent_at IS NULL') }
8
+ scope :sent, -> { where("sent_at IS NOT NULL") }
9
+ scope :failed, -> { where("failed_attempts > ?", 0) }
10
+ scope :opened, -> { where("opened_at IS NOT NULL") }
11
+
12
+ # open up everything for mass assignment
13
+ attr_protected
11
14
 
12
15
  # Action Methods
13
16
  def send!
@@ -1,3 +1,6 @@
1
1
  class Role < ActiveRecord::Base
2
2
  has_and_belongs_to_many :users
3
+ validates :title, presence: true
4
+ attr_accessible :title
5
+
3
6
  end
@@ -5,6 +5,8 @@ class Sale < ActiveRecord::Base
5
5
  validates_presence_of :title, :description, :start, :end
6
6
  validates_numericality_of :value
7
7
 
8
+ # open up everything for mass assignment
9
+ attr_protected
8
10
 
9
11
  # Define the types of sale calculation
10
12
  @@sale_types = {:fixed => "All products in this sale are set to the same price. (e.g. Sale = $5.50: Product A = $5.50, Product B = $5.50",
@@ -2,4 +2,8 @@ class Subscriber < ActiveRecord::Base
2
2
  validates :email, :presence => true, :uniqueness => true
3
3
  has_many :subscriber_group_members
4
4
  has_many :groups, :through => :subscriber_group_members, :class_name => "SubscriberGroup"
5
+
6
+ # open up everything for mass assignment
7
+ attr_protected
8
+
5
9
  end
@@ -3,4 +3,8 @@ class SubscriberGroup < ActiveRecord::Base
3
3
  validates_uniqueness_of :title
4
4
  has_many :subscriber_group_members, :foreign_key => :group_id
5
5
  has_many :subscribers, :through => :subscriber_group_members
6
+
7
+ # open up everything for mass assignment
8
+ attr_protected
9
+
6
10
  end
@@ -1,4 +1,8 @@
1
1
  class SubscriberGroupMember < ActiveRecord::Base
2
2
  belongs_to :group, :class_name => "SubscriberGroup", :foreign_key => "group_id"
3
3
  belongs_to :subscriber
4
+
5
+ # open up everything for mass assignment
6
+ attr_protected
7
+
4
8
  end
@@ -8,7 +8,10 @@ class TaxRate < ActiveRecord::Base
8
8
  validate :unique_country_and_province
9
9
 
10
10
  # the new ActiveAssociation stuff is teh bomb!
11
- scope :by_country_and_province, joins(:country).joins("LEFT OUTER JOIN provinces ON tax_rates.province_id = provinces.id").order('countries.title, provinces.title')
11
+ scope :by_country_and_province, -> { joins(:country).joins("LEFT OUTER JOIN provinces ON tax_rates.province_id = provinces.id").order('countries.title, provinces.title') }
12
+
13
+ # open up everything for mass assignment
14
+ attr_protected
12
15
 
13
16
  protected
14
17
 
@@ -19,7 +22,7 @@ class TaxRate < ActiveRecord::Base
19
22
  tax_rates = TaxRate.where(:country_id => self.country_id, :province_id => self.province_id).all
20
23
  end
21
24
  if tax_rates.size > 0
22
- errors.add :base, "A tax rate already exists for this country and province"
25
+ errors.add :base, "A tax rate already exists for this country and province"
23
26
  end
24
27
  end
25
28
 
@@ -1,8 +1,7 @@
1
1
  class User < ActiveRecord::Base
2
2
  # Include default devise modules. Others available are:
3
3
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
4
- devise :database_authenticatable, :registerable,
5
- :recoverable, :rememberable, :trackable, :validatable
4
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
6
5
 
7
6
  # Setup accessible (or protected) attributes for your model
8
7
  attr_accessible :email, :password, :password_confirmation, :remember_me, :avatar, :avatar_asset_id, :avatar_asset_url
@@ -15,6 +15,8 @@ class Video < ActiveRecord::Base
15
15
 
16
16
  before_update :revert_if_new_upload
17
17
 
18
+ # open up everything for mass assignment
19
+ attr_protected
18
20
 
19
21
  def video=(filename)
20
22
  self.video_file_name = filename.gsub('videos/', '')
@@ -3,7 +3,7 @@ class VideoFeed < ActiveRecord::Base
3
3
  require 'open-uri'
4
4
 
5
5
  # Scopes, attachments, etc.
6
- default_scope :order => "published_at DESC"
6
+ default_scope { order("published_at DESC") }
7
7
 
8
8
  # Validations
9
9
  validates_presence_of :video_id, :title, :channel
@@ -83,4 +83,4 @@ class VideoFeed < ActiveRecord::Base
83
83
  :source => item.link.split("://")[1].split(".com")[0]
84
84
  )
85
85
  end
86
- end
86
+ end
@@ -9,4 +9,4 @@
9
9
  = asset.list_title
10
10
  .spacer
11
11
  .float-left= link_to "Edit", edit_forge_asset_path(asset), :class => ("basic-asset-edit" unless asset.attachment_content_type.match(/video/))
12
- .float-right= link_to "Delete", forge_asset_path(asset), :method => :delete, :confirm => "Are you sure?"
12
+ .float-right= link_to "Delete", forge_asset_path(asset), :method => :delete, :data => { :confirm => "Are you sure?" }
@@ -4,7 +4,10 @@
4
4
  = "(Draft)" unless post.published?
5
5
 
6
6
  %br/
7
- %small Posted in #{post.post_categories.map(&:title).to_sentence}
7
+ - if post.post_categories.empty?
8
+ %small Uncategorized
9
+ - else
10
+ %small Posted in #{post.post_categories.map(&:title).to_sentence}
8
11
  .item-actions
9
12
  .item-info{:style => "width: 137px;"}
10
13
  %strong= post.created_at.strftime('%B %e, %Y')
@@ -14,4 +17,4 @@
14
17
  = edit_link(post)
15
18
  = delete_link(post)
16
19
 
17
- .spacer
20
+ .spacer
@@ -32,6 +32,10 @@
32
32
  = collection_select(:settings, :shipper, @carriers, :name, :name, {:include_blank => true})
33
33
  %hr
34
34
 
35
+ %h3 Tax Rates
36
+ .explanation
37
+ = link_to "Click here to manage your tax rates", forge_tax_rates_path
38
+
35
39
  .spacer
36
40
 
37
41
  .spacer
@@ -2,11 +2,11 @@
2
2
  .item-title
3
3
  %strong= link_to subscriber.name, "mailto:#{subscriber.email}"
4
4
  .item-actions
5
- .item-action.edit{:style => "width: 110px;"}<
5
+ .item-action.edit
6
6
  = link_to image_tag('forge/icons/edit.png', :style => "vertical-align: middle;"), edit_forge_subscriber_path(subscriber)
7
7
  %small= link_to "Edit", edit_forge_subscriber_path(subscriber)
8
8
  .item-action.last<
9
9
  = link_to image_tag('forge/icons/delete.png', :style => "vertical-align: middle;"), forge_subscriber_path(subscriber), :method => :delete, :confirm => "Are you sure?"
10
10
  %small= link_to "Delete", forge_subscriber_path(subscriber), :method => :delete, :confirm => "Are you sure?"
11
11
 
12
- .spacer
12
+ .spacer
@@ -1,3 +1,3 @@
1
1
  %p You have received a message! Reply to this email to get in touch with the person who sent it.
2
2
 
3
- %p You can now #{link_to "log in here", "#{MySettings.full_url}/login"}.
3
+ %p You can now #{link_to "log in here", "#{MySettings.site_url}/login"}.
@@ -3,10 +3,9 @@ require File.expand_path('../boot', __FILE__)
3
3
  require 'rails/all'
4
4
 
5
5
  if defined?(Bundler)
6
- # If you precompile assets before deploying to production, use this line
7
- Bundler.require *Rails.groups(:assets => %w(development test))
8
- # If you want your assets lazily compiled in production, use this line
9
- # Bundler.require(:default, :assets, Rails.env)
6
+ # Require the gems listed in Gemfile, including any gems
7
+ # you've limited to :test, :development, or :production.
8
+ Bundler.require(:default, Rails.env)
10
9
  end
11
10
 
12
11
  module Forge3
@@ -22,9 +21,6 @@ module Forge3
22
21
  # :all can be used as a placeholder for all plugins not explicitly named.
23
22
  # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
23
 
25
- # Activate observers that should always be running.
26
- config.active_record.observers = :comment_observer
27
-
28
24
  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
25
  # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
26
  config.time_zone = 'Eastern Time (US & Canada)'
@@ -42,8 +38,6 @@ module Forge3
42
38
  # Configure sensitive parameters which will be filtered from the log file.
43
39
  config.filter_parameters << :password << :password_confirmation << :credit_card
44
40
 
45
- config.action_controller.page_cache_directory = File.join(Rails.public_path, 'system', 'cache')
46
-
47
41
  config.autoload_paths += [
48
42
  File.join(Rails.root, 'lib'),
49
43
  File.join(Rails.root, 'app', 'form_builders'),
@@ -0,0 +1,30 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
+ development:
4
+ adapter: mysql2
5
+ encoding: utf8
6
+ database: _development
7
+ username:
8
+ password:
9
+ socket:
10
+
11
+ # Warning: The database defined as "test" will be erased and
12
+ # re-generated from your development database when you run "rake".
13
+ # Do not set this db to the same as development or production.
14
+ test:
15
+ adapter: mysql2
16
+ encoding: utf8
17
+ database: _test
18
+ username:
19
+ password:
20
+ socket:
21
+
22
+ production:
23
+ adapter: mysql2
24
+ encoding: utf8
25
+ reconnect: true
26
+ database: _production
27
+ pool: 5
28
+ username:
29
+ password:
30
+ host: 10.200.113.226
@@ -1,14 +1,14 @@
1
1
  Forge3::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/environment.rb
3
3
 
4
+ # Do not eager load code on boot.
5
+ config.eager_load = false
6
+
4
7
  # In the development environment your application's code is reloaded on
5
8
  # every request. This slows down response time but is perfect for development
6
9
  # since you don't have to restart the webserver when you make code changes.
7
10
  config.cache_classes = false
8
11
 
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
@@ -34,10 +34,6 @@ Forge3::Application.configure do
34
34
 
35
35
  # Raise exception on mass assignment protection for Active Record models
36
36
  config.active_record.mass_assignment_sanitizer = :strict
37
-
38
- # Log the query plan for queries taking more than this (works
39
- # with SQLite, MySQL, and PostgreSQL)
40
- config.active_record.auto_explain_threshold_in_seconds = 999
41
37
  end
42
38
 
43
39
  ActionMailer::Base.raise_delivery_errors = true
@@ -4,6 +4,12 @@ Forge3::Application.configure do
4
4
  # e-commerce sites: uncomment this line once the SSL certificate is in place
5
5
  # config.force_ssl = true
6
6
 
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
7
13
  # The production environment is meant for finished, "live" apps.
8
14
  # Code is not reloaded between requests
9
15
  config.cache_classes = true
@@ -1,15 +1,17 @@
1
1
  Forge3::Application.configure do
2
2
  # Settings specified here will take precedence over those in config/environment.rb
3
3
 
4
+ # Do not eager load code on boot. This avoids loading your whole application
5
+ # just for the purpose of running a single test. If you are using a tool that
6
+ # preloads Rails for running tests, you may have to set it to true.
7
+ config.eager_load = false
8
+
4
9
  # The test environment is used exclusively to run your application's
5
10
  # test suite. You never need to work with it otherwise. Remember that
6
11
  # your test database is "scratch space" for the test suite and is wiped
7
12
  # and recreated between test runs. Don't rely on the data there!
8
13
  config.cache_classes = true
9
14
 
10
- # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
12
-
13
15
  # Show full error reports and disable caching
14
16
  config.consider_all_requests_local = true
15
17
  config.action_controller.perform_caching = false
@@ -1,147 +1,19 @@
1
- module Ckeditor
2
- module Utils
3
- class << self
4
- def escape_single_quotes(str)
5
- str.gsub('\\','\0\0').gsub('</','<\/').gsub(/\r\n|\n|\r/, "\\n").gsub(/["']/) { |m| "\\#{m}" }
6
- end
7
-
8
- def parameterize_filename(filename)
9
- extension = File.extname(filename)
10
- basename = filename.gsub(/#{extension}$/, "")
11
-
12
- [basename.parameterize('_'), extension].join.downcase
13
- end
14
-
15
- def js_replace(dom_id, options = {})
16
- js_options = applay_options(options)
17
- js = ["if (CKEDITOR.instances['#{dom_id}']) {CKEDITOR.remove(CKEDITOR.instances['#{dom_id}']);}"]
18
-
19
- if js_options.blank?
20
- js << "CKEDITOR.replace('#{dom_id}');"
21
- else
22
- js << "CKEDITOR.replace('#{dom_id}', { #{js_options} });"
23
- end
24
-
25
- js.join
26
- end
27
-
28
- def js_fileuploader(uploader_type, options = {})
29
- options = { :multiple => true, :element => "fileupload" }.merge(options)
30
-
31
- case uploader_type.to_s.downcase
32
- when "image" then
33
- options[:action] = "^EDITOR.config.filebrowserImageUploadUrl"
34
- options[:allowedExtensions] = Ckeditor.image_file_types
35
- when "flash" then
36
- options[:action] = "^EDITOR.config.filebrowserFlashUploadUrl"
37
- options[:allowedExtensions] = ["swf"]
38
- else
39
- options[:action] = "^EDITOR.config.filebrowserUploadUrl"
40
- options[:allowedExtensions] = Ckeditor.attachment_file_types
41
- end
42
-
43
- js_options = applay_options(options)
44
-
45
- "$(document).ready(function(){ new qq.FileUploaderInput({ #{js_options} }); });".html_safe
46
- end
47
-
48
- def applay_options(options)
49
- str = []
50
-
51
- options.each do |key, value|
52
- item = case value
53
- when String then
54
- value.split(//).first == '^' ? value.slice(1..-1) : "'#{value}'"
55
- when Hash then
56
- "{ #{applay_options(value)} }"
57
- when Array then
58
- arr = value.collect { |v| "'#{v}'" }
59
- "[ #{arr.join(',')} ]"
60
- else value
61
- end
62
-
63
- str << %Q{"#{key}": #{item}}
64
- end
65
-
66
- str.sort.join(',')
67
- end
68
-
69
- def filethumb(filename)
70
- extname = filename.blank? ? "unknown" : File.extname(filename).gsub(/^\./, '')
71
- image = "#{extname}.gif"
72
- source = Ckeditor.root_path.join("vendor/assets/javascripts/ckeditor/filebrowser/images/thumbs")
73
-
74
- unless File.exists?(File.join(source, image))
75
- image = "unknown.gif"
76
- end
77
-
78
- File.join(Ckeditor.relative_path, "filebrowser/images/thumbs", image)
79
- end
80
- end
81
- end
82
- end
83
-
84
- module Ckeditor
85
- module Helpers
86
- module FormBuilder
87
- extend ActiveSupport::Concern
88
-
89
- def cktext_area(method, options = {})
90
- @template.send("cktext_area", @object_name, method, objectify_options(options))
91
- end
92
- end
93
- end
94
- end
95
-
96
- module Ckeditor
97
- module Helpers
98
- module ViewHelper
99
- extend ActiveSupport::Concern
100
-
101
- def cktext_area_tag(name, content = nil, options = {})
102
- element_id = sanitize_to_id(name)
103
- options = { :language => I18n.locale.to_s }.merge(options)
104
- input_html = { :id => element_id }.merge( options.delete(:input_html) || {} )
105
-
106
- output_buffer = ActiveSupport::SafeBuffer.new
107
- output_buffer << text_area_tag(name, content, input_html)
108
- output_buffer << javascript_tag(Utils.js_replace(element_id, options))
109
-
110
- output_buffer
111
- end
112
- end
113
- end
114
- end
1
+ # Use this hook to configure ckeditor
2
+ Ckeditor.setup do |config|
3
+ # ==> ORM configuration
4
+ # Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
5
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
6
+ # available as additional gems.
7
+ require "ckeditor/orm/active_record"
115
8
 
9
+ # Allowed image file types for upload.
10
+ # Set to nil or [] (empty array) for all file types
11
+ # config.image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]
116
12
 
117
- module Ckeditor
118
- module Helpers
119
- module FormHelper
120
- extend ActiveSupport::Concern
121
-
122
- include ActionView::Helpers::TagHelper
123
- include ActionView::Helpers::JavaScriptHelper
124
-
125
- def cktext_area(object_name, method, options = {})
126
- options = { :language => I18n.locale.to_s }.merge(options)
127
- input_html = (options.delete(:input_html) || {})
128
- hash = input_html.stringify_keys
129
-
130
- instance_tag = ActionView::Base::InstanceTag.new(object_name, method, self, options.delete(:object))
131
- instance_tag.send(:add_default_name_and_id, hash)
132
-
133
- output_buffer = ActiveSupport::SafeBuffer.new
134
- output_buffer << instance_tag.to_text_area_tag(input_html)
135
- output_buffer << javascript_tag(Utils.js_replace(hash['id'], options))
136
-
137
- output_buffer
138
- end
139
- end
140
- end
141
- end
13
+ # Allowed attachment file types for upload.
14
+ # Set to nil or [] (empty array) for all file types
15
+ # config.attachment_file_types = ["doc", "docx", "xls", "odt", "ods", "pdf", "rar", "zip", "tar", "swf"]
142
16
 
143
- ActiveSupport.on_load :action_view do
144
- ActionView::Base.send :include, Ckeditor::Helpers::ViewHelper
145
- ActionView::Base.send :include, Ckeditor::Helpers::FormHelper
146
- ActionView::Helpers::FormBuilder.send :include, Ckeditor::Helpers::FormBuilder
17
+ # Setup authorization to be run as a before filter
18
+ # config.authorize_with :cancan
147
19
  end