elexis-wiki-interface 0.4.8 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/Gemfile.lock +25 -1
- data/README.textile +2 -3
- data/bin/wiki_pull +6 -3
- data/bin/wiki_pull_and_commit +38 -0
- data/bin/wiki_push +2 -2
- data/elexis-wiki-interface.gemspec +4 -3
- data/history.textile +14 -0
- data/lib/elexis/wiki/images.rb +338 -0
- data/lib/elexis/wiki/interface.rb +152 -2
- data/lib/elexis/wiki/version.rb +5 -0
- data/lib/elexis/wiki/workspace.rb +286 -0
- data/spec/data/images/ch.elexis.agenda/.project +36 -0
- data/spec/data/images/ch.elexis.agenda/META-INF/MANIFEST.MF +33 -0
- data/spec/data/images/ch.elexis.agenda/doc/fixmedikationaufruf.png +0 -0
- data/spec/data/images/ch.elexis.agenda/plugin.properties +8 -0
- data/spec/data/images/ch.elexis.agenda/plugin.xml +209 -0
- data/spec/data/images/ch.elexis.agenda/plugin_de.properties +8 -0
- data/spec/data/images/ch.elexis.agenda/plugin_en.properties +8 -0
- data/spec/data/images/ch.elexis.agenda/plugin_fr.properties +7 -0
- data/spec/data/images/ch.elexis.core.application.feature/.project +23 -0
- data/spec/data/images/ch.elexis.core.application.feature/build.properties +1 -0
- data/spec/data/images/ch.elexis.core.application.feature/feature.xml +699 -0
- data/spec/data/images/ch.elexis.core.application.feature/pom.xml +12 -0
- data/spec/data/images/ch.elexis.icpc/.project +28 -0
- data/spec/data/images/ch.elexis.icpc/META-INF/MANIFEST.MF +26 -0
- data/spec/data/images/ch.elexis.icpc/doc/Com.hilotec.elexis.opendocument_anleitung_opendocument_1.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/FixmedikationAufruf.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/Icpc8.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/ch.elexis.icpc_icpc1.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/disposan.gif +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/elexis_logo.jpg +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/favicon_green.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc0.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc1.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc2.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc3.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc4.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc5.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc6.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc7.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/icpc9.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/kabel.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/medevit_inbox1.png +0 -0
- data/spec/data/images/ch.elexis.icpc/doc/test.mediawiki +15 -0
- data/spec/data/images/ch.elexis.icpc/doc/test2.mediawiki +19 -0
- data/spec/data/images/ch.elexis.icpc/plugin.xml +74 -0
- data/spec/data/images/ch.elexis.notes/.project +34 -0
- data/spec/data/images/ch.elexis.notes/META-INF/MANIFEST.MF +17 -0
- data/spec/data/images/ch.elexis.notes/doc/At.medevit.medelexis.text.msword:WordBriefe.png +0 -0
- data/spec/data/images/ch.elexis.notes/doc/Ch.medelexis.openoffice:TextverarbeitungSettings.png +0 -0
- data/spec/data/images/ch.elexis.notes/doc/Icpc1.png +0 -0
- data/spec/data/images/ch.elexis.notes/doc/kabel.png +0 -0
- data/spec/data/images/ch.elexis.notes/doc/medidirect:use2.png +0 -0
- data/spec/data/images/ch.elexis.notes/doc/test.mediawiki +13 -0
- data/spec/data/images/ch.elexis.notes/plugin.properties +1 -0
- data/spec/data/images/ch.elexis.notes/plugin.xml +36 -0
- data/spec/data/images/ch.elexis.notes/plugin_de.properties +3 -0
- data/spec/data/images/ch.elexis.notes/plugin_en.properties +3 -0
- data/spec/data/images/ch.elexis.notes/plugin_fr.properties +3 -0
- data/spec/data/images/doc_de/.project +42 -0
- data/spec/data/images/elexis_api_test.png +0 -0
- data/spec/data/push/elexis_api_test.png +0 -0
- data/spec/images_spec.rb +236 -0
- data/spec/interface_spec.rb +118 -0
- data/spec/pull_spec.rb +16 -5
- metadata +128 -13
- data/History.txt +0 -41
- data/bin/wiki_pull_daily +0 -28
- data/lib/elexis/wiki/interface/version.rb +0 -7
- data/lib/elexis/wiki/interface/workspace.rb +0 -404
- data/spec/push_spec.rb +0 -31
- data/spec/update_images_spec.rb +0 -95
- data/spec/user_spec.rb +0 -32
@@ -1,8 +1,158 @@
|
|
1
|
-
|
1
|
+
#encoding: utf-8
|
2
|
+
|
3
|
+
require 'eclipse/plugin'
|
4
|
+
require 'media_wiki'
|
5
|
+
require 'mediawiki_api'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'open-uri'
|
8
|
+
require 'time'
|
9
|
+
require 'yaml'
|
2
10
|
|
3
11
|
module Elexis
|
4
12
|
module Wiki
|
5
|
-
|
13
|
+
ImagePrefix = /Datei:|Image:/i
|
14
|
+
|
15
|
+
class Interface
|
16
|
+
attr_reader :user, :password, :wiki_url, :mw_gw, :mw_api
|
17
|
+
|
18
|
+
private
|
19
|
+
def load_config_file(wiki_url)
|
20
|
+
if ENV['TRAVIS']
|
21
|
+
@user = 'nobody'
|
22
|
+
@password = 'nopassword'
|
23
|
+
@mw_gw = MediaWiki::Gateway.new(@wiki_url)
|
24
|
+
@mw_api = MediawikiApi::Client.new @wiki_url
|
25
|
+
else
|
26
|
+
possibleCfgs = [File.join(Dir.pwd, 'config.yml'), '/etc/elexis-wiki-interface/config.yml', ]
|
27
|
+
possibleCfgs.each{ |cfg| @config_yml = cfg; break if File.exists?(cfg) }
|
28
|
+
raise "need a config file #{possibleCfgs.join(' or ')} for wiki with user/password" unless File.exists?(@config_yml)
|
29
|
+
yaml = YAML.load_file(@config_yml)
|
30
|
+
@wiki_url = wiki_url
|
31
|
+
@wiki_url ||= defined?(RSpec) ? yaml['test_wiki'] : yaml['wiki']
|
32
|
+
@user = yaml['user'] if yaml
|
33
|
+
@password = yaml['password'] if yaml
|
34
|
+
@mw_gw = MediaWiki::Gateway.new(@wiki_url)
|
35
|
+
@mw_gw.login(@user, @password)
|
36
|
+
@mw_api = MediawikiApi::Client.new @wiki_url
|
37
|
+
res = @mw_api.log_in(@user, @password)
|
38
|
+
end
|
39
|
+
puts "MediWiki #{@wiki_url} user #{@user} with password #{@password}" if $VERBOSE
|
40
|
+
wiki_url
|
41
|
+
end
|
42
|
+
|
43
|
+
public
|
44
|
+
|
45
|
+
def initialize(wiki_url=nil)
|
46
|
+
load_config_file(wiki_url)
|
47
|
+
$ws_errors = []
|
48
|
+
end
|
49
|
+
|
50
|
+
def images(page)
|
51
|
+
pages = @mw_gw.images(page)
|
52
|
+
end
|
53
|
+
|
54
|
+
def users
|
55
|
+
@mw_gw.users
|
56
|
+
end
|
57
|
+
|
58
|
+
def contributions(username)
|
59
|
+
@mw_gw.contributions(username)
|
60
|
+
end
|
61
|
+
|
62
|
+
def get(page)
|
63
|
+
@mw_gw.get(page)
|
64
|
+
end
|
65
|
+
|
66
|
+
def create(page, content, options = {})
|
67
|
+
@mw_api.create_page(page, content)
|
68
|
+
end
|
69
|
+
|
70
|
+
def edit(page, text, comment = nil)
|
71
|
+
@mw_api.edit({:title => page, :text => text, :comment => comment})
|
72
|
+
end
|
73
|
+
|
74
|
+
def delete(page, reason='')
|
75
|
+
@mw_api.delete_page(page, reason)
|
76
|
+
end
|
77
|
+
|
78
|
+
def upload_image(filename, path, comment='', options = "ignorewarnings")
|
79
|
+
# fails with mediawiki 1.19 because of missing @tokens
|
80
|
+
res = @mw_api.upload_image(filename, path, comment, options)
|
81
|
+
msg = "Uploaded #{filename}"
|
82
|
+
unless res.data['result'] == 'Success'
|
83
|
+
puts "Unable to upload #{filename} #{res.data['result'] }"
|
84
|
+
raise "Unable to upload #{filename} #{res.data['result'] }"
|
85
|
+
end
|
86
|
+
res
|
87
|
+
rescue MediawikiApi::ApiError => e
|
88
|
+
msg = "uploading #{filename} failed #{e}"
|
89
|
+
puts msg
|
90
|
+
puts e.backtrace.join("\n") if $VERBOSE
|
91
|
+
raise msg
|
92
|
+
end
|
93
|
+
alias_method :upload, :upload_image
|
94
|
+
|
95
|
+
def wiki_json_timestamp_to_time(json, page_or_img)
|
96
|
+
return nil unless json
|
97
|
+
begin
|
98
|
+
m = json.match(/timestamp['"]:['"]([^'"]+)/)
|
99
|
+
return Time.parse(m[1]) if m
|
100
|
+
end
|
101
|
+
nil
|
102
|
+
end
|
103
|
+
|
104
|
+
# http://wiki.elexis.info/api.php?action=query&format=json&list=allimages&ailimit=5&aiprop=timestamp&aiprefix=Ch.elexis.notes:config.png&*
|
105
|
+
def get_image_modification_name(image)
|
106
|
+
short_image = image.sub(ImagePrefix, '')
|
107
|
+
json_url = "#{@wiki_url}?action=query&format=json&list=allimages&ailimit=5&aiprop=timestamp&iiprop=url&aiprefix=#{short_image}"
|
108
|
+
json = RestClient.get(json_url)
|
109
|
+
wiki_json_timestamp_to_time(json, image)
|
110
|
+
end
|
111
|
+
|
112
|
+
# helper function, as mediawiki-gateway does not handle this situation correctly
|
113
|
+
def download_image_file(image, destination = nil, pageName = nil)
|
114
|
+
if not destination or not File.exist? destination
|
115
|
+
# first search by pagename and imagename
|
116
|
+
if pageName
|
117
|
+
json_url = "#{@wiki_url}?action=query&format=json&list=allimages&ailimit=5&aiprefix=#{pageName}&aifrom=#{image.sub(ImagePrefix, '')}"
|
118
|
+
else
|
119
|
+
json_url = "#{@wiki_url}?action=query&format=json&list=allimages&ailimit=1&aifrom=#{image.sub(File.extname(image), '')}"
|
120
|
+
end
|
121
|
+
json = RestClient.get(json_url)
|
122
|
+
unless json
|
123
|
+
puts "JSON: Could not fetch for image #{image} for #{pageName} using #{json_url}"
|
124
|
+
return
|
125
|
+
end
|
126
|
+
begin
|
127
|
+
answer = JSON.parse(json)
|
128
|
+
image_url = nil
|
129
|
+
image_url = answer['query'].first[1].first['url'] if answer['query'] and answer['query'].size >= 1 and answer['query'].first[1].size > 0
|
130
|
+
unless image_url
|
131
|
+
# as we did not find it search imagename only
|
132
|
+
json_url = "#{@wiki_url}?action=query&format=json&list=allimages&ailimit=5&aifrom=#{image.sub(ImagePrefix, '')}"
|
133
|
+
json = RestClient.get(json_url)
|
134
|
+
if json
|
135
|
+
answer = JSON.parse(json)
|
136
|
+
image_url = answer['query'].first[1].first['url'] if answer['query'] and answer['query'].size >= 1 and answer['query'].first[1].size > 0
|
137
|
+
end
|
138
|
+
end
|
139
|
+
if image_url and /#{image}/i.match(image_url)
|
140
|
+
return open(image_url).read unless destination
|
141
|
+
File.open(destination, 'w') do |file|
|
142
|
+
file.write(open(image_url).read)
|
143
|
+
end
|
144
|
+
files = Dir.glob(destination, File::FNM_CASEFOLD)
|
145
|
+
else
|
146
|
+
puts "skipping image #{image} for page #{pageName}" if $VERBOSE
|
147
|
+
end
|
148
|
+
rescue => e
|
149
|
+
puts "JSON: Could not fetch for image #{image} for #{pageName} using #{json_url}"
|
150
|
+
puts " was '#{json}'"
|
151
|
+
puts " error was #{e.inspect}"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
puts "Downloaded image #{destination} #{File.size(destination)} bytes" if $VERBOSE and File.exists?(destination)
|
155
|
+
end
|
6
156
|
end
|
7
157
|
end
|
8
158
|
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'eclipse/plugin'
|
3
|
+
require "elexis/wiki/interface"
|
4
|
+
require "elexis/wiki/images"
|
5
|
+
require 'fileutils'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'time'
|
8
|
+
require 'yaml'
|
9
|
+
|
10
|
+
module Elexis
|
11
|
+
module Wiki
|
12
|
+
class Workspace
|
13
|
+
TestPattern = /[\._]test[s]*$/i
|
14
|
+
attr_reader :info, :views_missing_documentation, :perspectives_missing_documentation, :features_missing_documentation,
|
15
|
+
:ws_dir, :doc_project, :features, :info,
|
16
|
+
:if, :wiki_url, :user, :password
|
17
|
+
def initialize(dir, wiki = nil)
|
18
|
+
$stdout.sync = true
|
19
|
+
@if = Elexis::Wiki::Interface.new(wiki)
|
20
|
+
raise "must define wiki with user and password in #{@config_yml}" unless @if.user and @if.password and @if.wiki_url
|
21
|
+
$ws_errors = []
|
22
|
+
@info = Eclipse::Workspace.new(dir)
|
23
|
+
@doc_projects = Dir.glob(File.join(dir, "doc_??", ".project"))
|
24
|
+
@ws_dir = dir
|
25
|
+
@info.parse_sub_dirs
|
26
|
+
@info.show if $VERBOSE
|
27
|
+
@views_missing_documentation =[]
|
28
|
+
@perspectives_missing_documentation =[]
|
29
|
+
@features_missing_documentation =[]
|
30
|
+
end
|
31
|
+
|
32
|
+
def show_missing(details = false)
|
33
|
+
puts
|
34
|
+
msg = "Show errors for #{@info.workspace_dir}"
|
35
|
+
puts "-" * msg.size
|
36
|
+
puts msg
|
37
|
+
puts "-" * msg.size
|
38
|
+
|
39
|
+
if views_missing_documentation.size and
|
40
|
+
features_missing_documentation.size == 0 and
|
41
|
+
perspectives_missing_documentation.size == 0
|
42
|
+
puts "Eclipse-Workspace #{@info.workspace_dir} seems to have documented all views, features, plugins and perspectives"
|
43
|
+
else
|
44
|
+
puts "Eclipse-Workspace #{@info.workspace_dir} needs documenting "
|
45
|
+
if views_missing_documentation.size > 0
|
46
|
+
puts " #{views_missing_documentation.size} views"
|
47
|
+
puts " #{views_missing_documentation.inspect}" if details
|
48
|
+
end
|
49
|
+
if features_missing_documentation.size > 0
|
50
|
+
puts " #{features_missing_documentation.size} features"
|
51
|
+
puts " #{features_missing_documentation.inspect}" if details
|
52
|
+
end
|
53
|
+
if perspectives_missing_documentation.size > 0
|
54
|
+
puts " #{perspectives_missing_documentation.size} perspectives"
|
55
|
+
puts " #{perspectives_missing_documentation.inspect}" if details
|
56
|
+
end
|
57
|
+
end
|
58
|
+
puts $ws_errors
|
59
|
+
puts "Displayed #{$ws_errors.size} errors"
|
60
|
+
end
|
61
|
+
def push_doc_dir(id, docDir = nil)
|
62
|
+
docDir ||= File.join(@info.workspace_dir, id, 'doc')
|
63
|
+
to_push = Dir.glob("#{docDir}/*.mediawiki")
|
64
|
+
to_push.each{
|
65
|
+
|file|
|
66
|
+
# verify that locally committed file is newer than the page in the wiki
|
67
|
+
# verify that the content after the push matches the local content
|
68
|
+
my_new_content = File.new(file).read
|
69
|
+
to_verify = my_new_content.gsub(/\n+/,"\n").chomp
|
70
|
+
pagename = File.basename(file, '.mediawiki').capitalize
|
71
|
+
last_wiki_modification = get_page_modification_time(pagename)
|
72
|
+
last_git_modification = get_git_modification(file)
|
73
|
+
unless last_wiki_modification
|
74
|
+
puts "first upload #{File.basename(file)} last_git_modification is #{last_git_modification}" if $VERBOSE
|
75
|
+
@if.create(pagename, my_new_content,{:overwrite => true, :summary => "pushed by #{File.basename(__FILE__)}" })
|
76
|
+
else
|
77
|
+
got = @if.get(pagename).gsub(/\n+/,"\n")
|
78
|
+
if got == to_verify
|
79
|
+
puts "No changes to push for #{file}"
|
80
|
+
next
|
81
|
+
end
|
82
|
+
@if.edit(pagename, to_verify,{:overwrite => true, :summary => "pushed by #{File.basename(__FILE__)}" })
|
83
|
+
puts "Uploaded #{file} to #{pagename}" # if $VERBOSE
|
84
|
+
end
|
85
|
+
}
|
86
|
+
if to_push.size > 0 # then upload also all *.png files
|
87
|
+
images_to_push = Dir.glob("#{docDir}/*.png")
|
88
|
+
images_to_push.each{
|
89
|
+
|image|
|
90
|
+
if /:/.match(File.basename(image))
|
91
|
+
puts "You may not add a file containg ':' or it will break git for Windows. Remove/rename #{image}"
|
92
|
+
exit
|
93
|
+
end
|
94
|
+
|
95
|
+
git_mod = get_git_modification(image)
|
96
|
+
wiki_mod = @if.get_image_modification_name(File.basename(image))
|
97
|
+
|
98
|
+
if wiki_mod == nil
|
99
|
+
puts "first upload #{File.basename(image)} as last_git_modification is #{git_mod}" if $VERBOSE
|
100
|
+
else
|
101
|
+
to_verify = File.new(image, 'rb').read
|
102
|
+
got = @if.download_image_file(File.basename(image))
|
103
|
+
if got and got == to_verify
|
104
|
+
puts "nothing to upload for #{image}" if $VERBOSE
|
105
|
+
next
|
106
|
+
end
|
107
|
+
end
|
108
|
+
begin
|
109
|
+
res = @if.upload(File.basename(image), image)
|
110
|
+
puts "res für #{image} exists? #{File.exists?(image)} ist #{res.to_s}" if $VERBOSE
|
111
|
+
rescue MediaWiki::APIError => e
|
112
|
+
puts "rescue für #{image} #{e}" # if $VERBOSE
|
113
|
+
if /verification-error/.match(e.to_s)
|
114
|
+
puts "If you received API error: code 'verification-error', info 'This file did not pass file verification'"
|
115
|
+
puts "this means that the file type and content do not match, e.g. you have a *png file but in reality it is a JPEG file."
|
116
|
+
puts "In this case convert file.png file.png fixes this problem"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
}
|
120
|
+
end
|
121
|
+
end
|
122
|
+
def push
|
123
|
+
@doc_projects.each{
|
124
|
+
|prj|
|
125
|
+
dir = File.dirname(prj)
|
126
|
+
push_doc_dir(File.basename(dir), dir)
|
127
|
+
}
|
128
|
+
@info.features.each{ |id, info| push_doc_dir(id) }
|
129
|
+
@info.plugins.each{ |id,plugin| push_doc_dir(id) }
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_git_modification(file)
|
133
|
+
return nil unless File.exists?(file)
|
134
|
+
git_time = `git log -1 --pretty=format:%ai '#{file}'`
|
135
|
+
return nil unless git_time.length > 8
|
136
|
+
Time.parse(git_time.chomp).utc
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_page_modification_time(pagename)
|
140
|
+
json_url = "#{@if.wiki_url}?action=query&format=json&prop=revisions&titles=#{pagename}&rvprop=timestamp"
|
141
|
+
json = RestClient.get(json_url)
|
142
|
+
@if.wiki_json_timestamp_to_time(json, pagename)
|
143
|
+
end
|
144
|
+
|
145
|
+
def remove_image_files_with_id(id, info, docDir = nil)
|
146
|
+
docDir ||= File.join(@info.workspace_dir, id, 'doc')
|
147
|
+
files = Dir.glob(File.join(docDir, "#{id}_*jpg"), File::FNM_CASEFOLD) +
|
148
|
+
Dir.glob(File.join(docDir, "#{id}_*gif"), File::FNM_CASEFOLD) +
|
149
|
+
Dir.glob(File.join(docDir, "#{id}_*png"), File::FNM_CASEFOLD)
|
150
|
+
system("git rm #{files.join(' ')}") if files.size > 0
|
151
|
+
end
|
152
|
+
|
153
|
+
def pull
|
154
|
+
savedDir = Dir.pwd
|
155
|
+
idx = 0
|
156
|
+
@doc_projects.each{
|
157
|
+
|prj|
|
158
|
+
puts "#{@if.wiki_url} Pulling for doc_project nr #{idx}: #{prj}" if (idx % 10) == 0
|
159
|
+
idx += 1
|
160
|
+
dir = File.dirname(prj)
|
161
|
+
get_content_from_wiki(dir, File.basename(dir))
|
162
|
+
remove_image_files_with_id(File.basename(File.dirname(prj)), info, dir)
|
163
|
+
} # unless defined?(RSpec)
|
164
|
+
|
165
|
+
idx = 0
|
166
|
+
@info.plugins.each{
|
167
|
+
|id, info|
|
168
|
+
# next if not defined?(RSpec) and not /org.iatrix/i.match(id)
|
169
|
+
puts "#{@if.wiki_url} Pulling for plugin nr #{idx}: #{id}" if (idx % 10) == 0
|
170
|
+
idx += 1
|
171
|
+
pull_docs_views(info)
|
172
|
+
pull_docs_plugins(info)
|
173
|
+
pull_docs_perspectives(info)
|
174
|
+
remove_image_files_with_id(id, info)
|
175
|
+
}
|
176
|
+
|
177
|
+
idx = 0
|
178
|
+
@info.features.each{
|
179
|
+
|id, info|
|
180
|
+
# next if not defined?(RSpec) and not /ehc|icp/i.match(id)
|
181
|
+
puts "#{@if.wiki_url} Pulling for feature nr #{idx}: #{id}" if (idx % 10) == 0
|
182
|
+
idx += 1
|
183
|
+
check_page_in_matrix(id)
|
184
|
+
pull_docs_features(info)
|
185
|
+
remove_image_files_with_id(id, info)
|
186
|
+
}
|
187
|
+
|
188
|
+
Dir.chdir(savedDir)
|
189
|
+
end
|
190
|
+
|
191
|
+
def perspectiveToPageName(perspective)
|
192
|
+
# http://wiki.elexis.info/P_Abrechnungen
|
193
|
+
name = 'P_'+ perspective.id.gsub(' ', '')
|
194
|
+
puts "perspectiveToPageName for #{perspective.inspect} is '#{name}'" if $VERBOSE
|
195
|
+
name
|
196
|
+
end
|
197
|
+
def viewToPageName(plugin_id, view)
|
198
|
+
# für ch.elexis.agenda.views.TagesView (= view.id)
|
199
|
+
# http://wiki.elexis.info/ChElexisAgendaViewsTagesview
|
200
|
+
# wurde unter http://wiki.elexis.info/Hauptseite ein Link Agenda (= view.name) angelegt.
|
201
|
+
# evtl. sollten wir testen, ob dieser Link vorhanden ist
|
202
|
+
# http://wiki.elexis.info/ChElexisIcpcViewsEpisodesview
|
203
|
+
comps = view.id.split('.')
|
204
|
+
pageName = comps[0..-2].collect{|x| x.capitalize}.join + 'Views'+view.id.split('.').last.capitalize
|
205
|
+
puts "viewToPageName for #{plugin_id}/#{view.id} is #{pageName}" if $VERBOSE
|
206
|
+
pageName
|
207
|
+
end
|
208
|
+
|
209
|
+
def check_page_in_matrix(pagename, matrix_name = 'Matrix_3.0')
|
210
|
+
savedDir = Dir.pwd
|
211
|
+
Dir.chdir(@ws_dir)
|
212
|
+
res = get_content_from_wiki('.', matrix_name)
|
213
|
+
return true if res.index("[[#{pagename}]]") or res.index("[[#{pagename}.feature.group]]")
|
214
|
+
$ws_errors << "#{matrix_name}: could not find #{pagename}"
|
215
|
+
Dir.chdir(savedDir)
|
216
|
+
end
|
217
|
+
|
218
|
+
private
|
219
|
+
def get_content_from_wiki(out_dir, pageName)
|
220
|
+
puts "get_content_from_wiki page #{pageName} -> #{out_dir}" if $VERBOSE
|
221
|
+
out_name = File.join(out_dir, pageName + '.mediawiki')
|
222
|
+
FileUtils.makedirs(out_dir) unless File.directory?(out_dir)
|
223
|
+
savedDir = Dir.pwd
|
224
|
+
Dir.chdir(out_dir)
|
225
|
+
begin
|
226
|
+
content = @if.get(pageName)
|
227
|
+
rescue
|
228
|
+
puts "Unable to get #{pageName} for #{out_dir} from #{@if.wiki_url ? File.dirname(@if.wiki_url): 'nil'}"
|
229
|
+
return nil
|
230
|
+
end
|
231
|
+
if content
|
232
|
+
ausgabe = File.open(out_name, 'w+') { |f| f.write content }
|
233
|
+
images = @if.images(pageName)
|
234
|
+
images.each{
|
235
|
+
|image|
|
236
|
+
image_name = File.basename(image)
|
237
|
+
m = Wiki::ImagePattern.match(image_name)
|
238
|
+
image_name = m[2] if m and not image_name.index('-')
|
239
|
+
@if.download_image_file(image_name, image_name, pageName)
|
240
|
+
|
241
|
+
break if defined?(RSpec) and not /matrix|icpc|ehc/i.match(pageName) # speed up RSpec
|
242
|
+
}
|
243
|
+
else
|
244
|
+
puts "Could not fetch #{pageName} from #{@if}" if $VERBOSE
|
245
|
+
end
|
246
|
+
Dir.chdir(savedDir)
|
247
|
+
content
|
248
|
+
end
|
249
|
+
def pull_docs_views(plugin)
|
250
|
+
id = plugin.symbolicName
|
251
|
+
plugin.views.each{
|
252
|
+
|id, view|
|
253
|
+
pageName = viewToPageName(plugin.symbolicName, view)
|
254
|
+
content = get_content_from_wiki(File.join(@info.workspace_dir, File.basename(plugin.jar_or_src), 'doc'), pageName)
|
255
|
+
next if TestPattern.match(id)
|
256
|
+
@views_missing_documentation << pageName unless content
|
257
|
+
}
|
258
|
+
end
|
259
|
+
def pull_docs_perspectives(plugin)
|
260
|
+
id = plugin.symbolicName
|
261
|
+
plugin.perspectives.each{
|
262
|
+
|id, perspective|
|
263
|
+
pageName = perspectiveToPageName(perspective)
|
264
|
+
content = get_content_from_wiki(File.join(@info.workspace_dir, File.basename(plugin.jar_or_src), 'doc'), pageName)
|
265
|
+
next if TestPattern.match(id)
|
266
|
+
@perspectives_missing_documentation << pageName unless content
|
267
|
+
}
|
268
|
+
end
|
269
|
+
def pull_docs_plugins(plugin)
|
270
|
+
id = plugin.symbolicName
|
271
|
+
pageName = id.capitalize
|
272
|
+
content = get_content_from_wiki(File.join(@info.workspace_dir, File.basename(plugin.jar_or_src), 'doc'), pageName)
|
273
|
+
return if TestPattern.match(id)
|
274
|
+
end
|
275
|
+
def pull_docs_features(feature)
|
276
|
+
id = feature.symbolicName
|
277
|
+
pageName = id.capitalize
|
278
|
+
content = get_content_from_wiki(File.join(@info.workspace_dir, id, 'doc'), pageName)
|
279
|
+
unless content
|
280
|
+
content = get_content_from_wiki(File.join(@info.workspace_dir, id, 'doc'), pageName.sub(/feature$/, 'feature.feature.group'))
|
281
|
+
puts "pull_docs_features failed #{id} #{pageName}" unless content
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|