User:Evad37/KML.js

/* Thoughts ...

1) Add a Template:Attached KML (Q6690822) transclusion for each mainspace page which BOTH has a wikidata item with a KML file (P3096) statement AND does not already have a Template:Attached KML (Q6690822) transclusion  - should be exclusion compliant, and leave a meaningful edit summary with that info (or linking to an explanation) to avoid edit wars etc.  - rate limited? 2) Check the subpages (excluding /doc and /testcases) of Template:Attached KML (Q6690822), and for any without Wikidata items, create items with instance of (P31):Wikimedia KML file (Q26267864) 3) For each subpage which get an item created, check if the corresponding mainspace page (with the same name as the subpage) exists and has a Template:Attached KML (Q6690822) transclusion:  - If it does, then add a KML file (P3096) statement to the page's item (which may need to be created), linking to the newly created item for the kml subpage   - If it doesn't, then manual review is required - perhaps the bot could generate a report in its userspace, or perhaps just rely on these cases being picked up by this Wikidata constraint)



//TODO: interface

//1) //  a) Get items with P3096 and enwiki sitelink //  b) Get Wikipedia article titles that correspond to those items //   c) For each article: //     i) [maybe every nth article?] Check that it is okay to proceed (run page set to TRUE / enough time has passed since last edit / edit count limit hasn't been reached) //      i) Get page contents //    ii) Check that there is no  template, and no opt-out template ( or ) //    iii) Determine appropriate section to edit (either "External links" or the last section) //    iv) Make the edit, increment edit count

// ALTERNATIVE: // // - Get s to articles which have Wikidata items with P3096 and enwiki sitelink -- using Sparql query // - Convert these to article titles using Excel formula like "=LEFT(MID(A2,32,999),LEN(A2)-32)" (adjust based on domain/sub-domain) // - Filter out pages which have Template:Attached KML, or are in a dab category, or should otherwise be excuded -- using following PetScan query, pasting article titles into Manual list: https://petscan.wmflabs.org/?language=en&project=wikipedia&categories=Attached%20KML%20with%20same%20name%20as%20article%0D%0AAll%20Disambiguation%20pages&combination=union&ns%5B0%5D=1&manual_list_wiki=enwiki&source_combination=manual%20NOT%20categories&interface_language=en&active_tab=tab_other_sources // - Use the resulting list to append Attached KML using AWB