Path of Exile Wiki

Please consider helping keep the wiki up to date. Check the to-do list of updates needed for version 3.14.0.

Game data exports will becoming later as the technical changes in addition to regular changes take some more time.

READ MORE

Path of Exile Wiki
mNo edit summary
mNo edit summary
Line 12: Line 12:
 
-- todo: rework, add a mapping for fields
 
-- todo: rework, add a mapping for fields
 
p.version = function(frame)
 
p.version = function(frame)
g_args = getArgs(frame, {parentFirst = true})
+
g_args = getArgs(frame, { parentFirst = true })
 
g_frame = util.misc.get_frame(frame)
 
g_frame = util.misc.get_frame(frame)
   
Line 25: Line 25:
   
 
-- Parser
 
-- Parser
local vargs = {before = '←', after = '→'}
+
local vargs = { before = '←', after = '→' }
 
local properties = {}
 
local properties = {}
   
Line 34: Line 34:
   
 
local query = {}
 
local query = {}
query[#query + 1] = string.format('[[Is version::%s]][[Has release date::+]]', g_args[arg])
+
query[#query + 1] = string.format('[[Is version::%s]] [[Has release date::+]]', g_args[arg])
 
query[#query + 1] = '?Has release date'
 
query[#query + 1] = '?Has release date'
   
Line 55: Line 55:
 
-- Output
 
-- Output
 
-- todo: rework it somehow
 
-- todo: rework it somehow
local patch_date = g_frame:callParserFunction('#show: Version ' .. g_args['patch'], {'?Has release date'})
+
local patch_date = g_frame:callParserFunction('#show: Version ' .. g_args['patch'], { '?Has release date' })
   
 
local tbl = mw.html.create('table')
 
local tbl = mw.html.create('table')
  +
tbl:attr('class', 'wikitable successionbox'):tag('tr'):tag('th'):attr('colspan', 3):wikitext('[[Version history|Version History]]'):done():done():tag('tr'):tag('td'):attr('style', 'width: 30%;'):wikitext(vargs['before']):done():tag('td'):attr('style', 'width: 40%;'):wikitext(string.format('[[Version %s]]<br>%s', g_args['patch'], patch_date)):done():tag('td'):attr('style', 'width: 30%;'):wikitext(vargs['after'])
tbl
 
:attr('class', 'wikitable successionbox')
 
:tag('tr')
 
:tag('th')
 
:attr('colspan', 3)
 
:wikitext('[[Version history|Version History]]')
 
:done()
 
:done()
 
:tag('tr')
 
:tag('td')
 
:attr('style', 'width: 30%;')
 
:wikitext(vargs['before'])
 
:done()
 
:tag('td')
 
:attr('style', 'width: 40%;')
 
:wikitext(string.format('[[Version %s]]<br>%s', g_args['patch'], patch_date))
 
:done()
 
:tag('td')
 
:attr('style', 'width: 30%;')
 
:wikitext(vargs['after'])
 
   
 
local cats = {
 
local cats = {
Line 92: Line 73:
   
 
p.version_history_list = function(frame)
 
p.version_history_list = function(frame)
g_args = getArgs(frame, {parentFirst = true})
+
g_args = getArgs(frame, { parentFirst = true })
 
g_frame = util.misc.get_frame(frame)
 
g_frame = util.misc.get_frame(frame)
   
Line 105: Line 86:
 
end
 
end
   
local query = {
+
local query = {
g_args.conditions,
+
g_args.conditions,
 
'?Is version',
 
'?Is version',
'?Has release date',
+
'?Has release date',
sort = 'Has release date, Is version',
+
sort = 'Has release date, Is version',
order = 'desc, desc',
+
order = 'desc, desc',
 
link = 'none',
 
link = 'none',
offset = 0,
+
offset = 0,
 
}
}
 
   
local results = {}
+
local results = {}
repeat
+
repeat
local result = util.smw.query(query, g_frame)
+
local result = util.smw.query(query, g_frame)
query.offset = query.offset + #result
+
query.offset = query.offset + #result
   
for _, v in ipairs(result) do -- todo
+
for _, v in ipairs(result) do -- todo
results[#results + 1] = v
+
results[#results + 1] = v
end
+
end
until #result < 1000
+
until #result < 1000
   
local out = {}
+
local out = {}
local last_minor_version, current_list
+
local last_minor_version, current_list
   
for i, result in ipairs(results) do
+
for i, result in ipairs(results) do
 
local date = result['Has release date']
 
local date = result['Has release date']
 
local version = result['Is version']
 
local version = result['Is version']
   
local v = util.cast.version(result['Is version'])
+
local v = util.cast.version(result['Is version'])
local minor_version = table.concat({v[1], v[2], v[3]}, '.') -- todo: rework it
+
local minor_version = table.concat({ v[1], v[2], v[3] }, '.') -- todo: rework it
   
 
if minor_version ~= last_minor_version then
 
if minor_version ~= last_minor_version then
Line 145: Line 126:
 
end
 
end
   
current_list
+
current_list:tag('li'):wikitext(string.format('%s &ndash; [[Version %s]]', date, version))
:tag('li')
 
:wikitext(string.format('%s &ndash; [[Version %s]]', date, version))
 
   
 
-- save the last list
 
-- save the last list
Line 154: Line 133:
 
end
 
end
   
last_minor_version = minor_version
+
last_minor_version = minor_version
end
+
end
   
return table.concat(out, '\n')
+
return table.concat(out, '\n')
 
end
 
end
   

Revision as of 22:59, 25 October 2016

Template info icon Module documentation[view] [edit] [history] [purge]

Templates

local getArgs = require('Module:Arguments').getArgs
local util = require('Module:Util')

local p = {}
local g_frame, g_args

-- -----

-- ----------------------------------------------------------------------------------------------------
-- Template: Version

-- todo: rework, add a mapping for fields
p.version = function(frame)
    g_args = getArgs(frame, { parentFirst = true })
    g_frame = util.misc.get_frame(frame)

    --[[ test args
    = p.version{
        before = '2.4.0h',
        patch = '2.4.1',
        patchdate = 'October 18, 2016',
        after = '2.4.1b',
    }
    --]]

    -- Parser
    local vargs = { before = '←', after = '→' }
    local properties = {}

    -- querying before and after
    for arg in pairs(vargs) do
        if g_args[arg] ~= nil then
            properties['Has version ' .. arg] = g_args[arg]

            local query = {}
            query[#query + 1] = string.format('[[Is version::%s]] [[Has release date::+]]', g_args[arg])
            query[#query + 1] = '?Has release date'

            local result = ''
            local results = util.smw.query(query, g_frame)
            if #results ~= 0 then
                result = results[1]['Has release date']
            end

            vargs[arg] = string.format('[[Version %s|%s %s]]<br>%s', g_args[arg], vargs[arg], g_args[arg], result)
        else
            vargs[arg] = nil
        end
    end

    properties['Is version'] = g_args['patch']
    properties['Has release date'] = g_args['patchdate']
    util.smw.set(g_frame, properties)

    -- Output
    -- todo: rework it somehow
    local patch_date = g_frame:callParserFunction('#show: Version ' .. g_args['patch'], { '?Has release date' })

    local tbl = mw.html.create('table')
    tbl:attr('class', 'wikitable successionbox'):tag('tr'):tag('th'):attr('colspan', 3):wikitext('[[Version history|Version History]]'):done():done():tag('tr'):tag('td'):attr('style', 'width: 30%;'):wikitext(vargs['before']):done():tag('td'):attr('style', 'width: 40%;'):wikitext(string.format('[[Version %s]]<br>%s', g_args['patch'], patch_date)):done():tag('td'):attr('style', 'width: 30%;'):wikitext(vargs['after'])

    local cats = {
        'Category:Versions',
    }

    return tostring(tbl) .. util.misc.add_category(cats)
end

-- -----

-- ----------------------------------------------------------------------------------------------------
-- Template: SMW version history

p.version_history_list = function(frame)
    g_args = getArgs(frame, { parentFirst = true })
    g_frame = util.misc.get_frame(frame)

    -- test args
    -- = p.version_history_list{conditions='[[Is version::~0.9*]]'}
    -- = p.version_history_list{conditions='[[Is version::~1*||~2*]]'}

    if g_args.conditions then
        g_args.conditions = g_args.conditions .. '[[Has release date::+]]'
    else
        g_args.conditions = '[[Is version::+]][[Has release date::+]]'
    end

    local query = {
        g_args.conditions,
        '?Is version',
        '?Has release date',
        sort = 'Has release date, Is version',
        order = 'desc, desc',
        link = 'none',
        offset = 0,
    }

    local results = {}
    repeat
        local result = util.smw.query(query, g_frame)
        query.offset = query.offset + #result

        for _, v in ipairs(result) do -- todo
        results[#results + 1] = v
        end
    until #result < 1000

    local out = {}
    local last_minor_version, current_list

    for i, result in ipairs(results) do
        local date = result['Has release date']
        local version = result['Is version']

        local v = util.cast.version(result['Is version'])
        local minor_version = table.concat({ v[1], v[2], v[3] }, '.') -- todo: rework it

        if minor_version ~= last_minor_version then

            if current_list ~= nil then
                out[#out + 1] = tostring(current_list)
            end

            out[#out + 1] = string.format('===Version %s===', minor_version)
            current_list = mw.html.create('ul')
        end

        current_list:tag('li'):wikitext(string.format('%s &ndash; [[Version %s]]', date, version))

        -- save the last list
        if (i == #results) and (current_list ~= nil) then
            out[#out + 1] = tostring(current_list)
        end

        last_minor_version = minor_version
    end

    return table.concat(out, '\n')
end

-- -----

return p