<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<meta charset="UTF-8" />
<title>Talk:All Pages - The Heroes of Might and Magic III wiki</title>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta name="generator" content="MediaWiki 1.23.5" />
<link rel="alternate" type="application/x-wiki" title="Edit" href="./index.php?title=Talk:All_Pages&amp;action=edit" />
<link rel="edit" title="Edit" href="./index.php?title=Talk:All_Pages&amp;action=edit" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="opensearch_desc.php" title="The Heroes of Might and Magic III wiki (en)" />
<link rel="EditURI" type="application/rsd+xml" href="api.php?action=rsd" />
<link rel="alternate" type="application/atom+xml" title="The Heroes of Might and Magic III wiki Atom feed" href="./index.php?title=Special:RecentChanges&amp;feed=atom" />
<link rel="stylesheet" href="load.php?debug=false&amp;lang=en&amp;modules=mediawiki.legacy.commonPrint,shared|mediawiki.skinning.interface|mediawiki.ui.button|skins.monobook.styles&amp;only=styles&amp;skin=monobook&amp;*" />
<!--[if IE 6]><link rel="stylesheet" href="/wiki/skins/monobook/IE60Fixes.css?303" media="screen" /><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="/wiki/skins/monobook/IE70Fixes.css?303" media="screen" /><![endif]--><meta name="ResourceLoaderDynamicStyles" content="" />
<link rel="stylesheet" href="load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=styles&amp;skin=monobook&amp;*" />
<style>a:lang(ar),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}
/* cache key: h3wiki:resourceloader:filter:minify-css:7:9987a8d12e227de4fc8ea4a562cec67b */</style>
<script src="load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=monobook&amp;*"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"Talk","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":1,"wgPageName":"Talk:All_Pages","wgTitle":"All Pages","wgCurRevisionId":24507,"wgRevisionId":24507,"wgArticleId":4970,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":[],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"Talk:All_Pages","wgIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function($,jQuery){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"editfont":"default","editondblclick":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":1,"extendwatchlist":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nickname":"","norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"rcdays":7,"rclimit":50,"rows":25,"showhiddencats":0,"shownumberswatching":1,"showtoolbar":1,"skin":"monobook","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":1,"watchdefault":1,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,
"useeditwarning":1,"prefershttps":1,"language":"en","variant-gan":"gan","variant-iu":"iu","variant-kk":"kk","variant-ku":"ku","variant-shi":"shi","variant-sr":"sr","variant-tg":"tg","variant-uz":"uz","variant-zh":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"variant":"en"});},{},{});mw.loader.implement("user.tokens",function($,jQuery){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});},{},{});
/* cache key: h3wiki:resourceloader:filter:minify-js:7:9f426b327d5b26fdba4b6c7f571e2def */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
</head>
<body class="mediawiki ltr sitedir-ltr ns-1 ns-talk page-Talk_All_Pages skin-monobook action-view">
<div id="globalWrapper">
<div id="column-content">

<div id="content" class="mw-body-primary" role="main" style="padding-right: 124px;">

<div id="addie" style="position: absolute; right: 0;">

<script type="text/javascript"><!--
google_ad_client = "ca-pub-6690847397983079";
/* SideBarH3Wiki */
google_ad_slot = "8403653991";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>


	<a id="top"></a>
	
	<h1 id="firstHeading" class="firstHeading" lang="en"><span dir="auto">Talk:All Pages</span></h1>
	<div id="bodyContent" class="mw-body">
		<div id="siteSub">From The Heroes of Might and Magic III wiki</div>
		<div id="contentSub"></div>
		<div id="jump-to-nav" class="mw-jump">Jump to: <a href="./Talk:All_Pages#column-one">navigation</a>, <a href="./Talk:All_Pages#searchInput">search</a></div>

		<!-- start content -->
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><h2><span class="mw-headline" id="List_generation">List generation</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="./index.php?title=Talk:All_Pages&amp;action=edit&amp;section=1" title="Edit section: List generation">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<pre>
#!/usr/bin/env python3

import pathlib
import urllib.request
import json

if not pathlib.Path('output').exists():
    pathlib.Path('output').mkdir()

all_pages_output_file = open('output/AllPages.mediawiki', 'w')

all_pages_output_file.write('[[Category: Indices]]\n\n')

category_output_files = {}

base_url = 'http://heroes.thelazy.net/wiki/'
page_titles_by_category = {}
category_titles_by_category = {}

