Module:Gutenberg: Difference between revisions

From Zoophilia Wiki
Jump to navigationJump to search
meta>GreenC
m (Green Cardamom moved page Module:Gutenberg author 2 to Module:Gutenberg without leaving a redirect)
meta>GreenC
No edit summary
Line 8: Line 8:
   local tname = "Gutenberg author" -- name of calling template. Change if template is renamed.
   local tname = "Gutenberg author" -- name of calling template. Change if template is renamed.
   
   
   local id     = nil -- author ID
   local id       = nil -- author name, or author number. The later will go direct to the author page, the former to a search results page.
   local name   = nil -- display name (default: article title)
   local name     = nil -- display name on Wikipedia (default: article title)
  local cite    = nil -- use inline citation format (deprecated feature)
   local url     = nil
   local url     = nil
   local tagline = "at [[Project Gutenberg]]"
   local tagline = "at ''Books and Writers''"
   local urlheadname  = "//www.gutenberg.org/author/"
   local urlhead = "https://web.archive.org/web/20130704043115/http://www.kirjasto.sci.fi/"
  local urlheadnumb  = "//www.gutenberg.org/ebooks/author/"
  local urlhead  = nil
 
  if args.id == "" or args.id == nil then
    return "Error in {{" .. tname .. "}}, id missing. Please see documentation."
  else
    id = mw.text.trim(args.id)
    if tonumber(a) ~= nil then -- it's a number
      urlhead = urlheadnumb
    else
      urlhead = urlheadname
    end
  end
 
  if args.name == "" or args.name == nil then
    name = mw.title.getCurrentTitle().text
  else
    name = mw.text.trim(args.name)
  end
  name = mw.ustring.gsub(name,"%s%(.*%)", "") -- remove disambiguation ()
 
  url = "[" .. urlhead .. id .. "Works by " .. name .. "] " .. tagline
 
  return url


end
end


return p
return p

Revision as of 18:38, 3 October 2015

Documentation for this module may be created at Module:Gutenberg/doc

local p = {}
 
function p.author(frame)
  
  local pframe = frame:getParent()
  local args = pframe.args
 
  local tname = "Gutenberg author" -- name of calling template. Change if template is renamed.
 
  local id       = nil -- author name, or author number. The later will go direct to the author page, the former to a search results page.
  local name     = nil -- display name on Wikipedia (default: article title)
  local url      = nil
  local tagline  = "at [[Project Gutenberg]]"
  local urlheadname  = "//www.gutenberg.org/author/"
  local urlheadnumb  = "//www.gutenberg.org/ebooks/author/"
  local urlhead  = nil

  if args.id == "" or args.id == nil then
    return "Error in {{" .. tname .. "}}, id missing. Please see documentation."
  else
    id = mw.text.trim(args.id)
    if tonumber(a) ~= nil then -- it's a number
      urlhead = urlheadnumb
    else
      urlhead = urlheadname
    end
  end 

  if args.name == "" or args.name == nil then
    name = mw.title.getCurrentTitle().text
  else
    name = mw.text.trim(args.name)
  end
  name = mw.ustring.gsub(name,"%s%(.*%)", "") -- remove disambiguation () 

  url = "[" .. urlhead .. id .. "Works by " .. name .. "] " .. tagline

  return url

end

return p