Jump to content
 







Main menu
   


Navigation  



Main page
Contents
Current events
Random article
About Wikipedia
Contact us
Donate
 




Contribute  



Help
Learn to edit
Community portal
Recent changes
Upload file
 








Search  

































Create account

Log in
 









Create account
 Log in
 




Pages for logged out editors learn more  



Contributions
Talk
 



















Contents

   



(Top)
 


1 Usage  














Module:Librivox book






العربية
تۆرکجه

Беларуская (тарашкевіца)
Deutsch
فارسی

Hrvatski
Bahasa Indonesia
Jawa

Македонски

Bahasa Melayu


Română

Simple English
سنڌي
Српски / srpski

Türkçe
Українська
اردو
Tiếng Vit

 

Edit links
 









Module
Talk
 

















Read
View source
View history
 








Tools
   


Actions  



Read
View source
View history
 




General  



What links here
Related changes
Upload file
Special pages
Permanent link
Page information
Get shortened URL
Download QR code
Wikidata item
 




Print/export  



Download as PDF
Printable version
 
















Appearance
   

 





Permanently protected module

From Wikipedia, the free encyclopedia
 


Usage

There is currently 1 template that invokes this module, {{Librivox book}}.

local p = {}
 
function p.book(frame)

  local pframe = frame:getParent()
  local args = pframe.args

  local tname = "Librivox book" -- name of calling template. Change if template rename.

  local title   = nil -- display and search title (default: article name w/out dab)
  local dtitle  = nil -- display title (default: title)
  local stitle  = nil -- search title (default: title)
  local lname   = nil -- last name
  local id      = nil -- unsupported argument
  local author  = nil -- author
  local tagline = "public domain audiobook at [[LibriVox]]"
  local urlhead = "https://librivox.org/search?"
  local italic   = "''"

  id = trimArg(args.id)
  if id then
    error("Error in Template:" .. tname .. " - id argument not supported - please see documentation at [[Template:Librivox author]]")
  end

  title = trimArg(args.title)
  if not title then
    title = mw.title.getCurrentTitle().text
  end
  dtitle = mw.ustring.gsub(title,'%s+%([^%(]-%)$', '')        -- Remove the final disambig paren
  stitle = dtitle

  if trimArg(args.stitle) then
    stitle = trimArg(args.stitle)
    if not trimArg(args.title) then                           -- For when used outside main article space
      dtitle = stitle
    end
  end
  if trimArg(args.dtitle) then
    dtitle = trimArg(args.dtitle)
    italic  = ""
  end

  local stitle = mw.ustring.gsub(stitle," ", "+")             -- replace "<space>" with "+"

  author = trimArg(args.author)
  if not author then
    lname = ""
  else
    --- Split name into words, count words, set name to last word
    local N = mw.text.split(author, " ")
    local l, count = mw.ustring.gsub(author, "%S+", "")
    lname = N[count]
  end

  local url = "[[File:Speaker Icon.svg|15px|link=|alt=]] " .. "[" .. urlhead .. "title=" .. stitle .. "&author=" .. lname .. "&reader=&keywords=&genre_id=0&status=all&project_type=either&recorded_language=&sort_order=catalog_date&search_page=1&search_form=advanced" .. " " .. italic .. dtitle .. italic .. "]" .. " " .. tagline

  return url

end

function trimArg(arg)
  if arg == "" or arg == nil then
    return nil
  else
    return mw.text.trim(arg)
  end
end

return p

Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Librivox_book&oldid=884971039"

Category: 
Modules in beta
Hidden category: 
Wikipedia template-protected modules
 



This page was last edited on 25 February 2019, at 04:12 (UTC).

Text is available under the Creative Commons Attribution-ShareAlike License 4.0; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.



Privacy policy

About Wikipedia

Disclaimers

Contact Wikipedia

Code of Conduct

Developers

Statistics

Cookie statement

Mobile view



Wikimedia Foundation
Powered by MediaWiki