refinerycms-snippets 0.4.0 → 0.4.1
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.
- data/app/controllers/admin/snippets_controller.rb +29 -0
- data/app/views/admin/pages/tabs/_snippets_content.html.erb +4 -0
- data/app/views/admin/snippets/_form.html.erb +8 -19
- data/app/views/admin/snippets/_form_actions.html.erb +31 -0
- data/config/locales/en.yml +2 -0
- data/public/stylesheets/page-snippet-picker.css +10 -0
- metadata +5 -6
- data/app/views/snippets/index.html.erb +0 -11
- data/app/views/snippets/show.html.erb +0 -33
@@ -3,5 +3,34 @@ module Admin
|
|
3
3
|
|
4
4
|
crudify :snippet, :xhr_paging => true
|
5
5
|
|
6
|
+
def create
|
7
|
+
if (@snippet = Snippet.create(params[:snippet])).valid?
|
8
|
+
(request.xhr? ? flash.now : flash).notice = t(
|
9
|
+
'refinery.crudify.created',
|
10
|
+
:what => "#{@snippet.title}"
|
11
|
+
)
|
12
|
+
|
13
|
+
unless request.xhr?
|
14
|
+
redirect_to (params[:continue_editing] =~ /1/ ? edit_admin_snippet_path(@snippet) : admin_snippets_url)
|
15
|
+
else
|
16
|
+
response = Hash.new
|
17
|
+
response['redirect'] = edit_admin_snippet_path(@snippet) if params[:continue_editing]
|
18
|
+
render :json => response
|
19
|
+
end
|
20
|
+
|
21
|
+
else
|
22
|
+
unless request.xhr?
|
23
|
+
render :action => 'new'
|
24
|
+
else
|
25
|
+
html_snippets = Hash.new
|
26
|
+
html_snippets['flash_container'] = render_to_string(:partial => "/shared/admin/error_messages",
|
27
|
+
:locals => {
|
28
|
+
:object => @snippet,
|
29
|
+
:include_object_name => true
|
30
|
+
})
|
31
|
+
render :json => {'snippets' => html_snippets}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
6
35
|
end
|
7
36
|
end
|
@@ -1,4 +1,8 @@
|
|
1
|
+
<% if @page.new_record? %>
|
2
|
+
<div class="msg alert"><%= t('.please_save_page_before') %></div>
|
3
|
+
<% else %>
|
1
4
|
<%= render :partial => '/admin/pages/tabs/snippets_field' %>
|
5
|
+
<% end %>
|
2
6
|
|
3
7
|
<% content_for :stylesheets do %>
|
4
8
|
<%= stylesheet_link_tag 'page-snippet-picker' %>
|
@@ -14,37 +14,26 @@
|
|
14
14
|
<%= f.label :title -%>
|
15
15
|
<%= f.text_field :title, :class => 'larger widest' -%>
|
16
16
|
</div>
|
17
|
+
<br />
|
17
18
|
<div class='field'>
|
18
|
-
<div
|
19
|
-
<
|
20
|
-
<% [:body].each_with_index do |part, part_index| %>
|
21
|
-
<li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'>
|
22
|
-
<%= link_to part.to_s.titleize, "##{part}" %>
|
23
|
-
</li>
|
24
|
-
<% end %>
|
25
|
-
</ul>
|
26
|
-
|
27
|
-
<div id='page_part_editors'>
|
19
|
+
<div class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
|
20
|
+
<div>
|
28
21
|
<% [:body].each do |part| %>
|
29
|
-
<div
|
22
|
+
<div>
|
30
23
|
<%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
|
31
24
|
</div>
|
32
25
|
<% end %>
|
33
26
|
</div>
|
34
27
|
</div>
|
35
|
-
|
36
|
-
<%= render :partial =>
|
28
|
+
|
29
|
+
<%= render :partial => 'form_actions',
|
37
30
|
:locals => {
|
38
31
|
:f => f,
|
39
|
-
:continue_editing =>
|
32
|
+
:continue_editing => true,
|
40
33
|
:delete_title => t('delete', :scope => 'admin.snippets.snippet'),
|
41
34
|
:delete_confirmation => t('message', :scope => 'shared.admin.delete', :title => @snippet.title)
|
42
35
|
} %>
|
43
36
|
<% end -%>
|
44
37
|
<% content_for :javascripts do %>
|
45
|
-
|
46
|
-
$(document).ready(function(){
|
47
|
-
page_options.init(false, '', '');
|
48
|
-
});
|
49
|
-
</script>
|
38
|
+
|
50
39
|
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<div class="form-actions">
|
2
|
+
<div class="form-actions-left">
|
3
|
+
<%= hidden_field_tag :continue_editing, 1 %>
|
4
|
+
|
5
|
+
<%= submit_tag t('save', :scope => 'shared.admin.form_actions'),
|
6
|
+
:id => 'save-button',
|
7
|
+
:class => 'wymupdate button no-js-hide' %>
|
8
|
+
|
9
|
+
<%= submit_tag t('save_and_continue_editing', :scope => 'shared.admin.continue_editing'),
|
10
|
+
:id => 'save-continue-button',
|
11
|
+
:class => "wymupdate button" %>
|
12
|
+
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<% content_for :javascripts do %>
|
16
|
+
<script type="text/javascript">
|
17
|
+
$(document).ready(function () {
|
18
|
+
var save_button = $('#save-button'),
|
19
|
+
save_continue_button = $('#save-continue-button'),
|
20
|
+
continue_input = $('#continue_editing');
|
21
|
+
|
22
|
+
save_button.bind('click', function () {
|
23
|
+
continue_input.val('0');
|
24
|
+
});
|
25
|
+
|
26
|
+
save_continue_button.bind('click', function () {
|
27
|
+
continue_input.val('1');
|
28
|
+
});
|
29
|
+
});
|
30
|
+
</script>
|
31
|
+
<% end %>
|
data/config/locales/en.yml
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-snippets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marek L.
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-28 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -54,9 +54,8 @@ files:
|
|
54
54
|
- app/controllers/admin/snippets_page_controller.rb
|
55
55
|
- app/models/snippet_page.rb
|
56
56
|
- app/models/snippet.rb
|
57
|
-
- app/views/snippets/show.html.erb
|
58
|
-
- app/views/snippets/index.html.erb
|
59
57
|
- app/views/admin/snippets/_snippets.html.erb
|
58
|
+
- app/views/admin/snippets/_form_actions.html.erb
|
60
59
|
- app/views/admin/snippets/edit.html.erb
|
61
60
|
- app/views/admin/snippets/_sortable_list.html.erb
|
62
61
|
- app/views/admin/snippets/index.html.erb
|
@@ -1,33 +0,0 @@
|
|
1
|
-
<% content_for :body_content_title do %>
|
2
|
-
<%= @snippet.title %>
|
3
|
-
<% end %>
|
4
|
-
|
5
|
-
<% content_for :body_content_left do %>
|
6
|
-
<section>
|
7
|
-
<h1>Title</h1>
|
8
|
-
<p>
|
9
|
-
<%=raw @snippet.title %>
|
10
|
-
</p>
|
11
|
-
</section>
|
12
|
-
<section>
|
13
|
-
<h1>Body</h1>
|
14
|
-
<p>
|
15
|
-
<%=raw @snippet.body %>
|
16
|
-
</p>
|
17
|
-
</section>
|
18
|
-
<% end %>
|
19
|
-
|
20
|
-
<% content_for :body_content_right do %>
|
21
|
-
<aside>
|
22
|
-
<h2><%= t('.other') %></h2>
|
23
|
-
<ul id="snippets">
|
24
|
-
<% @snippets.each do |snippet| %>
|
25
|
-
<li>
|
26
|
-
<%= link_to snippet.title, snippet_url(snippet) %>
|
27
|
-
</li>
|
28
|
-
<% end %>
|
29
|
-
</ul>
|
30
|
-
</aside>
|
31
|
-
<% end %>
|
32
|
-
|
33
|
-
<%= render :partial => "/shared/content_page" %>
|