def main():
    base_page_query = 'http://heroes.thelazy.net/wiki/api.php?action=query&amp;list=allpages&amp;aplimit=500&amp;apfilterredir=nonredirects&amp;format=json&amp;apfrom='
    continue_title = ''
    page_titles = {}

    while True:
        request = urllib.request.urlopen(base_page_query + continue_title.replace(' ', '_'))
        response = request.read()
        results = json.loads(response.decode())
        for page in results['query']['allpages']:
            title = page['title']
            page_titles[title] = base_url + title
        if 'query-continue' in results:
            continue_title = results['query-continue']['allpages']['apcontinue']
        else:
            break

    page_title_queries = []
    page_title_query = ''

    for title, url in page_titles.items():
        if title&#160;!= 'Main Page' and title&#160;!= 'Search':
            page_title_query += title + '|'
            if len(page_title_query) &gt; 50:
                page_title_queries.append(page_title_query.rstrip('|'))
                page_title_query = ''

    prop_page_query = 'http://heroes.thelazy.net/wiki/api.php?action=query&amp;prop=categories&amp;format=json&amp;titles='

    for page_title_query in page_title_queries:
        request = urllib.request.urlopen(prop_page_query + page_title_query.replace(' ', '_'))
        response = request.read()
        results = json.loads(response.decode())
        for _, result in results['query']['pages'].items():
            if 'categories' not in result:
                print('\n\n')
                print(result['title'] + ' has no categories.')
                print('\n\n')
                continue
            progress = result['title'] + '&#160;: '
            for category in result['categories']:
                if category['title'] not in page_titles_by_category:
                    page_titles_by_category[category['title']] = set()
                page_titles_by_category[category['title']].add(result['title'])
                progress += category['title'] + ', '
            print(progress.rstrip(', '))

    base_category_query = 'http://heroes.thelazy.net/wiki/api.php?action=query&amp;list=allcategories&amp;aclimit=500&amp;acprop=size&amp;format=json&amp;acfrom='
    continue_category = ''
    category_titles = {}

    while True:
        request = urllib.request.urlopen(base_category_query + continue_category.replace(' ', '_'))
        response = request.read()
        results = json.loads(response.decode())
        for category in results['query']['allcategories']:
            if category['size'] is 0 or category['size'] is '0':
                continue
            title = category['*']
            category_titles[title] = base_url + title
        if 'query-continue' in results:
            continue_category = results['query-continue']['allcategories']['accontinue']
        else:
            break

    category_title_queries = []
    category_title_query = ''

    for title, url in category_titles.items():
        category_title_query += 'Category:' + title + '|'
        if len(category_title_query) &gt; 50:
            category_title_queries.append(category_title_query.rstrip('|'))
            category_title_query = ''

    prop_category_query = 'http://heroes.thelazy.net/wiki/api.php?action=query&amp;prop=categories&amp;format=json&amp;titles='

    for category_title_query in category_title_queries:
        request = urllib.request.urlopen(prop_category_query + category_title_query.replace(' ', '_'))
        response = request.read()
        results = json.loads(response.decode())
        for _, result in results['query']['pages'].items():
            if 'categories' not in result:
                print('\n\n')
                print(result['title'] + ' has no categories.')
                print('\n\n')
                continue
            progress = result['title'] + '&#160;: '
            for category in result['categories']:
                if category['title'] not in category_titles_by_category:
                    category_titles_by_category[category['title']] = set()
                category_titles_by_category[category['title']].add(result['title'])
                progress += category['title'] + ', '
            print(progress.rstrip(', '))

    print('\n\n')
    print(page_titles_by_category)
    print('\n\n')
    print(category_titles_by_category)

    for category_title in sorted(category_titles_by_category['Category:Content']):
        category_file_name = ''.join([i for i in category_title if i.isalpha()])
        category_output_files[category_file_name] = open('output/' + category_file_name + '.mediawiki', 'w')
        category_output_files[category_file_name].write('[[Category: Indices]]\n\n')
        print_titles(category_file_name, category_title)

def print_titles(category_file_name, category_title, category_level='=', indent_level=''):
    all_pages_output_file.write(category_level + ' &lt;span class=&quot;plainlinks&quot;&gt;[' + base_url + category_title.replace(' ', '_') + ' ' + indent_level + category_title.split('Category:', 1).pop() + ']&lt;/span&gt; ' + category_level + '\n\n')
    category_output_files[category_file_name].write(category_level + ' &lt;span class=&quot;plainlinks&quot;&gt;[' + base_url + category_title.replace(' ', '_') + ' ' + indent_level + category_title.split('Category:', 1).pop() + ']&lt;/span&gt; ' + category_level + '\n\n')
    category_level += '='
    indent_level += '&#160;&#160;&#160;&#160;'
    if category_title in page_titles_by_category:
        for page_title in sorted(page_titles_by_category[category_title]):
            all_pages_output_file.write('&lt;span class=&quot;plainlinks&quot;&gt;[' + base_url + page_title.replace(' ', '_') + ' ' + indent_level + page_title + ']&lt;/span&gt;\n\n')
            category_output_files[category_file_name].write('&lt;span class=&quot;plainlinks&quot;&gt;[' + base_url + page_title.replace(' ', '_') + ' ' + indent_level + page_title + ']&lt;/span&gt;\n\n')
    if category_title in category_titles_by_category:
        for child_category_title in sorted(category_titles_by_category[category_title]):
            print_titles(category_file_name, child_category_title, category_level, indent_level)

