|
|
| Line 1: |
Line 1: |
| -- Current stable version. Increment this when a new version is released.
| | local p = {} |
| local STABLE = 34 | |
| local RECENT = 33
| |
|
| |
|
| local p = {} | | -- Define your wiki's target game versions |
| | local STABLE = "0.34" |
| | local TRUNK = "0.35" |
|
| |
|
| -- Tries to parse a version number
| | function p.get_stable(frame) |
| -- returns either a version number, "trunk", or nil (meaning unknown)
| | return STABLE |
| local function parse_version(version)
| |
| if type(version) == "number" or version == "trunk" then
| |
| return version | |
| end
| |
| local num = tonumber(version)
| |
| if num then
| |
| -- convert 0.17 to 17
| |
| if num < 1 then
| |
| num = 100*num
| |
| end
| |
| if num > STABLE then
| |
| return "trunk"
| |
| else
| |
| return num
| |
| end
| |
| end
| |
| return nil
| |
| end | | end |
|
| |
|
| function p.version_tag(frame) | | function p.get_trunk(frame) |
| local version = parse_version(frame.args[1])
| | return TRUNK |
| local current = version == STABLE
| |
| local previ = version == RECENT
| |
| local trunk = version == "trunk"
| |
| local unknown = not version
| |
| | |
| local bgcolor = "fc6"
| |
| if current then
| |
| bgcolor = "99FF99"
| |
| elseif trunk then
| |
| bgcolor = "BCEBF5"
| |
| elseif previ then
| |
| bgcolor = "e0fae0"
| |
| end
| |
| | |
| local bordercolor = "f90"
| |
| if current then
| |
| bordercolor = "33FF66"
| |
| elseif trunk then
| |
| bordercolor = "04A0BF"
| |
| elseif previ then
| |
| bordercolor = "33FF66"
| |
| end
| |
| | |
| local result = [[<div style="border: 1px solid #%s; background-color: #%s; border-left: 15px solid #%s; margin-bottom: 20px; width: 100%%; padding: 4px 10px; line-height: 1.1em; width: auto;">]]
| |
| result = result:format(bordercolor, bgcolor, bordercolor)
| |
| if trunk then
| |
| result = result .. "'''''[[Trunk]]-only''': This article pertains to a feature of Crawl which is being tested. It will likely change before the next release, and may even be removed entirely.''"
| |
| else
| |
| result = result .. "'''''Version "
| |
| if unknown then
| |
| result = result .. "Unknown"
| |
| else
| |
| result = result .. "[[0." .. version .. "]]"
| |
| end
| |
| result = result .. "''': "
| |
| if current then
| |
| result = result .. "This article is up to date for the [[0." .. STABLE .. "|latest stable release]] of ''Dungeon Crawl Stone Soup''."
| |
| else
| |
| result = result .. "This article '''may not be''' up to date for the [[0." .. STABLE .. "|latest stable release]] of Crawl.''"
| |
| end
| |
| end
| |
| result = result .. "</div>"
| |
| | |
| result = result .. "\n[[Category:"
| |
| if trunk then
| |
| result = result .. "Trunk" | |
| elseif unknown then
| |
| result = result .. "Unknown"
| |
| else
| |
| result = result .. "0." .. version
| |
| end
| |
| result = result .. " articles]]"
| |
| | |
| return result
| |
| end | | end |
|
| |
|
| function p.version_list(frame) | | -- Fallback mapping function that standard templates use to output version info |
| local prev_versions = {}
| | function p.show(frame) |
| for version = STABLE - 1, 1, -1 do
| | local version = frame.args[1] or STABLE |
| table.insert(prev_versions, "[[0." .. version .. "]]")
| | local result = "'''Version " .. version .. "''': " |
| end
| | return result |
| | |
| local result = [=[{| cellspacing="0" cellpadding="0" style="margin:0em 0em 1em 0em; width:100%; background-color:white"
| |
| | style="width:50%; vertical-align:top; border:1px solid #CC6600; background-color:#FF9966;" |
| |
| <div style="border-bottom:0px solid #CC6600; background-color:#FF6633; padding:0.2em 0.5em 0.2em 0.5em; font-size:110%; font-weight:bold;">[[:Category:Crawl Versions|Versions]]</div>
| |
| <div style="border-bottom:0px solid #CC6600; padding:0.4em 1em 1em 1em;">
| |
| The Crawl Wiki is kept up to date with the latest stable release: [[0.]=]
| |
| result = result .. STABLE .. "]]\n"
| |
| result = result .. "* Previous releases: " .. table.concat(prev_versions, " | ") .. "\n"
| |
| result = result .. "* In [[trunk]] development: [[0." .. STABLE + 1 .. "]]</div>\n|}"
| |
| return result
| |
| end | | end |
|
| |
|
| return p | | return p |
Documentation for this module may be created at Module:Version/doc
local p = {}
-- Define your wiki's target game versions
local STABLE = "0.34"
local TRUNK = "0.35"
function p.get_stable(frame)
return STABLE
end
function p.get_trunk(frame)
return TRUNK
end
-- Fallback mapping function that standard templates use to output version info
function p.show(frame)
local version = frame.args[1] or STABLE
local result = "'''Version " .. version .. "''': "
return result
end
return p