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.
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('Dev:Arguments').getArgs
local i18n = require('Dev:I18n').loadMessages('Quote')


local getArgs = require('Module:Arguments').getArgs
local function build(quote_contents, quote_source, options)
local i18n = require('Module:I18n').loadMessages('Quote')
    local quote_container = mw.html.create('blockquote')
 
        :addClass('pull-quote')
 
        :addClass(options.align)
-- =========================================================
        :addClass(options.extraclasses)
-- Parameters
        :css(options.styles)
-- =========================================================
        :cssText(options.extrastyles)
 
       
local function parameter(args, ...)
     quote_container:node(quote_contents)
    local names = { ... }
          
 
    if quote_source then
     for _, name in ipairs(names) do
    quote_container:tag('div')
         local value = i18n:parameter(name, args)
    :addClass('pull-quote__source')
 
        :tag('cite')
        if value ~= nil and value ~= '' then
        :wikitext(quote_source)
            return value
        :done()
        end
        :done()
     end
     end
 
   
     return nil
     return quote_container
end
end


 
local function options(args)
-- =========================================================
     local options = {}
-- Options
   
-- =========================================================
    options.styles = {}
 
     options.extraclasses = i18n:parameter('class', args)
local function getOptions(args)
     options.extrastyles = i18n:parameter('style', args)
 
     options.align = ''
     local options = {
     local align = i18n:parameter('align', args)
        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
     if align then
         align = string.lower(align)
         options.align = 'pull-quote--' .. align
 
        options.styles['width'] = i18n:parameter('width', args) or
        if align == 'left' or align == 'right' then
                                  i18n:parameter('quotewidth', args) or
            options.classes[#options.classes + 1] =
                                  '300px'
                'pp-quote--' .. align
 
            local width =
                parameter(args, 'width', 'quotewidth')
 
            if width then
                options.styles.width = width
            end
        end
     end
     end
 
   
     return options
     return options
end
end


 
-- let MediaWiki parser auto-generate <p> tags
-- =========================================================
local function paragraph(quotetext)
-- Build quote
return '\n' .. quotetext .. '\n'
-- =========================================================
 
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
end
-- =========================================================
-- Normal quote
-- =========================================================


function Quote.quote(frame)
function Quote.quote(frame)
     local args = getArgs(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'
        )


    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


    -- Quote text
     local quote_contents = mw.html.create('div')
     local quoteContents = mw.html.create('div')
         :addClass('pull-quote__text')
         :addClass('pp-quote__text')
         :wikitext(paragraph(quotetext))
         :wikitext(quoteText)
      
 
     local quote_source = person
 
   
     -- Source
     local quoteSource
 
     if person and source then
     if person and source then
         quoteSource = person .. ', ' .. source
         quote_source = person .. ', ' .. source
    elseif person then
        quoteSource = person
     elseif source then
     elseif source then
        quoteSource = source
    quote_source = source
     end
     end
 
   
 
     return build(quote_contents, quote_source, options)
     return build(
        quoteContents,
        quoteSource,
        options
    )
end
end
-- =========================================================
-- Dialogue
-- =========================================================


function Quote.dialogue(frame)
function Quote.dialogue(frame)
     local args = getArgs(frame)
     local args = getArgs(frame)
     local options = getOptions(args)
   
 
     local options = options(args)
     local quoteContents = mw.html.create('div')
   
         :addClass('pp-quote__text')
     local quote_contents = mw.html.create('div')
         :addClass('pp-quote__text--dialogue')
         :addClass('pull-quote__text')
 
          
 
     local quote_source
     -- 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)


    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)
     -- Dialogue source
     local source = i18n:parameter('source', args)
     local context =
        parameter(args, 'context')
 
     local source =
        parameter(args, 'source')
 
    local quoteSource
 
     if context and source then
     if context and source then
         quoteSource = context .. ', ' .. source
         quote_source = context .. ', ' .. source
     elseif context then
     elseif context and not source then
         quoteSource = context
         quote_source = context
     elseif source then
     elseif source and not context then
         quoteSource = source
         quote_source = source
     end
     end
 
   
 
     return build(quote_contents, quote_source, options)
     return build(
      
        quoteContents,
        quoteSource,
        options
     )
end
end


return Quote
return Quote
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:||}}
{{#ifeq:|||}}
{{#expr:}}
{{#switch:||#default=}}
{{#replace:||}}
{{#titleparts:}}
{{#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&mdash;&nbsp;&comma;&shy;