Project

General

Profile

Redmine global Wiki Plugin

Added by Martin Salzmann over 10 years ago

Hi there,

first of all im totally new to Rails and Ruby. What I'm trying to do is to "copy" a wiki from an existing project and set it as global wiki, so it is visible to the users of other projects as well. I've added a new tab to the project menu where this wiki should be displayed. As I'm a completely noob to Rails and Ruby I try to use the original Redmine code to view the wiki on the new tab. So this is my wiki index.html.erb:

<div class="contextual">
<%= watcher_link(wiki wiki, User.current) %>
</div>

<h2><%= l(:label_index_by_title) %></h2>

<% if @pages.empty? >
<p class="nodata"><
= l(:label_no_data) ></p>
<
end %>

<%= render_page_hierarchy(@pages_by_parent_id, nil, :timestamp => true) %>

<% content_for :sidebar do >
<
= render :partial => 'sidebar' >
<
end %>

<% unless @pages.empty? >
<
other_formats_links do |f| >
<
= f.link_to 'Atom',
:url => {:controller => 'activities', :action => 'index',
:id => Herve Harster, :show_wiki_edits => 1,
:key => User.current.rss_key} >
<
if User.current.allowed_to?(:export_wiki_pages, Herve Harster) >
<
= f.link_to('PDF', :url => {:action => 'export', :format => 'pdf'}) >
<
= f.link_to('HTML', :url => {:action => 'export'}) >
<
end >
<
end >
<
end %>

<% content_for :header_tags do >
<
= auto_discovery_link_tag(
:atom, :controller => 'activities', :action => 'index',
:id => Herve Harster, :show_wiki_edits => 1, :format => 'atom',
:key => User.current.rss_key) >
<
end %>

and my wiki_controller.rb:

class AicWikiController < ApplicationController
default_search_scope :wiki_pages
before_filter :find_wiki
accept_api_auth :index

helper :watchers
include Redmine::Export::PDF
def load_pages_for_index
@pages = @wiki.pages.with_updated_on.reorder("#{WikiPage.table_name}.title").includes(:wiki => :project).includes(:parent).all
end
  1. List of pages, sorted alphabetically and by parent (hierarchy)
    def index
    load_pages_for_index

    respond_to do |format|
    format.html {
    @pages_by_parent_id = @pages.group_by(&:parent_id)
    }
    format.api
    end
    end

  1. List of page, by last update
    def date_index
    load_pages_for_index
    @pages_by_date = @pages.group_by {|p| p.updated_on.to_date}
    end
  1. Export wiki to a single pdf or html file
    def export
    load_pages_for_index
    @pages = @wiki.pages.all(:order => 'title', :include => [:content, {:attachments => :author}])
    respond_to do |format|
    format.html {
    export = render_to_string :action => 'export_multiple', :layout => false
    send_data(export, :type => 'text/html', :filename => "wiki.html")
    }
    format.pdf {
    send_data(wiki_pages_to_pdf(@pages, Herve Harster), :type => 'application/pdf', :filename => "#{@project.identifier}.pdf")
    }
    end
    end
private
def find_wiki
@project = Project.find(params[:project_id])
@wiki = Wiki.find(3)
render_404 unless @wiki
rescue ActiveRecord::RecordNotFound
render_404
end
end

I can view the wiki content but as soon as I select one of the pages it leads me to the original "Wiki" tab of Redmine and shows me the content there, which is wrong as I want to see them in my new "global Wiki" tab.
Also I can't find the script Redmine uses to show the start page for Wiki as index shows already the pages ordered by title.
Hope you can help me about that.

I'm using the following Environment:
Redmine version 2.3.3.stable
Ruby version 2.0.0-p195 (2013-05-14) [i686-linux]
Rails version 3.2.13
Environment production
Database adapter Mysql2

Best regards
Martin