Talk:AllPages: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
m (Imahero moved page Talk:AllPages to Talk:All Pages)
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
== List generation ==
==Generate==
<pre>
In the past I used a python script to generate this page. At some point I figured out how to do it using <nowiki>{{Special:AllPages|hideredirects=1|namespace=0|from=|to=a}}...</nowiki> instead. [[user_talk:imahero|imahero]] 00:56, 8 December 2023 (UTC)
#!/usr/bin/env python3
 
import urllib.request
import json
 
base_url = 'http://heroes.thelazy.net/wiki/'
base_query = 'http://heroes.thelazy.net/wiki/api.php?action=query&list=allpages&aplimit=500&apfilterredir=nonredirects&format=json&apfrom='
query_title = ''
titles = {}
 
while True:
    request = urllib.request.urlopen(base_query + query_title)
    response = request.read()
    results = json.loads(response.decode())
    for page in results['query']['allpages']:
        title = page['title']
        titles[title] = base_url + urllib.parse.quote(title.replace(' ', '_'))
    if 'query-continue' in results:
        query_title = results['query-continue']['allpages']['apcontinue']
    else:
        break
 
output_file = open('output.mediawiki', 'w')
 
for title, url in sorted(titles.items()):
    if title != 'AllPages':
        output_file.write('[' + url + ' ' + title + ']\n<br>\n')
</pre>
--[[User:imahero|imahero]] 04:19, 6 September 2016 (CEST)
 
:Nice technical page, but I must ask is there any use for it? At least for me this seems quite useless, causing hinder rather than help. –[[User:Kapteeni Ruoska|Kapteeni Ruoska]] ([[User talk:Kapteeni Ruoska|talk]]) 06:11, 7 September 2016 (CEST)
 
::I wanted to make sure there wasn't anything I was missing. When I'm browsing through the list it's easier to click these links than copy pasting the auto-generated titles from the api query.
::--[[User:imahero|imahero]] 03:14, 8 September 2016 (CEST)
 
:::Sure, just wondering, as the wiki already has [[Special:AllPages]], but perhaps there is a use for that. –[[User:Kapteeni Ruoska|Kapteeni Ruoska]] ([[User talk:Kapteeni Ruoska|talk]]) 07:27, 8 September 2016 (CEST)
 
::::[[Special:AllPages]] felt too clumsy for me to navigate. All I really wanted was a single list of all nonredirect links :)
:::: --[[User:imahero|imahero]] 08:31, 8 September 2016 (CEST)
 
I may want to go back to using the external link syntax if breaking the [[Special:LonelyPages|orphaned pages]] is a big deal. For now I've just added the orphaned pages here and I'll just update the list every time I generate the AllPages list.<br>
--[[User:imahero|imahero]] 15:19, 8 September 2016 (CEST)
 
::I changed it back to use the external link syntax to make sure the [[Special:LonelyPages|orphaned pages]] list still works properly. <br>
:: --[[User:imahero|imahero]] 22:48, 8 September 2016 (CEST)

Latest revision as of 00:56, 8 December 2023

Generate[edit]

In the past I used a python script to generate this page. At some point I figured out how to do it using {{Special:AllPages|hideredirects=1|namespace=0|from=|to=a}}... instead. –imahero 00:56, 8 December 2023 (UTC)