muck-contents 0.2.12 → 0.2.13

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.12
1
+ 0.2.13
@@ -35,14 +35,20 @@ class Muck::ContentsController < ApplicationController
35
35
  # <%= f.text_field :custom_thing %>
36
36
  # <% end -%>
37
37
  # </div>
38
+ #
39
+ # If you are overriding this method in a different controller (ie not contents_controller.rb) you can set
40
+ # the template to render in a different location. For example, if you have a controller named blogs_controller.rb
41
+ # that inherits Muck::ContentsController you can do this to render the new template in the /view/blogs/new.html.erb:
42
+ # @new_template = 'blogs/new'
43
+ #
38
44
  def new
39
45
  @content ||= Content.new
40
46
  @content.uri = params[:path] if params[:path]
41
47
  if logged_in? && has_permission_to_add_content(current_user, @parent, @content)
42
48
  flash[:notice] = @new_content_message || t('muck.contents.page_doesnt_exist_create')
43
49
  respond_to do |format|
44
- format.html { render :template => 'contents/new'}
45
- format.pjs { render :template => 'contents/new', :layout => 'popup'}
50
+ format.html { render :template => @new_template || 'contents/new'}
51
+ format.pjs { render :template => @new_template || 'contents/new', :layout => 'popup'}
46
52
  end
47
53
  else
48
54
  # TODO think about caching this:
@@ -71,7 +77,7 @@ class Muck::ContentsController < ApplicationController
71
77
  @content.save!
72
78
  respond_to do |format|
73
79
  format.html do
74
- redirect_back_or_default(@content.uri)
80
+ after_create_redirect
75
81
  end
76
82
  # HACK there should be a way to force polymorphic_url to use an id instead of to_param
77
83
  update_path = polymorphic_url([@parent, @content]).gsub(@content.to_param, "#{@content.id}") # force the id. The slugs can cause problems during edit
@@ -93,11 +99,16 @@ class Muck::ContentsController < ApplicationController
93
99
  end
94
100
  end
95
101
 
102
+ # If you are overriding this method in a different controller (ie not contents_controller.rb) you can set
103
+ # the template to render in a different location. For example, if you have a controller named blogs_controller.rb
104
+ # that inherits Muck::ContentsController you can do this to render the new template in the /view/blogs/edit.html.erb:
105
+ # @new_template = 'blogs/edit'
106
+ #
96
107
  def edit
97
108
  @page_title = @content.locale_title(I18n.locale)
98
109
  respond_to do |format|
99
- format.html { render :template => 'contents/edit'}
100
- format.pjs { render :template => 'contents/edit', :layout => 'popup'}
110
+ format.html { render :template => @edit_template || 'contents/edit'}
111
+ format.pjs { render :template => @edit_template || 'contents/edit', :layout => 'popup'}
101
112
  end
102
113
  end
103
114
 
@@ -106,7 +117,7 @@ class Muck::ContentsController < ApplicationController
106
117
  @content.update_attributes!(params[:content])
107
118
  respond_to do |format|
108
119
  format.html do
109
- redirect_to @content.uri
120
+ after_update_redirect
110
121
  end
111
122
  format.json { render :json => { :success => true, :content => @content, :parent_id => @parent ? @parent.id : nil, :type => 'update' } }
112
123
  end
@@ -127,7 +138,7 @@ class Muck::ContentsController < ApplicationController
127
138
  respond_to do |format|
128
139
  format.html do
129
140
  flash[:notice] = t('muck.contents.content_removed')
130
- redirect_back_or_default(current_user)
141
+ after_destroy_redirect
131
142
  end
132
143
  format.js do
133
144
  render(:update) do |page|
@@ -140,6 +151,18 @@ class Muck::ContentsController < ApplicationController
140
151
 
141
152
  protected
142
153
 
154
+ def after_create_redirect
155
+ redirect_to @content.uri
156
+ end
157
+
158
+ def after_update_redirect
159
+ redirect_to @content.uri
160
+ end
161
+
162
+ def after_destroy_redirect
163
+ redirect_back_or_default(current_user)
164
+ end
165
+
143
166
  # Setups up the layouts that are available in the 'layouts' pulldown.
144
167
  # Override this method to change the available layouts. Note that the
145
168
  # layout will need to exist in your 'views/layouts' directory
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-contents}
8
- s.version = "0.2.12"
8
+ s.version = "0.2.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball", "Joel Duffin"]
12
- s.date = %q{2009-12-16}
12
+ s.date = %q{2009-12-18}
13
13
  s.email = %q{justin@tatemae.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.rdoc"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-contents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Ball
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-16 00:00:00 -07:00
13
+ date: 2009-12-18 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency