polyblock 0.6.2 → 0.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec215ea6c52b8c58c40be3369880eff3c60605e4
4
- data.tar.gz: 5b9cc0433a80e9b47c207801b092235c380a23ba
3
+ metadata.gz: f4a75a7d76cfc5bc2b0419088d4c25ec536998a3
4
+ data.tar.gz: 072aa1504a72695350bda2f2f22b61e521c3b51d
5
5
  SHA512:
6
- metadata.gz: 5e436274e70a377316bdf59a58d2d120c106020e50710863ca744c6c60c59f169612c4a43fd981d7b2845a0916d17d234adf23ae0f3d93745cf7aff96a1329f0
7
- data.tar.gz: e4c8f3a1f000cfcfe4ac48b88ae32f6250a6786e46da5572db647707c4d62c7bd2165805327cc29246fdb74c68d229a6eff67c2f7db24ebd2f78e3de2692106d
6
+ metadata.gz: 4a82bb323b736d6a825ead87c24dccdd23c978db6645ff59ed422c9fa6c190e64d06e2bd4f5e8a7de8abfb7e72812a48f104389e3f77cb758869d153f14bc8c6
7
+ data.tar.gz: 11c937ea4f582e894f1106f71c0541c30fa855d9e69d55efe3121e758d487d1cd599999944b39b21d6214349316dd6f7021c79230e4a7cdf24b0fe0a3689d91f
@@ -1,78 +1,4 @@
1
1
  module Polyblock
2
2
  module ApplicationHelper
3
-
4
- def pb(name, options={})
5
- options = {
6
- # :editable => false,
7
- :tag => :div,
8
- :tag_options => {},
9
- :condensed => false,
10
- :length => 250,
11
- :omission => '... (continued)'
12
- }.merge(options)
13
-
14
- # Fetch or create Polyblock
15
- pb = Block.fetch_or_create(name)
16
- pb_id = pb.new_record? ? Block.next_id : pb.id
17
- name = pb.name if name.is_a? Block
18
- random_id = Block.random_id
19
-
20
- # Build output tag
21
- content = pb.content.present? ? pb.content : "[Editable content space for Polyblock <code>#{name}</code>]"
22
- tag_options = options[:tag_options].deep_merge({:id => "pb-#{pb_id}-#{random_id}", :data => {:pbid => pb_id, :pbname => name}})
23
- tag_options[:contenteditable] = if options[:condensed]
24
- 'false'
25
- elsif options.has_key?(:editable)
26
- options[:editable] ? 'true' : 'false'
27
- elsif respond_to?(:can?) && can?(:manage, pb)
28
- 'true'
29
- elsif respond_to?(:user_signed_in?) && user_signed_in?
30
- if current_user.respond_to?(:admin?) && current_user.admin?
31
- 'true'
32
- elsif pb.contentable.present? &&
33
- pb.contentable.respond_to?(:user_id) &&
34
- pb.contentable.user_id == current_user.id
35
- 'true'
36
- else
37
- 'false'
38
- end
39
- else
40
- 'false'
41
- end
42
- tag_options.delete(:contenteditable) if tag_options[:contenteditable] == 'false'
43
- tag_options[:class] = (tag_options.key?(:class) ? "#{tag_options[:class]} ": '') + 'polyblock'
44
- tag_options[:data][:pb_exists] = pb.new_record?
45
-
46
- # Truncation
47
- if options[:condensed]
48
- tag_options[:class] += " polyblock-condensed"
49
- content = CGI.unescapeHTML(content.gsub('<br><br>', '<br>').gsub('&nbsp;', ' '))
50
- truncate(sanitize(strip_tags(content)), :length => options[:length], :omission => options[:omission])
51
- else
52
- content_tag(options[:tag], content, tag_options, false)
53
- end
54
- end
55
-
56
- def simple_fields_for_polyblock(name, f, options={})
57
- options = {
58
- :label => false,
59
- :input_html => {}
60
- }.merge(options)
61
-
62
- pb = if name.is_a?(String)
63
- Block.fetch_or_initialize(name)
64
- elsif name.is_a?(Symbol)
65
- f.object
66
- else
67
- nil
68
- end
69
-
70
- render :partial => 'polyblock/simple_fields_for', :locals => {:f => f, :pb => pb, :name => name, :options => options}
71
- end
72
-
73
- def polyblock_editor_bar
74
- render :partial => 'polyblock/editor_bar'
75
- end
76
-
77
3
  end
78
4
  end
@@ -1,4 +1,78 @@
1
1
  module Polyblock
2
2
  module PolyblocksHelper
