This is an old revision of this page, as edited by Evad37(talk | contribs) at 16:38, 17 August 2016(make a start). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.Revision as of 16:38, 17 August 2016 by Evad37(talk | contribs)(make a start)
This module is rated as beta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing.
This module depends on the following other modules:
On English Wikipedia, this module is called by {{Attached KML}}. See that template's documentation for usage instructions
Set up on another wiki
Create template and module
Import this module to that wiki (or copy the code over, giving attribution in the edit summary). Give the module a name that makes sense in that wiki's language (hereafter referred to as MODULENAME)
Create a template (which should probably have the same name as the module, but referred to here as TEMPLATENAME) containing the code <includeonly>{{#invoke:MODULENAME|main}}</includeonly><noinclude>{{TEMPLATENAME|demo=yes}}{{Documentation}}</noinclude>
Localise the module. Edit the top bits of the module, between the comments -- ##### Localisation (L10n) settings ##### and -- #### End of L10n settings ####, replacing values between "" symbols with local values (as necessary)
Create the categories defined in the module localisation. These should be made hidden categories, either by including a Template:Hidden category (Q5879327) template, or by directly including the __HIDDENCAT__magic word.
Add documentation to the template (e.g. by translating Template:Attached KML/doc, adjusting as necessary per any localisations made in the previous step) and to the module (please transfer/translate these instructions so that wikimedians who read your wiki but not the English Wikipedia can also set up the module and template on another wiki).
-- Table of available wikis, in the order that they are to be searched for kml files-- (once a kml file is found, further sites are not checked)localsites={}sites[1]={"commonswiki","commons.wikimedia.org"}sites[2]={"enwiki","en.wikipedia.org"}sites[3]={"zhwiki","zh.wikipedia.org"}localp={}functionp.main(frame)localparent=frame.getParent(frame)localurlifnot(frame.args.uselocal)thenurl=getUrlFromWikidata()endifnot(url)thenlocalfrompage=parent.args.fromormw.title.getCurrentTitle()url="https://en.wikipedia.org/w/index.php?title=Template:Attached_KML/"..mw.uri.encode(frompage,"WIKI").."&action=raw"endreturnurl-- TODO: pass url through to proposed functions belowend-- TODO: function to make external links from url-- TODO: _main function to replicate current template (create wikitext for title display, or inline display, or both)-- TODO: function to make title links-- TODO: function to make inline (box) linkslocalfunctiongetUrlFromWikidata()-- Attempts to get url from linked wikidata items, will return nil if it can'tlocalentity=mw.wikibase.getEntityObject()ifnotentitythenreturnnilendlocalkml_claim=entity.claims["P000"]-- TODO: replace with real P value once property createdifkml_claimthen-- get the QID of the first value of the propertyif(kml_claim[1]andkml_claim[1].mainsnak.snaktype=="value"andkml_claim[1].mainsnak.datavalue.type=="wikibase-entityid")thenlocalkml_qid="Q"..claims[1].mainsnak.datavalue.value["numeric-id"]localkml_entity=mw.wikibase.getEntity(kml_qid)ifnotkml_entitythenreturnnilendlocalkml_sitelinklocalkml_urlfori,vinipairs(sites)dokml_sitelink=kml_entity:getSitelink(v[1])ifkml_sitelinkthenkml_url="//"..v[2].."/w/index.php?title="..mw.uri.encode(kml_sitelink,"WIKI").."&action=raw"endifkml_urlthenbreakendendreturnkml_urlornilelsereturnnilendelsereturnnilendendreturnp