refinerycms-snippets 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
19
- <ul id='page_parts'>
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 class='page_part' id='<%= part %>'>
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 => "/shared/admin/form_actions",
28
+
29
+ <%= render :partial => 'form_actions',
37
30
  :locals => {
38
31
  :f => f,
39
- :continue_editing => false,
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
- <script>
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 %>
@@ -18,6 +18,8 @@ en:
18
18
  delete: Remove this snippet forever
19
19
  pages:
20
20
  tabs:
21
+ snippets_content:
22
+ please_save_page_before: Please save this page before you can add any snippets.
21
23
  snippets_field:
22
24
  active: Active
23
25
  inactive: Inactive
@@ -27,3 +27,13 @@ a.add-snippet {
27
27
  #inactive-snippets ul {
28
28
  background: #fcfcfc;
29
29
  }
30
+
31
+ .msg {
32
+ margin: 5px 5px 10px;
33
+ padding: 20px;
34
+ }
35
+
36
+ .msg.alert {
37
+ color: #f66;
38
+ background: #fff;
39
+ }
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
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-17 00:00:00 +02:00
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,11 +0,0 @@
1
- <% content_for :body_content_left do %>
2
- <ul id="snippets">
3
- <% @snippets.each do |snippet| %>
4
- <li>
5
- <%= link_to snippet.title, snippet_url(snippet) %>
6
- </li>
7
- <% end %>
8
- </ul>
9
- <% end %>
10
-
11
- <%= render :partial => "/shared/content_page" %>
@@ -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" %>