blocky 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/app/helpers/blocky_helper.rb +2 -4
- data/app/models/blocky/content_block.rb +6 -4
- data/app/views/blocky/content_blocks/index.html.erb +2 -5
- data/db/migrate/20140520212037_add_page_path_to_content_blocks.rb +7 -0
- data/lib/blocky/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2b133372cdb42fddfcde315ee3cf807c07f09ed
|
4
|
+
data.tar.gz: b0e2b556c60553e2237ec40366e8c4748dbae848
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 985a2a51f3473ecfa5afbc6644b896a0a4e1281dc5241e7e8bc28dc1c85fc6b3d84316e4c623c2ecae811b30d1ca25254153c2db3c2d3b14e96e5616a99cdf3c
|
7
|
+
data.tar.gz: b3aa84a7cf0af11e0f977e8a21ef29226b3e000817548baf74fe510a4b49c74e99732f4660b44215aa135236f346d9678a384ed6693a368c302b3faed2b08725
|
data/README.md
CHANGED
@@ -52,6 +52,14 @@ TODO: Add example for limiting access to admin users.
|
|
52
52
|
|
53
53
|
## Usage
|
54
54
|
|
55
|
+
Include `BlockyHelper` in your `ApplicationHelper`:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
module ApplicationHelper
|
59
|
+
include BlockyHelper
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
55
63
|
To create a content block, simply use the `blocky` helper
|
56
64
|
and specify a content key in any ERB template:
|
57
65
|
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module BlockyHelper
|
2
2
|
|
3
3
|
def blocky(block_name, options={})
|
4
|
-
|
5
|
-
action_name = options[:global] ? nil : controller.action_name
|
4
|
+
page_path = options[:global] ? nil : request.fullpath
|
6
5
|
|
7
6
|
content_block = Blocky::ContentBlock.where({
|
8
|
-
|
9
|
-
action: action_name,
|
7
|
+
page_path: page_path,
|
10
8
|
name: block_name
|
11
9
|
}).first_or_create
|
12
10
|
|
@@ -2,15 +2,16 @@ module Blocky
|
|
2
2
|
class ContentBlock < ActiveRecord::Base
|
3
3
|
before_save :tidy_content
|
4
4
|
|
5
|
-
scope :global, -> { where("
|
6
|
-
scope :per_page, -> { where("
|
5
|
+
scope :global, -> { where("page_path IS NULL") }
|
6
|
+
scope :per_page, -> { where("page_path IS NOT NULL") }
|
7
7
|
|
8
8
|
def global?
|
9
|
-
self.
|
9
|
+
self.page_path.nil?
|
10
10
|
end
|
11
11
|
|
12
12
|
def tidy_content
|
13
13
|
tidy = Tidy.new({
|
14
|
+
char_encoding: "raw",
|
14
15
|
doctype: "omit",
|
15
16
|
indent: "auto",
|
16
17
|
indent_spaces: 2,
|
@@ -20,7 +21,8 @@ module Blocky
|
|
20
21
|
tab_size: 2,
|
21
22
|
tidy_mark: false
|
22
23
|
})
|
23
|
-
|
24
|
+
html = tidy.clean(self.content.to_s.strip)
|
25
|
+
self.content = "\n" + (html.blank? ? "<p><br/></p>" : html) + "\n"
|
24
26
|
end
|
25
27
|
|
26
28
|
end
|
@@ -25,15 +25,12 @@
|
|
25
25
|
</td>
|
26
26
|
</tr>
|
27
27
|
<% end %>
|
28
|
-
<% @content_blocks.group_by{|content_block|
|
28
|
+
<% @content_blocks.group_by{|content_block| content_block.page_path }.each do |page_path, content_blocks| %>
|
29
29
|
<% content_blocks.each_with_index do |content_block, index| %>
|
30
|
-
|
31
|
-
<% page_url = main_app.url_for(controller: "/#{group[0]}", action: group[1], only_path: true) %>
|
32
|
-
|
33
30
|
<tr class="per-page <%= index == 0 ? 'page-start' : '' %>">
|
34
31
|
<td class="page">
|
35
32
|
<% if index == 0 %>
|
36
|
-
<%= link_to
|
33
|
+
<%= link_to page_path, page_path, target: "_blank" %>
|
37
34
|
<% end %>
|
38
35
|
</td>
|
39
36
|
<td>
|
data/lib/blocky/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blocky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Pattison
|
@@ -344,6 +344,7 @@ files:
|
|
344
344
|
- config/jshint.json
|
345
345
|
- config/routes.rb
|
346
346
|
- db/migrate/20140326210255_create_blocky_content_blocks.rb
|
347
|
+
- db/migrate/20140520212037_add_page_path_to_content_blocks.rb
|
347
348
|
- lib/blocky.rb
|
348
349
|
- lib/blocky/engine.rb
|
349
350
|
- lib/blocky/version.rb
|