if __name__ == &quot;__main__&quot;:
    main()
</pre>
<h2><span class="mw-headline" id="Discussion">Discussion</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="./index.php?title=Talk:All_Pages&amp;action=edit&amp;section=2" title="Edit section: Discussion">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
<p>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. –<a href="./User:Kapteeni_Ruoska" title="User:Kapteeni Ruoska">Kapteeni Ruoska</a> (<a href="./User_talk:Kapteeni_Ruoska" title="User talk:Kapteeni Ruoska">talk</a>) 06:11, 7 September 2016 (CEST)
</p>
<dl>
<dd>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.
</dd>
<dd>--<a href="./User:Imahero" title="User:Imahero">imahero</a> 03:14, 8 September 2016 (CEST)
</dd>
</dl>
<dl>
<dd><dl>
<dd>Sure, just wondering, as the wiki already has <a href="./Special:AllPages" title="Special:AllPages">Special:AllPages</a>, but perhaps there is a use for that. –<a href="./User:Kapteeni_Ruoska" title="User:Kapteeni Ruoska">Kapteeni Ruoska</a> (<a href="./User_talk:Kapteeni_Ruoska" title="User talk:Kapteeni Ruoska">talk</a>) 07:27, 8 September 2016 (CEST)
</dd>
</dl>
</dd>
</dl>
<dl>
<dd><dl>
<dd><dl>
<dd><a href="./Special:AllPages" title="Special:AllPages">Special:AllPages</a> felt too clumsy for me to navigate. All I really wanted was a single list of all nonredirect links&#160;:)
</dd>
<dd> --<a href="./User:Imahero" title="User:Imahero">imahero</a> 08:31, 8 September 2016 (CEST)
</dd>
</dl>
</dd>
</dl>
</dd>
</dl>
<p>I may want to go back to using the external link syntax if breaking the <a href="./Special:LonelyPages" title="Special:LonelyPages">orphaned pages</a> 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 />
--<a href="./User:Imahero" title="User:Imahero">imahero</a> 15:19, 8 September 2016 (CEST)
</p>
<dl>
<dd><dl>
<dd>I changed it back to use the external link syntax to make sure the <a href="./Special:LonelyPages" title="Special:LonelyPages">orphaned pages</a> list still works properly. <br />
</dd>
<dd> --<a href="./User:Imahero" title="User:Imahero">imahero</a> 22:48, 8 September 2016 (CEST)
</dd>
</dl>
</dd>
</dl>
<p>It's now sorted by category. <br />
--<a href="./User:Imahero" title="User:Imahero">imahero</a> 12:26, 10 September 2016 (CEST)
</p>
<!-- 
NewPP limit report
CPU time usage: 0.028 seconds
Real time usage: 0.029 seconds
Preprocessor visited node count: 15/1000000
Preprocessor generated node count: 32/1000000
Post‐expand include size: 0/2097152 bytes
Template argument size: 0/2097152 bytes
Highest expansion depth: 2/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key h3wiki:pcache:idhash:4970-0!*!0!!*!*!* and timestamp 20190808093323 and revision id 24507
 -->
</div><div class="printfooter">
Retrieved from "<a href="./index.php?title=Talk:All_Pages&amp;oldid=24507">http://heroes.thelazy.net/wiki/index.php?title=Talk:All_Pages&amp;oldid=24507</a>"</div>
		<div id='catlinks' class='catlinks catlinks-allhidden'></div>		<!-- end content -->
				<div class="visualClear"></div>
	</div>
</div></div>
<div id="column-one">
	<h2>Navigation menu</h2>
	<div id="p-cactions" class="portlet" role="navigation">
		<h3>Views</h3>
		<div class="pBody">
			<ul>
				<li id="ca-nstab-main"><a href="All_Pages" title="View the content page [c]" accesskey="c">Page</a></li>
				<li id="ca-talk" class="selected"><a href="./Talk:All_Pages" title="Discussion about the content page [t]" accesskey="t">Discussion</a></li>
				<li id="ca-edit" class="istalk"><a href="./index.php?title=Talk:All_Pages&amp;action=edit" title="You can edit this page. Please use the preview button before saving [e]" accesskey="e">Edit</a></li>
				<li id="ca-addsection"><a href="./index.php?title=Talk:All_Pages&amp;action=edit&amp;section=new" title="Start a new section [+]" accesskey="+">+</a></li>
				<li id="ca-history"><a href="./index.php?title=Talk:All_Pages&amp;action=history" rel="archives" title="Past revisions of this page [h]" accesskey="h">History</a></li>
			</ul>
		</div>
	</div>
	<div class="portlet" id="p-personal" role="navigation">
		<h3>Personal tools</h3>
		<div class="pBody">
			<ul>
				<li id="pt-createaccount"><a href="./index.php?title=Special:UserLogin&amp;returnto=Talk:All+Pages&amp;returntoquery=t=Talk%253AAll_Pages&amp;type=signup">Create account</a></li>
				<li id="pt-login"><a href="./index.php?title=Special:UserLogin&amp;returnto=Talk:All+Pages&amp;returntoquery=t=Talk%253AAll_Pages" title="You are encouraged to log in; however, it is not mandatory [o]" accesskey="o">Log in</a></li>
			</ul>
		</div>
	</div>
	<div class="portlet" id="p-logo" role="banner">
