Module: MediaWiki::Query::Lists::Backlinks
- Included in:
- MediaWiki::Query::Lists
- Defined in:
- lib/mediawiki/query/lists/backlinks.rb
Instance Method Summary collapse
-
#get_image_backlinks(title, list_redirects = nil, thru_redir = false, limit = @query_limit_default) ⇒ Array<String>
Gets image backlinks, or the pages that use a given image.
-
#get_interwiki_backlinks(prefix = nil, title = nil, limit = @query_limit_default) ⇒ Array<String>
Gets interwiki backlinks by the prefix and title.
-
#get_language_backlinks(language = nil, title = nil, limit = @query_limit_default) ⇒ Array<String>
Gets language backlinks by the language and title.
-
#get_url_backlinks(url = nil, limit = @query_limit_default) ⇒ Array<String>, Array<Hash<Symbol, String>>
Gets all external link page titles.
-
#what_links_here(title, limit = @query_limit_default) ⇒ Array<String>
Gets an array of backlinks to a given title, like Special:WhatLinksHere.
Instance Method Details
#get_image_backlinks(title, list_redirects = nil, thru_redir = false, limit = @query_limit_default) ⇒ Array<String>
Gets image backlinks, or the pages that use a given image.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mediawiki/query/lists/backlinks.rb', line 66 def get_image_backlinks(title, list_redirects = nil, thru_redir = false, limit = @query_limit_default) params = { list: 'imageusage', iutitle: title, iulimit: get_limited(limit) } params[:iufilterredir] = list_redirects.nil? ? 'all' : list_redirects params[:iuredirect] = '1' if thru_redir query_ary(params, 'imageusage', 'title') end |
#get_interwiki_backlinks(prefix = nil, title = nil, limit = @query_limit_default) ⇒ Array<String>
Gets interwiki backlinks by the prefix and title.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mediawiki/query/lists/backlinks.rb', line 29 def get_interwiki_backlinks(prefix = nil, title = nil, limit = @query_limit_default) params = { list: 'iwbacklinks', iwbllimit: get_limited(limit) } params[:iwblprefix] = prefix unless prefix.nil? params[:iwbltitle] = title unless title.nil? query_ary(params, 'iwbacklinks', 'title') end |
#get_language_backlinks(language = nil, title = nil, limit = @query_limit_default) ⇒ Array<String>
Gets language backlinks by the language and title.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mediawiki/query/lists/backlinks.rb', line 46 def get_language_backlinks(language = nil, title = nil, limit = @query_limit_default) language.downcase! if language.match(/[^A-Z]*/)[0].empty? params = { list: 'langbacklinks', lbltitle: get_limited(limit) } params[:lbllang] = language unless language.nil? params[:lbltitle] = title unless title.nil? query_ary(params, 'langbacklinks', 'title') end |
#get_url_backlinks(url = nil, limit = @query_limit_default) ⇒ Array<String>, Array<Hash<Symbol, String>>
Gets all external link page titles.
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/mediawiki/query/lists/backlinks.rb', line 86 def get_url_backlinks(url = nil, limit = @query_limit_default) params = { list: 'exturlusage', eulimit: get_limited(limit) } params[:euquery] = url if url query(params) do |return_val, query| query['exturlusage'].each { |bl| return_val << url ? bl['title'] : { url: bl['url'], title: bl['title'] } } end end |
#what_links_here(title, limit = @query_limit_default) ⇒ Array<String>
Gets an array of backlinks to a given title, like Special:WhatLinksHere.
12 13 14 15 16 17 18 19 20 |
# File 'lib/mediawiki/query/lists/backlinks.rb', line 12 def what_links_here(title, limit = @query_limit_default) params = { list: 'backlinks', bltitle: title, bllimit: get_limited(limit) } query_ary(params, 'backlinks', 'title') end |