3
+
4
+ def pb(name, options={})
5
+ options = {
6
+ # :editable => false,
7
+ :tag => :div,
8
+ :tag_options => {},
9
+ :condensed => false,
10
+ :length => 250,
11
+ :omission => '... (continued)'
12
+ }.merge(options)
13
+
14
+ # Fetch or create Polyblock
15
+ pb = Block.fetch_or_create(name)
16
+ pb_id = pb.new_record? ? Block.next_id : pb.id
17
+ name = pb.name if name.is_a? Block
18
+ random_id = Block.random_id
19
+
20
+ # Build output tag
21
+ content = pb.content.present? ? pb.content : "[Editable content space for Polyblock <code>#{name}</code>]"
22
+ tag_options = options[:tag_options].deep_merge({:id => "pb-#{pb_id}-#{random_id}", :data => {:pbid => pb_id, :pbname => name}})
23
+ tag_options[:contenteditable] = if options[:condensed]
24
+ 'false'
25
+ elsif options.has_key?(:editable)
26
+ options[:editable] ? 'true' : 'false'
27
+ elsif respond_to?(:can?) && can?(:manage, pb)
28
+ 'true'
29
+ elsif respond_to?(:user_signed_in?) && user_signed_in?
30
+ if current_user.respond_to?(:admin?) && current_user.admin?
31
+ 'true'
32
+ elsif pb.contentable.present? &&
33
+ pb.contentable.respond_to?(:user_id) &&
34
+ pb.contentable.user_id == current_user.id
35
+ 'true'
36
+ else
37
+ 'false'
38
+ end
39
+ else
40
+ 'false'
41
+ end
42
+ tag_options.delete(:contenteditable) if tag_options[:contenteditable] == 'false'
43
+ tag_options[:class] = (tag_options.key?(:class) ? "#{tag_options[:class]} ": '') + 'polyblock'
44
+ tag_options[:data][:pb_exists] = pb.new_record?
45
+
46
+ # Truncation
47
+ if options[:condensed]
48
+ tag_options[:class] += " polyblock-condensed"
49
+ content = CGI.unescapeHTML(content.gsub('<br><br>', '<br>').gsub('&nbsp;', ' '))
50
+ truncate(sanitize(strip_tags(content)), :length => options[:length], :omission => options[:omission])
51
+ else
52
+ content_tag(options[:tag], content, tag_options, false)
53
+ end
54
+ end
55
+
56
+ def simple_fields_for_polyblock(name, f, options={})
57
+ options = {
58
+ :label => false,
59
+ :input_html => {}
60
+ }.merge(options)
61
+
62
+ pb = if name.is_a?(String)
63
+ Block.fetch_or_initialize(name)
64
+ elsif name.is_a?(Symbol)
65
+ f.object
66
+ else
67
+ nil
68
+ end
69
+
70
+ render :partial => 'polyblock/simple_fields_for', :locals => {:f => f, :pb => pb, :name => name, :options => options}
71
+ end
72
+
73
+ def polyblock_editor_bar
74
+ render :partial => 'polyblock/editor_bar'
75
+ end
76
+
3
77
  end
4
78
  end
@@ -1,11 +1,11 @@
1
1
  require "ckeditor"
2
2
 
3
3
  module Polyblock
4
- class Engine < ::Rails::Engine
4
+ class Engine < Rails::Engine
5
5
  isolate_namespace Polyblock
6
6
  initializer 'polyblock_engine.action_controller' do |app|
7
7
  ActiveSupport.on_load :action_controller do
8
- helper Polyblock::ApplicationHelper
8
+ helper Polyblock::PolyblocksHelper
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Polyblock
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyblock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MacKinley Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-07 00:00:00.000000000 Z
11
+ date: 2014-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -2548,7 +2548,6 @@ files:
2548
2548
  - test/dummy/tmp/cache/assets/development/sprockets/ffb79443786077c55e033012dcb39372
2549
2549
  - test/dummy/tmp/cache/assets/development/sprockets/ffdb359321552b05439e0337844f817d
2550
2550
  - test/dummy/tmp/cache/assets/development/sprockets/fffa8f692e900a66d630702707280ecc
2551
- - test/dummy/tmp/pids/server.pid
2552
2551
  - test/fixtures/polyblock/blocks.yml
2553
2552
  - test/helpers/polyblock/polyblocks_helper_test.rb
2554
2553
  - test/integration/navigation_test.rb
@@ -4922,7 +4921,6 @@ test_files:
4922
4921
  - test/dummy/tmp/cache/assets/development/sprockets/ffb79443786077c55e033012dcb39372
4923
4922
  - test/dummy/tmp/cache/assets/development/sprockets/ffdb359321552b05439e0337844f817d
4924
4923
  - test/dummy/tmp/cache/assets/development/sprockets/fffa8f692e900a66d630702707280ecc
4925
- - test/dummy/tmp/pids/server.pid
4926
4924
  - test/fixtures/polyblock/blocks.yml
4927
4925
  - test/helpers/polyblock/polyblocks_helper_test.rb
4928
4926
  - test/integration/navigation_test.rb
@@ -1 +0,0 @@
1
- 36572