Project

General

Profile

patching the default wiki template?

Added by markus schulte over 11 years ago

hi there,

we are on redmine 2.2 which is why we can not use the gsc-template module. we don't need its template switching mechanics anyways.

it would just be nice if we would not have to enter the same stuff, namely {{>toc}} and some other macros, whenever we create a new page.

i thought the best way to achieve this is to patch the default template?

but is there a default template? i can't find it.

any other approaches?

cheers,

/markus


Replies (5)

RE: patching the default wiki template? - Added by Ivan Cenov over 11 years ago

markus schulte wrote:

any other approaches?

Create templates as text files and copy-paste them after creating new wiki page.

RE: patching the default wiki template? - Added by markus schulte over 11 years ago

hmm... not that i dislike pragmatic approaches in anyway.

i'd prefer to try this [[http://www.redmine.org/issues/3806]] but i need to preserve upgradability and never wrote a redmine plugin.

/markus

RE: patching the default wiki template? - Added by Ivan Cenov over 11 years ago

markus schulte wrote:

hmm... not that i dislike pragmatic approaches in anyway.

i'd prefer to try this [[http://www.redmine.org/issues/3806]] but i need to preserve upgradability and never wrote a redmine plugin.

/markus

I agree this is pragmatic approach and I don't like it too, but there is no other solution by now.

RE: patching the default wiki template? - Added by markus schulte over 11 years ago

if i just knew how to overwrite the function "initial_page_content(page)" which is defined in "lib/redmine/wiki_formatting/textile/helper.rb":

module Redmine
module WikiFormatting
module Textile
module Helper
def wikitoolbar_for(field_id)
...
def initial_page_content(page)
...

if i just knew that, i think i could make an init.rb file doing the trick.

/m

RE: patching the default wiki template? - Added by markus schulte over 11 years ago

ruby must be a beautiful language if one would only know it.

this really did the trick for me:

1. follow the first two steps of this tutorial: http://www.redmine.org/projects/redmine/wiki/Plugin_Tutorial until you have a populated redmine_wiki_template directory.

2. edit init.rb like this:


Redmine::Plugin.register :redmine_wiki_template do
  name 'Redmine Wiki Template plugin'
  author 'markus'
  description 'This adds a Template to the Wiki'
  version '0.0.1'
  url 'http://example.com/path/to/plugin'
  author_url 'http://example.com/about'
end

module Redmine
  module WikiFormatting
    module Textile
      module Helper
        alias_method :orig_initial_page_content, :initial_page_content
        def initial_page_content(page)
          "{{>toc}}\nh1. #{@page.pretty_title}" 
        end
      end
    end
  end
end

it should be possible to dump all these other files but i don't dare. i don't want to put my success on danger :-) /m

    (1-5/5)