Search code examples
rubyredmineredmine-plugins

Retrieve/iterate Redmine wiki content and return it?


I'm trying to achieve a simple plugin that takes the current wiki page content and matches/replaces everytime a word occurs via regular expression/ The regular expression part itself is easy, I'm more interested in how to retrieve/iterate the wiki content and return it after replacing. How can I do this?

Thanks!

Dennis


Solution

  • If you're writing a plugin, I'm sure you know their source is available on github, and if you check that out you can use the models they already provide. I haven't tested, but it looks like if you:

    require "#{path_to_redmine_source}/app/models/wiki_content"
    WikiContent.all.each do |post|
      post.text.gsub!(/important_data/, "nonsense")
      post.save!
    end
    

    that should work, and it will use whatever adapter's redmine already has configured. It will, however, require loading all the plugins that redmine uses, which could suck.