Added parent-child relationship to pages to visualize a breadcrump and subpages.
This commit is contained in:
parent
00619ccf55
commit
a8c93c08b7
24 changed files with 513 additions and 51 deletions
|
|
@ -12,7 +12,7 @@ class PagesController < ApplicationController
|
|||
|
||||
def show
|
||||
@page = Page.find_by_permalink(params[:permalink])
|
||||
|
||||
|
||||
if @page.nil?
|
||||
redirect_to new_page_path(:title => params[:permalink])
|
||||
elsif @page.redirect?
|
||||
|
|
@ -24,6 +24,7 @@ class PagesController < ApplicationController
|
|||
def new
|
||||
@page = Page.new
|
||||
@page.title = params[:title].gsub("_", " ") if params[:title]
|
||||
@page.parent = Page.find_by_permalink(params[:parent]) if params[:parent]
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
|
|
|
|||
|
|
@ -95,8 +95,13 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
# to set a title for both the h1-tag and the title in the header
|
||||
def title(page_title)
|
||||
content_for(:title) { page_title }
|
||||
def title(page_title, show_title = true)
|
||||
@content_for_title = page_title.to_s
|
||||
@show_title = show_title
|
||||
end
|
||||
|
||||
def show_title?
|
||||
@show_title
|
||||
end
|
||||
|
||||
def tab_is_active?(tab)
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@ module PagesHelper
|
|||
# end
|
||||
# end
|
||||
|
||||
def wikified_body(body)
|
||||
WikiCloth.new({:data => body, :link_handler => Wikilink.new}).to_html
|
||||
def wikified_body(page)
|
||||
WikiCloth.new({:data => page.body, :link_handler => Wikilink.new, :params => {:referer => page.title}}).to_html
|
||||
end
|
||||
|
||||
def link_to_wikipage(page)
|
||||
link_to page.title, "/wiki/#{page.title}"
|
||||
end
|
||||
# def generate_toc(body)
|
||||
# toc = ""
|
||||
# body.gsub(/^([=]{1,6})\s*(.*?)\s*(\1)/) do
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class Page < ActiveRecord::Base
|
|||
|
||||
acts_as_versioned :version_column => :lock_version
|
||||
self.non_versioned_columns += ['permalink', 'created_at', 'title']
|
||||
acts_as_tree :order => "title"
|
||||
|
||||
attr_accessor :old_title # Save title to create redirect page when editing title
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
- if flash[:error]
|
||||
%h3.error#flashError= flash[:error]
|
||||
#loader{:style => "display:none;"}= image_tag("loader.gif", :border => 0)
|
||||
- if yield(:title)
|
||||
- if show_title?
|
||||
%h1= yield(:title)
|
||||
= yield
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
- content = wikified_body @page.body
|
||||
- content = wikified_body @page
|
||||
//#toc
|
||||
//%h2 Inhaltsverzeichnis
|
||||
//= generate_toc @page.body
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@
|
|||
- form_for @page do |f|
|
||||
= f.error_messages
|
||||
= f.hidden_field :lock_version
|
||||
= f.hidden_field :parent_id
|
||||
%p
|
||||
%b Title
|
||||
%b Titel
|
||||
%br/
|
||||
= f.text_field :title
|
||||
%p
|
||||
|
|
|
|||
|
|
@ -1,14 +1,29 @@
|
|||
- title @page.title
|
||||
- title @page.title, false
|
||||
|
||||
#page-versions{:style => "float:right;margin-top:-2%;text-align:right;"}
|
||||
= link_to "Bearbeiten", edit_page_path(@page)
|
||||
= link_to_function "Versionen (#{@page.versions.count})", "Element.toggle('versions')"
|
||||
#versions{:style => "display:none"}
|
||||
%ul
|
||||
- for version in @page.versions.reverse
|
||||
%li
|
||||
= link_to I18n.l(version.updated_at, :format => "%d.%m.%y %H:%M"), version_page_path(@page, :version => version.lock_version)
|
||||
= "(#{User.find(version.updated_by).nick})"
|
||||
%h1
|
||||
%span#breadcrump
|
||||
- for page in @page.ancestors.reverse
|
||||
= link_to_wikipage(page)
|
||||
>>
|
||||
= @page.title
|
||||
|
||||
#sidebar
|
||||
#page-versions
|
||||
= link_to "Bearbeiten", edit_page_path(@page)
|
||||
= link_to_function "Versionen (#{@page.versions.count})", "Element.toggle('versions')"
|
||||
#versions{:style => "display:none"}
|
||||
%ul
|
||||
- for version in @page.versions.reverse
|
||||
%li
|
||||
= link_to I18n.l(version.updated_at, :format => "%d.%m.%y %H:%M"), version_page_path(@page, :version => version.lock_version)
|
||||
= "(#{User.find(version.updated_by).nick})"
|
||||
|
||||
- unless @page.children.empty?
|
||||
#children
|
||||
%h2 Unterseiten
|
||||
%ul
|
||||
- for page in @page.children
|
||||
%li= link_to_wikipage(page)
|
||||
|
||||
= render :partial => 'body'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue