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.
- checksums.yaml +4 -4
- data/app/helpers/polyblock/application_helper.rb +5 -1
- data/app/inputs/polyblock_input.rb +10 -0
- data/app/views/polyblock/_simple_fields_for.html.haml +3 -0
- data/lib/polyblock/has_polyblock.rb +5 -1
- data/lib/polyblock/version.rb +1 -1
- data/test/dummy/app/assets/javascripts/parents.js +2 -0
- data/test/dummy/app/assets/stylesheets/parents.css +4 -0
- data/test/dummy/app/controllers/home_controller.rb +2 -1
- data/test/dummy/app/controllers/parents_controller.rb +2 -0
- data/test/dummy/app/helpers/parents_helper.rb +2 -0
- data/test/dummy/app/models/ckeditor/asset.rb +4 -0
- data/test/dummy/app/models/ckeditor/attachment_file.rb +12 -0
- data/test/dummy/app/models/ckeditor/picture.rb +13 -0
- data/test/dummy/app/models/parent.rb +5 -0
- data/test/dummy/app/views/home/index.html.haml +9 -0
- data/test/dummy/config/initializers/ckeditor.rb +23 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20131221163647_create_ckeditor_assets.rb +26 -0
- data/test/dummy/db/migrate/20131221213025_create_parents.rb +9 -0
- data/test/dummy/db/schema.rb +7 -1
- data/test/dummy/log/development.log +2997 -0
- data/test/dummy/test/controllers/parents_controller_test.rb +7 -0
- data/test/dummy/test/fixtures/parents.yml +7 -0
- data/test/dummy/test/helpers/parents_helper_test.rb +4 -0
- data/test/dummy/test/models/parent_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/46f7f6cd9693efb15b4dc5070b73b0fe +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/575c35f72050e9f765d8364f3b20e4b5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5e3715c04d0a5e4a7a6f1166bb182052 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/89f42f270616a15d4bfb8e90cc2460d3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c927d4ef4c48ace72171092f4d565ead +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e0385411965254693a01d2ca240dee61 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- metadata +47 -3
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74d9c58c1d0c41a6f2a3c714ebaec68295108e52
|
4
|
+
data.tar.gz: f8149eb5e63addbbe5a641a65ffedbfdd3155fb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
@@ -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
|
|
data/lib/polyblock/version.rb
CHANGED
@@ -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,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
|
data/test/dummy/config/routes.rb
CHANGED
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
|
data/test/dummy/db/schema.rb
CHANGED
@@ -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:
|
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"
|