Module:Numlinks: Difference between revisions

Ganaram inukshuk (talk | contribs)
Created page with "-- Page is following provisonal style guide: User:Ganaram_inukshuk/Provisional_style_guide_for_Lua local ordinal = require("Module:Ordinal")._ordinal -- Generate a table of..."
 
Ganaram inukshuk (talk | contribs)
simplify args
Line 5: Line 5:
-- Generate a table of previous and next links for numbered pages, with support
-- Generate a table of previous and next links for numbered pages, with support
-- for up to two numbers. Args are as follows:
-- for up to two numbers. Args are as follows:
-- - Link count: how many links up and down should be displayed? For n, a count
-- - Link config: what is the arrangement of links? Options are:
--   of 1 gives links for n-1 and n+1; count 2 is n-2, n-1, n+1, and n+2. This
-- -- Side-1: For n, links are for n-1 and n+1
--   does not apply if there are two values n and m, to limit the number of
-- -- Side-2: For n, links are for n-2 to n+1
--   links to be made.
-- -- Side-3: For n, links are for n-3 to n+3
-- -- Side-4: For n, links are for n-4 to n+4
-- -- Side-5: For n, links are for n-5 to n+5
-- -- 8-Link: For n and m, links are n +/- 1 and m +/- 1. There are no options
--   for additional links.
-- - Is ordinal: should the values be cardinal numbers (eg, 12edo) or ordinal
-- - Is ordinal: should the values be cardinal numbers (eg, 12edo) or ordinal
--  numbers (eg, 12th-octave)?
--  numbers (eg, 12th-octave)?
-- - Page text: Text is formatted as [pre-text][n][post-text], stored in a table
-- - Page text: Text is formatted as [pre-text][n][post-text], stored in a table
--  { pre } or { pre, post }. If two values, n and m, are present, then the
--  { pre } or { pre, post }. If the link config is for 8 links, then text is
--  format is [pre-text-1][n][post-text-1][pre-text-2][m][post-text-2], where
--  formatted as [pre-text][n][mid-text][m][post-text], stored in a table
--  the second pre/post text is entered as a second table.
--  { mid, post } or { pre, mid, post }. Pre-text can be omitted since most
--  pages don't have pre-text (12edo, 5L 2s).  
-- - Link text: Same as page text, except this changes the text of the link. If
-- - Link text: Same as page text, except this changes the text of the link. If
--  this is not specified, then the page and link text are the same.
--  this is not specified, then the page and link text are the same.
Line 21: Line 26:
--  whole numbers.
--  whole numbers.
function p._numlinks(args)
function p._numlinks(args)
local link_count  = args["Link Count"]
local link_config = args["Link Config"]
local is_ordinal  = args["Is Ordinal"] ~= nil and args["Is Ordinal"] or false
local is_ordinal  = args["Is Ordinal"] ~= nil and args["Is Ordinal"] or false
local page_text_1 = args["Page Text 1"]
local page_text  = args["Page Text"]
local page_text_2 = args["Page Text 2"]
local link_text  = args["Link Text"] ~= nil and args["Link Text"] or args["Page Text"]
local link_text_1 = args["Link Text 1"] ~= nil and args["Link Text 1"] or args["Page Text 1"]
local link_text_2 = args["Link Text 2"] ~= nil and args["Link Text 2"] or args["Page Text 2"]
local min_1      = args["Min 1"] ~= nil and args["Min 1"] or 1
local min_1      = args["Min 1"] ~= nil and args["Min 1"] or 1
local min_2      = args["Min 2"] ~= nil and args["Min 2"] or 1
local min_2      = args["Min 2"] ~= nil and args["Min 2"] or 1
end
end