├── .dokaz ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .rubocop_todo.yml ├── .travis.yml ├── .yardopts ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── bin └── mediawiktory-gen ├── lib ├── media_wiktory.rb ├── mediawiktory.rb ├── mediawiktory │ ├── generator.rb │ ├── generator │ │ ├── api.rb │ │ ├── module.rb │ │ ├── param.rb │ │ ├── renderable.rb │ │ └── templates │ │ │ ├── _action_method.erb │ │ │ ├── _module_in_param_docs.erb │ │ │ ├── _param_impl_boolean.erb │ │ │ ├── _param_impl_enum.erb │ │ │ ├── _param_impl_enum_of_modules.erb │ │ │ ├── _param_impl_string.erb │ │ │ ├── _param_impl_timestamp.erb │ │ │ ├── _param_method.erb │ │ │ ├── action.rb.erb │ │ │ ├── action_class.rb.erb │ │ │ ├── actions.rb.erb │ │ │ ├── api.rb.erb │ │ │ ├── client.rb.erb │ │ │ ├── module_class.rb.erb │ │ │ └── response.rb.erb │ ├── version.rb │ └── wikipedia │ │ ├── actions.rb │ │ ├── actions │ │ ├── abusefiltercheckmatch.rb │ │ ├── abusefilterchecksyntax.rb │ │ ├── abusefilterevalexpression.rb │ │ ├── abusefilterunblockautopromote.rb │ │ ├── addstudents.rb │ │ ├── antispoof.rb │ │ ├── base.rb │ │ ├── block.rb │ │ ├── bouncehandler.rb │ │ ├── categorytree.rb │ │ ├── centralauthtoken.rb │ │ ├── centralnoticechoicedata.rb │ │ ├── centralnoticequerycampaign.rb │ │ ├── changeauthenticationdata.rb │ │ ├── checktoken.rb │ │ ├── cirrus-config-dump.rb │ │ ├── cirrus-mapping-dump.rb │ │ ├── cirrus-settings-dump.rb │ │ ├── clearhasmsg.rb │ │ ├── clientlogin.rb │ │ ├── compare.rb │ │ ├── createaccount.rb │ │ ├── cspreport.rb │ │ ├── cxconfiguration.rb │ │ ├── cxdelete.rb │ │ ├── cxpublish.rb │ │ ├── cxsave.rb │ │ ├── cxsuggestionlist.rb │ │ ├── cxtoken.rb │ │ ├── delete.rb │ │ ├── deleteeducation.rb │ │ ├── deleteglobalaccount.rb │ │ ├── echomarkread.rb │ │ ├── echomarkseen.rb │ │ ├── edit.rb │ │ ├── editmassmessagelist.rb │ │ ├── emailuser.rb │ │ ├── enlist.rb │ │ ├── expandtemplates.rb │ │ ├── fancycaptchareload.rb │ │ ├── featuredfeed.rb │ │ ├── feedcontributions.rb │ │ ├── feedrecentchanges.rb │ │ ├── feedwatchlist.rb │ │ ├── filerevert.rb │ │ ├── flagconfig.rb │ │ ├── globalblock.rb │ │ ├── globaluserrights.rb │ │ ├── graph.rb │ │ ├── help.rb │ │ ├── imagerotate.rb │ │ ├── import.rb │ │ ├── jsonconfig.rb │ │ ├── jsondata.rb │ │ ├── languagesearch.rb │ │ ├── linkaccount.rb │ │ ├── liststudents.rb │ │ ├── login.rb │ │ ├── logout.rb │ │ ├── managetags.rb │ │ ├── massmessage.rb │ │ ├── mergehistory.rb │ │ ├── mobileview.rb │ │ ├── move.rb │ │ ├── oathvalidate.rb │ │ ├── opensearch.rb │ │ ├── options.rb │ │ ├── pagetriageaction.rb │ │ ├── pagetriagelist.rb │ │ ├── pagetriagestats.rb │ │ ├── pagetriagetagging.rb │ │ ├── pagetriagetemplate.rb │ │ ├── paraminfo.rb │ │ ├── parse.rb │ │ ├── parsoid-batch.rb │ │ ├── patrol.rb │ │ ├── protect.rb │ │ ├── purge.rb │ │ ├── query.rb │ │ ├── refresheducation.rb │ │ ├── removeauthenticationdata.rb │ │ ├── resetpassword.rb │ │ ├── review.rb │ │ ├── reviewactivity.rb │ │ ├── revisiondelete.rb │ │ ├── rollback.rb │ │ ├── rsd.rb │ │ ├── sanitize-mapdata.rb │ │ ├── scribunto-console.rb │ │ ├── setglobalaccountstatus.rb │ │ ├── setnotificationtimestamp.rb │ │ ├── setpagelanguage.rb │ │ ├── shortenurl.rb │ │ ├── sitematrix.rb │ │ ├── spamblacklist.rb │ │ ├── stabilize.rb │ │ ├── stashedit.rb │ │ ├── strikevote.rb │ │ ├── tag.rb │ │ ├── templatedata.rb │ │ ├── thank.rb │ │ ├── titleblacklist.rb │ │ ├── tokens.rb │ │ ├── transcodereset.rb │ │ ├── ulslocalization.rb │ │ ├── unblock.rb │ │ ├── undelete.rb │ │ ├── unlinkaccount.rb │ │ ├── upload.rb │ │ ├── userrights.rb │ │ ├── validatepassword.rb │ │ ├── visualeditor.rb │ │ ├── visualeditoredit.rb │ │ ├── watch.rb │ │ ├── webapp-manifest.rb │ │ ├── wikilove.rb │ │ └── zeroconfig.rb │ │ ├── api.rb │ │ ├── client.rb │ │ ├── modules │ │ ├── abusefilters.rb │ │ ├── abuselog.rb │ │ ├── allcategories.rb │ │ ├── alldeletedrevisions.rb │ │ ├── allfileusages.rb │ │ ├── allimages.rb │ │ ├── alllinks.rb │ │ ├── allmessages.rb │ │ ├── allpages.rb │ │ ├── allredirects.rb │ │ ├── allrevisions.rb │ │ ├── alltransclusions.rb │ │ ├── allusers.rb │ │ ├── authmanagerinfo.rb │ │ ├── babel.rb │ │ ├── backlinks.rb │ │ ├── betafeatures.rb │ │ ├── blocks.rb │ │ ├── categories.rb │ │ ├── categoryinfo.rb │ │ ├── categorymembers.rb │ │ ├── centralnoticelogs.rb │ │ ├── checkuser.rb │ │ ├── checkuserlog.rb │ │ ├── contenttranslation.rb │ │ ├── contenttranslationcorpora.rb │ │ ├── contenttranslationlangtrend.rb │ │ ├── contenttranslationstats.rb │ │ ├── contenttranslationsuggestions.rb │ │ ├── contributors.rb │ │ ├── coordinates.rb │ │ ├── cxpublishedtranslations.rb │ │ ├── cxtranslatorstats.rb │ │ ├── deletedrevisions.rb │ │ ├── deletedrevs.rb │ │ ├── duplicatefiles.rb │ │ ├── embeddedin.rb │ │ ├── extlinks.rb │ │ ├── extracts.rb │ │ ├── exturlusage.rb │ │ ├── featureusage.rb │ │ ├── filearchive.rb │ │ ├── filerepoinfo.rb │ │ ├── fileusage.rb │ │ ├── flagged.rb │ │ ├── g-allcategories.rb │ │ ├── g-alldeletedrevisions.rb │ │ ├── g-allfileusages.rb │ │ ├── g-allimages.rb │ │ ├── g-alllinks.rb │ │ ├── g-allpages.rb │ │ ├── g-allredirects.rb │ │ ├── g-allrevisions.rb │ │ ├── g-alltransclusions.rb │ │ ├── g-backlinks.rb │ │ ├── g-categories.rb │ │ ├── g-categorymembers.rb │ │ ├── g-contenttranslation.rb │ │ ├── g-contenttranslationsuggestions.rb │ │ ├── g-deletedrevisions.rb │ │ ├── g-duplicatefiles.rb │ │ ├── g-embeddedin.rb │ │ ├── g-exturlusage.rb │ │ ├── g-fileusage.rb │ │ ├── g-geosearch.rb │ │ ├── g-gettingstartedgetpages.rb │ │ ├── g-images.rb │ │ ├── g-imageusage.rb │ │ ├── g-iwbacklinks.rb │ │ ├── g-langbacklinks.rb │ │ ├── g-links.rb │ │ ├── g-linkshere.rb │ │ ├── g-mostviewed.rb │ │ ├── g-oldreviewedpages.rb │ │ ├── g-pageswithprop.rb │ │ ├── g-prefixsearch.rb │ │ ├── g-projectpages.rb │ │ ├── g-protectedtitles.rb │ │ ├── g-querypage.rb │ │ ├── g-random.rb │ │ ├── g-recentchanges.rb │ │ ├── g-redirects.rb │ │ ├── g-revisions.rb │ │ ├── g-search.rb │ │ ├── g-templates.rb │ │ ├── g-transcludedin.rb │ │ ├── g-watchlist.rb │ │ ├── g-watchlistraw.rb │ │ ├── g-wblistentityusage.rb │ │ ├── gadgetcategories.rb │ │ ├── gadgets.rb │ │ ├── geosearch.rb │ │ ├── gettingstartedgetpages.rb │ │ ├── globalallusers.rb │ │ ├── globalblocks.rb │ │ ├── globalgroups.rb │ │ ├── globalusage.rb │ │ ├── globaluserinfo.rb │ │ ├── imageinfo.rb │ │ ├── images.rb │ │ ├── imageusage.rb │ │ ├── info.rb │ │ ├── iwbacklinks.rb │ │ ├── iwlinks.rb │ │ ├── json.rb │ │ ├── jsonfm.rb │ │ ├── langbacklinks.rb │ │ ├── langlinks.rb │ │ ├── links.rb │ │ ├── linkshere.rb │ │ ├── logevents.rb │ │ ├── mapdata.rb │ │ ├── mmsites.rb │ │ ├── mostviewed.rb │ │ ├── mystashedfiles.rb │ │ ├── none.rb │ │ ├── notifications.rb │ │ ├── oath.rb │ │ ├── oldreviewedpages.rb │ │ ├── ores.rb │ │ ├── pageassessments.rb │ │ ├── pageimages.rb │ │ ├── pagepropnames.rb │ │ ├── pageprops.rb │ │ ├── pageswithprop.rb │ │ ├── pageterms.rb │ │ ├── pageviews.rb │ │ ├── php.rb │ │ ├── phpfm.rb │ │ ├── prefixsearch.rb │ │ ├── projectpages.rb │ │ ├── projects.rb │ │ ├── protectedtitles.rb │ │ ├── querypage.rb │ │ ├── random.rb │ │ ├── rawfm.rb │ │ ├── recentchanges.rb │ │ ├── redirects.rb │ │ ├── references.rb │ │ ├── revisions.rb │ │ ├── search.rb │ │ ├── siteinfo.rb │ │ ├── siteviews.rb │ │ ├── stashimageinfo.rb │ │ ├── tags.rb │ │ ├── templates.rb │ │ ├── tokens.rb │ │ ├── transcludedin.rb │ │ ├── transcodestatus.rb │ │ ├── unreadnotificationpages.rb │ │ ├── usercontribs.rb │ │ ├── userinfo.rb │ │ ├── users.rb │ │ ├── videoinfo.rb │ │ ├── watchlist.rb │ │ ├── watchlistraw.rb │ │ ├── wbentityusage.rb │ │ ├── wblistentityusage.rb │ │ ├── wikibase.rb │ │ ├── wikisets.rb │ │ ├── xml.rb │ │ └── xmlfm.rb │ │ └── response.rb └── nokogiri │ └── more.rb ├── mediawiktory.gemspec └── spec ├── dokaz_helpers.rb ├── fixtures ├── api.php.html ├── api_short.php.html ├── argentina.json ├── argentina_cont.json ├── missing.json ├── query-meta.json ├── query-pages-last.json ├── query-pages.json └── siteinfo.json ├── mediawiktory ├── generator │ ├── api_spec.rb │ ├── module_spec.rb │ └── param_spec.rb └── wikipedia │ ├── action_spec.rb │ ├── api_spec.rb │ ├── client_spec.rb │ └── response_spec.rb └── spec_helper.rb /.dokaz: -------------------------------------------------------------------------------- 1 | --require ./spec/dokaz_helpers.rb 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp 2 | vendor 3 | .bundle 4 | pkg 5 | Gemfile.lock 6 | .yardoc 7 | deprecated 8 | doc 9 | test 10 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require=./spec/spec_helper.rb 2 | --color 3 | -------------------------------------------------------------------------------- /.rubocop_todo.yml: -------------------------------------------------------------------------------- 1 | # This configuration was generated by 2 | # `rubocop --auto-gen-config` 3 | # on 2017-05-06 16:11:16 +0300 using RuboCop version 0.48.1. 4 | # The point is for the user to remove these configuration records 5 | # one by one as the offenses are removed from the code base. 6 | # Note that changes in the inspected code, or installation of new 7 | # versions of RuboCop, may require this file to be generated again. 8 | 9 | # Offense count: 5 10 | # Cop supports --auto-correct. 11 | # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. 12 | # SupportedStyles: aligned, indented, indented_relative_to_receiver 13 | #Style/MultilineMethodCallIndentation: 14 | #Exclude: 15 | #- 'lib/mediawiktory/generator/api.rb' 16 | #- 'lib/mediawiktory/generator/renderable.rb' 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | cache: bundler 2 | language: ruby 3 | rvm: 4 | - "2.1" 5 | - "2.2" 6 | - "2.3.0" 7 | - "2.4.0" 8 | - "jruby-9.1.7.0" 9 | matrix: 10 | allow_failures: 11 | - rvm: "jruby-9.1.7.0" 12 | before_install: 13 | - gem install bundler 14 | install: 15 | - bundle install --retry=3 --without development docs 16 | script: 17 | - bundle exec rspec 18 | -------------------------------------------------------------------------------- /.yardopts: -------------------------------------------------------------------------------- 1 | --markup=markdown 2 | --no-private 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # MediaWiktory Changelog 2 | 3 | # 0.1.3 (2018-02-08) 4 | 5 | * Add gzip headers, as it should be done a long ago :( 6 | 7 | # 0.1.2 (2017-11-09) 8 | 9 | * Fix requiring `addressable` (@chrisadams). 10 | 11 | # 0.1.1 (2017-05-11) 12 | 13 | * **quickfix** properly registered `mediawiktory-gen` binary; 14 | * API definitions generated from recent Wikipedia API. 15 | 16 | # 0.1.0 (2017-05-10) 17 | 18 | * First mature release; 19 | * Change of API wrapper approach and allow to generate several different API wrappers; 20 | * Specs & docs. 21 | 22 | # 0.0.3 (2017-03-18) 23 | 24 | * Regenerated Wikipedia wrapper in correspondence to current API version; 25 | * Preparing to independent wrappers concept. 26 | 27 | # 0.0.2 (2015-12-21) 28 | 29 | * `Page` class for grouping records in `Query::Response`; 30 | * `User-Agent` header support; 31 | * Enums handling changed to symbols (were strings before); 32 | * Correct behavior on empty pagelist when using generator (@smostovoy); 33 | * Raise on errors in response (@smostovoy); 34 | * Access to warnings in response (@smostovoy); 35 | * Domain redirects transparent handling, 36 | http://en.wikipedia.org -> https://en.wikipedia.org (@smostovoy). 37 | 38 | # 0.0.1 (2015-11-30) 39 | 40 | Initial! 41 | 42 | 43 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to MediaWiktory 2 | 3 | Currently, MediaWiktory at early stages of development (aka "young yet useful"). Currenty problems 4 | and roadmap can be found at [GitHub Issues](https://github.com/molybdenum-99/mediawiktory/issues) and 5 | are grouped into milestones. 6 | 7 | Therefore, the big picture of "what next" is: 8 | * more validations and cleaner errors; 9 | * gfaceful handling of logging in, cookies and tokens; 10 | * support of "old" docs format (think wikia.com). 11 | 12 | You can join MediaWiktory development by usual fork-commit-pull request process, or by providing 13 | your own cases and problems you'd like to solve with it. 14 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | group :docs do 6 | gem 'rouge', '= 1.11.1' 7 | gem 'dokaz', github: 'zverok/dokaz' 8 | end 9 | 10 | group :test do 11 | gem 'rspec' 12 | gem 'rspec-its' 13 | gem 'saharspec', '~> 0.0.4' 14 | gem 'webmock' 15 | #gem 'byebug' 16 | end 17 | 18 | group :development do 19 | gem 'rubygems-tasks' 20 | gem 'rake' 21 | gem 'rubocop' 22 | end 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Victor 'Zverok' Shepelev and contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/setup' 2 | require 'rubygems/tasks' 3 | Gem::Tasks.new 4 | 5 | namespace :development do 6 | desc 'Render current wikipedia API into lib/mediawiktory/wikipedia' 7 | task :wikipedia do 8 | require 'mediawiktory/generator' 9 | 10 | MediaWiktory::Generator.new('https://en.wikipedia.org/w/api.php') 11 | .generate(path: 'lib/mediawiktory/wikipedia', namespace: 'MediaWiktory::Wikipedia') 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /bin/mediawiktory-gen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'optparse' 4 | 5 | options = {} 6 | OptionParser.new do |opts| 7 | opts.banner = 8 | "Usage: mediawiktory-gen [options]\n\n"\ 9 | "Generates MediaWiki API wrapper Ruby code for specified site in specified folder and namespace.\n"\ 10 | "Note that all previous content of the folder will be removed.\n\n"\ 11 | 12 | opts.on("-uURL", "--url=URL", "Source URL for option parsing. Typically it is http://some.domain/w/api.php.") do |u| 13 | options[:url] = u 14 | end 15 | 16 | opts.on("-nNAMESPACE", "--name=NAMESPACE", "Namespace which should include all the newly-generated classes and modules.") do |n| 17 | options[:namespace] = n 18 | end 19 | 20 | opts.on("-pPATH", "--path=PATH", "Path where to store new modules and classes. Note that there would be dozens of them, and that previous content of the folder will be removed.") do |p| 21 | options[:path] = p 22 | end 23 | 24 | opts.on("-h", "--help", "Prints this help") do 25 | puts opts 26 | exit 27 | end 28 | end.parse! 29 | 30 | $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') 31 | require_relative '../lib/mediawiktory/generator' 32 | 33 | MediaWiktory::Generator 34 | .new(options[:url]) 35 | .generate(path: options[:path], namespace: options[:namespace]) 36 | -------------------------------------------------------------------------------- /lib/media_wiktory.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative './mediawiktory' 4 | -------------------------------------------------------------------------------- /lib/mediawiktory.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # MediaWiktory is wrapper and wrapper generator for [MediaWiki API](https://www.mediawiki.org/wiki/API:Main_page). 4 | # 5 | # There are two ways of using MediaWiktory: 6 | # 7 | # 1. Either to generate your own wrapper (see {file:README.md} for explanations why and how to do it), or 8 | # 2. By using default wrapper, generated from recent Wikipedia docs, see {MediaWiktory::Wikipedia::Api}. 9 | # Note, that most of basic features (like "query some pages") of default wrapper could be used 10 | # with **any** MediaWiki installation, but more advanced features could work differently. Please 11 | # refer to {file:README.md} for more detailed explanation of those matters. 12 | # 13 | module MediaWiktory 14 | require_relative 'mediawiktory/version' 15 | require_relative 'mediawiktory/wikipedia/api' 16 | end 17 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/renderable.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'erb' 4 | 5 | module MediaWiktory 6 | class Generator 7 | module Renderable 8 | def to_h 9 | stringify_hash(super, recursive: true) 10 | end 11 | 12 | def render_to(path, **vars) 13 | FileUtils.mkdir_p File.dirname(path) 14 | File.write(path, to_html(**vars)) 15 | end 16 | 17 | def to_html(**vars) 18 | render(vars.fetch(:template, main_template), **vars) 19 | end 20 | 21 | def render(template, **vars) 22 | # puts "Rendering #{template} with #{self}#{vars}" 23 | vars.each { |name, val| instance_variable_set("@#{name}", val) } 24 | path = File.expand_path("../templates/#{template}.erb", __FILE__) 25 | ERB.new(File.read(path)) 26 | .tap { |tpl| tpl.filename = path } 27 | .result(binding) 28 | end 29 | 30 | def partial(template, context = nil) 31 | # puts "Rendering #{template} with #{context || self}" 32 | 33 | # Never repeat this at home, dear children. 34 | if context 35 | instance_variables.each { |var| context.instance_variable_set(var, instance_variable_get(var)) } 36 | end 37 | path = File.expand_path("../templates/#{template}.erb", __FILE__) 38 | ERB.new(File.read(path)) 39 | .tap { |tpl| tpl.filename = path } 40 | .result(context ? context.get_binding : binding) 41 | rescue => e 42 | puts "#{e} while #{template} with #{context || self}" 43 | raise 44 | end 45 | 46 | def get_binding # rubocop:disable Style/AccessorMethodName 47 | binding 48 | end 49 | 50 | private 51 | 52 | def stringify_hash(hash, recursive: false) 53 | hash.map { |k, v| 54 | [k.to_s, v.is_a?(Hash) && recursive ? stringify_hash(v, recursive: true) : v.to_s] 55 | }.to_h 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_action_method.erb: -------------------------------------------------------------------------------- 1 | 2 | # <%= description.strip.gsub('#', ' #') %> 3 | # 4 | # This method creates an instance of {<%= @namespace %>::Actions::<%= class_name %>} action. 5 | # 6 | <% unless params.empty? %> # Action parameters could be passed or by subsequent 7 | # {<%= @namespace %>::Actions::<%= class_name %>} method calls, like 8 | # 9 | # ```ruby 10 | # api.<%= method_name %>.<%= params.first.name %>('value') 11 | # ```<% end %> 12 | # 13 | # See {<%= @namespace %>::Actions::Base} for generic explanation of working with MediaWiki actions and 14 | # {<%= @namespace %>::Actions::<%= class_name %>} class for a list of parameters and usage. 15 | # 16 | # @return [<%= @namespace %>::Actions::<%= class_name %>] 17 | # 18 | def <%= method_name %> 19 | <%= class_name %>.new(client, @defaults) 20 | end 21 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_module_in_param_docs.erb: -------------------------------------------------------------------------------- 1 | <% modules.each do |mod| %> 2 | # * `:<%= mod.name.sub(/^g-/, '') %>` - {<%=@namespace%>::Modules::<%= mod.class_name %>} <%= mod.description %><% end %> 3 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_param_impl_boolean.erb: -------------------------------------------------------------------------------- 1 | merge(<%= full_name %>: 'true') 2 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_param_impl_enum.erb: -------------------------------------------------------------------------------- 1 | defined?(super) && super || [<%= enum_values %>].include?(value.to_s) && merge(<%= full_name %>: value.to_s<% if list? %>, replace: false<% end %>) 2 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_param_impl_enum_of_modules.erb: -------------------------------------------------------------------------------- 1 | <% unless full_name == 'format' %>defined?(super) && super || <% end %>[<%= enum_values %>].include?(value.to_sym) && merge(<%= full_name %>: value.to_s<% if list? %>, replace: false<% end %>).submodule({<%= modules_hash %>}[value.to_sym]) 2 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_param_impl_string.erb: -------------------------------------------------------------------------------- 1 | merge(<%= full_name %>: value.to_s<% if list? %>, replace: false<% end %>) 2 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_param_impl_timestamp.erb: -------------------------------------------------------------------------------- 1 | merge(<%= full_name %>: value.iso8601<% if list? %>, replace: false<% end %>) 2 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/_param_method.erb: -------------------------------------------------------------------------------- 1 | 2 | # <%= description %> 3 | # 4 | <% unless param_def.empty? %> # @param <%= param_def.sub('*', '') %> [<%= ruby_type %>]<%= param_docs %><% if real_type.include?('of modules') %><%= partial '_module_in_param_docs' %><% else %> 5 | <% end %><% end %> # @return [self] 6 | def <%= method_name %>(<%= param_def %>) 7 | <% if list? 8 | %>values.inject(self) { |res, val| res._<%= method_name %>(val)<% if impl_type.include?('enum') %> or fail ArgumentError, "Unknown value for <%= method_name %>: #{val}"<% end %> }<% 9 | elsif enum? %>_<%= method_name %>(value) or fail ArgumentError, "Unknown value for <%= method_name %>: #{value}"<% end %><% if list? || enum? %> 10 | end 11 | 12 | # @private 13 | def _<%= method_name %>(value) 14 | <%= partial("_param_impl_#{impl_type}") %> end<% else %><%= partial("_param_impl_#{impl_type}") %> end<% end %> 15 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/action_class.rb.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module <%= @namespace %> 4 | module Actions 5 | # <%= description %> 6 | # 7 | # Usage: 8 | # 9 | <% if params.empty? %> # ```ruby 10 | # api.<%= name %>.perform # returns string with raw output 11 | # # or 12 | # api.<%= name %>.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | <% else %> # ```ruby 17 | # api.<%= name %>.<%= params.first.name %>(value).perform # returns string with raw output 18 | # # or 19 | # api.<%= name %>.<%= params.first.name %>(value).response # returns output parsed and wrapped into Response object 20 | # ``` 21 | <% end %> # 22 | # See {Base} for generic explanation of working with MediaWiki actions and 23 | # {<%= @namespace %>::Response} for working with action responses. 24 | # 25 | # All action's parameters are documented as its public methods, see below. 26 | # 27 | class <%= class_name %> < <%=@namespace%>::Actions::<%= http_method %> 28 | <% params.each { |param| %><%= partial '_param_method', param %><% } %> end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/actions.rb.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative './actions/base' 4 | 5 | module <%= @namespace %> 6 | # Methods of this module contains all actions that can be used on {Api}. 7 | # You use them like this: 8 | # 9 | # ```ruby 10 | # api = <%= @namespace %>::Api.new 11 | # 12 | # api.query # method of Api, returning Actions::Query 13 | # .titles('Argentina', 'Bolivia') # methods of Actions::Query... 14 | # .prop(:revisions).prop(:content) # ...to set action options 15 | # .response 16 | # # => performs action and returns Response instance 17 | # ``` 18 | # 19 | # See also: 20 | # * {Api} for starting; 21 | # * {Actions::Base} for details of working with actions; 22 | # * and {Response}. 23 | # 24 | # Note that for each MediaWiki site the main method for **data extraction** (pages, categories, 25 | # meta-information) is {#query}. 26 | # 27 | module Actions 28 | <% actions.each { |action| %><%= partial '_action_method', action %><% } %> end 29 | end 30 | 31 | Dir[File.expand_path('../{actions,modules}/*.rb', __FILE__)].each { |f| require f } 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/client.rb.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'addressable' 4 | require 'faraday' 5 | require 'faraday_middleware' 6 | 7 | module <%= @namespace %> 8 | # Internal low-level client class, used by {Api}. 9 | # 10 | # Uses [Faraday](https://github.com/lostisland/faraday) library inside (and will expose it's settings 11 | # in future). 12 | # 13 | # You should not use it directly, all you need is in {Api}. 14 | class Client 15 | # Default MediaWiktory User-Agent header. 16 | # 17 | # You can set yours as an option to {#initialize} 18 | UA = 'MediaWiktory/0.1.0 '\ 19 | '(https://github.com/molybdenum-99/mediawiktory; zverok.offline@gmail.com)' 20 | 21 | class << self 22 | # User agent getter/setter. 23 | # 24 | # Default value is {UA}. 25 | # 26 | # You can also use per-instance option, see {#initialize} 27 | attr_accessor :user_agent 28 | end 29 | 30 | attr_reader :url 31 | 32 | def initialize(url, **options) 33 | @url = Addressable::URI.parse(url) 34 | @options = options 35 | @faraday = Faraday.new(url, headers: headers) do |f| 36 | f.request :url_encoded 37 | f.use FaradayMiddleware::FollowRedirects, limit: 5 38 | f.use FaradayMiddleware::Gzip 39 | f.adapter Faraday.default_adapter 40 | end 41 | end 42 | 43 | def user_agent 44 | @options[:user_agent] || @options[:ua] || self.class.user_agent || UA 45 | end 46 | 47 | def get(params) 48 | @faraday.get('', params).body 49 | end 50 | 51 | def post(params) 52 | @faraday.post('', params).body 53 | end 54 | 55 | private 56 | 57 | def headers 58 | {'Accept-Encoding' => 'gzip', 'User-Agent' => user_agent} 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /lib/mediawiktory/generator/templates/module_class.rb.erb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module <%= @namespace %> 4 | module Modules 5 | # <%= description %> 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {<%= @namespace %>::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module <%= class_name %> 20 | <% params.each { |param| %><%= partial '_param_method', param %><% } %> end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/mediawiktory/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory 4 | MAJOR = 0 5 | MINOR = 1 6 | PATCH = 3 7 | VERSION = [MAJOR, MINOR, PATCH].join('.') 8 | end 9 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/abusefiltercheckmatch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Check to see if an AbuseFilter matches a set of variables, editor logged AbuseFilter event. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.abusefiltercheckmatch.filter(value).perform # returns string with raw output 11 | # # or 12 | # api.abusefiltercheckmatch.filter(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Abusefiltercheckmatch < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The full filter text to check for a match. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def filter(value) 27 | merge(filter: value.to_s) 28 | end 29 | 30 | # JSON encoded array of variables to test against. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def vars(value) 35 | merge(vars: value.to_s) 36 | end 37 | 38 | # Recent change ID to check against. 39 | # 40 | # @param value [Integer] 41 | # @return [self] 42 | def rcid(value) 43 | merge(rcid: value.to_s) 44 | end 45 | 46 | # Abuse filter log ID to check against. 47 | # 48 | # @param value [Integer] 49 | # @return [self] 50 | def logid(value) 51 | merge(logid: value.to_s) 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/abusefilterchecksyntax.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Check syntax of an AbuseFilter filter. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.abusefilterchecksyntax.filter(value).perform # returns string with raw output 11 | # # or 12 | # api.abusefilterchecksyntax.filter(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Abusefilterchecksyntax < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The full filter text to check syntax on. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def filter(value) 27 | merge(filter: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/abusefilterevalexpression.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Evaluates an AbuseFilter expression. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.abusefilterevalexpression.expression(value).perform # returns string with raw output 11 | # # or 12 | # api.abusefilterevalexpression.expression(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Abusefilterevalexpression < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The expression to evaluate. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def expression(value) 27 | merge(expression: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/abusefilterunblockautopromote.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Unblocks a user from receiving autopromotions due to an abusefilter consequence. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.abusefilterunblockautopromote.user(value).perform # returns string with raw output 11 | # # or 12 | # api.abusefilterunblockautopromote.user(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Abusefilterunblockautopromote < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Username of the user you want to unblock. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def user(value) 27 | merge(user: value.to_s) 28 | end 29 | 30 | # A "csrf" token retrieved from action=query&meta=tokens 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def token(value) 35 | merge(token: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/addstudents.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Add multiple students to a course. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.addstudents.studentusernames(value).perform # returns string with raw output 11 | # # or 12 | # api.addstudents.studentusernames(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Addstudents < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The usernames of the students to add to the course. 23 | # 24 | # @param values [Array] 25 | # @return [self] 26 | def studentusernames(*values) 27 | values.inject(self) { |res, val| res._studentusernames(val) } 28 | end 29 | 30 | # @private 31 | def _studentusernames(value) 32 | merge(studentusernames: value.to_s, replace: false) 33 | end 34 | 35 | # The ID of the course to which the students should be added/removed. 36 | # 37 | # @param value [Integer] 38 | # @return [self] 39 | def courseid(value) 40 | merge(courseid: value.to_s) 41 | end 42 | 43 | # A "csrf" token retrieved from action=query&meta=tokens 44 | # 45 | # @param value [String] 46 | # @return [self] 47 | def token(value) 48 | merge(token: value.to_s) 49 | end 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/antispoof.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Check a username against AntiSpoof's normalisation checks. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.antispoof.username(value).perform # returns string with raw output 11 | # # or 12 | # api.antispoof.username(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Antispoof < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The username to check against AntiSpoof. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def username(value) 27 | merge(username: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/bouncehandler.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Receive a bounce email and process it to handle the failing recipient. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.bouncehandler.email(value).perform # returns string with raw output 11 | # # or 12 | # api.bouncehandler.email(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Bouncehandler < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The bounced email. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def email(value) 27 | merge(email: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/categorytree.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Internal module for the CategoryTree extension. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.categorytree.category(value).perform # returns string with raw output 11 | # # or 12 | # api.categorytree.category(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Categorytree < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Title in the category namespace, prefix will be ignored if given. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def category(value) 27 | merge(category: value.to_s) 28 | end 29 | 30 | # Options for the CategoryTree constructor as a JSON object. The depth option defaults to 1. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def options(value) 35 | merge(options: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/centralauthtoken.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Fetch a centralauthtoken for making an authenticated request to an attached wiki. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.centralauthtoken.perform # returns string with raw output 11 | # # or 12 | # api.centralauthtoken.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class Centralauthtoken < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/centralnoticechoicedata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get data needed to choose a banner for a given project and language 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.centralnoticechoicedata.project(value).perform # returns string with raw output 11 | # # or 12 | # api.centralnoticechoicedata.project(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Centralnoticechoicedata < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The project to get banner choice data for. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def project(value) 27 | merge(project: value.to_s) 28 | end 29 | 30 | # The language to get banner choice data for. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def language(value) 35 | merge(language: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/centralnoticequerycampaign.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get all configuration settings for a campaign. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.centralnoticequerycampaign.campaign(value).perform # returns string with raw output 11 | # # or 12 | # api.centralnoticequerycampaign.campaign(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Centralnoticequerycampaign < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Campaign name. Separate multiple values with a "|" (vertical bar). 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def campaign(value) 27 | merge(campaign: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/changeauthenticationdata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Change authentication data for the current user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.changeauthenticationdata.request(value).perform # returns string with raw output 11 | # # or 12 | # api.changeauthenticationdata.request(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Changeauthenticationdata < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Use this authentication request, by the id returned from action=query&meta=authmanagerinfo with amirequestsfor=change. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def request(value) 27 | merge(changeauthrequest: value.to_s) 28 | end 29 | 30 | # A "csrf" token retrieved from action=query&meta=tokens 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def token(value) 35 | merge(changeauthtoken: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/checktoken.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Check the validity of a token from action=query&meta=tokens. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.checktoken.type(value).perform # returns string with raw output 11 | # # or 12 | # api.checktoken.type(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Checktoken < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Type of token being tested. 23 | # 24 | # @param value [String] One of "createaccount", "csrf", "deleteglobalaccount", "login", "patrol", "rollback", "setglobalaccountstatus", "userrights", "watch". 25 | # @return [self] 26 | def type(value) 27 | _type(value) or fail ArgumentError, "Unknown value for type: #{value}" 28 | end 29 | 30 | # @private 31 | def _type(value) 32 | defined?(super) && super || ["createaccount", "csrf", "deleteglobalaccount", "login", "patrol", "rollback", "setglobalaccountstatus", "userrights", "watch"].include?(value.to_s) && merge(type: value.to_s) 33 | end 34 | 35 | # Token to test. 36 | # 37 | # @param value [String] 38 | # @return [self] 39 | def token(value) 40 | merge(token: value.to_s) 41 | end 42 | 43 | # Maximum allowed age of the token, in seconds. 44 | # 45 | # @param value [Integer] 46 | # @return [self] 47 | def maxtokenage(value) 48 | merge(maxtokenage: value.to_s) 49 | end 50 | end 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/cirrus-config-dump.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Dump of CirrusSearch configuration. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.cirrus-config-dump.perform # returns string with raw output 11 | # # or 12 | # api.cirrus-config-dump.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class CirrusConfigDump < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/cirrus-mapping-dump.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Dump of CirrusSearch mapping for this wiki. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.cirrus-mapping-dump.perform # returns string with raw output 11 | # # or 12 | # api.cirrus-mapping-dump.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class CirrusMappingDump < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/cirrus-settings-dump.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Dump of CirrusSearch settings for this wiki. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.cirrus-settings-dump.perform # returns string with raw output 11 | # # or 12 | # api.cirrus-settings-dump.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class CirrusSettingsDump < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/clearhasmsg.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Clears the hasmsg flag for the current user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.clearhasmsg.perform # returns string with raw output 11 | # # or 12 | # api.clearhasmsg.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class Clearhasmsg < MediaWiktory::Wikipedia::Actions::Post 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/compare.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get the difference between 2 pages. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.compare.fromtitle(value).perform # returns string with raw output 11 | # # or 12 | # api.compare.fromtitle(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Compare < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # First title to compare. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def fromtitle(value) 27 | merge(fromtitle: value.to_s) 28 | end 29 | 30 | # First page ID to compare. 31 | # 32 | # @param value [Integer] 33 | # @return [self] 34 | def fromid(value) 35 | merge(fromid: value.to_s) 36 | end 37 | 38 | # First revision to compare. 39 | # 40 | # @param value [Integer] 41 | # @return [self] 42 | def fromrev(value) 43 | merge(fromrev: value.to_s) 44 | end 45 | 46 | # Second title to compare. 47 | # 48 | # @param value [String] 49 | # @return [self] 50 | def totitle(value) 51 | merge(totitle: value.to_s) 52 | end 53 | 54 | # Second page ID to compare. 55 | # 56 | # @param value [Integer] 57 | # @return [self] 58 | def toid(value) 59 | merge(toid: value.to_s) 60 | end 61 | 62 | # Second revision to compare. 63 | # 64 | # @param value [Integer] 65 | # @return [self] 66 | def torev(value) 67 | merge(torev: value.to_s) 68 | end 69 | end 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/cspreport.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Used by browsers to report violations of the Content Security Policy. This module should never be used, except when used automatically by a CSP compliant web browser. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.cspreport.reportonly(value).perform # returns string with raw output 11 | # # or 12 | # api.cspreport.reportonly(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Cspreport < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Mark as being a report from a monitoring policy, not an enforced policy 23 | # 24 | # @return [self] 25 | def reportonly() 26 | merge(reportonly: 'true') 27 | end 28 | 29 | # What generated the CSP header that triggered this report 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def source(value) 34 | merge(source: value.to_s) 35 | end 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/cxconfiguration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Fetch the Content Translation configuration json for the given language pair. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.cxconfiguration.from(value).perform # returns string with raw output 11 | # # or 12 | # api.cxconfiguration.from(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Cxconfiguration < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The source language code. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def from(value) 27 | merge(from: value.to_s) 28 | end 29 | 30 | # The target language code. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def to(value) 35 | merge(to: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/cxdelete.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Delete a draft translation created using the Content Translation extension. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.cxdelete.from(value).perform # returns string with raw output 11 | # # or 12 | # api.cxdelete.from(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Cxdelete < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The source language code. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def from(value) 27 | merge(from: value.to_s) 28 | end 29 | 30 | # The target language code. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def to(value) 35 | merge(to: value.to_s) 36 | end 37 | 38 | # The title of the source page. 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def sourcetitle(value) 43 | merge(sourcetitle: value.to_s) 44 | end 45 | 46 | # A "csrf" token retrieved from action=query&meta=tokens 47 | # 48 | # @param value [String] 49 | # @return [self] 50 | def token(value) 51 | merge(token: value.to_s) 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/cxtoken.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get JWT tokens to authenticate with cxserver. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.cxtoken.token(value).perform # returns string with raw output 11 | # # or 12 | # api.cxtoken.token(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Cxtoken < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # A "csrf" token retrieved from action=query&meta=tokens 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def token(value) 27 | merge(token: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/deleteeducation.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Delete Education Program objects. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.deleteeducation.ids(value).perform # returns string with raw output 11 | # # or 12 | # api.deleteeducation.ids(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Deleteeducation < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The IDs of the objects to delete. 23 | # 24 | # @param values [Array] 25 | # @return [self] 26 | def ids(*values) 27 | values.inject(self) { |res, val| res._ids(val) } 28 | end 29 | 30 | # @private 31 | def _ids(value) 32 | merge(ids: value.to_s, replace: false) 33 | end 34 | 35 | # Type of object to delete. 36 | # 37 | # @param value [String] One of "org", "course". 38 | # @return [self] 39 | def type(value) 40 | _type(value) or fail ArgumentError, "Unknown value for type: #{value}" 41 | end 42 | 43 | # @private 44 | def _type(value) 45 | defined?(super) && super || ["org", "course"].include?(value.to_s) && merge(type: value.to_s) 46 | end 47 | 48 | # Reason for this deletion, for the log. 49 | # 50 | # @param value [String] 51 | # @return [self] 52 | def comment(value) 53 | merge(comment: value.to_s) 54 | end 55 | 56 | # A "csrf" token retrieved from action=query&meta=tokens 57 | # 58 | # @param value [String] 59 | # @return [self] 60 | def token(value) 61 | merge(token: value.to_s) 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/deleteglobalaccount.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Delete a global user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.deleteglobalaccount.user(value).perform # returns string with raw output 11 | # # or 12 | # api.deleteglobalaccount.user(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Deleteglobalaccount < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # User to delete. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def user(value) 27 | merge(user: value.to_s) 28 | end 29 | 30 | # Reason for deleting the user. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def reason(value) 35 | merge(reason: value.to_s) 36 | end 37 | 38 | # A "deleteglobalaccount" token retrieved from action=query&meta=tokens 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def token(value) 43 | merge(token: value.to_s) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/echomarkseen.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Mark notifications as seen for the current user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.echomarkseen.token(value).perform # returns string with raw output 11 | # # or 12 | # api.echomarkseen.token(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Echomarkseen < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # A "csrf" token retrieved from action=query&meta=tokens 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def token(value) 27 | merge(token: value.to_s) 28 | end 29 | 30 | # Type of notifications to mark as seen: 'alert', 'message' or 'all'. 31 | # 32 | # @param value [String] One of "alert", "message", "all". 33 | # @return [self] 34 | def type(value) 35 | _type(value) or fail ArgumentError, "Unknown value for type: #{value}" 36 | end 37 | 38 | # @private 39 | def _type(value) 40 | defined?(super) && super || ["alert", "message", "all"].include?(value.to_s) && merge(type: value.to_s) 41 | end 42 | 43 | # Timestamp format to use for output, 'ISO_8601' or 'MW'. 'MW' is deprecated here, so all clients should switch to 'ISO_8601'. This parameter will be removed, and 'ISO_8601' will become the only output format. 44 | # 45 | # @param value [String] One of "ISO_8601", "MW". 46 | # @return [self] 47 | def timestampFormat(value) 48 | _timestampFormat(value) or fail ArgumentError, "Unknown value for timestampFormat: #{value}" 49 | end 50 | 51 | # @private 52 | def _timestampFormat(value) 53 | defined?(super) && super || ["ISO_8601", "MW"].include?(value.to_s) && merge(timestampFormat: value.to_s) 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/editmassmessagelist.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Edit a mass message delivery list. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.editmassmessagelist.spamlist(value).perform # returns string with raw output 11 | # # or 12 | # api.editmassmessagelist.spamlist(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Editmassmessagelist < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Title of the delivery list to update. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def spamlist(value) 27 | merge(spamlist: value.to_s) 28 | end 29 | 30 | # Titles to add to the list. 31 | # 32 | # @param values [Array] 33 | # @return [self] 34 | def add(*values) 35 | values.inject(self) { |res, val| res._add(val) } 36 | end 37 | 38 | # @private 39 | def _add(value) 40 | merge(add: value.to_s, replace: false) 41 | end 42 | 43 | # Titles to remove from the list. 44 | # 45 | # @param values [Array] 46 | # @return [self] 47 | def remove(*values) 48 | values.inject(self) { |res, val| res._remove(val) } 49 | end 50 | 51 | # @private 52 | def _remove(value) 53 | merge(remove: value.to_s, replace: false) 54 | end 55 | 56 | # A "csrf" token retrieved from action=query&meta=tokens 57 | # 58 | # @param value [String] 59 | # @return [self] 60 | def token(value) 61 | merge(token: value.to_s) 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/emailuser.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Email a user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.emailuser.target(value).perform # returns string with raw output 11 | # # or 12 | # api.emailuser.target(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Emailuser < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # User to send email to. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def target(value) 27 | merge(target: value.to_s) 28 | end 29 | 30 | # Subject header. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def subject(value) 35 | merge(subject: value.to_s) 36 | end 37 | 38 | # Mail body. 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def text(value) 43 | merge(text: value.to_s) 44 | end 45 | 46 | # Send a copy of this mail to me. 47 | # 48 | # @return [self] 49 | def ccme() 50 | merge(ccme: 'true') 51 | end 52 | 53 | # A "csrf" token retrieved from action=query&meta=tokens 54 | # 55 | # @param value [String] 56 | # @return [self] 57 | def token(value) 58 | merge(token: value.to_s) 59 | end 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/fancycaptchareload.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get a new FancyCaptcha. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.fancycaptchareload.perform # returns string with raw output 11 | # # or 12 | # api.fancycaptchareload.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class Fancycaptchareload < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/featuredfeed.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Returns a featured content feed. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.featuredfeed.feedformat(value).perform # returns string with raw output 11 | # # or 12 | # api.featuredfeed.feedformat(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Featuredfeed < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The format of the feed. 23 | # 24 | # @param value [String] One of "rss", "atom". 25 | # @return [self] 26 | def feedformat(value) 27 | _feedformat(value) or fail ArgumentError, "Unknown value for feedformat: #{value}" 28 | end 29 | 30 | # @private 31 | def _feedformat(value) 32 | defined?(super) && super || ["rss", "atom"].include?(value.to_s) && merge(feedformat: value.to_s) 33 | end 34 | 35 | # Feed name. 36 | # 37 | # @param value [String] One of "potd", "featured", "onthisday". 38 | # @return [self] 39 | def feed(value) 40 | _feed(value) or fail ArgumentError, "Unknown value for feed: #{value}" 41 | end 42 | 43 | # @private 44 | def _feed(value) 45 | defined?(super) && super || ["potd", "featured", "onthisday"].include?(value.to_s) && merge(feed: value.to_s) 46 | end 47 | 48 | # Feed language code. Ignored by some feeds. 49 | # 50 | # @param value [String] 51 | # @return [self] 52 | def language(value) 53 | merge(language: value.to_s) 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/filerevert.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Revert a file to an old version. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.filerevert.filename(value).perform # returns string with raw output 11 | # # or 12 | # api.filerevert.filename(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Filerevert < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Target filename, without the File: prefix. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def filename(value) 27 | merge(filename: value.to_s) 28 | end 29 | 30 | # Upload comment. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def comment(value) 35 | merge(comment: value.to_s) 36 | end 37 | 38 | # Archive name of the revision to revert to. 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def archivename(value) 43 | merge(archivename: value.to_s) 44 | end 45 | 46 | # A "csrf" token retrieved from action=query&meta=tokens 47 | # 48 | # @param value [String] 49 | # @return [self] 50 | def token(value) 51 | merge(token: value.to_s) 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/flagconfig.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get basic information about review flag configuration for this site. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.flagconfig.perform # returns string with raw output 11 | # # or 12 | # api.flagconfig.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class Flagconfig < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/graph.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Access graph tag functionality. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.graph.hash(value).perform # returns string with raw output 11 | # # or 12 | # api.graph.hash(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Graph < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Hash value of the graph 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def hash(value) 27 | merge(hash: value.to_s) 28 | end 29 | 30 | # Title of the article with the graph 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def title(value) 35 | merge(title: value.to_s) 36 | end 37 | 38 | # Text of the graph to be converted to JSON. Must be posted and used without title and hash parameters 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def text(value) 43 | merge(text: value.to_s) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/help.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Display help for the specified modules. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.help.modules(value).perform # returns string with raw output 11 | # # or 12 | # api.help.modules(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Help < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Modules to display help for (values of the action and format parameters, or main). Can specify submodules with a +. 23 | # 24 | # @param values [Array] 25 | # @return [self] 26 | def modules(*values) 27 | values.inject(self) { |res, val| res._modules(val) } 28 | end 29 | 30 | # @private 31 | def _modules(value) 32 | merge(modules: value.to_s, replace: false) 33 | end 34 | 35 | # Include help for submodules of the named module. 36 | # 37 | # @return [self] 38 | def submodules() 39 | merge(submodules: 'true') 40 | end 41 | 42 | # Include help for submodules recursively. 43 | # 44 | # @return [self] 45 | def recursivesubmodules() 46 | merge(recursivesubmodules: 'true') 47 | end 48 | 49 | # Wrap the output in a standard API response structure. 50 | # 51 | # @return [self] 52 | def wrap() 53 | merge(wrap: 'true') 54 | end 55 | 56 | # Include a table of contents in the HTML output. 57 | # 58 | # @return [self] 59 | def toc() 60 | merge(toc: 'true') 61 | end 62 | end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/imagerotate.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # This module has been disabled. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.imagerotate.perform # returns string with raw output 11 | # # or 12 | # api.imagerotate.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class Imagerotate < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/jsonconfig.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Allows direct access to JsonConfig subsystem. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.jsonconfig.command(value).perform # returns string with raw output 11 | # # or 12 | # api.jsonconfig.command(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Jsonconfig < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Which sub-action to perform on JsonConfig: 23 | # 24 | # @param value [String] One of "status" (Shows JsonConfig configuration), "reset" (Clears configurations from cache. Requires title parameter and jsonconfig-reset right), "reload" (Reloads and caches configurations from config store. Requires title parameter and jsonconfig-reset right). 25 | # @return [self] 26 | def command(value) 27 | _command(value) or fail ArgumentError, "Unknown value for command: #{value}" 28 | end 29 | 30 | # @private 31 | def _command(value) 32 | defined?(super) && super || ["status", "reset", "reload"].include?(value.to_s) && merge(command: value.to_s) 33 | end 34 | 35 | # Namespace number of the title to process. 36 | # 37 | # @param value [Integer] 38 | # @return [self] 39 | def namespace(value) 40 | merge(namespace: value.to_s) 41 | end 42 | 43 | # Title to process without namespace prefix. 44 | # 45 | # @param value [String] 46 | # @return [self] 47 | def title(value) 48 | merge(title: value.to_s) 49 | end 50 | 51 | # For command=reload, use this content instead. 52 | # 53 | # @param value [String] 54 | # @return [self] 55 | def content(value) 56 | merge(content: value.to_s) 57 | end 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/jsondata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Retrieve localized JSON data. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.jsondata.title(value).perform # returns string with raw output 11 | # # or 12 | # api.jsondata.title(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Jsondata < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Title to get. By default assumes namespace to be "Data:" 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def title(value) 27 | merge(title: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/languagesearch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Search for language names in any script. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.languagesearch.search(value).perform # returns string with raw output 11 | # # or 12 | # api.languagesearch.search(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Languagesearch < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Search string. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def search(value) 27 | merge(search: value.to_s) 28 | end 29 | 30 | # Number of spelling mistakes allowed in the search string. 31 | # 32 | # @param value [Integer] 33 | # @return [self] 34 | def typos(value) 35 | merge(typos: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/liststudents.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get the usernames and other information for students enrolled in one or more courses. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.liststudents.courseids(value).perform # returns string with raw output 11 | # # or 12 | # api.liststudents.courseids(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Liststudents < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # IDs of the courses. 23 | # 24 | # @param values [Array] 25 | # @return [self] 26 | def courseids(*values) 27 | values.inject(self) { |res, val| res._courseids(val) } 28 | end 29 | 30 | # @private 31 | def _courseids(value) 32 | merge(courseids: value.to_s, replace: false) 33 | end 34 | 35 | # Which property to get for each student: 36 | # 37 | # @param value [String] One of "username" (The username of the student), "id" (The user ID of the student). 38 | # @return [self] 39 | def prop(value) 40 | _prop(value) or fail ArgumentError, "Unknown value for prop: #{value}" 41 | end 42 | 43 | # @private 44 | def _prop(value) 45 | defined?(super) && super || ["username", "id"].include?(value.to_s) && merge(prop: value.to_s) 46 | end 47 | 48 | # If given, the query will group students by course. 49 | # 50 | # @return [self] 51 | def group() 52 | merge(group: 'true') 53 | end 54 | 55 | # If given, the query will return usernames in CSV format, and it will return the articles assigned to those students. 56 | # 57 | # @return [self] 58 | def csv() 59 | merge(csv: 'true') 60 | end 61 | end 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/login.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Log in and get authentication cookies. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.login.name(value).perform # returns string with raw output 11 | # # or 12 | # api.login.name(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Login < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # User name. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def name(value) 27 | merge(lgname: value.to_s) 28 | end 29 | 30 | # Password. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def password(value) 35 | merge(lgpassword: value.to_s) 36 | end 37 | 38 | # Domain (optional). 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def domain(value) 43 | merge(lgdomain: value.to_s) 44 | end 45 | 46 | # A "login" token retrieved from action=query&meta=tokens 47 | # 48 | # @param value [String] 49 | # @return [self] 50 | def token(value) 51 | merge(lgtoken: value.to_s) 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/logout.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Log out and clear session data. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.logout.perform # returns string with raw output 11 | # # or 12 | # api.logout.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class Logout < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/massmessage.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Send a message to a list of pages. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.massmessage.spamlist(value).perform # returns string with raw output 11 | # # or 12 | # api.massmessage.spamlist(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Massmessage < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Page containing list of pages to leave a message on. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def spamlist(value) 27 | merge(spamlist: value.to_s) 28 | end 29 | 30 | # Subject line of the message. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def subject(value) 35 | merge(subject: value.to_s) 36 | end 37 | 38 | # Message body text. 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def message(value) 43 | merge(message: value.to_s) 44 | end 45 | 46 | # A "csrf" token retrieved from action=query&meta=tokens 47 | # 48 | # @param value [String] 49 | # @return [self] 50 | def token(value) 51 | merge(token: value.to_s) 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/oathvalidate.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Validate a two-factor authentication (OATH) token. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.oathvalidate.user(value).perform # returns string with raw output 11 | # # or 12 | # api.oathvalidate.user(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Oathvalidate < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # User to validate token for. Defaults to the current user. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def user(value) 27 | merge(user: value.to_s) 28 | end 29 | 30 | # Two-factor authentication (OATH) token. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def totp(value) 35 | merge(totp: value.to_s) 36 | end 37 | 38 | # A "csrf" token retrieved from action=query&meta=tokens 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def token(value) 43 | merge(token: value.to_s) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/pagetriageaction.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Mark an article as reviewed or unreviewed. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.pagetriageaction.pageid(value).perform # returns string with raw output 11 | # # or 12 | # api.pagetriageaction.pageid(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Pagetriageaction < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The article for which to be marked as reviewed or unreviewed. 23 | # 24 | # @param value [Integer] 25 | # @return [self] 26 | def pageid(value) 27 | merge(pageid: value.to_s) 28 | end 29 | 30 | # Whether the article is reviewed. 31 | # 32 | # @param value [String] One of "1", "0". 33 | # @return [self] 34 | def reviewed(value) 35 | _reviewed(value) or fail ArgumentError, "Unknown value for reviewed: #{value}" 36 | end 37 | 38 | # @private 39 | def _reviewed(value) 40 | defined?(super) && super || ["1", "0"].include?(value.to_s) && merge(reviewed: value.to_s) 41 | end 42 | 43 | # A "csrf" token retrieved from action=query&meta=tokens 44 | # 45 | # @param value [String] 46 | # @return [self] 47 | def token(value) 48 | merge(token: value.to_s) 49 | end 50 | 51 | # Personal note to page creators from reviewers. 52 | # 53 | # @param value [String] 54 | # @return [self] 55 | def note(value) 56 | merge(note: value.to_s) 57 | end 58 | 59 | # Whether to skip notification. 60 | # 61 | # @return [self] 62 | def skipnotif() 63 | merge(skipnotif: 'true') 64 | end 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/pagetriagestats.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get the stats for page triage. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.pagetriagestats.namespace(value).perform # returns string with raw output 11 | # # or 12 | # api.pagetriagestats.namespace(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Pagetriagestats < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # What namespace to pull stats from. 23 | # 24 | # @param value [Integer] 25 | # @return [self] 26 | def namespace(value) 27 | merge(namespace: value.to_s) 28 | end 29 | 30 | # Whether to include redirects. 31 | # 32 | # @return [self] 33 | def showredirs() 34 | merge(showredirs: 'true') 35 | end 36 | 37 | # Whether to include reviewed. 38 | # 39 | # @return [self] 40 | def showreviewed() 41 | merge(showreviewed: 'true') 42 | end 43 | 44 | # Whether to include unreviewed. 45 | # 46 | # @return [self] 47 | def showunreviewed() 48 | merge(showunreviewed: 'true') 49 | end 50 | 51 | # Whether to include "proposed for deleted". 52 | # 53 | # @return [self] 54 | def showdeleted() 55 | merge(showdeleted: 'true') 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/pagetriagetemplate.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Fetch templates that are used within the PageTriage application. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.pagetriagetemplate.view(value).perform # returns string with raw output 11 | # # or 12 | # api.pagetriagetemplate.view(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Pagetriagetemplate < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The PageTriage view for which you need the templates. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def view(value) 27 | merge(view: value.to_s) 28 | end 29 | 30 | # The template to fetch. Separate multiple with the | character. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def template(value) 35 | merge(template: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/parsoid-batch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.parsoid-batch.batch(value).perform # returns string with raw output 11 | # # or 12 | # api.parsoid-batch.batch(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class ParsoidBatch < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def batch(value) 27 | merge(batch: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/patrol.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Patrol a page or revision. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.patrol.rcid(value).perform # returns string with raw output 11 | # # or 12 | # api.patrol.rcid(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Patrol < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Recentchanges ID to patrol. 23 | # 24 | # @param value [Integer] 25 | # @return [self] 26 | def rcid(value) 27 | merge(rcid: value.to_s) 28 | end 29 | 30 | # Revision ID to patrol. 31 | # 32 | # @param value [Integer] 33 | # @return [self] 34 | def revid(value) 35 | merge(revid: value.to_s) 36 | end 37 | 38 | # Change tags to apply to the entry in the patrol log. 39 | # 40 | # @param values [Array] Allowed values: "ProveIt edit", "WPCleaner", "huggle", "large plot addition". 41 | # @return [self] 42 | def tags(*values) 43 | values.inject(self) { |res, val| res._tags(val) or fail ArgumentError, "Unknown value for tags: #{val}" } 44 | end 45 | 46 | # @private 47 | def _tags(value) 48 | defined?(super) && super || ["ProveIt edit", "WPCleaner", "huggle", "large plot addition"].include?(value.to_s) && merge(tags: value.to_s, replace: false) 49 | end 50 | 51 | # A "patrol" token retrieved from action=query&meta=tokens 52 | # 53 | # @param value [String] 54 | # @return [self] 55 | def token(value) 56 | merge(token: value.to_s) 57 | end 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/refresheducation.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Rebuild summary data of Education Program objects. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.refresheducation.ids(value).perform # returns string with raw output 11 | # # or 12 | # api.refresheducation.ids(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Refresheducation < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The IDs of the objects to refresh. 23 | # 24 | # @param values [Array] 25 | # @return [self] 26 | def ids(*values) 27 | values.inject(self) { |res, val| res._ids(val) } 28 | end 29 | 30 | # @private 31 | def _ids(value) 32 | merge(ids: value.to_s, replace: false) 33 | end 34 | 35 | # Type of object to refresh. 36 | # 37 | # @param value [String] One of "org", "course", "student". 38 | # @return [self] 39 | def type(value) 40 | _type(value) or fail ArgumentError, "Unknown value for type: #{value}" 41 | end 42 | 43 | # @private 44 | def _type(value) 45 | defined?(super) && super || ["org", "course", "student"].include?(value.to_s) && merge(type: value.to_s) 46 | end 47 | 48 | # A "csrf" token retrieved from action=query&meta=tokens 49 | # 50 | # @param value [String] 51 | # @return [self] 52 | def token(value) 53 | merge(token: value.to_s) 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/removeauthenticationdata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Remove authentication data for the current user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.removeauthenticationdata.request(value).perform # returns string with raw output 11 | # # or 12 | # api.removeauthenticationdata.request(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Removeauthenticationdata < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Use this authentication request, by the id returned from action=query&meta=authmanagerinfo with amirequestsfor=remove. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def request(value) 27 | merge(request: value.to_s) 28 | end 29 | 30 | # A "csrf" token retrieved from action=query&meta=tokens 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def token(value) 35 | merge(token: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/resetpassword.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Send a password reset email to a user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.resetpassword.user(value).perform # returns string with raw output 11 | # # or 12 | # api.resetpassword.user(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Resetpassword < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # User being reset. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def user(value) 27 | merge(user: value.to_s) 28 | end 29 | 30 | # Email address of the user being reset. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def email(value) 35 | merge(email: value.to_s) 36 | end 37 | 38 | # A "csrf" token retrieved from action=query&meta=tokens 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def token(value) 43 | merge(token: value.to_s) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/review.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Review a revision by approving or de-approving it. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.review.revid(value).perform # returns string with raw output 11 | # # or 12 | # api.review.revid(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Review < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The revision ID for which to set the flags. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def revid(value) 27 | merge(revid: value.to_s) 28 | end 29 | 30 | # A "csrf" token retrieved from action=query&meta=tokens 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def token(value) 35 | merge(token: value.to_s) 36 | end 37 | 38 | # Comment for the review. 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def comment(value) 43 | merge(comment: value.to_s) 44 | end 45 | 46 | # If set, revision will be unapproved rather than approved. 47 | # 48 | # @return [self] 49 | def unapprove() 50 | merge(unapprove: 'true') 51 | end 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/reviewactivity.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Advertise or de-advertise yourself as reviewing an unreviewed page or unreviewed changes. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.reviewactivity.previd(value).perform # returns string with raw output 11 | # # or 12 | # api.reviewactivity.previd(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Reviewactivity < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The prior revision ID (for reviewing changes only). 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def previd(value) 27 | merge(previd: value.to_s) 28 | end 29 | 30 | # The ID of the revision being reviewed. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def oldid(value) 35 | merge(oldid: value.to_s) 36 | end 37 | 38 | # Whether to advertise yourself as reviewing or no longer reviewing. 39 | # 40 | # @param value [String] One of "0", "1". 41 | # @return [self] 42 | def reviewing(value) 43 | _reviewing(value) or fail ArgumentError, "Unknown value for reviewing: #{value}" 44 | end 45 | 46 | # @private 47 | def _reviewing(value) 48 | defined?(super) && super || ["0", "1"].include?(value.to_s) && merge(reviewing: value.to_s) 49 | end 50 | 51 | # A "csrf" token retrieved from action=query&meta=tokens 52 | # 53 | # @param value [String] 54 | # @return [self] 55 | def token(value) 56 | merge(token: value.to_s) 57 | end 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/rsd.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Export an RSD (Really Simple Discovery) schema. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.rsd.perform # returns string with raw output 11 | # # or 12 | # api.rsd.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class Rsd < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/sanitize-mapdata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Performs data validation for Kartographer extension 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.sanitize-mapdata.title(value).perform # returns string with raw output 11 | # # or 12 | # api.sanitize-mapdata.title(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class SanitizeMapdata < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Title of page on which this GeoJSON is supposed to be located. If no title is provided, a dummy one will be used. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def title(value) 27 | merge(title: value.to_s) 28 | end 29 | 30 | # GeoJSON to sanitize 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def text(value) 35 | merge(text: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/scribunto-console.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Internal module for servicing XHR requests from the Scribunto console. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.scribunto-console.title(value).perform # returns string with raw output 11 | # # or 12 | # api.scribunto-console.title(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class ScribuntoConsole < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The title of the module to test. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def title(value) 27 | merge(title: value.to_s) 28 | end 29 | 30 | # The new content of the module. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def content(value) 35 | merge(content: value.to_s) 36 | end 37 | 38 | # Session token. 39 | # 40 | # @param value [Integer] 41 | # @return [self] 42 | def session(value) 43 | merge(session: value.to_s) 44 | end 45 | 46 | # The next line to evaluate as a script. 47 | # 48 | # @param value [String] 49 | # @return [self] 50 | def question(value) 51 | merge(question: value.to_s) 52 | end 53 | 54 | # Set to clear the current session state. 55 | # 56 | # @return [self] 57 | def clear() 58 | merge(clear: 'true') 59 | end 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/shortenurl.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Shorten a long URL into a shorter one. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.shortenurl.url(value).perform # returns string with raw output 11 | # # or 12 | # api.shortenurl.url(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Shortenurl < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # URL to be shortened. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def url(value) 27 | merge(url: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/spamblacklist.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Validate one or more URLs against the SpamBlacklist. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.spamblacklist.url(value).perform # returns string with raw output 11 | # # or 12 | # api.spamblacklist.url(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Spamblacklist < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # URLs to validate against the blacklist. 23 | # 24 | # @param values [Array] 25 | # @return [self] 26 | def url(*values) 27 | values.inject(self) { |res, val| res._url(val) } 28 | end 29 | 30 | # @private 31 | def _url(value) 32 | merge(url: value.to_s, replace: false) 33 | end 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/strikevote.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Allows admins to strike or unstrike a vote. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.strikevote.option(value).perform # returns string with raw output 11 | # # or 12 | # api.strikevote.option(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Strikevote < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Which action to take: strike or unstrike a vote. 23 | # 24 | # @param value [String] One of "strike" (Strike a vote (remove it from the count)), "unstrike" (Unstrike a vote (restore it to the count)). 25 | # @return [self] 26 | def option(value) 27 | _option(value) or fail ArgumentError, "Unknown value for option: #{value}" 28 | end 29 | 30 | # @private 31 | def _option(value) 32 | defined?(super) && super || ["strike", "unstrike"].include?(value.to_s) && merge(option: value.to_s) 33 | end 34 | 35 | # The reason for striking or unstriking the vote. 36 | # 37 | # @param value [String] 38 | # @return [self] 39 | def reason(value) 40 | merge(reason: value.to_s) 41 | end 42 | 43 | # The ID of the vote to be struck or unstruck. 44 | # 45 | # @param value [Integer] 46 | # @return [self] 47 | def voteid(value) 48 | merge(voteid: value.to_s) 49 | end 50 | 51 | # A "csrf" token retrieved from action=query&meta=tokens 52 | # 53 | # @param value [String] 54 | # @return [self] 55 | def token(value) 56 | merge(token: value.to_s) 57 | end 58 | end 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/thank.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Send a thank-you notification to an editor. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.thank.rev(value).perform # returns string with raw output 11 | # # or 12 | # api.thank.rev(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Thank < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Revision ID to thank someone for. 23 | # 24 | # @param value [Integer] 25 | # @return [self] 26 | def rev(value) 27 | merge(rev: value.to_s) 28 | end 29 | 30 | # A "csrf" token retrieved from action=query&meta=tokens 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def token(value) 35 | merge(token: value.to_s) 36 | end 37 | 38 | # A short string describing the source of the request, for example diff or history. 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def source(value) 43 | merge(source: value.to_s) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/titleblacklist.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Validate an article title, filename, or username against the TitleBlacklist. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.titleblacklist.title(value).perform # returns string with raw output 11 | # # or 12 | # api.titleblacklist.title(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Titleblacklist < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # The string to validate against the blacklist. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def title(value) 27 | merge(tbtitle: value.to_s) 28 | end 29 | 30 | # The action to be checked. 31 | # 32 | # @param value [String] One of "create", "edit", "upload", "createtalk", "createpage", "move", "new-account". 33 | # @return [self] 34 | def action(value) 35 | _action(value) or fail ArgumentError, "Unknown value for action: #{value}" 36 | end 37 | 38 | # @private 39 | def _action(value) 40 | defined?(super) && super || ["create", "edit", "upload", "createtalk", "createpage", "move", "new-account"].include?(value.to_s) && merge(tbaction: value.to_s) 41 | end 42 | 43 | # Don't try to override the titleblacklist. 44 | # 45 | # @return [self] 46 | def nooverride() 47 | merge(tbnooverride: 'true') 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/tokens.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get tokens for data-modifying actions. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.tokens.type(value).perform # returns string with raw output 11 | # # or 12 | # api.tokens.type(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Tokens < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Types of token to request. 23 | # 24 | # @param values [Array] Allowed values: "block", "createaccount", "csrf", "delete", "deleteglobalaccount", "edit", "email", "import", "login", "move", "options", "patrol", "protect", "rollback", "setglobalaccountstatus", "unblock", "userrights", "watch". 25 | # @return [self] 26 | def type(*values) 27 | values.inject(self) { |res, val| res._type(val) or fail ArgumentError, "Unknown value for type: #{val}" } 28 | end 29 | 30 | # @private 31 | def _type(value) 32 | defined?(super) && super || ["block", "createaccount", "csrf", "delete", "deleteglobalaccount", "edit", "email", "import", "login", "move", "options", "patrol", "protect", "rollback", "setglobalaccountstatus", "unblock", "userrights", "watch"].include?(value.to_s) && merge(type: value.to_s, replace: false) 33 | end 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/transcodereset.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Users with the 'transcode-reset' right can reset and re-run a transcode job. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.transcodereset.title(value).perform # returns string with raw output 11 | # # or 12 | # api.transcodereset.title(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Transcodereset < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # The media file title. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def title(value) 27 | merge(title: value.to_s) 28 | end 29 | 30 | # The transcode key you wish to reset. Fetch from action=query&prop=transcodestatus. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def transcodekey(value) 35 | merge(transcodekey: value.to_s) 36 | end 37 | 38 | # A "csrf" token retrieved from action=query&meta=tokens 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def token(value) 43 | merge(token: value.to_s) 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/ulslocalization.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get the localization of ULS in the given language. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.ulslocalization.language(value).perform # returns string with raw output 11 | # # or 12 | # api.ulslocalization.language(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Ulslocalization < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # Language code. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def language(value) 27 | merge(language: value.to_s) 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/unlinkaccount.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Remove a linked third-party account from the current user. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.unlinkaccount.request(value).perform # returns string with raw output 11 | # # or 12 | # api.unlinkaccount.request(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Unlinkaccount < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Use this authentication request, by the id returned from action=query&meta=authmanagerinfo with amirequestsfor=unlink. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def request(value) 27 | merge(request: value.to_s) 28 | end 29 | 30 | # A "csrf" token retrieved from action=query&meta=tokens 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def token(value) 35 | merge(token: value.to_s) 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/validatepassword.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Validate a password against the wiki's password policies. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.validatepassword.password(value).perform # returns string with raw output 11 | # # or 12 | # api.validatepassword.password(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Validatepassword < MediaWiktory::Wikipedia::Actions::Post 21 | 22 | # Password to validate. 23 | # 24 | # @param value [String] 25 | # @return [self] 26 | def password(value) 27 | merge(password: value.to_s) 28 | end 29 | 30 | # User name, for use when testing account creation. The named user must not exist. 31 | # 32 | # @param value [String] 33 | # @return [self] 34 | def user(value) 35 | merge(user: value.to_s) 36 | end 37 | 38 | # Email address, for use when testing account creation. 39 | # 40 | # @param value [String] 41 | # @return [self] 42 | def email(value) 43 | merge(email: value.to_s) 44 | end 45 | 46 | # Real name, for use when testing account creation. 47 | # 48 | # @param value [String] 49 | # @return [self] 50 | def realname(value) 51 | merge(realname: value.to_s) 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/webapp-manifest.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Returns a webapp manifest. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.webapp-manifest.perform # returns string with raw output 11 | # # or 12 | # api.webapp-manifest.response # returns output parsed and wrapped into Mash-like object 13 | # ``` 14 | # 15 | # This action has no parameters. 16 | # 17 | # See {Base} for generic explanation of working with MediaWiki actions and 18 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 19 | # 20 | # All action's parameters are documented as its public methods, see below. 21 | # 22 | class WebappManifest < MediaWiktory::Wikipedia::Actions::Get 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/actions/zeroconfig.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Actions 5 | # Get configuration of the Zero extension. 6 | # 7 | # Usage: 8 | # 9 | # ```ruby 10 | # api.zeroconfig.type(value).perform # returns string with raw output 11 | # # or 12 | # api.zeroconfig.type(value).response # returns output parsed and wrapped into Response object 13 | # ``` 14 | # 15 | # See {Base} for generic explanation of working with MediaWiki actions and 16 | # {MediaWiktory::Wikipedia::Response} for working with action responses. 17 | # 18 | # All action's parameters are documented as its public methods, see below. 19 | # 20 | class Zeroconfig < MediaWiktory::Wikipedia::Actions::Get 21 | 22 | # What kind of Zero info is needed: 23 | # 24 | # @param value [String] One of "config" (Get a trimmed-down carrier configuration based on the X-CS header), "message" (Get language-appropriate verbiage based on X-CS header; requires agent param). 25 | # @return [self] 26 | def type(value) 27 | _type(value) or fail ArgumentError, "Unknown value for type: #{value}" 28 | end 29 | 30 | # @private 31 | def _type(value) 32 | defined?(super) && super || ["config", "message"].include?(value.to_s) && merge(type: value.to_s) 33 | end 34 | 35 | # When setting type to message, include a source agent value as well. 36 | # 37 | # @param value [String] 38 | # @return [self] 39 | def agent(value) 40 | merge(agent: value.to_s) 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/client.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'addressable/uri' 4 | require 'addressable/template' 5 | require 'faraday' 6 | require 'faraday_middleware' 7 | 8 | module MediaWiktory::Wikipedia 9 | # Internal low-level client class, used by {Api}. 10 | # 11 | # Uses [Faraday](https://github.com/lostisland/faraday) library inside (and will expose it's settings 12 | # in future). 13 | # 14 | # You should not use it directly, all you need is in {Api}. 15 | class Client 16 | # Default MediaWiktory User-Agent header. 17 | # 18 | # You can set yours as an option to {#initialize} 19 | UA = 'MediaWiktory/0.1.0 '\ 20 | '(https://github.com/molybdenum-99/mediawiktory; zverok.offline@gmail.com)' 21 | 22 | class << self 23 | # User agent getter/setter. 24 | # 25 | # Default value is {UA}. 26 | # 27 | # You can also use per-instance option, see {#initialize} 28 | attr_accessor :user_agent 29 | end 30 | 31 | attr_reader :url 32 | 33 | def initialize(url, **options) 34 | @url = Addressable::URI.parse(url) 35 | @options = options 36 | @faraday = Faraday.new(url, headers: headers) do |f| 37 | f.request :url_encoded 38 | f.use FaradayMiddleware::FollowRedirects, limit: 5 39 | f.use FaradayMiddleware::Gzip 40 | f.adapter Faraday.default_adapter 41 | end 42 | end 43 | 44 | def user_agent 45 | @options[:user_agent] || @options[:ua] || self.class.user_agent || UA 46 | end 47 | 48 | def get(params) 49 | @faraday.get('', params).body 50 | end 51 | 52 | def post(params) 53 | @faraday.post('', params).body 54 | end 55 | 56 | private 57 | 58 | def headers 59 | {'Accept-Encoding' => 'gzip', 'User-Agent' => user_agent} 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/babel.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get information about what languages the user knows 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Babel 20 | 21 | # User to get information about 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def user(value) 26 | merge(babuser: value.to_s) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/betafeatures.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all BetaFeatures 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Betafeatures 20 | 21 | # Whether to fetch how many users have enabled a certain preference. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def counts(value) 26 | merge(bfcounts: value.to_s) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/categoryinfo.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Returns information about the given categories. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Categoryinfo 20 | 21 | # When more results are available, use this to continue. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def continue(value) 26 | merge(cicontinue: value.to_s) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/centralnoticelogs.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get a log of campaign configuration changes. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Centralnoticelogs 20 | 21 | # Campaign name (optional). Separate multiple values with a "|" (vertical bar). 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def campaign(value) 26 | merge(campaign: value.to_s) 27 | end 28 | 29 | # Username (optional). 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def user(value) 34 | merge(user: value.to_s) 35 | end 36 | 37 | # Maximum rows to return (optional). 38 | # 39 | # @param value [Integer, "max"] 40 | # @return [self] 41 | def limit(value) 42 | merge(limit: value.to_s) 43 | end 44 | 45 | # Offset into result set (optional). 46 | # 47 | # @param value [Integer] 48 | # @return [self] 49 | def offset(value) 50 | merge(offset: value.to_s) 51 | end 52 | 53 | # Start time of range (optional). 54 | # 55 | # @param value [Time] 56 | # @return [self] 57 | def start(value) 58 | merge(start: value.iso8601) 59 | end 60 | 61 | # End time of range (optional). 62 | # 63 | # @param value [Time] 64 | # @return [self] 65 | def end(value) 66 | merge(end: value.iso8601) 67 | end 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/contenttranslationcorpora.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get the section-aligned parallel text for a given translation. See also list=cxpublishedtranslations. Dumps are provided in different formats for high volume access. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Contenttranslationcorpora 20 | 21 | # ID of the translation. 22 | # 23 | # @param value [Integer] 24 | # @return [self] 25 | def translationid(value) 26 | merge(translationid: value.to_s) 27 | end 28 | 29 | # Whether to strip all HTML tags to return plaintext. 30 | # 31 | # @return [self] 32 | def striphtml() 33 | merge(striphtml: 'true') 34 | end 35 | 36 | # By default you will get all three of following if available: source text, machine translation and the postedited translation by the user. This parameter allows you not return some of these types. 37 | # 38 | # @param values [Array] Allowed values: "source", "mt", "user". 39 | # @return [self] 40 | def types(*values) 41 | values.inject(self) { |res, val| res._types(val) or fail ArgumentError, "Unknown value for types: #{val}" } 42 | end 43 | 44 | # @private 45 | def _types(value) 46 | defined?(super) && super || ["source", "mt", "user"].include?(value.to_s) && merge(types: value.to_s, replace: false) 47 | end 48 | end 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/contenttranslationlangtrend.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Query Content Translation database for numbers of translations by period of time. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Contenttranslationlangtrend 20 | 21 | # The source language code. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def source(value) 26 | merge(source: value.to_s) 27 | end 28 | 29 | # The target language code. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def target(value) 34 | merge(target: value.to_s) 35 | end 36 | 37 | # The interval for calculating the trend. Can be week or month. 38 | # 39 | # @param value [String] One of "week", "month". 40 | # @return [self] 41 | def interval(value) 42 | _interval(value) or fail ArgumentError, "Unknown value for interval: #{value}" 43 | end 44 | 45 | # @private 46 | def _interval(value) 47 | defined?(super) && super || ["week", "month"].include?(value.to_s) && merge(interval: value.to_s) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/contenttranslationstats.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get Content Translation statistics. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Contenttranslationstats 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/contenttranslationsuggestions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get suggestion lists for Content Translation. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Contenttranslationsuggestions 20 | 21 | # The source language code. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def from(value) 26 | merge(from: value.to_s) 27 | end 28 | 29 | # The target language code. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def to(value) 34 | merge(to: value.to_s) 35 | end 36 | 37 | # Return suggestions only from a particular list 38 | # 39 | # @param value [String] 40 | # @return [self] 41 | def listid(value) 42 | merge(listid: value.to_s) 43 | end 44 | 45 | # The maximum number of translation suggestions to fetch. 46 | # 47 | # @param value [Integer, "max"] 48 | # @return [self] 49 | def limit(value) 50 | merge(limit: value.to_s) 51 | end 52 | 53 | # Offset for paginated results. 54 | # 55 | # @param value [String] 56 | # @return [self] 57 | def offset(value) 58 | merge(offset: value.to_s) 59 | end 60 | 61 | # By default suggestions are returned in random order. If you wish to return each suggestion only once when using limit and offset, you must specify a seed for all the requests. 62 | # 63 | # @param value [Integer] 64 | # @return [self] 65 | def seed(value) 66 | merge(seed: value.to_s) 67 | end 68 | end 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/cxpublishedtranslations.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Fetch all published translations information. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Cxpublishedtranslations 20 | 21 | # The source language code. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def from(value) 26 | merge(from: value.to_s) 27 | end 28 | 29 | # The target language code. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def to(value) 34 | merge(to: value.to_s) 35 | end 36 | 37 | # The maximum number of translations to fetch. 38 | # 39 | # @param value [Integer, "max"] 40 | # @return [self] 41 | def limit(value) 42 | merge(limit: value.to_s) 43 | end 44 | 45 | # When more results are available, use this to continue. 46 | # 47 | # @param value [String] 48 | # @return [self] 49 | def offset(value) 50 | merge(offset: value.to_s) 51 | end 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/cxtranslatorstats.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Fetch the translation statistics for the given user. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Cxtranslatorstats 20 | 21 | # The translator's user name. This parameter is optional. If not passed, the currently logged-in user will be used. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def translator(value) 26 | merge(translator: value.to_s) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/duplicatefiles.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all files that are duplicates of the given files based on hash values. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Duplicatefiles 20 | 21 | # How many duplicate files to return. 22 | # 23 | # @param value [Integer, "max"] 24 | # @return [self] 25 | def limit(value) 26 | merge(dflimit: value.to_s) 27 | end 28 | 29 | # When more results are available, use this to continue. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def continue(value) 34 | merge(dfcontinue: value.to_s) 35 | end 36 | 37 | # The direction in which to list. 38 | # 39 | # @param value [String] One of "ascending", "descending". 40 | # @return [self] 41 | def dir(value) 42 | _dir(value) or fail ArgumentError, "Unknown value for dir: #{value}" 43 | end 44 | 45 | # @private 46 | def _dir(value) 47 | defined?(super) && super || ["ascending", "descending"].include?(value.to_s) && merge(dfdir: value.to_s) 48 | end 49 | 50 | # Look only for files in the local repository. 51 | # 52 | # @return [self] 53 | def localonly() 54 | merge(dflocalonly: 'true') 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/featureusage.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get a summary of logged API feature usages for a user agent. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Featureusage 20 | 21 | # Start of date range to query. 22 | # 23 | # @param value [Time] 24 | # @return [self] 25 | def start(value) 26 | merge(afustart: value.iso8601) 27 | end 28 | 29 | # End of date range to query. 30 | # 31 | # @param value [Time] 32 | # @return [self] 33 | def end(value) 34 | merge(afuend: value.iso8601) 35 | end 36 | 37 | # User agent to query. If not specified, the agent in the request will be queried. 38 | # 39 | # @param value [String] 40 | # @return [self] 41 | def agent(value) 42 | merge(afuagent: value.to_s) 43 | end 44 | 45 | # If specified, return details on only these features. 46 | # 47 | # @param values [Array] 48 | # @return [self] 49 | def features(*values) 50 | values.inject(self) { |res, val| res._features(val) } 51 | end 52 | 53 | # @private 54 | def _features(value) 55 | merge(afufeatures: value.to_s, replace: false) 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/filerepoinfo.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Return meta information about image repositories configured on the wiki. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Filerepoinfo 20 | 21 | # Which repository properties to get (there may be more available on some wikis): 22 | # 23 | # @param values [Array] Allowed values: "apiurl" (URL to the repository API - helpful for getting image info from the host), "name" (The key of the repository - used in e.g. $wgForeignFileRepos and imageinfo return values), "displayname" (The human-readable name of the repository wiki), "rooturl" (Root URL for image paths), "local" (Whether that repository is the local one or not). 24 | # @return [self] 25 | def prop(*values) 26 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 27 | end 28 | 29 | # @private 30 | def _prop(value) 31 | defined?(super) && super || ["apiurl", "name", "displayname", "rooturl", "local"].include?(value.to_s) && merge(friprop: value.to_s, replace: false) 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/flagged.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get information about the flagging status of the given pages. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Flagged 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/g-duplicatefiles.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all files that are duplicates of the given files based on hash values. _Generator module: for fetching pages corresponding to request._ 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module GDuplicatefiles 20 | 21 | # How many duplicate files to return. 22 | # 23 | # @param value [Integer, "max"] 24 | # @return [self] 25 | def limit(value) 26 | merge(gdflimit: value.to_s) 27 | end 28 | 29 | # When more results are available, use this to continue. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def continue(value) 34 | merge(gdfcontinue: value.to_s) 35 | end 36 | 37 | # The direction in which to list. 38 | # 39 | # @param value [String] One of "ascending", "descending". 40 | # @return [self] 41 | def dir(value) 42 | _dir(value) or fail ArgumentError, "Unknown value for dir: #{value}" 43 | end 44 | 45 | # @private 46 | def _dir(value) 47 | defined?(super) && super || ["ascending", "descending"].include?(value.to_s) && merge(gdfdir: value.to_s) 48 | end 49 | 50 | # Look only for files in the local repository. 51 | # 52 | # @return [self] 53 | def localonly() 54 | merge(gdflocalonly: 'true') 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/g-gettingstartedgetpages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # This API is for getting a list of one or more pages related to a particular GettingStarted task. _Generator module: for fetching pages corresponding to request._ 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module GGettingstartedgetpages 20 | 21 | # Task name, generally either "copyedit" (copy-editing suggestions) or "morelike" (pages similar to the base page/excluded title) 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def taskname(value) 26 | merge(ggsgptaskname: value.to_s) 27 | end 28 | 29 | # Full title of a page to exclude from the list; also used as the base title for recommendations based on a given page 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def excludedtitle(value) 34 | merge(ggsgpexcludedtitle: value.to_s) 35 | end 36 | 37 | # Requested count; will attempt to fetch this exact number, but may fetch fewer if no more are found after multiple attempts 38 | # 39 | # @param value [Integer] 40 | # @return [self] 41 | def count(value) 42 | merge(ggsgpcount: value.to_s) 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/g-images.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Returns all files contained on the given pages. _Generator module: for fetching pages corresponding to request._ 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module GImages 20 | 21 | # How many files to return. 22 | # 23 | # @param value [Integer, "max"] 24 | # @return [self] 25 | def limit(value) 26 | merge(gimlimit: value.to_s) 27 | end 28 | 29 | # When more results are available, use this to continue. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def continue(value) 34 | merge(gimcontinue: value.to_s) 35 | end 36 | 37 | # Only list these files. Useful for checking whether a certain page has a certain file. 38 | # 39 | # @param values [Array] 40 | # @return [self] 41 | def images(*values) 42 | values.inject(self) { |res, val| res._images(val) } 43 | end 44 | 45 | # @private 46 | def _images(value) 47 | merge(gimimages: value.to_s, replace: false) 48 | end 49 | 50 | # The direction in which to list. 51 | # 52 | # @param value [String] One of "ascending", "descending". 53 | # @return [self] 54 | def dir(value) 55 | _dir(value) or fail ArgumentError, "Unknown value for dir: #{value}" 56 | end 57 | 58 | # @private 59 | def _dir(value) 60 | defined?(super) && super || ["ascending", "descending"].include?(value.to_s) && merge(gimdir: value.to_s) 61 | end 62 | end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/g-langbacklinks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Find all pages that link to the given language link. _Generator module: for fetching pages corresponding to request._ 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module GLangbacklinks 20 | 21 | # Language for the language link. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def lang(value) 26 | merge(glbllang: value.to_s) 27 | end 28 | 29 | # Language link to search for. Must be used with lbllang. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def title(value) 34 | merge(glbltitle: value.to_s) 35 | end 36 | 37 | # When more results are available, use this to continue. 38 | # 39 | # @param value [String] 40 | # @return [self] 41 | def continue(value) 42 | merge(glblcontinue: value.to_s) 43 | end 44 | 45 | # How many total pages to return. 46 | # 47 | # @param value [Integer, "max"] 48 | # @return [self] 49 | def limit(value) 50 | merge(glbllimit: value.to_s) 51 | end 52 | 53 | # The direction in which to list. 54 | # 55 | # @param value [String] One of "ascending", "descending". 56 | # @return [self] 57 | def dir(value) 58 | _dir(value) or fail ArgumentError, "Unknown value for dir: #{value}" 59 | end 60 | 61 | # @private 62 | def _dir(value) 63 | defined?(super) && super || ["ascending", "descending"].include?(value.to_s) && merge(glbldir: value.to_s) 64 | end 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/g-mostviewed.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Lists the most viewed pages (based on last day's pageview count). _Generator module: for fetching pages corresponding to request._ 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module GMostviewed 20 | 21 | # The metric to use for counting views. Depending on what backend is used, not all metrics might be supported. You can use the siteinfo API (action=query&meta=siteinfo) to check, under pageviewservice-supported-metrics / 22 | # 23 | # @param value [String] One of "pageviews" (Plain pageviews). 24 | # @return [self] 25 | def metric(value) 26 | _metric(value) or fail ArgumentError, "Unknown value for metric: #{value}" 27 | end 28 | 29 | # @private 30 | def _metric(value) 31 | defined?(super) && super || ["pageviews"].include?(value.to_s) && merge(gpvimmetric: value.to_s) 32 | end 33 | 34 | # The number of pages to return. 35 | # 36 | # @param value [Integer, "max"] 37 | # @return [self] 38 | def limit(value) 39 | merge(gpvimlimit: value.to_s) 40 | end 41 | 42 | # When more results are available, use this to continue. 43 | # 44 | # @param value [Integer] 45 | # @return [self] 46 | def offset(value) 47 | merge(gpvimoffset: value.to_s) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/g-pageswithprop.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all pages using a given page property. _Generator module: for fetching pages corresponding to request._ 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module GPageswithprop 20 | 21 | # Page property for which to enumerate pages (action=query&list=pagepropnames returns page property names in use). 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def propname(value) 26 | merge(gpwppropname: value.to_s) 27 | end 28 | 29 | # When more results are available, use this to continue. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def continue(value) 34 | merge(gpwpcontinue: value.to_s) 35 | end 36 | 37 | # The maximum number of pages to return. 38 | # 39 | # @param value [Integer, "max"] 40 | # @return [self] 41 | def limit(value) 42 | merge(gpwplimit: value.to_s) 43 | end 44 | 45 | # In which direction to sort. 46 | # 47 | # @param value [String] One of "ascending", "descending". 48 | # @return [self] 49 | def dir(value) 50 | _dir(value) or fail ArgumentError, "Unknown value for dir: #{value}" 51 | end 52 | 53 | # @private 54 | def _dir(value) 55 | defined?(super) && super || ["ascending", "descending"].include?(value.to_s) && merge(gpwpdir: value.to_s) 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/g-projectpages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all pages associated with one or more projects. _Generator module: for fetching pages corresponding to request._ 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module GProjectpages 20 | 21 | # Also return assessments for the pages returned. 22 | # 23 | # @return [self] 24 | def assessments() 25 | merge(gwppassessments: 'true') 26 | end 27 | 28 | # The projects to list pages for. If this parameter is omitted, all projects will be included. 29 | # 30 | # @param values [Array] 31 | # @return [self] 32 | def projects(*values) 33 | values.inject(self) { |res, val| res._projects(val) } 34 | end 35 | 36 | # @private 37 | def _projects(value) 38 | merge(gwppprojects: value.to_s, replace: false) 39 | end 40 | 41 | # The maximum number of pages to return. 42 | # 43 | # @param value [Integer, "max"] 44 | # @return [self] 45 | def limit(value) 46 | merge(gwpplimit: value.to_s) 47 | end 48 | 49 | # When more results are available, use this to continue. 50 | # 51 | # @param value [String] 52 | # @return [self] 53 | def continue(value) 54 | merge(gwppcontinue: value.to_s) 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/gadgetcategories.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Returns a list of gadget categories. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Gadgetcategories 20 | 21 | # What gadget category information to get: 22 | # 23 | # @param values [Array] Allowed values: "name" (Internal category name), "title" (Category title), "members" (Number of gadgets in category). 24 | # @return [self] 25 | def prop(*values) 26 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 27 | end 28 | 29 | # @private 30 | def _prop(value) 31 | defined?(super) && super || ["name", "title", "members"].include?(value.to_s) && merge(gcprop: value.to_s, replace: false) 32 | end 33 | 34 | # Names of categories to retrieve. 35 | # 36 | # @param values [Array] 37 | # @return [self] 38 | def names(*values) 39 | values.inject(self) { |res, val| res._names(val) } 40 | end 41 | 42 | # @private 43 | def _names(value) 44 | merge(gcnames: value.to_s, replace: false) 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/gettingstartedgetpages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # This API is for getting a list of one or more pages related to a particular GettingStarted task. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Gettingstartedgetpages 20 | 21 | # Task name, generally either "copyedit" (copy-editing suggestions) or "morelike" (pages similar to the base page/excluded title) 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def taskname(value) 26 | merge(gsgptaskname: value.to_s) 27 | end 28 | 29 | # Full title of a page to exclude from the list; also used as the base title for recommendations based on a given page 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def excludedtitle(value) 34 | merge(gsgpexcludedtitle: value.to_s) 35 | end 36 | 37 | # Requested count; will attempt to fetch this exact number, but may fetch fewer if no more are found after multiple attempts 38 | # 39 | # @param value [Integer] 40 | # @return [self] 41 | def count(value) 42 | merge(gsgpcount: value.to_s) 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/globalgroups.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Enumerate all global groups. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Globalgroups 20 | 21 | # What pieces of information to include. 22 | # 23 | # @param values [Array] Allowed values: "rights". 24 | # @return [self] 25 | def prop(*values) 26 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 27 | end 28 | 29 | # @private 30 | def _prop(value) 31 | defined?(super) && super || ["rights"].include?(value.to_s) && merge(ggpprop: value.to_s, replace: false) 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/globalusage.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Returns global image usage for a certain image. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Globalusage 20 | 21 | # Which properties to return: 22 | # 23 | # @param values [Array] Allowed values: "url" (Adds url), "pageid" (Adds page ID), "namespace" (Adds namespace ID). 24 | # @return [self] 25 | def prop(*values) 26 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 27 | end 28 | 29 | # @private 30 | def _prop(value) 31 | defined?(super) && super || ["url", "pageid", "namespace"].include?(value.to_s) && merge(guprop: value.to_s, replace: false) 32 | end 33 | 34 | # How many links to return. 35 | # 36 | # @param value [Integer, "max"] 37 | # @return [self] 38 | def limit(value) 39 | merge(gulimit: value.to_s) 40 | end 41 | 42 | # When more results are available, use this to continue. 43 | # 44 | # @param value [String] 45 | # @return [self] 46 | def continue(value) 47 | merge(gucontinue: value.to_s) 48 | end 49 | 50 | # Filter local usage of the file. 51 | # 52 | # @return [self] 53 | def filterlocal() 54 | merge(gufilterlocal: 'true') 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/globaluserinfo.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Show information about a global user. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Globaluserinfo 20 | 21 | # User to get information about. Defaults to the current user. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def user(value) 26 | merge(guiuser: value.to_s) 27 | end 28 | 29 | # Which properties to get: 30 | # 31 | # @param values [Array] Allowed values: "groups" (Get a list of global groups this user belongs to), "rights" (Get a list of global rights this user has), "merged" (Get a list of merged accounts), "unattached" (Get a list of unattached accounts), "editcount" (Get the user's global edit count). 32 | # @return [self] 33 | def prop(*values) 34 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 35 | end 36 | 37 | # @private 38 | def _prop(value) 39 | defined?(super) && super || ["groups", "rights", "merged", "unattached", "editcount"].include?(value.to_s) && merge(guiprop: value.to_s, replace: false) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/images.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Returns all files contained on the given pages. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Images 20 | 21 | # How many files to return. 22 | # 23 | # @param value [Integer, "max"] 24 | # @return [self] 25 | def limit(value) 26 | merge(imlimit: value.to_s) 27 | end 28 | 29 | # When more results are available, use this to continue. 30 | # 31 | # @param value [String] 32 | # @return [self] 33 | def continue(value) 34 | merge(imcontinue: value.to_s) 35 | end 36 | 37 | # Only list these files. Useful for checking whether a certain page has a certain file. 38 | # 39 | # @param values [Array] 40 | # @return [self] 41 | def images(*values) 42 | values.inject(self) { |res, val| res._images(val) } 43 | end 44 | 45 | # @private 46 | def _images(value) 47 | merge(imimages: value.to_s, replace: false) 48 | end 49 | 50 | # The direction in which to list. 51 | # 52 | # @param value [String] One of "ascending", "descending". 53 | # @return [self] 54 | def dir(value) 55 | _dir(value) or fail ArgumentError, "Unknown value for dir: #{value}" 56 | end 57 | 58 | # @private 59 | def _dir(value) 60 | defined?(super) && super || ["ascending", "descending"].include?(value.to_s) && merge(imdir: value.to_s) 61 | end 62 | end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/mapdata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Request all map data from the page Metallica 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Mapdata 20 | 21 | # Pipe-separated groups to return data for 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def groups(value) 26 | merge(mpdgroups: value.to_s) 27 | end 28 | 29 | # Data for how many pages to return 30 | # 31 | # @param value [Integer, "max"] 32 | # @return [self] 33 | def limit(value) 34 | merge(mpdlimit: value.to_s) 35 | end 36 | 37 | # When more results are available, use this to continue. 38 | # 39 | # @param value [Integer] 40 | # @return [self] 41 | def continue(value) 42 | merge(mpdcontinue: value.to_s) 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/mmsites.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Serve autocomplete requests for the site field in MassMessage. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Mmsites 20 | 21 | # The prefix to search for. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def term(value) 26 | merge(term: value.to_s) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/mostviewed.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Lists the most viewed pages (based on last day's pageview count). 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Mostviewed 20 | 21 | # The metric to use for counting views. Depending on what backend is used, not all metrics might be supported. You can use the siteinfo API (action=query&meta=siteinfo) to check, under pageviewservice-supported-metrics / 22 | # 23 | # @param value [String] One of "pageviews" (Plain pageviews). 24 | # @return [self] 25 | def metric(value) 26 | _metric(value) or fail ArgumentError, "Unknown value for metric: #{value}" 27 | end 28 | 29 | # @private 30 | def _metric(value) 31 | defined?(super) && super || ["pageviews"].include?(value.to_s) && merge(pvimmetric: value.to_s) 32 | end 33 | 34 | # The number of pages to return. 35 | # 36 | # @param value [Integer, "max"] 37 | # @return [self] 38 | def limit(value) 39 | merge(pvimlimit: value.to_s) 40 | end 41 | 42 | # When more results are available, use this to continue. 43 | # 44 | # @param value [Integer] 45 | # @return [self] 46 | def offset(value) 47 | merge(pvimoffset: value.to_s) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/mystashedfiles.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get a list of files in the current user's upload stash. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Mystashedfiles 20 | 21 | # Which properties to fetch for the files. 22 | # 23 | # @param values [Array] Allowed values: "size" (Fetch the file size and image dimensions), "type" (Fetch the file's MIME type and media type). 24 | # @return [self] 25 | def prop(*values) 26 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 27 | end 28 | 29 | # @private 30 | def _prop(value) 31 | defined?(super) && super || ["size", "type"].include?(value.to_s) && merge(msfprop: value.to_s, replace: false) 32 | end 33 | 34 | # How many files to get. 35 | # 36 | # @param value [Integer, "max"] 37 | # @return [self] 38 | def limit(value) 39 | merge(msflimit: value.to_s) 40 | end 41 | 42 | # When more results are available, use this to continue. 43 | # 44 | # @param value [String] 45 | # @return [self] 46 | def continue(value) 47 | merge(msfcontinue: value.to_s) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/none.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Output nothing. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module None 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/oath.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Check to see if two-factor authentication (OATH) is enabled for a user. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Oath 20 | 21 | # User to get information about. Defaults to the current user. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def user(value) 26 | merge(oathuser: value.to_s) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/ores.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Return ORES configuration and model data for this wiki. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Ores 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/pageassessments.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Return associated projects and assessments for the given pages. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Pageassessments 20 | 21 | # When more results are available, use this to continue. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def continue(value) 26 | merge(pacontinue: value.to_s) 27 | end 28 | 29 | # Limit for total number of projects returned (total for all pages). 30 | # 31 | # @param value [Integer, "max"] 32 | # @return [self] 33 | def limit(value) 34 | merge(palimit: value.to_s) 35 | end 36 | 37 | # Also return assessments by subprojects. 38 | # 39 | # @return [self] 40 | def subprojects() 41 | merge(pasubprojects: 'true') 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/pagepropnames.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all page property names in use on the wiki. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Pagepropnames 20 | 21 | # When more results are available, use this to continue. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def continue(value) 26 | merge(ppncontinue: value.to_s) 27 | end 28 | 29 | # The maximum number of names to return. 30 | # 31 | # @param value [Integer, "max"] 32 | # @return [self] 33 | def limit(value) 34 | merge(ppnlimit: value.to_s) 35 | end 36 | end 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/pageprops.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get various page properties defined in the page content. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Pageprops 20 | 21 | # When more results are available, use this to continue. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def continue(value) 26 | merge(ppcontinue: value.to_s) 27 | end 28 | 29 | # Only list these page properties (action=query&list=pagepropnames returns page property names in use). Useful for checking whether pages use a certain page property. 30 | # 31 | # @param values [Array] 32 | # @return [self] 33 | def prop(*values) 34 | values.inject(self) { |res, val| res._prop(val) } 35 | end 36 | 37 | # @private 38 | def _prop(value) 39 | merge(ppprop: value.to_s, replace: false) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/pageterms.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get terms associated with a page via an associated data item. On a wikibase entity page, the entity terms are used directly. Caveat: On a repo wiki, pageterms only works directly on entity pages, not on pages connected to an item. This may change in the future. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Pageterms 20 | 21 | # When more results are available, use this to continue. 22 | # 23 | # @param value [Integer] 24 | # @return [self] 25 | def continue(value) 26 | merge(wbptcontinue: value.to_s) 27 | end 28 | 29 | # The types of terms to get, e.g. 'description'. If not specified, all types are returned. 30 | # 31 | # @param values [Array] Allowed values: "alias", "description", "label". 32 | # @return [self] 33 | def terms(*values) 34 | values.inject(self) { |res, val| res._terms(val) or fail ArgumentError, "Unknown value for terms: #{val}" } 35 | end 36 | 37 | # @private 38 | def _terms(value) 39 | defined?(super) && super || ["alias", "description", "label"].include?(value.to_s) && merge(wbptterms: value.to_s, replace: false) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/pageviews.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Shows per-page pageview data (the number of daily pageviews for each of the last pvipdays days). The result format is page title (with underscores) => date (Ymd) => count. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Pageviews 20 | 21 | # The metric to use for counting views. Depending on what backend is used, not all metrics might be supported. You can use the siteinfo API (action=query&meta=siteinfo) to check, under pageviewservice-supported-metrics / 22 | # 23 | # @param value [String] One of "pageviews" (Plain pageviews). 24 | # @return [self] 25 | def metric(value) 26 | _metric(value) or fail ArgumentError, "Unknown value for metric: #{value}" 27 | end 28 | 29 | # @private 30 | def _metric(value) 31 | defined?(super) && super || ["pageviews"].include?(value.to_s) && merge(pvipmetric: value.to_s) 32 | end 33 | 34 | # The number of days to show. 35 | # 36 | # @param value [Integer] 37 | # @return [self] 38 | def days(value) 39 | merge(pvipdays: value.to_s) 40 | end 41 | 42 | # When more results are available, use this to continue. 43 | # 44 | # @param value [String] 45 | # @return [self] 46 | def continue(value) 47 | merge(pvipcontinue: value.to_s) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/php.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Output data in serialized PHP format. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Php 20 | 21 | # Output formatting: 22 | # 23 | # @param value [String] One of "1" (Backwards-compatible format (XML-style booleans, * keys for content nodes, etc.)), "2" (Experimental modern format. Details may change!), "latest" (Use the latest format (currently 2), may change without warning). 24 | # @return [self] 25 | def formatversion(value) 26 | _formatversion(value) or fail ArgumentError, "Unknown value for formatversion: #{value}" 27 | end 28 | 29 | # @private 30 | def _formatversion(value) 31 | defined?(super) && super || ["1", "2", "latest"].include?(value.to_s) && merge(formatversion: value.to_s) 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/phpfm.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Output data in serialized PHP format (pretty-print in HTML). 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Phpfm 20 | 21 | # Return the pretty-printed HTML and associated ResourceLoader modules as a JSON object. 22 | # 23 | # @return [self] 24 | def wrappedhtml() 25 | merge(wrappedhtml: 'true') 26 | end 27 | 28 | # Output formatting: 29 | # 30 | # @param value [String] One of "1" (Backwards-compatible format (XML-style booleans, * keys for content nodes, etc.)), "2" (Experimental modern format. Details may change!), "latest" (Use the latest format (currently 2), may change without warning). 31 | # @return [self] 32 | def formatversion(value) 33 | _formatversion(value) or fail ArgumentError, "Unknown value for formatversion: #{value}" 34 | end 35 | 36 | # @private 37 | def _formatversion(value) 38 | defined?(super) && super || ["1", "2", "latest"].include?(value.to_s) && merge(formatversion: value.to_s) 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/projectpages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all pages associated with one or more projects. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Projectpages 20 | 21 | # Also return assessments for the pages returned. 22 | # 23 | # @return [self] 24 | def assessments() 25 | merge(wppassessments: 'true') 26 | end 27 | 28 | # The projects to list pages for. If this parameter is omitted, all projects will be included. 29 | # 30 | # @param values [Array] 31 | # @return [self] 32 | def projects(*values) 33 | values.inject(self) { |res, val| res._projects(val) } 34 | end 35 | 36 | # @private 37 | def _projects(value) 38 | merge(wppprojects: value.to_s, replace: false) 39 | end 40 | 41 | # The maximum number of pages to return. 42 | # 43 | # @param value [Integer, "max"] 44 | # @return [self] 45 | def limit(value) 46 | merge(wpplimit: value.to_s) 47 | end 48 | 49 | # When more results are available, use this to continue. 50 | # 51 | # @param value [String] 52 | # @return [self] 53 | def continue(value) 54 | merge(wppcontinue: value.to_s) 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/projects.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List all the projects. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Projects 20 | 21 | # Also include subprojects. 22 | # 23 | # @return [self] 24 | def subprojects() 25 | merge(pjsubprojects: 'true') 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/rawfm.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Output data, including debugging elements, in JSON format (pretty-print in HTML). 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Rawfm 20 | 21 | # Return the pretty-printed HTML and associated ResourceLoader modules as a JSON object. 22 | # 23 | # @return [self] 24 | def wrappedhtml() 25 | merge(wrappedhtml: 'true') 26 | end 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/references.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Return a data representation of references associated with the given pages. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module References 20 | 21 | # When more results are available, use this to continue. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def continue(value) 26 | merge(rfcontinue: value.to_s) 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/siteviews.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Shows sitewide pageview data (daily pageview totals for each of the last pvisdays days). The result format is date (Ymd) => count. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Siteviews 20 | 21 | # The metric to use for counting views. Depending on what backend is used, not all metrics might be supported. You can use the siteinfo API (action=query&meta=siteinfo) to check, under pageviewservice-supported-metrics / 22 | # 23 | # @param value [String] One of "pageviews" (Plain pageviews), "uniques" (Unique visitors). 24 | # @return [self] 25 | def metric(value) 26 | _metric(value) or fail ArgumentError, "Unknown value for metric: #{value}" 27 | end 28 | 29 | # @private 30 | def _metric(value) 31 | defined?(super) && super || ["pageviews", "uniques"].include?(value.to_s) && merge(pvismetric: value.to_s) 32 | end 33 | 34 | # The number of days to show. 35 | # 36 | # @param value [Integer] 37 | # @return [self] 38 | def days(value) 39 | merge(pvisdays: value.to_s) 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/tags.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # List change tags. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Tags 20 | 21 | # When more results are available, use this to continue. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def continue(value) 26 | merge(tgcontinue: value.to_s) 27 | end 28 | 29 | # The maximum number of tags to list. 30 | # 31 | # @param value [Integer, "max"] 32 | # @return [self] 33 | def limit(value) 34 | merge(tglimit: value.to_s) 35 | end 36 | 37 | # Which properties to get: 38 | # 39 | # @param values [Array] Allowed values: "name" (Adds name of tag), "displayname" (Adds system message for the tag), "description" (Adds description of the tag), "hitcount" (Adds the number of revisions and log entries that have this tag), "defined" (Indicate whether the tag is defined), "source" (Gets the sources of the tag, which may include extension for extension-defined tags and manual for tags that may be applied manually by users), "active" (Whether the tag is still being applied). 40 | # @return [self] 41 | def prop(*values) 42 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 43 | end 44 | 45 | # @private 46 | def _prop(value) 47 | defined?(super) && super || ["name", "displayname", "description", "hitcount", "defined", "source", "active"].include?(value.to_s) && merge(tgprop: value.to_s, replace: false) 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/tokens.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Gets tokens for data-modifying actions. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Tokens 20 | 21 | # Types of token to request. 22 | # 23 | # @param values [Array] Allowed values: "createaccount", "csrf", "deleteglobalaccount", "login", "patrol", "rollback", "setglobalaccountstatus", "userrights", "watch". 24 | # @return [self] 25 | def type(*values) 26 | values.inject(self) { |res, val| res._type(val) or fail ArgumentError, "Unknown value for type: #{val}" } 27 | end 28 | 29 | # @private 30 | def _type(value) 31 | defined?(super) && super || ["createaccount", "csrf", "deleteglobalaccount", "login", "patrol", "rollback", "setglobalaccountstatus", "userrights", "watch"].include?(value.to_s) && merge(type: value.to_s, replace: false) 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/transcodestatus.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get transcode status for a given file page. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Transcodestatus 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/wikibase.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Get information about the Wikibase client and the associated Wikibase repository. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Wikibase 20 | 21 | # Which properties to get: 22 | # 23 | # @param values [Array] Allowed values: "url" ( Base URL, script path and article path of the Wikibase repository), "siteid" ( The siteid of this site). 24 | # @return [self] 25 | def prop(*values) 26 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 27 | end 28 | 29 | # @private 30 | def _prop(value) 31 | defined?(super) && super || ["url", "siteid"].include?(value.to_s) && merge(wbprop: value.to_s, replace: false) 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/wikisets.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Enumerate all wiki sets. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Wikisets 20 | 21 | # The name of the wiki set to start from. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def from(value) 26 | merge(wsfrom: value.to_s) 27 | end 28 | 29 | # What pieces of information to include. 30 | # 31 | # @param values [Array] Allowed values: "type" (Opt-in based (includes only specified wikis) or opt-out based (includes all wikis except specified)), "wikisincluded" (The wikis that are included in this wiki set), "wikisnotincluded" (The wikis that are not included in this wiki set). 32 | # @return [self] 33 | def prop(*values) 34 | values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" } 35 | end 36 | 37 | # @private 38 | def _prop(value) 39 | defined?(super) && super || ["type", "wikisincluded", "wikisnotincluded"].include?(value.to_s) && merge(wsprop: value.to_s, replace: false) 40 | end 41 | 42 | # How many wiki sets to return. 43 | # 44 | # @param value [Integer, "max"] 45 | # @return [self] 46 | def limit(value) 47 | merge(wslimit: value.to_s) 48 | end 49 | 50 | # Order results by name. 51 | # 52 | # @return [self] 53 | def orderbyname() 54 | merge(wsorderbyname: 'true') 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/xml.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Output data in XML format. 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Xml 20 | 21 | # If specified, adds the named page as an XSL stylesheet. The value must be a title in the MediaWiki namespace ending in .xsl. 22 | # 23 | # @param value [String] 24 | # @return [self] 25 | def xslt(value) 26 | merge(xslt: value.to_s) 27 | end 28 | 29 | # If specified, adds an XML namespace. 30 | # 31 | # @return [self] 32 | def includexmlnamespace() 33 | merge(includexmlnamespace: 'true') 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /lib/mediawiktory/wikipedia/modules/xmlfm.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module MediaWiktory::Wikipedia 4 | module Modules 5 | # Output data in XML format (pretty-print in HTML). 6 | # 7 | # The "submodule" (MediaWiki API term) is included in action after setting some param, providing 8 | # additional tweaking for this param. Example (for {MediaWiktory::Wikipedia::Actions::Query} and 9 | # its submodules): 10 | # 11 | # ```ruby 12 | # api.query # returns Actions::Query 13 | # .prop(:revisions) # adds prop=revisions to action URL, and includes Modules::Revisions into action 14 | # .limit(10) # method of Modules::Revisions, adds rvlimit=10 to URL 15 | # ``` 16 | # 17 | # All submodule's parameters are documented as its public methods, see below. 18 | # 19 | module Xmlfm 20 | 21 | # Return the pretty-printed HTML and associated ResourceLoader modules as a JSON object. 22 | # 23 | # @return [self] 24 | def wrappedhtml() 25 | merge(wrappedhtml: 'true') 26 | end 27 | 28 | # If specified, adds the named page as an XSL stylesheet. The value must be a title in the MediaWiki namespace ending in .xsl. 29 | # 30 | # @param value [String] 31 | # @return [self] 32 | def xslt(value) 33 | merge(xslt: value.to_s) 34 | end 35 | 36 | # If specified, adds an XML namespace. 37 | # 38 | # @return [self] 39 | def includexmlnamespace() 40 | merge(includexmlnamespace: 'true') 41 | end 42 | end 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /lib/nokogiri/more.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'naught' 4 | 5 | # @private 6 | # Used only by Generator 7 | module Nokogiri 8 | module More 9 | module NodeChildrenGroups 10 | def children_groups(*selectors) 11 | groups = [] 12 | flat = children.select { |node| selectors.any? { |s| node.matches?(s) } } 13 | groups << make_group(flat, selectors) until flat.empty? 14 | groups 15 | end 16 | 17 | def each_term 18 | children_groups('dt', 'dd') 19 | end 20 | 21 | private 22 | 23 | def make_group(flat, selectors) 24 | sel = selectors.dup 25 | group = [[]] 26 | until flat.empty? 27 | if flat.first.matches?(sel.first) 28 | group.last << flat.shift 29 | elsif sel.size > 1 && flat.first.matches?(sel[1]) 30 | sel.shift 31 | group << [] 32 | group.last << flat.shift 33 | else 34 | break 35 | end 36 | end 37 | group 38 | end 39 | end 40 | 41 | NodeNaught = Naught.build do |config| 42 | config.black_hole 43 | 44 | # so you can just `at?(selector).tap{|node| ...` 45 | # and never be inside `tap`, if it's not found 46 | def tap 47 | self 48 | end 49 | end 50 | 51 | module NodeQuestMethods 52 | def at?(selector) 53 | at(selector) || NodeNaught.new 54 | end 55 | 56 | def at_css?(selector) 57 | at_css(selector) || NodeNaught.new 58 | end 59 | 60 | def at_xpath?(selector) 61 | at_xpath(selector) || NodeNaught.new 62 | end 63 | 64 | def find_child?(selector) 65 | find_child(selector) || NodeNaught.new 66 | end 67 | end 68 | end 69 | 70 | Nokogiri::XML::Node.send(:include, More::NodeChildrenGroups) 71 | Nokogiri::XML::Node.send(:include, More::NodeQuestMethods) 72 | end 73 | -------------------------------------------------------------------------------- /mediawiktory.gemspec: -------------------------------------------------------------------------------- 1 | require './lib/mediawiktory/version' 2 | 3 | Gem::Specification.new do |s| 4 | s.name = 'mediawiktory' 5 | s.version = MediaWiktory::VERSION 6 | s.authors = ['Victor Shepelev'] 7 | s.email = 'zverok.offline@gmail.com' 8 | s.homepage = 'https://github.com/molybdenum-99/mediawiktory' 9 | 10 | s.summary = 'Full-featured MediaWiki client with Arel-like queries' 11 | s.licenses = ['MIT'] 12 | 13 | s.required_ruby_version = '>= 2.1.0' 14 | 15 | s.files = `git ls-files`.split($RS).reject do |file| 16 | file =~ /^(?: 17 | spec\/.* 18 | |Gemfile 19 | |Rakefile 20 | |\.rspec 21 | |\.gitignore 22 | |\.rubocop.yml 23 | |\.travis.yml 24 | )$/x 25 | end 26 | s.require_paths = ["lib"] 27 | 28 | s.bindir = 'bin' 29 | s.executables << 'mediawiktory-gen' 30 | 31 | s.add_dependency 'nokogiri' 32 | s.add_dependency 'naught' 33 | s.add_dependency 'faraday' 34 | s.add_dependency 'faraday_middleware' 35 | s.add_dependency 'hashie' 36 | s.add_dependency 'addressable' 37 | end 38 | -------------------------------------------------------------------------------- /spec/dokaz_helpers.rb: -------------------------------------------------------------------------------- 1 | $:.unshift 'lib' 2 | require 'mediawiktory' 3 | require 'pp' 4 | -------------------------------------------------------------------------------- /spec/fixtures/argentina_cont.json: -------------------------------------------------------------------------------- 1 | {"pageid":18951905,"ns":0,"title":"Argentina","images":[{"ns":6,"title":"File:Boxed East arrow.svg"},{"ns":6,"title":"File:B\u00e9r\u00e9nice Bejo Cannes 2013 2.jpg"},{"ns":6,"title":"File:Camino a las Sierras de C\u00f3rdoba 2009-11.jpg"},{"ns":6,"title":"File:Casa de Gobierno 002.jpg"},{"ns":6,"title":"File:Casa y monta\u00f1a.jpg"},{"ns":6,"title":"File:Cerro Chapelco Paisaje.jpg"},{"ns":6,"title":"File:Ciudadunivstation3.jpg"},{"ns":6,"title":"File:Coat of arms of Argentina.svg"},{"ns":6,"title":"File:Colon-interior-escenario-TM.jpg"},{"ns":6,"title":"File:Commons-logo.svg"}],"categories":[{"ns":14,"title":"Category:Articles containing potentially dated statements from 2011"},{"ns":14,"title":"Category:Articles containing potentially dated statements from 2012"},{"ns":14,"title":"Category:Articles containing potentially dated statements from 2013"},{"ns":14,"title":"Category:Articles containing potentially dated statements from 2014"},{"ns":14,"title":"Category:Articles including recorded pronunciations"},{"ns":14,"title":"Category:Articles with DMOZ links"},{"ns":14,"title":"Category:Articles with Spanish-language external links"},{"ns":14,"title":"Category:Articles with attributed pull quotes"},{"ns":14,"title":"Category:Articles with dead external links from August 2014"},{"ns":14,"title":"Category:Articles with dead external links from June 2015"}]} 2 | -------------------------------------------------------------------------------- /spec/fixtures/missing.json: -------------------------------------------------------------------------------- 1 | {"ns":0,"title":"Argentinfa","missing":"","contentmodel":"wikitext","pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr","fullurl":"https://en.wikipedia.org/wiki/Argentinfa","editurl":"https://en.wikipedia.org/w/index.php?title=Argentinfa&action=edit","canonicalurl":"https://en.wikipedia.org/wiki/Argentinfa"} 2 | -------------------------------------------------------------------------------- /spec/fixtures/query-pages-last.json: -------------------------------------------------------------------------------- 1 | {"batchcomplete":"","query":{"pages":{"693026":{"pageid":693026,"ns":14,"title":"Category:Venezuela","contentmodel":"wikitext","pagelanguage":"en","pagelanguagehtmlcode":"en","pagelanguagedir":"ltr","touched":"2015-11-28T07:25:24Z","lastrevid":662359871,"length":217},"18951905":{"pageid":18951905,"categories":[{"ns":14, "title":"Category:Wikipedia articles with GND identifiers"}]}}}} 2 | -------------------------------------------------------------------------------- /spec/fixtures/siteinfo.json: -------------------------------------------------------------------------------- 1 | {"batchcomplete":"","query":{"general":{"mainpage":"Main Page","base":"https://en.wikipedia.org/wiki/Main_Page","sitename":"Wikipedia","logo":"//en.wikipedia.org/static/images/project-logos/enwiki.png","generator":"MediaWiki 1.29.0-wmf.20","phpversion":"5.6.99-hhvm","phpsapi":"srv","hhvmversion":"3.12.14","dbtype":"mysql","dbversion":"10.0.23-MariaDB-log","imagewhitelistenabled":"","langconversion":"","titleconversion":"","linkprefixcharset":"","linkprefix":"","linktrail":"/^([a-z]+)(.*)$/sD","legaltitlechars":" %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+","invalidusernamechars":"@:","fixarabicunicode":"","fixmalayalamunicode":"","git-hash":"345b2bebe0ca8d6870dd0ae0757ffe050d38a753","git-branch":"wmf/1.29.0-wmf.20","case":"first-letter","lang":"en","fallback":[],"fallback8bitEncoding":"windows-1252","writeapi":"","maxarticlesize":2097152,"timezone":"UTC","timeoffset":0,"articlepath":"/wiki/$1","scriptpath":"/w","script":"/w/index.php","variantarticlepath":false,"server":"//en.wikipedia.org","servername":"en.wikipedia.org","wikiid":"enwiki","time":"2017-04-22T11:59:00Z","misermode":"","uploadsenabled":"","maxuploadsize":4294967296,"minuploadchunksize":1024,"galleryoptions":{"imagesPerRow":0,"imageWidth":120,"imageHeight":120,"captionLength":"","showBytes":"","mode":"traditional"},"thumblimits":[120,150,180,200,220,250,300,400],"imagelimits":[{"width":320,"height":240},{"width":640,"height":480},{"width":800,"height":600},{"width":1024,"height":768},{"width":1280,"height":1024}],"favicon":"//en.wikipedia.org/static/favicon/wikipedia.ico","centralidlookupprovider":"CentralAuth","allcentralidlookupproviders":["CentralAuth","local"],"interwikimagic":"","magiclinks":{"ISBN":"","PMID":"","RFC":""},"pageviewservice-supported-metrics":{"pageviews":{"pageviews":""},"siteviews":{"pageviews":"","uniques":""},"mostviewed":{"pageviews":""}}}}} -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $:.unshift 'lib' 2 | require 'mediawiktory' 3 | 4 | require 'rspec/its' 5 | require 'webmock/rspec' 6 | require 'saharspec' 7 | 8 | include Saharspec::Util 9 | 10 | class String 11 | def unindent 12 | multiline(self) 13 | end 14 | end 15 | 16 | def read_fixture(path) 17 | File.read(File.join('spec/fixtures', path)) 18 | end 19 | --------------------------------------------------------------------------------