<a href="Main_Page" style="background-image: url(h3logo.png);" title="Visit the main page"></a>
	</div>
	<div class="generated-sidebar portlet" id="p-navigation" role="navigation">
		<h3>Navigation</h3>
		<div class='pBody'>
			<ul>
				<li id="n-mainpage-description"><a href="Main_Page" title="Visit the main page [z]" accesskey="z">Main page</a></li>
				<li id="n-recentchanges"><a href="./Special:RecentChanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li>
				<li id="n-randompage"><a href="./Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
				<li id="n-help"><a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents" title="The place to find out">Help</a></li>
			</ul>
		</div>
	</div>
	<div id="p-search" class="portlet" role="search">
		<h3><label for="searchInput">Search</label></h3>
		<div id="searchBody" class="pBody">
			<form action="http://heroes.thelazy.net/wiki/index.php" id="searchform">
				<input type='hidden' name="title" value="Special:Search"/>
				<input type="search" name="search" placeholder="Search" title="Search The Heroes of Might and Magic III wiki [f]" accesskey="f" id="searchInput" />
				<input type="submit" name="go" value="Go" title="Go to a page with this exact name if exists" id="searchGoButton" class="searchButton" />&#160;
				<input type="submit" name="fulltext" value="Search" title="Search the pages for this text" id="mw-searchButton" class="searchButton" />
			</form>

					</div>
	</div>
	<div class="portlet" id="p-tb" role="navigation">
		<h3>Tools</h3>
		<div class="pBody">
			<ul>
				<li id="t-whatlinkshere"><a href="./Talk:All_Pages.1" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
				<li id="t-recentchangeslinked"><a href="./Talk:All_Pages.2" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
				<li id="t-specialpages"><a href="./Special:SpecialPages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li>
				<li id="t-print"><a href="./index.php?title=Talk:All_Pages&amp;t=Talk:All_Pages&amp;printable=yes" rel="alternate" title="Printable version of this page [p]" accesskey="p">Printable version</a></li>
				<li id="t-permalink"><a href="./index.php?title=Talk:All_Pages&amp;oldid=24507" title="Permanent link to this revision of the page">Permanent link</a></li>
				<li id="t-info"><a href="./index.php?title=Talk:All_Pages&amp;action=info">Page information</a></li>
			</ul>
		</div>
	</div>
</div><!-- end of the left (by default at least) column -->
<div class="visualClear"></div>
<div id="footer" role="contentinfo">
	<div id="f-poweredbyico">
		<a href="http://www.mediawiki.org/"><img src="poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" width="88" height="31" /></a>
	</div>
	<ul id="f-list">
		<li id="lastmod"> This page was last modified on 17 September 2016, at 13:15.</li>
		<li id="privacy"><a href="./The_Heroes_of_Might_and_Magic_III_wiki:Privacy_policy" title="The Heroes of Might and Magic III wiki:Privacy policy">Privacy policy</a></li>
		<li id="about"><a href="./The_Heroes_of_Might_and_Magic_III_wiki:About" title="The Heroes of Might and Magic III wiki:About">About The Heroes of Might and Magic III wiki</a></li>
		<li id="disclaimer"><a href="./The_Heroes_of_Might_and_Magic_III_wiki:General_disclaimer" title="The Heroes of Might and Magic III wiki:General disclaimer">Disclaimers</a></li>
	</ul>
</div>
</div>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-7375938-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>


<script>/*<![CDATA[*/window.jQuery && jQuery.ready();/*]]>*/</script><script>if(window.mw){
mw.loader.state({"site":"loading","user":"ready","user.groups":"ready"});
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.hidpi","mediawiki.page.ready","mediawiki.searchSuggest"],null,true);
}</script>
<script src="load.php?debug=false&amp;lang=en&amp;modules=site&amp;only=scripts&amp;skin=monobook&amp;*"></script>
<script>if(window.mw){
mw.config.set({"wgBackendResponseTime":185});
}</script></body></html>