diff --git a/Wiki.rb b/Wiki.rb
index 8d2d63d..1058172 100644
--- a/Wiki.rb
+++ b/Wiki.rb
@@ -7,11 +7,10 @@ class Wiki
@text = nil
@dummy = false
- def initialize
- config = YAML::load_file(File.join(__dir__, 'config.yaml'))
- @client = MWClient.new config["url"]
- @client.log_in config["username"], config["password"]
- @dummy = config["dummy"]
+ def initialize(url, username, password, dummy = false)
+ @client = MWClient.new url
+ @client.log_in username, password
+ @dummy = dummy
end
def create_page(name, content)
diff --git a/start.rb b/start.rb
index f6d2337..0b18c55 100755
--- a/start.rb
+++ b/start.rb
@@ -1,12 +1,26 @@
#!/usr/bin/ruby
require './Wiki.rb'
-wiki = Wiki.new
-list = wiki.get_list()['allpages']
-for page in list do
- page_text = wiki.get_text(page['title']).body
- if page_text.match(/\[\[Category\:Jokes\]\]/) and not page_text.match(//) then
- page_text = page_text + "\n\n"
- wiki.create_page(page['title'], page_text)
+config = YAML::load_file(File.join(__dir__, 'config.yaml'))
+config["sites"].each do |site|
+ wiki = Wiki.new(site["url"], site["username"], site["password"], config["dummy"])
+ list = wiki.get_list()['allpages']
+ for page in list do
+ page_text = wiki.get_text(page['title']).body
+ changed = false
+ if not page_text.include?("[[Category:#{config["category"]}]]") then
+ next
+ end
+ if not page_text.include?("") then
+ page_text = page_text + "\n\n"
+ changed = true
+ end
+ if not page_text.include?("") then
+ page_text = page_text + "\n\n"
+ changed = true
+ end
+ if changed then
+ wiki.create_page(page['title'], page_text)
+ end
end
end