Module:Changelog: Difference between revisions
m Changelog Tag Tree to ChangelogTagTree |
m preprocess output |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {}; | local p = {}; | ||
local date_module = require('Module:Date') | local date_module = require('Module:Date') | ||
local | local changelog_configs = mw.loadJsonData("Data:ChangelogConfigs.json") | ||
local tag_tree = mw.loadJsonData("Data:ChangelogTagTree.json") | local tag_tree = mw.loadJsonData("Data:ChangelogTagTree.json") | ||
local dictionary_module = require('Module:Dictionary') | local dictionary_module = require('Module:Dictionary') | ||
-- Takes in changelog_configs | |||
-- Returns [oldest_id, next_oldest_id, ..., newest_id] | |||
local function get_ordered_ids(data) | |||
-- Collect the keys into a table | |||
local keys = {} | |||
for key in pairs(data) do | |||
table.insert(keys, key) | |||
end | |||
-- Sort the keys (ascending order) | |||
table.sort(keys) | |||
-- Build an ordered array | |||
local ordered_array = {} | |||
for _, key in ipairs(keys) do | |||
table.insert(ordered_array, key) | |||
end | |||
return ordered_array | |||
end | |||
--Global scope | |||
local ordered_ids = get_ordered_ids(changelog_configs) | |||
--Only Data:Changelog_05-03-2024.json is loaded right now, as it still needs work and for now it was uploaded manually, need an uploader script to handle it | --Only Data:Changelog_05-03-2024.json is loaded right now, as it still needs work and for now it was uploaded manually, need an uploader script to handle it | ||
--Returns all lines of a given date that has that tag | --Returns all lines of a given date that has that tag | ||
local function | local function write_changelog_lines(id, config, tag_to_filter) | ||
-- Get the data for the respective line | -- Get the data for the respective line | ||
local changelog_data = mw.loadJsonData( | local page_name = id_to_changelog_data_page(id) | ||
local title = mw.title.new(page_name) | |||
if not (title and title.exists) then | |||
return "" | |||
end | |||
local changelog_data = mw.loadJsonData(page_name) | |||
local lines = "" | local lines = "" | ||
for index, line in ipairs(changelog_data) do | for index, line in ipairs(changelog_data) do | ||
Line 27: | Line 57: | ||
--Expand the Update history table/row template for 1 specific changelog | --Expand the Update history table/row template for 1 specific changelog | ||
local function write_changelog( | local function write_changelog(id, config, tag_to_filter) | ||
local date = config["date"] | |||
local template_title = "Update history table/row" | local template_title = "Update history table/row" | ||
local template_args = {} | local template_args = {} | ||
--05-03-2024 to May 3, 2024 | --05-03-2024 to May 3, 2024 | ||
template_args["update"] = date_module.format_date(date) | template_args["update"] = date_module.format_date(date) | ||
template_args["changes"] = | template_args["changes"] = write_changelog_lines(id, config, tag_to_filter) | ||
if (template_args["changes"] ~= "") then | if (template_args["changes"] ~= "") then | ||
return mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args } | return mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args } | ||
Line 56: | Line 87: | ||
-- Write changelog for each date | -- Write changelog for each date | ||
for index, | for index, id in ipairs(ordered_ids) do | ||
config = changelog_configs[id] | |||
if (num_dates_str ~= nil and index > num_dates) then | if (num_dates_str ~= nil and index > num_dates) then | ||
break | break | ||
else | else | ||
content = content .. write_changelog( | content = content .. mw.getCurrentFrame():preprocess(write_changelog(id, config, tag)) .. "\n" | ||
end | end | ||
index = index+1 | |||
end | end | ||
Line 69: | Line 102: | ||
end | end | ||
function | function id_to_changelog_data_page(id) | ||
return "Data:Changelog " .. | return "Data:Changelog " .. id .. ".json" | ||
end | end | ||
Line 77: | Line 110: | ||
local str = "" | local str = "" | ||
for | for i, id in ipairs(ordered_ids) do | ||
str = str .. "[[" .. | str = str .. "[[" .. id_to_changelog_data_page(id) .. "]]<br>" | ||
end | end | ||
Line 84: | Line 117: | ||
end | end | ||
p. | p.write_changelog_by_date_id = function(frame) | ||
local | local date_id_to_write = frame.args[1] | ||
-- Determine the previous and next update | -- Determine the previous and next update | ||
-- Find the index in dates list | -- Find the index in dates list | ||
local | --ordered_ids defined at global scope | ||
local | local previous_id = '' | ||
local | local the_id = '' | ||
local | local next_id = '' | ||
for | local id_found = false | ||
if | for i, id in ipairs(ordered_ids) do | ||
-- | if id == date_id_to_write then | ||
--id found | |||
the_id = id | |||
elseif | id_found = true | ||
elseif id_found and next_id == '' then --on next iteration, save the next id | |||
next_id = id | |||
break | break | ||
end | end | ||
if not | if not id_found then | ||
previous_id = id -- only update previous if the_id isnt found | |||
end | end | ||
end | |||
if not id_found then | |||
return "date_id " .. date_id_to_write .. " not found" | |||
end | end | ||
local config = changelog_configs[the_id] | |||
local template_title = 'Update layout' | local template_title = 'Update layout' | ||
local template_args = { | local template_args = { | ||
['prev_update'] = | ['prev_update'] = prev_id, | ||
['current_update'] = | ['current_update'] = the_id, | ||
['next_update'] = | ['next_update'] = next_id, | ||
['source'] = | ['source'] = config[link], | ||
['source_title'] = | ['source_title'] = the_id .. ' Update', | ||
['notes'] = | ['notes'] = mw.getCurrentFrame():preprocess(write_changelog_lines(the_id, config, 'All')) | ||
} | } | ||
Line 125: | Line 163: | ||
-- Iterate changelog dates | -- Iterate changelog dates | ||
for | for i, id in ipairs(ordered_ids) do | ||
local changelog_data = mw.loadJsonData( | -- If next changelog data page doesn't yet exist, return latest page that exists | ||
local page_name = id_to_changelog_data_page(id) | |||
local title = mw.title.new(page_name) | |||
if not (title and title.exists) then | |||
return '[[Update:' .. id .. '|' .. id .. ']]' | |||
end | |||
local changelog_data = mw.loadJsonData(page_name) | |||
-- Iterate lines | -- Iterate lines | ||
Line 135: | Line 180: | ||
for _, tag in ipairs(tags) do | for _, tag in ipairs(tags) do | ||
if tag_to_search == tag then | if tag_to_search == tag then | ||
return '[[Update:' .. | return '[[Update:' .. id .. '|' .. id .. ']]' | ||
end | end | ||
end | end |
Latest revision as of 22:36, 21 December 2024
Overview
Generates lines of changes for all data pages. See [[Category:Changelog Dates]] for the dates of all changelogs, and Changelogs for list of all the data pages that contain a Changelog.
How to edit changelogs
Each changelogs should be exactly as written on the forum post, so edits are rarely justified, below are the exceptions to look out for
- Typos by the poster should have
{{sic}}
added so that readers know the typoe was intentionally written verbatim - An entity's name is old, i.e. Yamato's Shadow Explosion was renamed to Shadow Transformation. See #Missing tags for detailed examples
- Similarly named but unrelated entities (tags) are both mistakenly assigned, i.e. Barrage and Heavy Barrage. See #Similar tags are assigned for detailed examples
- Entity is referenced but isn't affected by the change. See #Tag referenced but unaffected for a detailed example
What are tags?
Each line in a changelog is parsed by User:DeadBot to have certain tags assigned to it. For example, if the forum post looks like Abrams: Shoulder Bash blah blah
It will be assigned tags, Shoulder Bash
since its named explicitly, and therefore Ability
, Abrams
, and Hero
. This will make this line added to all changelogs on pages Abrams/Update history, Shoulder Bash/Update history, Ability/Update history, and Hero/Update history.
Similarly, for the line Warp Stone: Distance traveled blah blah
, the tags assigned would be Warp Stone
since its named explicitly, along with the tags Item
and Weapon Item
.
Missing tags
Given the line Yamato: Shadow Explosion bonus Spirit per victim increased from 10 to 15
, User:DeadBot will be able to assign the Yamato
tag, but will not know which ability it is referring to, as Yamato's ability was renamed to Shadow Transformation. This would originally appear as
"Description": "* {{PageRef|Yamato}}: Shadow Explosion bonus Spirit per victim increased from 10 to 15", "Tags": [ "Yamato", "Hero" ]
To correct is, simply add the related tags for Shadow Transformation. To determine the related tags, see To see all related tags, see Module:Changelog/doc#Tag tree. Add the call to Template:PageRef in the description. The alt_name
parameter will need to be passed to nickname the ability as Shadow Explosion, so that it stays written as is, but still links and is added to the relevant pages. The corrected changelog would then be
"Description": "* {{PageRef|Yamato}}: {{PageRef|Shadow Transformation|alt_name=Shadow Explosion}} bonus Spirit per victim increased from 10 to 15", "Tags": [ "Yamato", "Hero", "Ability", "Shadow Transformation" ]
Similar tags are assigned
Given the line * McGinnis: Heavy Barrage spirit scaling increased from 0.3 to 0.35
, User:DeadBot will see both McGinnis' Heavy Barrage ability and Pocket's Barrage ability and assign both as tags. This would originally appear as
"Description": "* {{PageRef|McGinnis}}: {{PageRef|Heavy Barrage}} spirit scaling increased from 0.3 to 0.35", "Tags": [ "McGinnis", "Hero", "Heavy Barrage", "Ability", "Barrage", "Pocket" ]
To correct it, first determine if its referring to McGinnis' Heavy Barrage or Pocket's Barrage. In this case, it is quite obvious that its referring to McGinnis' Heavy Barrage. Then, simply remove all tags related to Pocket's Barrage. This includes both "Barrage"
and "Pocket"
. To determine all related tags, see Module:Changelog/doc#Tag tree.
The corrected list of tags would then be
"Tags": [ "McGinnis", "Hero", "Heavy Barrage", "Ability", ]
Similarly, for the following example
"Description": "* {{PageRef|Torment Pulse}}: Interval improved from 2s to 1.5s", "Tags": [ "Torment Pulse", "Item", "Spirit Item", "Pulse", "Ability", "Rutger", "Hero" ]
It is actually referring to Torment Pulse the Item, so the tags "Pulse"
, "Ability"
, and "Rutger"
, "Hero"
would all need to be removed.
Another example, given the line:
"Description": "* {{PageRef|Cosmic Veil|alt_name=Veil}} {{PageRef|Walker}}: Cooldown increased from 20s to 25s", "Tags": [ "Veil Walker", "Item", "Vitality Item", "Objective", "NPC", "Walker" "Cosmic Veil" ]
Here, the changelog is clearly referring to the item Veil Walker, not Cosmic Veils and Walkers. The fixed line would be:
"Description": "* {{PageRef|Veil Walker}}: Cooldown increased from 20s to 25s", "Tags": [ "Veil Walker", "Item", "Vitality Item", "Objective", "NPC", ]
Tag referenced but unaffected
Given the line Surge of Power: When the passive procs, you no longer get slowed when shooting (similar to Fleetfoot).
, User:DeadBot will assign the tag Fleetfoot and all its related tags, even if Fleetfloot wasn't actually changed or modified at all. This would originally appear as
"Description": "* {{PageRef|Surge of Power}}: When the passive procs, you no longer get slowed when shooting (similar to {{PageRef|Fleetfoot}})", "Tags": [ "Fleetfoot", "Item", "Weapon Item", "Surge of Power", "Spirit Item" ]
To correct it, remove Fleetfoot and all its related tags (Weapon Item tag in this case), but leave the call to PageRef so that it can still refer users to the Fleetfoot page. After correction it should be
"Description": "* {{PageRef|Surge of Power}}: When the passive procs, you no longer get slowed when shooting (similar to {{PageRef|Fleetfoot}})", "Tags": [ "Item", "Surge of Power", "Spirit Item" ]
Tag tree
The tag tree is how to determine what tags are related. Given a tag, the tags that are in the same chain and have a shorter indentation will/should also be added to the list of tags.
For example, any change to Frost Bomb will also be referenced on the pages Ability, Kelvin, and Hero.
- Hero
- <hero_name> i.e. Abrams
- Ability
- <ability_name> i.e. Frost Bomb
- Ability
- <hero_name> i.e. Abrams
- Item
- Weapon Item
- <weapon_item_name> i.e. Basic Magazine
- Vitality Item
- <vitality_item_name> i.e. Extra Health
- Spirit Item
- <spirit_item_name> i.e. Boundless Spirit
- Weapon Item
- Map
- Other
More Tag tree examples:
- If
Map
tag is assigned, no other tags should be assigned - If
Weapon Item
is assigned,Basic Magazine
shouldn't be assigned unless it is also referenced in the line, butItem
should be assigned - If
Basic Magazine
is assigned,Weapon Item
, andItem
should be assigned
The full tree can be found at Changelogs
Functions
All of these functions are callable by wikitext, i.e. {{#invoke|Changelog|invokable_name|param1|paramN}}
write_changelogs
The main invokable that will be used. Given a specific tag, it outputs all relevant changelogs from all dates in a Template:Update history table.
Parameters
- tag - Tag to search relevant changelogs for. Should be localized, i.e. Abrams for hero_atlas in english.
- num_dates - (OPTIONAL) Number of dates to add, recommend 3 for articles. If unprovided, defaults to all.
Examples
For use on Pocket/Update history:
{{#invoke:Changelog|write_changelogs|Pocket}}
Outputs
Update | Changes |
---|---|
|
For use on Pocket#Update history:
{{#invoke:Changelog|write_changelogs|Pocket|3}}
Outputs
Update | Changes |
---|---|
|
write_changelog_by_date_id
Write's a specific date's changelog, as opposed to a specific tag's changelog.
Parameters
- date_id_to_write - Date-id to write, format yyyy-mm-dd, view all at [[Category:Changelog Dates]]
Examples
{{#invoke:Changelog|write_changelog_by_date_id|2024-05-03}}
Updates | ||
---|---|---|
← N/A | 2024-05-03 | 2024-05-10 → |
Patch notes
File:Other.pngGeneral Changes:
==
* Added a Recommend A Friend button to the dashboard that you can use to send us requests for people to include in our playtesting
* Added a Resources page to the dashboard which contains a browsable item shop
* Added overhead text display when another hero uses active items
* The hotkeys F1-F5 to change cameras to allied heroes now maps directly to the order of heroes on the top bar left to right
* Added the Patron to the spectate-when-dead cycle if the enemy is in your base or everyone on your team is dead
* Added support for File:Flex Slot.pngFlex File:Item.pngItems in the Hero File:Sandbox.pngSandbox
* Increased the range of the mouse sensitivity slider from 0.5→4.0 to 0.05→8.0
* Increased the default framerate cap from 120 to 400
* Improved UI display when endgame objectives are being attacked
* Added music for when the base is under attack
* Changed the local player icon on the the minimap to always be on top of enemy icons
* Shop music will now only play for shops players can access
* Postgame graphs now default to team stats rather than individual
* Added borders around hero icons on the minimap when watching replays/spectating
* Top bar now shows incoming players before they are fully connected
* Added console command to hide the bar at the bottom in replays ('citadel_hide_replay_hud 1' to hide it, 'citadel_hide_replay_hud 0' to bring it back)
* Various VOIP improvements
* Fixed open mic threshold
* Fixed various consistency issues with the presentation of File:Souls.pngSouls terminology, icons, etc
* Fixed Flying Cloak teleporting players into geometry or out of the world
* Fixed Warp Stone teleporting you through geometry
* Fixed Fixation decimal point display
* Fixed File:Parry.pngParry animation not playing
* Fixed various issues with the spectate UI display
* Removed the slow climbing vertical recoil on Yamato's alt fire
* Fixed AP count not showing if you are dead, spectating a team mate or when holding alt/tab to upgrade your abilities
Gameplay Changes:
==
* File:Trooper.pngTroopers DPS vs Lane File:Guardian.pngGuardians reduced from 44 to 36
* File:Objective.pngObjectives now have 80% damage reduction anti-backdoor defense when there haven't been File:Creep.pngcreeps nearby in a while
* The uncapturable File:Zipline.pngzipline nodes near your base now extend out 2 more nodes (this means attackers can't capture File:Zipline.png[[Zipline|File:Zipline.pngziplines]] quite as close to the enemy base)
* You are now silenced while carrying the File:Soul Urn.pngUrn
* File:Soul Urn.pngUrn bounty increased from 900 + 160/minute to 900 + 200/minute
* File:Sinner's Sacrifice.pngVaults base bounty increased from 150 to 200
* Abrams: Base Health increased from 550 to 600
* Abrams: Siphon DPS increased from 24 to 35
* Bebop: Weapon no longer has horizontal/vertical recoil
* Dynamo: Singularity DPS increased from 48 to 60
* Dynamo: Singularity T3 Max HP DPS increased from 3.2% to 3.8%
* Grey Talon: Charge Shot damage increased from 95 to 105
* Grey Talon: Charge Shot T2 damage reduced from 80 to 70
* Grey Talon: Guided Owl damage increased from 200 to 300
* Haze: Bullet Dance bonus Fire Rate reduced from +30 to +20
* Haze: Smoke Bomb duration scaling from Spirit improved from 0.2 to 0.3
* Infernus: Catalyst no longer slows Infernus to 1.3 m/s during the cast delay
* Infernus: Concussive Combustion damage increased from 130 to 160
* Kelvin: Frost Grenade T3 bonus damage increased from +100 to +175
* Lady Geist: Blood Bomb damage increased from 80 to 100
* Lady Geist: Blood Bomb T2 damage increased from +65 to +70
* Lady Geist: Blood Bomb tooltip fixed to reference the correct self damage type and that it can be reduced with armor
* Lady Geist: Malice damage amp per shard increased from 10% to 15%
* Lash: Grapple cooldown reduced from 55 to 45
* Lash: Flog Damage increased from 55 to 65
* Lash: Flog lifesteal from heroes increased from 70% to 80% of damage dealt
* Lash: Flog lifesteal from non-heroes reduced from 35% to 30% of damage dealt
* Lash: Death Slam T1 from +3m to +5m
* Lash: Fixed Death Slam's targeting cone not finding enemies near the edges
* Lash: Fixed Death Slam to only target enemies who stay in the targeting cone
* McGinnis: Heavy Barrage now reduces your speed rather than setting it to a low cap (by itself this change isn't a buff or a nerf, but it allows you to buy items to move faster during the ultimate)
* McGinnis: Heavy Barrage camera interaction with Fleetfoot Boots has been fixed
* Mo & Krill: Sand Blast range increased from 25m to 30m
* Mo & Krill: Sand Blast width increased from 3m to 5m
* Mo & Krill: Sand Blast is now permissive with small obstructions in the way
* Mo & Krill: Burrow no longer loses its state as you change elevations
* Mo & Krill: Burrow now knocks enemies up when you come up
* Mo & Krill: Combo DPS increased from 50 to 60
* Mo & Krill: No longer listed as a recommended new player hero
* Vindicta: Base Bullet Damage reduced from 15 to 14
* Vindicta: Bullet Damage gained per boon reduced from 0.88 to 0.7 (these are gained occasionally as you earn souls, up to 11 times)
* Vindicta: Stake T1 bonus duration reduced from +1.5s to +1.0s
* Vindicta: Is now a recommended hero for new players
* Yamato: Crimson Slash radius increased from 11m to 12m
* Yamato: Crimson Slash fire rate debuff duration increased from 3s to 4s
* Yamato: Crimson Slash T2 changed from "-5s Cooldown" to "10% Max Health heal on hero hit"
* Yamato: Crimson Slash T3 changed from "12% Max Health heal on hero hit" to "-6s Cooldown"
* Yamato: Power Slash T1 Bullet Resist increased from 40% to 60%
* Yamato: Flying Strike cooldown reduced from 35 to 20
* Yamato: Flying Strike T2 changed from "-15s Cooldown" to "+20 Cast Range"
* Yamato: Flying Strike range no longer scales with Spirit
* Yamato: Shadow Explosion bonus Spirit per victim increased from 10 to 15
* Yamato: Shadow Explosion bonus Fire Rate per victim increased from 5 to 10
* Yamato: Shadow Explosion buff duration increased from 8s to 15s
write_data_pages_list
Writes list of all changelog data pages using the list of patches at Data:ChangelogConfigs.json. Used on [[Category:Changelog Dates]].
Parameters
None
Examples
{{#invoke:Changelog|write_data_pages_list}}
Outputs
Data:Changelog 2024-05-03.json
Data:Changelog 2024-05-10.json
Data:Changelog 2024-05-13.json
Data:Changelog 2024-05-16.json
Data:Changelog 2024-05-19.json
Data:Changelog 2024-05-23.json
Data:Changelog 2024-05-24.json
Data:Changelog 2024-05-30.json
Data:Changelog 2024-06-01.json
Data:Changelog 2024-06-06.json
Data:Changelog 2024-06-07.json
Data:Changelog 2024-06-13.json
Data:Changelog 2024-06-14.json
Data:Changelog 2024-06-16.json
Data:Changelog 2024-06-20.json
Data:Changelog 2024-06-23.json
Data:Changelog 2024-06-27.json
Data:Changelog 2024-07-04.json
Data:Changelog 2024-07-11.json
Data:Changelog 2024-07-18.json
Data:Changelog 2024-07-23.json
Data:Changelog 2024-08-01.json
Data:Changelog 2024-08-06.json
Data:Changelog 2024-08-15.json
Data:Changelog 2024-08-16.json
Data:Changelog 2024-08-18.json
Data:Changelog 2024-08-22.json
Data:Changelog 2024-08-23.json
Data:Changelog 2024-08-29.json
Data:Changelog 2024-09-01.json
Data:Changelog 2024-09-12.json
Data:Changelog 2024-09-14.json
Data:Changelog 2024-09-17.json
Data:Changelog 2024-09-19.json
Data:Changelog 2024-09-26.json
Data:Changelog 2024-09-27.json
Data:Changelog 2024-09-29.json
Data:Changelog 2024-10-02.json
Data:Changelog 2024-10-07.json
Data:Changelog 2024-10-10.json
Data:Changelog 2024-10-11.json
Data:Changelog 2024-10-15.json
Data:Changelog 2024-10-18.json
Data:Changelog 2024-10-18-1.json
Data:Changelog 2024-10-24.json
Data:Changelog 2024-10-24_HeroLab.json
Data:Changelog 2024-10-27.json
Data:Changelog 2024-10-29.json
Data:Changelog 2024-10-29_HeroLab.json
Data:Changelog 2024-11-01.json
Data:Changelog 2024-11-01_HeroLab.json
Data:Changelog 2024-11-07.json
Data:Changelog 2024-11-07_HeroLab.json
Data:Changelog 2024-11-08_HeroLab.json
Data:Changelog 2024-11-10.json
Data:Changelog 2024-11-13.json
Data:Changelog 2024-11-21.json
Data:Changelog 2024-11-21_HeroLab.json
Data:Changelog 2024-11-24_HeroLab.json
Data:Changelog 2024-11-26_HeroLab.json
Data:Changelog 2024-11-29.json
Data:Changelog 2024-12-06.json
Data:Changelog 2024-12-06_HeroLab.json
Data:Changelog 2024-12-17.json
get_last_updated
Retrieve the last date that a tag was updated on. Planned to be used on a given tag's page, i.e. Abrams's infobox could mention that it was last updated on 2024-05-03.
Parameters
- tag - Tag to search
Examples
{{#invoke:Changelog|get_last_updated|Basic Magazine}}
Outputs
local p = {};
local date_module = require('Module:Date')
local changelog_configs = mw.loadJsonData("Data:ChangelogConfigs.json")
local tag_tree = mw.loadJsonData("Data:ChangelogTagTree.json")
local dictionary_module = require('Module:Dictionary')
-- Takes in changelog_configs
-- Returns [oldest_id, next_oldest_id, ..., newest_id]
local function get_ordered_ids(data)
-- Collect the keys into a table
local keys = {}
for key in pairs(data) do
table.insert(keys, key)
end
-- Sort the keys (ascending order)
table.sort(keys)
-- Build an ordered array
local ordered_array = {}
for _, key in ipairs(keys) do
table.insert(ordered_array, key)
end
return ordered_array
end
--Global scope
local ordered_ids = get_ordered_ids(changelog_configs)
--Only Data:Changelog_05-03-2024.json is loaded right now, as it still needs work and for now it was uploaded manually, need an uploader script to handle it
--Returns all lines of a given date that has that tag
local function write_changelog_lines(id, config, tag_to_filter)
-- Get the data for the respective line
local page_name = id_to_changelog_data_page(id)
local title = mw.title.new(page_name)
if not (title and title.exists) then
return ""
end
local changelog_data = mw.loadJsonData(page_name)
local lines = ""
for index, line in ipairs(changelog_data) do
description = line["Description"]
if tag_to_filter == 'All' then
lines = lines .. description .. "<br>"
else
for index2, tag in ipairs(line["Tags"]) do
if tag == tag_to_filter then
lines = lines .. description .. "<br>"
end
end
end
end
return lines
end
--Expand the Update history table/row template for 1 specific changelog
local function write_changelog(id, config, tag_to_filter)
local date = config["date"]
local template_title = "Update history table/row"
local template_args = {}
--05-03-2024 to May 3, 2024
template_args["update"] = date_module.format_date(date)
template_args["changes"] = write_changelog_lines(id, config, tag_to_filter)
if (template_args["changes"] ~= "") then
return mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args }
else
return ""
end
end
-- Write changelogs table
p.write_changelogs = function(frame)
tag = frame.args[1]
num_dates_str = frame.args[2]
local num_dates
if (tag == nil) then return "tag parameter must be provided" end
if (num_dates_str ~= nil) then
num_dates = tonumber(num_dates_str)
if (num_dates == nil) then return "num_dates parameter must be numerical" end
end
local template_title = "Update history table"
local template_args = {}
local content = "\n"
-- Write changelog for each date
for index, id in ipairs(ordered_ids) do
config = changelog_configs[id]
if (num_dates_str ~= nil and index > num_dates) then
break
else
content = content .. mw.getCurrentFrame():preprocess(write_changelog(id, config, tag)) .. "\n"
end
index = index+1
end
template_args["contents"] = content
return mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args }
end
function id_to_changelog_data_page(id)
return "Data:Changelog " .. id .. ".json"
end
--Shows all changelog date data pages as a list of pages
p.write_data_pages_list = function(frame)
local str = ""
for i, id in ipairs(ordered_ids) do
str = str .. "[[" .. id_to_changelog_data_page(id) .. "]]<br>"
end
return str
end
p.write_changelog_by_date_id = function(frame)
local date_id_to_write = frame.args[1]
-- Determine the previous and next update
-- Find the index in dates list
--ordered_ids defined at global scope
local previous_id = ''
local the_id = ''
local next_id = ''
local id_found = false
for i, id in ipairs(ordered_ids) do
if id == date_id_to_write then
--id found
the_id = id
id_found = true
elseif id_found and next_id == '' then --on next iteration, save the next id
next_id = id
break
end
if not id_found then
previous_id = id -- only update previous if the_id isnt found
end
end
if not id_found then
return "date_id " .. date_id_to_write .. " not found"
end
local config = changelog_configs[the_id]
local template_title = 'Update layout'
local template_args = {
['prev_update'] = prev_id,
['current_update'] = the_id,
['next_update'] = next_id,
['source'] = config[link],
['source_title'] = the_id .. ' Update',
['notes'] = mw.getCurrentFrame():preprocess(write_changelog_lines(the_id, config, 'All'))
}
return mw.getCurrentFrame():expandTemplate{title = template_title, args = template_args}
end
p.get_last_updated = function(frame)
local tag_to_search = frame.args[1]
-- Iterate changelog dates
for i, id in ipairs(ordered_ids) do
-- If next changelog data page doesn't yet exist, return latest page that exists
local page_name = id_to_changelog_data_page(id)
local title = mw.title.new(page_name)
if not (title and title.exists) then
return '[[Update:' .. id .. '|' .. id .. ']]'
end
local changelog_data = mw.loadJsonData(page_name)
-- Iterate lines
for _, line in ipairs(changelog_data) do
local tags = line['Tags']
-- Iterate tags
for _, tag in ipairs(tags) do
if tag_to_search == tag then
return '[[Update:' .. id .. '|' .. id .. ']]'
end
end
end
end
return dictionary_module.translate('N/A')
end
function p.write_tag_tree(frame)
return p.write_branch(tag_tree, 1)
end
function p.write_branch(branch, depth)
local list_str = ""
if branch == nil then return "" end
for parent, children in pairs(branch) do
list_str = list_str .. string.rep("*", depth) .. string.format("[[%s#Update history|%s]]\n", parent, parent)
if children ~= nil then
list_str = list_str .. p.write_branch(children, depth+1)
end
end
return list_str
end
return p