forked from sergeyirl/redmine2confluence-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exportwiki.rb
44 lines (35 loc) · 1.07 KB
/
exportwiki.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class ExportWiki
def self.export_text(p)
c = p.content_for_version(nil)
"#{c.text}"
end
# extract first version author and date
def self.export_extra_info(dir, p)
File.open(dir + "/" + p.title + ".extra-info", "w") do |f|
f.printf("'%s' '%s'\n", User.find_by_id(p.content.versions[0].author_id).login, p.content.versions[0].updated_on)
end
end
def self.export_attach(dir, wikipage)
unless wikipage.attachments.empty?
dir = dir + "/" + wikipage.title
Dir.mkdir(dir)
wikipage.attachments.each { |a|FileUtils.cp(a.diskfile, dir + "/" + a.filename ) }
end
true
end
def self.export_wiki(dir, wiki)
dir = dir + "/" + wiki.project.identifier
Dir.mkdir(dir)
wiki.pages.each do |p|
export_attach( dir, p )
export_extra_info( dir, p )
File.open(dir + "/" + p.title + ".textile", "w") { |f| f.write(export_text(p)) }
end
true
end
def self.export_all
system ("mkdir -p /tmp/redmine")
Project.all.each { |prj| export_wiki("/tmp/redmine/", prj.wiki) }
end
end
# vim:et:sw=2:ts=2: