diff --git a/Wiki.rb b/Wiki.rb index 4113faf..1d32a56 100644 --- a/Wiki.rb +++ b/Wiki.rb @@ -48,5 +48,5 @@ class Wiki return revision['*'].force_encoding("UTF-8") end - attr_accessor :dummy + attr_accessor :dummy, :client end diff --git a/undo.rb b/undo.rb index 547ba90..77a1c45 100755 --- a/undo.rb +++ b/undo.rb @@ -1,6 +1,13 @@ #!/usr/bin/ruby require './Wiki.rb' +def rollback(wiki, title) + wiki.client.action :rollback, + title: title, + token_type: :rollback, + user: 'Enadmin' +end + 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"]) @@ -11,11 +18,8 @@ config["sites"].each do |site| end puts page['title'] page_text = wiki.get_text(page['title']) - puts page_text - exit # TODO - REMOVE - changed = false - if changed then - wiki.create_page(page['title'], page_text) + if page_text.match('') + rollback(wiki, page['title']) end end end