Home
Random
Log in
Settings
About the Petit Planet Wiki
Search
Editing
Module
:
Quote
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- <nowiki> local Quote = {} local getArgs = require('Module:Arguments').getArgs local i18n = require('Module:I18n').loadMessages('Quote') -- ========================================================= -- Parameters -- ========================================================= local function parameter(args, ...) local names = { ... } for _, name in ipairs(names) do local value = i18n:parameter(name, args) if value ~= nil and value ~= '' then return value end end return nil end -- ========================================================= -- Options -- ========================================================= local function getOptions(args) local options = { classes = {}, styles = {} } local extraClasses = parameter(args, 'class') if extraClasses then options.extraClasses = extraClasses end local extraStyles = parameter(args, 'style') if extraStyles then options.extraStyles = extraStyles end -- Alignment local align = parameter(args, 'align') if align then align = string.lower(align) if align == 'left' or align == 'right' then options.classes[#options.classes + 1] = 'pp-quote--' .. align local width = parameter(args, 'width', 'quotewidth') if width then options.styles.width = width end end end return options end -- ========================================================= -- Build quote -- ========================================================= local function build(quoteContents, quoteSource, options) local quote = mw.html.create('blockquote') :addClass('pp-quote') -- Alignment classes for _, className in ipairs(options.classes) do quote:addClass(className) end -- Extra classes if options.extraClasses then quote:addClass(options.extraClasses) end -- Explicit styles for property, value in pairs(options.styles) do quote:css(property, value) end if options.extraStyles then quote:cssText(options.extraStyles) end -- Quote content quote:node(quoteContents) -- Source if quoteSource and quoteSource ~= '' then quote :tag('div') :addClass('pp-quote__source') :wikitext(quoteSource) :done() end return quote end -- ========================================================= -- Normal quote -- ========================================================= function Quote.quote(frame) local args = getArgs(frame) local options = getOptions(args) local quoteText = args[1] or parameter(args, 'quotetext', 'quote', 'text') or '' local person = args[2] or parameter( args, 'person', 'speaker', 'personquoted' ) local source = args[3] or parameter( args, 'source', 'quote_source' ) -- Quote text local quoteContents = mw.html.create('div') :addClass('pp-quote__text') :wikitext(quoteText) -- Source local quoteSource if person and source then quoteSource = person .. ', ' .. source elseif person then quoteSource = person elseif source then quoteSource = source end return build( quoteContents, quoteSource, options ) end -- ========================================================= -- Dialogue -- ========================================================= function Quote.dialogue(frame) local args = getArgs(frame) local options = getOptions(args) local quoteContents = mw.html.create('div') :addClass('pp-quote__text') :addClass('pp-quote__text--dialogue') -- Dialogue lines for i = 1, #args, 2 do local speaker = args[i] local line = args[i + 1] if speaker and line then quoteContents :tag('div') :addClass('pp-quote__line') :tag('strong') :addClass('pp-quote__speaker') :wikitext(speaker .. ':') :done() :wikitext(' ' .. line) :done() end end -- Dialogue source local context = parameter(args, 'context') local source = parameter(args, 'source') local quoteSource if context and source then quoteSource = context .. ', ' .. source elseif context then quoteSource = context elseif source then quoteSource = source end return build( quoteContents, quoteSource, options ) end return Quote
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
Petit Planet Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Below are commonly used wikitext from
MediaWiki:Edittools
. Click on any to insert them in the edit box.
File Pages
==Summary==
==Licensing==
{{Fairuse}}
{{File|}}
Dynamic Page List
¦
²
«
»
²{¦}²
«»
«/»
«!----»
Array in DPL
¹
^2{
}^2
^2{¹}^2
Parser Functions
{{#if:||}}
{{#if:<condition>|<result if true>|<result if false>}}
{{#ifeq:|||}}
{{#ifeq:<text1>|<text2>|<result if text1=text2>|<result if text1≠text2>}}
{{#expr:}}
{{#expr:<mathematical expression>}}
{{#switch:||#default=}}
{{#switch:<text1>|<text2>=<result if text1=text2>|<text3>=<result if text1=text3>|#default=<result if no valid match>}}
{{#replace:||}}
{{#replace:<text1>|<plain text to find in text1>|<plain text to insert in place of the text found>}}
{{#titleparts:}}
{{#replace:<page name>}}
{{#tag:|}}
{{#tag:<name of html tag>|<content inside html tag>}}
Markup
{{}}
|
[]
[[]]
[[Category:]]
#REDIRECT [[]] [[Category:Redirect Pages]]
<code></code>
<includeonly></includeonly>
<noinclude></noinclude>
<nowiki></nowiki>
<!---->
<br>
§
Notices
{{Stub|}}
{{Stub Dialogue}}
{{Upcoming}}
{{Under Construction}}
{{Placeholder|}}
Magic Words
{{!}}
{{formatnum:}}
{{lc:}}
{{uc:}}
{{PAGENAME}}
{{FULLPAGENAME}}
{{ROOTPAGENAME}}
{{BASEPAGENAME}}
{{SUBPAGENAME}}
{{DISPLAYTITLE:|noreplace}}
__TOC__
__NOTOC__
__EXPECTUNUSEDCATEGORY__
__HIDDENCAT__
HTML Entities
—
,
­
Pages included on this page:
Template:Documentation/Header
(
edit
)
Template:Documentation/styles.css
(
edit
)
Template:T
(
edit
)
Template:TOC Right
(
edit
)
Module:Arguments
(
edit
)
Module:Arguments/i18n
(
edit
)
Module:Common/i18n
(
edit
)
Module:Config
(
edit
)
Module:Documentation
(
edit
)
Module:Documentation/config
(
edit
)
Module:Documentation/i18n
(
edit
)
Module:Entrypoint
(
edit
)
Module:Exists
(
edit
)
Module:Fallbacklist
(
edit
)
Module:Feature
(
edit
)
Module:Formatting
(
edit
)
Module:I18n
(
edit
)
Module:Languages
(
edit
)
Module:Quote/doc
(
edit
)
Module:TableTools
(
edit
)
Module:Yesno
(
edit
)
This page is a member of 2 hidden categories:
Category:Pages using DynamicPageList4 parser function
Category:Pages using DynamicPageList4