Commit ef14f4866093690b767ffd79a915db99c7b8e7e8

Authored by AntonioTerceiro
1 parent f538457e

ActionItem21: minor changes to make content viewing work



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@961 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/public/content_viewer_controller.rb
@@ -3,10 +3,14 @@ class ContentViewerController < PublicController @@ -3,10 +3,14 @@ class ContentViewerController < PublicController
3 needs_profile 3 needs_profile
4 4
5 def view_page 5 def view_page
6 - path = params[:page].clone  
7 - path.unshift(params[:profile])  
8 - @path = path.join('/')  
9 - @page = Article.find_by_path(@path) 6 + path = params[:page].join('/')
  7 +
  8 + if path.blank?
  9 + @page = profile.home_page
  10 + else
  11 + @page = profile.articles.find_by_path(path)
  12 + end
  13 +
10 if @page.nil? 14 if @page.nil?
11 render_not_found(@path) 15 render_not_found(@path)
12 end 16 end
app/helpers/application_helper.rb
@@ -105,9 +105,8 @@ module ApplicationHelper @@ -105,9 +105,8 @@ module ApplicationHelper
105 105
106 def link_to_document(doc, text = nil) 106 def link_to_document(doc, text = nil)
107 text ||= doc.title 107 text ||= doc.title
108 - path = doc.full_path.split(/\//)  
109 - profile = path.shift  
110 - link_to text, homepage_path(:profile => profile , :page => path) 108 + path = doc.path.split(/\//)
  109 + link_to text, homepage_path(:profile => doc.profile.identifier , :page => path)
111 end 110 end
112 111
113 # TODO: add the actual links 112 # TODO: add the actual links
app/views/content_viewer/view_page.rhtml
1 -<h1><%= @page.title %></h2> 1 +<h2><%= @page.title %></h2>
2 2
3 -<% if @page.parent && !@page.parent.full_path.blank? %> 3 +<% if @page.parent && !@page.parent.path.blank? %>
4 <%= link_to_document(@page.parent, _('Up')) %> 4 <%= link_to_document(@page.parent, _('Up')) %>
5 <% end %> 5 <% end %>
6 <% if logged_in? && current_user.person.has_permission?('post_content', profile) %> 6 <% if logged_in? && current_user.person.has_permission?('post_content', profile) %>