refinerycms-sl-snippets 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +79 -0
- data/app/views/refinery/admin/pages/tabs/_snippets_field.html.erb +1 -6
- data/config/routes.rb +2 -2
- data/lib/gemspec.rb +3 -4
- data/lib/refinery/snippets/engine.rb +17 -3
- data/lib/refinery/snippets/version.rb +1 -1
- data/readme.md +7 -7
- data/refinerycms-snippets.gemspec +9 -95
- metadata +77 -97
- data/app/views/admin/pages/tabs/_snippets_field.html.erb +0 -46
- data/lib/extensions/application_helper_extensions.rb +0 -39
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 67a1046563022c8837198b7aaa38d61ef8128d6e
|
4
|
+
data.tar.gz: 4837fd13e9e6d17524d2cf34a28a0825f7eb9fa4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63a08423fae4ada007a5fe09933db9e26c53460ca0a23b53cf44e56306fe17740f3562f24232312276c846e7195e20345af53238462e34ba6766f9e9a873c27d
|
7
|
+
data.tar.gz: 1efb7a524cb8f72dd7d985c6f3a51058a07c3309b294e089c9261424539dc2c6019a05717e1ee19671de34aaae35857877b15cd17e854098a0758de8f8527132
|
data/.gitignore
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
.bundle
|
2
|
+
db/*.sqlite3
|
3
|
+
log/*.log
|
4
|
+
tmp/
|
5
|
+
# Rails
|
6
|
+
.bundle
|
7
|
+
db/*.sqlite3
|
8
|
+
db/*.sqlite3-journal
|
9
|
+
*.log
|
10
|
+
tmp/**/*
|
11
|
+
|
12
|
+
# Documentation
|
13
|
+
doc/api
|
14
|
+
doc/app
|
15
|
+
doc/*
|
16
|
+
.yardoc
|
17
|
+
.yardopts
|
18
|
+
|
19
|
+
# Public Uploads
|
20
|
+
public/system/*
|
21
|
+
public/themes/*
|
22
|
+
|
23
|
+
# Public Cache
|
24
|
+
public/javascripts/cache
|
25
|
+
public/stylesheets/cache
|
26
|
+
|
27
|
+
# Vendor Cache
|
28
|
+
vendor/cache
|
29
|
+
|
30
|
+
# Acts as Indexed
|
31
|
+
index/**/*
|
32
|
+
|
33
|
+
# Refinery Specific
|
34
|
+
*.tmproj
|
35
|
+
*.autobackupbyrefinery.*
|
36
|
+
/refinerycms-*.gem
|
37
|
+
.autotest
|
38
|
+
|
39
|
+
# Mac
|
40
|
+
.DS_Store
|
41
|
+
|
42
|
+
# Windows
|
43
|
+
Thumbs.db
|
44
|
+
|
45
|
+
# NetBeans
|
46
|
+
nbproject
|
47
|
+
|
48
|
+
# Eclipse
|
49
|
+
.project
|
50
|
+
|
51
|
+
# Redcar
|
52
|
+
.redcar
|
53
|
+
|
54
|
+
# Rubinius
|
55
|
+
*.rbc
|
56
|
+
|
57
|
+
# Vim
|
58
|
+
*.swp
|
59
|
+
*.swo
|
60
|
+
|
61
|
+
# RubyMine
|
62
|
+
.idea
|
63
|
+
|
64
|
+
# Backup
|
65
|
+
*~
|
66
|
+
|
67
|
+
# Capybara Bug
|
68
|
+
capybara-*html
|
69
|
+
|
70
|
+
# sass
|
71
|
+
.sass-cache
|
72
|
+
.sass-cache/*
|
73
|
+
|
74
|
+
#rvm
|
75
|
+
.rvmrc
|
76
|
+
.rvmrc.*
|
77
|
+
|
78
|
+
/log/
|
79
|
+
/autotest/
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<%
|
20
20
|
inactive_snippets = []
|
21
21
|
Refinery::Snippet.all.inject(inactive_snippets) do |s, snippet|
|
22
|
-
unless snippet.after?(part) and snippet.before?(part)
|
22
|
+
unless s.blank? || (snippet.after?(part) and snippet.before?(part))
|
23
23
|
s << snippet
|
24
24
|
end
|
25
25
|
end
|
@@ -48,8 +48,3 @@
|
|
48
48
|
<% end %>
|
49
49
|
</div>
|
50
50
|
</div>
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
data/config/routes.rb
CHANGED
@@ -2,7 +2,7 @@ Refinery::Core::Engine.routes.append do
|
|
2
2
|
|
3
3
|
# Admin routes
|
4
4
|
namespace :admin, :path => 'refinery', :as => 'admin' do
|
5
|
-
resources :snippets, :
|
5
|
+
resources :snippets, except: :show do
|
6
6
|
collection do
|
7
7
|
post :update_positions
|
8
8
|
end
|
@@ -15,4 +15,4 @@ Refinery::Core::Engine.routes.append do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
end
|
18
|
+
end
|
data/lib/gemspec.rb
CHANGED
@@ -19,11 +19,10 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = %w(lib)
|
20
20
|
s.homepage = %q{https://github.com/simplelogica/refinerycms-snippets}
|
21
21
|
|
22
|
-
s.add_dependency 'refinerycms-pages', '
|
22
|
+
s.add_dependency 'refinerycms-pages', '~> 2.1.0.dev'
|
23
23
|
|
24
|
-
s.files
|
25
|
-
|
26
|
-
]
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
27
26
|
s.require_path = 'lib'
|
28
27
|
end
|
29
28
|
EOF
|
@@ -10,7 +10,6 @@ module Refinery
|
|
10
10
|
|
11
11
|
config.before_initialize do
|
12
12
|
require 'extensions/page_extensions'
|
13
|
-
require 'extensions/application_helper_extensions'
|
14
13
|
end
|
15
14
|
|
16
15
|
initializer "register refinery_snippets plugin", :after => :set_routes_reloader do |app|
|
@@ -19,7 +18,7 @@ module Refinery
|
|
19
18
|
plugin.pathname = root
|
20
19
|
plugin.name = "refinery_snippets"
|
21
20
|
plugin.url = proc {Refinery::Core::Engine.routes.url_helpers.admin_snippets_path}
|
22
|
-
plugin.menu_match =
|
21
|
+
plugin.menu_match = %r{refinery/snippets(_page_parts)?$}
|
23
22
|
plugin.activity = {
|
24
23
|
:class_name => :'refinery/snippet',
|
25
24
|
:title => 'title'
|
@@ -33,7 +32,22 @@ module Refinery
|
|
33
32
|
has_many :snippets, :through => :snippet_page_parts, :order => 'position ASC'
|
34
33
|
end
|
35
34
|
Refinery::Page.send :include, Extensions::Page
|
36
|
-
|
35
|
+
Refinery::Pages::PagePartSectionPresenter.class_eval do
|
36
|
+
def initialize(page_part)
|
37
|
+
super()
|
38
|
+
self.id = convert_title_to_id(page_part.title) if page_part.title
|
39
|
+
|
40
|
+
content = ""
|
41
|
+
content += page_part.snippets.before.map{ |snippet| content_or_render_of(snippet) }.join
|
42
|
+
content += page_part.body
|
43
|
+
content += page_part.snippets.after.map{ |snippet| content_or_render_of(snippet) }.join
|
44
|
+
self.fallback_html = content.html_safe
|
45
|
+
end
|
46
|
+
|
47
|
+
def content_or_render_of(snippet)
|
48
|
+
snippet.template? ? render(:file => snippet.template_path) : snippet.body
|
49
|
+
end
|
50
|
+
end
|
37
51
|
end
|
38
52
|
|
39
53
|
config.after_initialize do
|
data/readme.md
CHANGED
@@ -6,21 +6,19 @@ Snippets allows you to relate one or more html blocks or erb templates to any pa
|
|
6
6
|
|
7
7
|
## Requirements
|
8
8
|
|
9
|
-
*
|
10
|
-
* RefineryCMS with 'Pages' engine (refinerycms-pages >= 2.0.0)
|
9
|
+
* RefineryCMS with 'Pages' engine (refinerycms-pages = 2.1.0.dev)
|
11
10
|
|
12
11
|
## TODO
|
13
12
|
|
14
13
|
* improve UI
|
15
14
|
* Documentation
|
16
15
|
* Tests
|
17
|
-
* Update to work properly with Rails 3 asset pipeline.
|
18
16
|
|
19
17
|
## Install
|
20
18
|
|
21
19
|
Add this line to your applications `Gemfile`
|
22
20
|
|
23
|
-
gem 'refinerycms-sl-snippets', '~> 1.
|
21
|
+
gem 'refinerycms-sl-snippets', '~> 1.1.0', :require => 'refinerycms-snippets'
|
24
22
|
|
25
23
|
Next run
|
26
24
|
|
@@ -31,8 +29,10 @@ Next run
|
|
31
29
|
## Usage
|
32
30
|
|
33
31
|
* Create Snippet on /refinery/snippets
|
34
|
-
* Now you can attach snippet to page when you click Edit this page on `/refinery/pages`. In the Snippets tab you can select the part to which you want to attach the block and add it after and/or before the html body of the part.
|
35
|
-
* Next you can
|
32
|
+
* Now you can attach snippet to page when you click Edit this page on `/refinery/pages`. In the Snippets tab you can select the part to which you want to attach the block and add it after and/or before the html body of the part.
|
33
|
+
* Next you can initialize a PagePartSectionPresenter with the page part that you would like to render and access its html output:
|
34
|
+
* presenter = Refinery::Pages::PagePartSectionPresenter.new(page_part)
|
35
|
+
* presenter.wrapped_html
|
36
36
|
* You have some other interesting methods to work with snippets:
|
37
37
|
* content_or_render_of(snippet): will return the content body (or erb template) of the snippet.
|
38
38
|
* page.snippets: returns all the snippets attached to all the parts of page.
|
@@ -42,7 +42,7 @@ Next run
|
|
42
42
|
|
43
43
|
## ERB templates usage
|
44
44
|
|
45
|
-
Snippets search for templates in RAILS_VIEWS_PATH/shared/snippets. The snippet
|
45
|
+
Snippets search for templates in RAILS_VIEWS_PATH/shared/snippets. The snippet searches for a file with its same name but with all non A-Za-z0-9 characters changed to underscores. If this file exists, snippet html body is ignored and the template is rendered in its place. Methods rendering the template, if exists, in place of the body are content_of(@page, :part) and content_or_render_of(snippet).
|
46
46
|
|
47
47
|
For example, a template with title "VIP clients: photos" would search in "app/views/shared/snippets" for a file named "vip_clients_photos.html.erb"; "Country & region banners: España" for "country_region_banners_espa_na" and so on.
|
48
48
|
|
@@ -1,106 +1,20 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.platform = Gem::Platform::RUBY
|
3
3
|
s.name = %q{refinerycms-sl-snippets}
|
4
|
-
s.version = %q{1.0.
|
4
|
+
s.version = %q{1.0.2}
|
5
5
|
s.description = %q{Ruby on Rails Snippets engine for Refinery CMS}
|
6
|
-
s.date = %q{
|
6
|
+
s.date = %q{2012-09-12}
|
7
7
|
s.summary = %q{Html snippets for Refinery CMS page}
|
8
|
-
s.authors = ['Rodrigo García Suárez', '
|
8
|
+
s.authors = ['Rodrigo García Suárez', 'Simplelógica', 'Marek L.']
|
9
9
|
s.email = %q{rodrigo@simplelogica.net}
|
10
10
|
s.require_paths = %w(lib)
|
11
11
|
s.homepage = %q{https://github.com/simplelogica/refinerycms-snippets}
|
12
|
-
|
13
|
-
s.add_dependency 'refinerycms-pages', '>= 2.0.0'
|
14
12
|
|
15
|
-
s.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
'app/controllers',
|
22
|
-
'app/controllers/refinery',
|
23
|
-
'app/controllers/refinery/admin',
|
24
|
-
'app/controllers/refinery/admin/snippets_controller.rb',
|
25
|
-
'app/controllers/refinery/admin/snippets_page_parts_controller.rb',
|
26
|
-
'app/assets',
|
27
|
-
'app/assets/stylesheets',
|
28
|
-
'app/assets/stylesheets/page-snippet-picker.css',
|
29
|
-
'app/assets/javascripts',
|
30
|
-
'app/assets/javascripts/part-snippets-select.js',
|
31
|
-
'app/assets/javascripts/page-snippet-picker.js',
|
32
|
-
'app/views',
|
33
|
-
'app/views/refinery',
|
34
|
-
'app/views/refinery/admin',
|
35
|
-
'app/views/refinery/admin/snippets',
|
36
|
-
'app/views/refinery/admin/snippets/index.html.erb',
|
37
|
-
'app/views/refinery/admin/snippets/edit.html.erb',
|
38
|
-
'app/views/refinery/admin/snippets/_snippet.html.erb',
|
39
|
-
'app/views/refinery/admin/snippets/new.html.erb',
|
40
|
-
'app/views/refinery/admin/snippets/_locale_picker.html.erb',
|
41
|
-
'app/views/refinery/admin/snippets/_snippets.html.erb',
|
42
|
-
'app/views/refinery/admin/snippets/_records.html.erb',
|
43
|
-
'app/views/refinery/admin/snippets/_form.html.erb',
|
44
|
-
'app/views/refinery/admin/snippets/_actions.html.erb',
|
45
|
-
'app/views/refinery/admin/snippets/_sortable_list.html.erb',
|
46
|
-
'app/views/refinery/admin/snippets_page_parts',
|
47
|
-
'app/views/refinery/admin/snippets_page_parts/add.html.erb',
|
48
|
-
'app/views/refinery/admin/snippets_page_parts/remove.html.erb',
|
49
|
-
'app/views/refinery/admin/pages',
|
50
|
-
'app/views/refinery/admin/pages/tabs',
|
51
|
-
'app/views/refinery/admin/pages/tabs/_snippets_field.html.erb',
|
52
|
-
'app/views/refinery/admin/pages/tabs/_snippets_content.html.erb',
|
53
|
-
'app/views/refinery/admin/pages/tabs/_snippets.html.erb',
|
54
|
-
'app/views/refinery/admin/pages/tabs/_snippets_list_item.html.erb',
|
55
|
-
'app/views/admin',
|
56
|
-
'app/views/admin/pages',
|
57
|
-
'app/views/admin/pages/tabs',
|
58
|
-
'app/views/admin/pages/tabs/_snippets_field.html.erb',
|
59
|
-
'lib',
|
60
|
-
'lib/generators',
|
61
|
-
'lib/generators/refinery',
|
62
|
-
'lib/generators/refinery/snippets_generator.rb',
|
63
|
-
'lib/refinery',
|
64
|
-
'lib/refinery/snippets.rb',
|
65
|
-
'lib/refinery/snippets',
|
66
|
-
'lib/refinery/snippets/version.rb',
|
67
|
-
'lib/refinery/snippets/tabs.rb',
|
68
|
-
'lib/refinery/snippets/engine.rb',
|
69
|
-
'lib/refinerycms-snippets.rb',
|
70
|
-
'lib/gemspec.rb',
|
71
|
-
'lib/tasks',
|
72
|
-
'lib/tasks/snippets.rake',
|
73
|
-
'lib/extensions',
|
74
|
-
'lib/extensions/application_helper_extensions.rb',
|
75
|
-
'lib/extensions/page_extensions.rb',
|
76
|
-
'db',
|
77
|
-
'db/seeds.rb',
|
78
|
-
'db/migrate',
|
79
|
-
'db/migrate/1_create_snippets.rb',
|
80
|
-
'db/migrate/6_remove_position_from_snippets.rb',
|
81
|
-
'db/migrate/2_translate_snippets.rb',
|
82
|
-
'db/migrate/3_create_snippets_page_parts.rb',
|
83
|
-
'spec',
|
84
|
-
'spec/models',
|
85
|
-
'spec/models/page_spec.rb',
|
86
|
-
'spec/models/snippet_spec.rb',
|
87
|
-
'spec/helpers',
|
88
|
-
'spec/helpers/application_helper_spec.rb',
|
89
|
-
'refinerycms-snippets.gemspec',
|
90
|
-
'config',
|
91
|
-
'config/routes.rb',
|
92
|
-
'config/locales',
|
93
|
-
'config/locales/nl.yml',
|
94
|
-
'config/locales/en.yml',
|
95
|
-
'config/locales/es.yml',
|
96
|
-
'config/locales/cs.yml',
|
97
|
-
'readme.md',
|
98
|
-
'features',
|
99
|
-
'features/support',
|
100
|
-
'features/support/paths.rb',
|
101
|
-
'features/step_definitions',
|
102
|
-
'features/step_definitions/snippet_steps.rb',
|
103
|
-
'features/manage_snippets.feature'
|
104
|
-
]
|
13
|
+
s.add_dependency 'refinerycms-pages', '~> 2.1.0.dev'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("
|
16
|
+
")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("
|
18
|
+
")
|
105
19
|
s.require_path = 'lib'
|
106
20
|
end
|
metadata
CHANGED
@@ -1,135 +1,115 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-sl-snippets
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
14
|
-
-
|
6
|
+
authors:
|
7
|
+
- Rodrigo García Suárez
|
8
|
+
- Simplelógica
|
15
9
|
- Marek L.
|
16
10
|
autorequire:
|
17
11
|
bindir: bin
|
18
12
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
dependencies:
|
23
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
24
16
|
name: refinerycms-pages
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
hash: 15
|
32
|
-
segments:
|
33
|
-
- 2
|
34
|
-
- 0
|
35
|
-
- 0
|
36
|
-
version: 2.0.0
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.1.0.dev
|
37
22
|
type: :runtime
|
38
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 2.1.0.dev
|
39
29
|
description: Ruby on Rails Snippets engine for Refinery CMS
|
40
30
|
email: rodrigo@simplelogica.net
|
41
31
|
executables: []
|
42
|
-
|
43
32
|
extensions: []
|
44
|
-
|
45
33
|
extra_rdoc_files: []
|
46
|
-
|
47
|
-
|
48
|
-
- app/
|
49
|
-
- app/
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- app/assets/javascripts/page-snippet-picker.js
|
37
|
+
- app/assets/javascripts/part-snippets-select.js
|
38
|
+
- app/assets/stylesheets/page-snippet-picker.css
|
50
39
|
- app/controllers/refinery/admin/snippets_controller.rb
|
51
40
|
- app/controllers/refinery/admin/snippets_page_parts_controller.rb
|
52
|
-
- app/
|
53
|
-
- app/
|
54
|
-
- app/
|
55
|
-
- app/views/refinery/admin/
|
56
|
-
- app/views/refinery/admin/
|
57
|
-
- app/views/refinery/admin/
|
58
|
-
- app/views/refinery/admin/snippets/
|
41
|
+
- app/models/refinery/snippet.rb
|
42
|
+
- app/models/refinery/snippet_page_part.rb
|
43
|
+
- app/views/refinery/admin/pages/tabs/_snippets.html.erb
|
44
|
+
- app/views/refinery/admin/pages/tabs/_snippets_content.html.erb
|
45
|
+
- app/views/refinery/admin/pages/tabs/_snippets_field.html.erb
|
46
|
+
- app/views/refinery/admin/pages/tabs/_snippets_list_item.html.erb
|
47
|
+
- app/views/refinery/admin/snippets/_actions.html.erb
|
48
|
+
- app/views/refinery/admin/snippets/_form.html.erb
|
59
49
|
- app/views/refinery/admin/snippets/_locale_picker.html.erb
|
60
|
-
- app/views/refinery/admin/snippets/_snippets.html.erb
|
61
50
|
- app/views/refinery/admin/snippets/_records.html.erb
|
62
|
-
- app/views/refinery/admin/snippets/
|
63
|
-
- app/views/refinery/admin/snippets/
|
51
|
+
- app/views/refinery/admin/snippets/_snippet.html.erb
|
52
|
+
- app/views/refinery/admin/snippets/_snippets.html.erb
|
64
53
|
- app/views/refinery/admin/snippets/_sortable_list.html.erb
|
54
|
+
- app/views/refinery/admin/snippets/edit.html.erb
|
55
|
+
- app/views/refinery/admin/snippets/index.html.erb
|
56
|
+
- app/views/refinery/admin/snippets/new.html.erb
|
65
57
|
- app/views/refinery/admin/snippets_page_parts/add.html.erb
|
66
58
|
- app/views/refinery/admin/snippets_page_parts/remove.html.erb
|
67
|
-
-
|
68
|
-
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
-
|
59
|
+
- config/locales/cs.yml
|
60
|
+
- config/locales/en.yml
|
61
|
+
- config/locales/es.yml
|
62
|
+
- config/locales/nl.yml
|
63
|
+
- config/routes.rb
|
64
|
+
- db/migrate/1_create_snippets.rb
|
65
|
+
- db/migrate/2_translate_snippets.rb
|
66
|
+
- db/migrate/3_create_snippets_page_parts.rb
|
67
|
+
- db/migrate/6_remove_position_from_snippets.rb
|
68
|
+
- db/seeds.rb
|
69
|
+
- features/manage_snippets.feature
|
70
|
+
- features/step_definitions/snippet_steps.rb
|
71
|
+
- features/support/paths.rb
|
72
|
+
- lib/extensions/page_extensions.rb
|
73
|
+
- lib/gemspec.rb
|
72
74
|
- lib/generators/refinery/snippets_generator.rb
|
73
75
|
- lib/refinery/snippets.rb
|
74
|
-
- lib/refinery/snippets/version.rb
|
75
|
-
- lib/refinery/snippets/tabs.rb
|
76
76
|
- lib/refinery/snippets/engine.rb
|
77
|
+
- lib/refinery/snippets/tabs.rb
|
78
|
+
- lib/refinery/snippets/version.rb
|
77
79
|
- lib/refinerycms-snippets.rb
|
78
|
-
- lib/gemspec.rb
|
79
80
|
- lib/tasks/snippets.rake
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
- db/migrate/1_create_snippets.rb
|
84
|
-
- db/migrate/6_remove_position_from_snippets.rb
|
85
|
-
- db/migrate/2_translate_snippets.rb
|
86
|
-
- db/migrate/3_create_snippets_page_parts.rb
|
81
|
+
- readme.md
|
82
|
+
- refinerycms-snippets.gemspec
|
83
|
+
- spec/helpers/application_helper_spec.rb
|
87
84
|
- spec/models/page_spec.rb
|
88
85
|
- spec/models/snippet_spec.rb
|
89
|
-
- spec/helpers/application_helper_spec.rb
|
90
|
-
- refinerycms-snippets.gemspec
|
91
|
-
- config/routes.rb
|
92
|
-
- config/locales/nl.yml
|
93
|
-
- config/locales/en.yml
|
94
|
-
- config/locales/es.yml
|
95
|
-
- config/locales/cs.yml
|
96
|
-
- readme.md
|
97
|
-
- features/support/paths.rb
|
98
|
-
- features/step_definitions/snippet_steps.rb
|
99
|
-
- features/manage_snippets.feature
|
100
|
-
has_rdoc: true
|
101
86
|
homepage: https://github.com/simplelogica/refinerycms-snippets
|
102
87
|
licenses: []
|
103
|
-
|
88
|
+
metadata: {}
|
104
89
|
post_install_message:
|
105
90
|
rdoc_options: []
|
106
|
-
|
107
|
-
require_paths:
|
91
|
+
require_paths:
|
108
92
|
- lib
|
109
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
-
|
111
|
-
requirements:
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
112
95
|
- - ">="
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
version: "0"
|
118
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
-
none: false
|
120
|
-
requirements:
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
121
100
|
- - ">="
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
|
124
|
-
segments:
|
125
|
-
- 0
|
126
|
-
version: "0"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
127
103
|
requirements: []
|
128
|
-
|
129
104
|
rubyforge_project:
|
130
|
-
rubygems_version:
|
105
|
+
rubygems_version: 2.5.1
|
131
106
|
signing_key:
|
132
|
-
specification_version:
|
107
|
+
specification_version: 4
|
133
108
|
summary: Html snippets for Refinery CMS page
|
134
|
-
test_files:
|
135
|
-
|
109
|
+
test_files:
|
110
|
+
- features/manage_snippets.feature
|
111
|
+
- features/step_definitions/snippet_steps.rb
|
112
|
+
- features/support/paths.rb
|
113
|
+
- spec/helpers/application_helper_spec.rb
|
114
|
+
- spec/models/page_spec.rb
|
115
|
+
- spec/models/snippet_spec.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
<div id="<%= "part-#{part.id}" %>" class="part-snippets">
|
2
|
-
<div class="active-snippets block">
|
3
|
-
<% if part.snippets.before.any? %>
|
4
|
-
<h3><%= t('.before_body') %></h3>
|
5
|
-
<ul>
|
6
|
-
<%= render :partial => '/admin/pages/tabs/snippets_list_item', :collection => part.snippets.before, :as => :snippet, :locals => {:part => part, :before_body => true} %>
|
7
|
-
</ul>
|
8
|
-
<% end %>
|
9
|
-
<% if part.snippets.after.any? %>
|
10
|
-
<h3><%= t('.after_body') %></h3>
|
11
|
-
<ul>
|
12
|
-
<%= render :partial => '/admin/pages/tabs/snippets_list_item', :collection => part.snippets.after, :as => :snippet, :locals => {:part => part, :before_body => false} %>
|
13
|
-
</ul>
|
14
|
-
<% end %>
|
15
|
-
</div>
|
16
|
-
<div class="inactive-snippets block">
|
17
|
-
<% inactive_snippets = Snippet.all %>
|
18
|
-
<% if inactive_snippets.length > 0 %>
|
19
|
-
<h3><%= t('.inactive') %></h3>
|
20
|
-
<ul>
|
21
|
-
<% inactive_snippets.each do |snippet| %>
|
22
|
-
<li class='clearfix record <%= cycle('on', 'on-hover') %>' >
|
23
|
-
<span class="title"><%= snippet.title %></span>
|
24
|
-
<div class="actions">
|
25
|
-
<% unless snippet.after?(part) %>
|
26
|
-
<%= link_to t('.add_after_body'), {:controller => 'snippets_page_parts', :action => 'add', :id => @page.id, :snippet_id => snippet.id, :part_id => part.id}, :class => 'add_icon add-snippet' %>
|
27
|
-
<% else %>
|
28
|
-
<span class="add_icon add-snippet"><%= t('.add_after_body') %></span>
|
29
|
-
<% end %>
|
30
|
-
<% unless snippet.before?(part) %>
|
31
|
-
<%= link_to t('.add_before_body'), {:controller => 'snippets_page_parts', :action => 'add', :id => @page.id, :snippet_id => snippet.id, :part_id => part.id, :before_body => 'true'}, :class => 'add_icon add-snippet' %>
|
32
|
-
<% else %>
|
33
|
-
<span class="add_icon add-snippet"><%= t('.add_before_body') %></span>
|
34
|
-
<% end %>
|
35
|
-
</div>
|
36
|
-
</li>
|
37
|
-
<% end %>
|
38
|
-
</ul>
|
39
|
-
<% end %>
|
40
|
-
</div>
|
41
|
-
</div>
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Extensions
|
2
|
-
module ApplicationHelper
|
3
|
-
|
4
|
-
def self.included(base)
|
5
|
-
base.class_eval do
|
6
|
-
|
7
|
-
##
|
8
|
-
# Accessor method to get a page part from a page.
|
9
|
-
# Example:
|
10
|
-
#
|
11
|
-
# content_of(Page.first, :body)
|
12
|
-
#
|
13
|
-
# Will return the body page part of the first page wrap with its
|
14
|
-
# attached snippets.
|
15
|
-
def content_of(page, part_title)
|
16
|
-
part = page.parts.detect do |part|
|
17
|
-
part.title.present? and #protecting against the problem that occurs when have nil title
|
18
|
-
part.title == part_title.to_s or
|
19
|
-
part.title.downcase.gsub(" ", "_") == part_title.to_s.downcase.gsub(" ", "_")
|
20
|
-
end
|
21
|
-
|
22
|
-
if part
|
23
|
-
content = ""
|
24
|
-
content += part.snippets.before.map{|snippet| content_or_render_of(snippet)}.join
|
25
|
-
part_body = part.try(:body)
|
26
|
-
content += part_body unless part_body.nil?
|
27
|
-
content += part.snippets.after.map{|snippet| content_or_render_of(snippet)}.join
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def content_or_render_of(snippet)
|
32
|
-
snippet.template? ? render(:file => snippet.template_path) : snippet.body
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|