Skip to content

Commit

Permalink
picture captions no longer show as editable on non-admin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
nakajima committed Feb 3, 2009
1 parent 0929f6a commit a025aa3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
6 changes: 2 additions & 4 deletions app/controllers/admin/posts_controller.rb
Expand Up @@ -12,9 +12,7 @@ def index
@posts = post_repo.paginate_index(:page => params[:page])

respond_to do |format|
format.html # index.html.erb
format.rss { render :action => 'index.rss.builder' }
format.xml { render :xml => @posts }
format.html { render :template => 'admin/posts/index.html.erb' }
end
end

Expand All @@ -25,7 +23,7 @@ def show
redirect_to admin_posts_path and return unless @post.type.match(/Article|Snippet/)
@comment = flash[:comment] || @post.comments.build
respond_to do |format|
format.html # show.html.erb
format.html { render :template => 'admin/posts/show.html.erb' }
format.xml { render :xml => @post }
end
end
Expand Down
3 changes: 1 addition & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -51,9 +51,8 @@ def edit_in_place_for(resource, field, options={})
record = resource.is_a?(Array) ? resource.last : resource

options[:id] ||= "#{dom_id(record)}_#{field}"
options[:url] ||= options[:rel] = polymorphic_path(resource)
options[:tag] ||= :div
options[:url] ||= url_for(resource)
options[:rel] = options.delete(:url)

classes = options[:class].try(:split, ' ') || []
classes << 'editable'
Expand Down
2 changes: 1 addition & 1 deletion app/models/post.rb
Expand Up @@ -31,7 +31,7 @@ def type
end

def to_param
permalink
from_feed? ? id.to_s : permalink
end

def delete!
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/posts/types/_picture.html.erb
Expand Up @@ -4,7 +4,7 @@
</div>
<%= image_tag post.permalink %>
<% if post.header -%>
<%= edit_in_place_for post, :header, :tag => :small, :url => "/posts/#{post.id}", :id => "post_#{post.id}_header" %>
<%= edit_in_place_for [:admin, post], :header, :tag => :small, :id => "#{dom_id(post)}_header" %>
<% end -%>
<cite>
&#x2010; Posted from <%= link_to 'flickr', post.cite %>
Expand Down
4 changes: 1 addition & 3 deletions app/views/posts/types/_picture.html.erb
Expand Up @@ -3,9 +3,7 @@
<span class="day"><%= post.created_at.strftime('%e') -%></span>
</div>
<%= image_tag post.permalink %>
<% if post.header -%>
<%= edit_in_place_for post, :header, :tag => :small, :url => "/posts/#{post.id}", :id => "post_#{post.id}_header" %>
<% end -%>
<small><%= post.header %></small>
<cite>
&#x2010; Posted from <%= link_to 'flickr', post.cite %>
</cite>
12 changes: 6 additions & 6 deletions config/routes.rb
Expand Up @@ -14,12 +14,12 @@
map.namespace(:admin) do |admin|
admin.root :controller => 'posts'
admin.resources :posts
admin.resources :articles, :controller => 'posts', :has_many => :comments
admin.resources :quotes, :controller => 'posts'
admin.resources :pictures, :controller => 'posts'
admin.resources :tweets, :controller => 'posts'
admin.resources :links, :controller => 'posts'
admin.resources :snippets, :controller => 'posts', :has_many => :comments
admin.resources :articles, :has_many => :comments
admin.resources :quotes
admin.resources :pictures
admin.resources :tweets
admin.resources :links
admin.resources :snippets, :has_many => :comments
admin.resources :comments, :member => { :report => :put }
end

Expand Down
3 changes: 2 additions & 1 deletion public/javascripts/admin.js
Expand Up @@ -33,7 +33,8 @@ Event.observe(document, 'dom:loaded', function() {

parseField: function() {
var params = new Array; var values = new Array;
var levels = this.element.readAttribute('rel').replace(/(http:|https:|file:)\/\/[^\/]+/, '').split('/').without('');
var levels = this.element.readAttribute('rel').replace(/admin/, '');
levels = levels.replace(/(http:|https:|file:)\/\/[^\/]+/, '').split('/').without('');
levels.each(function(level, i) {
if ( i % 2 == 0 ) { params.push(level.gsub(/s$/, '')) }
else { values.push(level); }
Expand Down

0 comments on commit a025aa3

Please sign in to comment.