polyblock 0.1.2 → 0.1.6

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/polyblock/application_helper.rb +5 -1
  3. data/app/inputs/polyblock_input.rb +10 -0
  4. data/app/views/polyblock/_simple_fields_for.html.haml +3 -0
  5. data/lib/polyblock/has_polyblock.rb +5 -1
  6. data/lib/polyblock/version.rb +1 -1
  7. data/test/dummy/app/assets/javascripts/parents.js +2 -0
  8. data/test/dummy/app/assets/stylesheets/parents.css +4 -0
  9. data/test/dummy/app/controllers/home_controller.rb +2 -1
  10. data/test/dummy/app/controllers/parents_controller.rb +2 -0
  11. data/test/dummy/app/helpers/parents_helper.rb +2 -0
  12. data/test/dummy/app/models/ckeditor/asset.rb +4 -0
  13. data/test/dummy/app/models/ckeditor/attachment_file.rb +12 -0
  14. data/test/dummy/app/models/ckeditor/picture.rb +13 -0
  15. data/test/dummy/app/models/parent.rb +5 -0
  16. data/test/dummy/app/views/home/index.html.haml +9 -0
  17. data/test/dummy/config/initializers/ckeditor.rb +23 -0
  18. data/test/dummy/config/routes.rb +3 -0
  19. data/test/dummy/db/development.sqlite3 +0 -0
  20. data/test/dummy/db/migrate/20131221163647_create_ckeditor_assets.rb +26 -0
  21. data/test/dummy/db/migrate/20131221213025_create_parents.rb +9 -0
  22. data/test/dummy/db/schema.rb +7 -1
  23. data/test/dummy/log/development.log +2997 -0
  24. data/test/dummy/test/controllers/parents_controller_test.rb +7 -0
  25. data/test/dummy/test/fixtures/parents.yml +7 -0
  26. data/test/dummy/test/helpers/parents_helper_test.rb +4 -0
  27. data/test/dummy/test/models/parent_test.rb +7 -0
  28. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  29. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  30. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  31. data/test/dummy/tmp/cache/assets/development/sprockets/46f7f6cd9693efb15b4dc5070b73b0fe +0 -0
  32. data/test/dummy/tmp/cache/assets/development/sprockets/575c35f72050e9f765d8364f3b20e4b5 +0 -0
  33. data/test/dummy/tmp/cache/assets/development/sprockets/5e3715c04d0a5e4a7a6f1166bb182052 +0 -0
  34. data/test/dummy/tmp/cache/assets/development/sprockets/89f42f270616a15d4bfb8e90cc2460d3 +0 -0
  35. data/test/dummy/tmp/cache/assets/development/sprockets/c927d4ef4c48ace72171092f4d565ead +0 -0
  36. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  37. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  38. data/test/dummy/tmp/cache/assets/development/sprockets/e0385411965254693a01d2ca240dee61 +0 -0
  39. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  40. metadata +47 -3
  41. data/test/dummy/app/views/home/index.html.erb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89d636a53b88be7c7037cf9a542f828b10faf406
4
- data.tar.gz: 5b113a6f07a02637b2997464992ee56776022fe8
3
+ metadata.gz: 74d9c58c1d0c41a6f2a3c714ebaec68295108e52
4
+ data.tar.gz: f8149eb5e63addbbe5a641a65ffedbfdd3155fb5
5
5
  SHA512:
6
- metadata.gz: c190b16b8df8707144581d9655f454ad6536255d3a17c084239ff1de997f318dfb1733f0f03fa137b57f75686b3d309617d9eee231b837175faf25ecda6f039f
7
- data.tar.gz: 01f746ce76f27d4c53b34bf6a535ddf1c86d7a617cfec2ce5374f4bfec0ade06cc38ef04af143b1198e02da6d91a534beb98507fdd30228c14efa185281a8ffc
6
+ metadata.gz: a6c54aef3188412f96543e24c5b3a0bb9b9690ae93a1453ae53cf5da36bc42baf287ca7371ac578a3a61dd197fdf2bdc3b70b592fe03db8071eb052e85dba868
7
+ data.tar.gz: 3fe20542653b9d5254e3c0de4b2620e34b49d3fcb66307903c3f560c235e767285370e6d8b1a42929db46a490292bd1bf0445228b288b621982b3335b875ff71
@@ -9,7 +9,7 @@ module Polyblock
9
9
  name = pb.name
10
10
  pb_exists = true
11
11
  else
12
- matches = Polyblock::Block.where({:name => name})
12
+ matches = Polyblock::Block.where :name => name
13
13
  pb_exists = matches.any?
14
14
  pb = if pb_exists then matches.first() else Polyblock::Block.new({:name => name}) end
15
15
  pb_id = if pb_exists then pb.id else Polyblock::Block.count + 1 end
@@ -25,5 +25,9 @@ module Polyblock
25
25
  content_tag(tag, pb.content, tag_options, false)
26
26
  end
27
27
 
28
+ def simple_fields_for_polyblock(name, f)
29
+ render :partial => "polyblock/simple_fields_for", :locals => {:f => f, :name => name}
30
+ end
31
+
28
32
  end
29
33
  end
@@ -0,0 +1,10 @@
1
+ module Polyblock::Hooks::SimpleForm
2
+ class PolyblockInput < SimpleForm::Inputs::Base
3
+ def input
4
+ @builder.hidden_field("")
5
+ @builder.cktext_area(attribute_name, input_html_options)
6
+ end
7
+ end
8
+ end
9
+
10
+ ::SimpleForm::FormBuilder.map_type :polyblock, :to => Polyblock::Hooks::SimpleForm::PolyblockInput
@@ -0,0 +1,3 @@
1
+ = f.simple_fields_for name do |ff|
2
+ = ff.input_field :name, :as => :hidden, :value => name.to_s
3
+ = ff.input_field :content, :as => :ckeditor
@@ -7,11 +7,15 @@ module Polyblock
7
7
 
8
8
  module ClassMethods
9
9
  def has_polyblock(name, options={})
10
- defaults = {:class_name => "Polyblock::Block", :as => :contentable}
10
+ defaults = {:class_name => "Polyblock::Block", :as => :contentable, :conditions => {:name => name}}
11
11
  has_one name, defaults.merge(options)
12
12
  accepts_nested_attributes_for name
13
+ include Polyblock::HasPolyblock::LocalInstanceMethods
13
14
  end
14
15
  end
16
+
17
+ module LocalInstanceMethods
18
+ end
15
19
  end
16
20
  end
17
21
 
@@ -1,3 +1,3 @@
1
1
  module Polyblock
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -1,7 +1,8 @@
1
1
  class HomeController < ApplicationController
2
2
 
3
3
  def index
4
-
4
+ @parent = Parent.new
5
+ @parent.build_child
5
6
  end
6
7
 
7
8
  end
@@ -0,0 +1,2 @@
1
+ class ParentsController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ module ParentsHelper
2
+ end
@@ -0,0 +1,4 @@
1
+ class Ckeditor::Asset < ActiveRecord::Base
2
+ include Ckeditor::Orm::ActiveRecord::AssetBase
3
+ include Ckeditor::Backend::Paperclip
4
+ end
@@ -0,0 +1,12 @@
1
+ class Ckeditor::AttachmentFile < Ckeditor::Asset
2
+ has_attached_file :data,
3
+ :url => "/ckeditor_assets/attachments/:id/:filename",
4
+ :path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
5
+
6
+ validates_attachment_size :data, :less_than => 100.megabytes
7
+ validates_attachment_presence :data
8
+
9
+ def url_thumb
10
+ @url_thumb ||= Ckeditor::Utils.filethumb(filename)
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class Ckeditor::Picture < Ckeditor::Asset
2
+ has_attached_file :data,
3
+ :url => "/ckeditor_assets/pictures/:id/:style_:basename.:extension",
4
+ :path => ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension",
5
+ :styles => { :content => '800>', :thumb => '118x100#' }
6
+
7
+ validates_attachment_size :data, :less_than => 2.megabytes
8
+ validates_attachment_presence :data
9
+
10
+ def url_content
11
+ url(:content)
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ class Parent < ActiveRecord::Base
2
+
3
+ has_polyblock :child
4
+
5
+ end
@@ -0,0 +1,9 @@
1
+ %h1 Polyblock Test Dummy
2
+
3
+ %h3 Polyblock with Inline Editing
4
+ = pb("Test")
5
+
6
+ %h3 Polyblock SimpleForm
7
+ = simple_form_for @parent do |f|
8
+ = f.input :name
9
+ = simple_fields_for_polyblock :child, f
@@ -0,0 +1,23 @@
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"
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"]
12
+
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"]
16
+
17
+ # Setup authorization to be run as a before filter
18
+ # config.authorize_with :cancan
19
+
20
+ # Asset model classes
21
+ # config.picture_model { Ckeditor::Picture }
22
+ # config.attachment_file_model { Ckeditor::AttachmentFile }
23
+ end
@@ -1,4 +1,7 @@
1
1
  Rails.application.routes.draw do
2
+ mount Ckeditor::Engine => '/ckeditor'
3
+ resources :parents
4
+
2
5
  root :to => "home#index"
3
6
  mount Polyblock::Engine => "/polyblock"
4
7
  end
Binary file
@@ -0,0 +1,26 @@
1
+ class CreateCkeditorAssets < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :ckeditor_assets do |t|
4
+ t.string :data_file_name, :null => false
5
+ t.string :data_content_type
6
+ t.integer :data_file_size
7
+
8
+ t.integer :assetable_id
9
+ t.string :assetable_type, :limit => 30
10
+ t.string :type, :limit => 30
11
+
12
+ # Uncomment it to save images dimensions, if your need it
13
+ t.integer :width
14
+ t.integer :height
15
+
16
+ t.timestamps
17
+ end
18
+
19
+ add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], :name => "idx_ckeditor_assetable_type"
20
+ add_index "ckeditor_assets", ["assetable_type", "assetable_id"], :name => "idx_ckeditor_assetable"
21
+ end
22
+
23
+ def self.down
24
+ drop_table :ckeditor_assets
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ class CreateParents < ActiveRecord::Migration
2
+ def change
3
+ create_table :parents do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20131201194124) do
14
+ ActiveRecord::Schema.define(version: 20131221213025) do
15
15
 
16
16
  create_table "ckeditor_assets", force: true do |t|
17
17
  t.string "data_file_name", null: false
@@ -29,6 +29,12 @@ ActiveRecord::Schema.define(version: 20131201194124) do
29
29
  add_index "ckeditor_assets", ["assetable_type", "assetable_id"], name: "idx_ckeditor_assetable"
30
30
  add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], name: "idx_ckeditor_assetable_type"
31
31
 
32
+ create_table "parents", force: true do |t|
33
+ t.string "name"
34
+ t.datetime "created_at"
35
+ t.datetime "updated_at"
36
+ end
37
+
32
38
  create_table "polyblock_blocks", force: true do |t|
33
39
  t.string "name"
34
40
  t.text "content"