Jump to content

Module:Folger Shakespeare

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Xover (talk | contribs) at 17:53, 5 February 2018 (Hmm. Maybe I'm just overthinking this?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- This module's function lookup table, used by the calling context
local p = {}

function p.sfd(frame)
  local pframe = frame:getParent()

  cfg = mw.loadData('Module:Folger Digital/Configuration');

  local play  = cfg.aliases[pframe.args[1]]
  local act   = pframe.args[2]
  local scene = pframe.args[3]
  local line  = pframe.args[4]

  local location
  local ftln = pframe.args['ftln']
  if ftln then
    location = mw.ustring.format('ftln-%04d', ftln)
  else
    location = mw.ustring.format('line-%d.%d.%d', act, scene, line)
  end

  local url = mw.ustring.format(cfg.url_pattern, play, location)

  local   id = play .. act .. '_' .. scene .. '_' .. line
  local name = 'FOOTNOTE' .. id

  local play_name = cfg.names[play].title

  local location_link = mw.ustring.format(
    cfg.location_format, url, act, scene, line
  )
  local cite = '\'\'' .. play_name .. '\'\', ' .. location_link

  local result = frame:extensionTag{
    name = 'ref',
    args = {name = name},
    content = cite,
  };
  return result;
end

return p