Commit ef14f4866093690b767ffd79a915db99c7b8e7e8
1 parent
f538457e
Exists in
master
and in
28 other branches
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
Showing
3 changed files
with
12 additions
and
9 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -3,10 +3,14 @@ class ContentViewerController < PublicController |
3 | 3 | needs_profile |
4 | 4 | |
5 | 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 | 14 | if @page.nil? |
11 | 15 | render_not_found(@path) |
12 | 16 | end | ... | ... |
app/helpers/application_helper.rb
... | ... | @@ -105,9 +105,8 @@ module ApplicationHelper |
105 | 105 | |
106 | 106 | def link_to_document(doc, text = nil) |
107 | 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 | 110 | end |
112 | 111 | |
113 | 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 | 4 | <%= link_to_document(@page.parent, _('Up')) %> |
5 | 5 | <% end %> |
6 | 6 | <% if logged_in? && current_user.person.has_permission?('post_content', profile) %> | ... | ... |