Editing Module:Quote
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
-- <nowiki> | -- <nowiki> | ||
local Quote = {} | local Quote = {} | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local i18n = require('Module:I18n').loadMessages('Quote') | local i18n = require('Module:I18n').loadMessages('Quote') | ||
local function build(quote_contents, quote_source, options) | |||
local quote_container = mw.html.create('blockquote') | |||
:addClass('pull-quote') | |||
:addClass(options.align) | |||
:addClass(options.extraclasses) | |||
local function | :css(options.styles) | ||
local | :cssText(options.extrastyles) | ||
quote_container:node(quote_contents) | |||
if quote_source then | |||
if | quote_container:tag('div') | ||
:addClass('pull-quote__source') | |||
:tag('cite') | |||
:wikitext(quote_source) | |||
:done() | |||
:done() | |||
end | end | ||
return | return quote_container | ||
end | end | ||
local function options(args) | |||
local options = {} | |||
options.styles = {} | |||
options.extraclasses = i18n:parameter('class', args) | |||
local function | options.extrastyles = i18n:parameter('style', args) | ||
options.align = '' | |||
local options = { | local align = i18n:parameter('align', args) | ||
local align = parameter( | |||
if align then | if align then | ||
options.align = 'pull-quote--' .. align | |||
options.styles['width'] = i18n:parameter('width', args) or | |||
i18n:parameter('quotewidth', args) or | |||
'300px' | |||
end | end | ||
return options | return options | ||
end | end | ||
-- let MediaWiki parser auto-generate <p> tags | |||
local function paragraph(quotetext) | |||
-- | return '\n' .. quotetext .. '\n' | ||
local function | |||
end | end | ||
function Quote.quote(frame) | function Quote.quote(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local options = options(args) | |||
local quotetext = args[1] or | |||
i18n:parameter('quotetext', args) or | |||
i18n:parameter('quote', args) or | |||
i18n:parameter('text', args) or '' | |||
local person = args[2] or | |||
i18n:parameter('person', args) or | |||
i18n:parameter('speaker', args) or | |||
i18n:parameter('personquoted', args) or nil | |||
local source = args[3] or | |||
i18n:parameter('source', args) or | |||
i18n:parameter('quote_source', args) or nil | |||
local quote_contents = mw.html.create('div') | |||
local | :addClass('pull-quote__text') | ||
:addClass(' | :wikitext(paragraph(quotetext)) | ||
:wikitext( | |||
local quote_source = person | |||
local | |||
if person and source then | if person and source then | ||
quote_source = person .. ', ' .. source | |||
elseif source then | elseif source then | ||
quote_source = source | |||
end | end | ||
return build(quote_contents, quote_source, options) | |||
return build( | |||
end | end | ||
function Quote.dialogue(frame) | function Quote.dialogue(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local options = | |||
local options = options(args) | |||
local | |||
:addClass(' | local quote_contents = mw.html.create('div') | ||
:addClass('pull-quote__text') | |||
local quote_source | |||
for i, v in ipairs(args) do | |||
local next_param = i + 1 | |||
if i % 2 ~= 0 then | |||
quote_contents:tag('div') | |||
:addClass('pull-quote__line') | |||
:tag('strong') | |||
:addClass('pull-quote__speaker') | |||
:wikitext(v .. ':') | |||
:done() | :done() | ||
:wikitext(' ' .. paragraph(args[next_param])) | |||
:done() | |||
end | end | ||
end | end | ||
local context = i18n:parameter('context', args) | |||
local source = i18n:parameter('source', args) | |||
local context = | |||
local source = | |||
if context and source then | if context and source then | ||
quote_source = context .. ', ' .. source | |||
elseif context then | elseif context and not source then | ||
quote_source = context | |||
elseif source then | elseif source and not context then | ||
quote_source = source | |||
end | end | ||
return build(quote_contents, quote_source, options) | |||
return build( | |||
end | end | ||
return Quote | return Quote | ||