Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Editing Module:BSW/MainPage

From the only original and legitimate Battlestar Wiki: the free-as-in-beer, non-corporate, open-content encyclopedia, analytical reference, and episode guide on all things Battlestar Galactica. Accept neither subpar substitutes nor subpar clones.
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 28: Line 28:
-- External link via wikitext: [url label] — survives sanitizer
-- External link via wikitext: [url label] — survives sanitizer
local function xlink( frame, url, label )
local function xlink( frame, url, label )
     return frame:preprocess( '<span class="plainlinks">[' .. url .. ' ' .. (label or url) .. ']</span>' )
     return frame:preprocess( '[' .. url .. ' ' .. (label or url) .. ']' )
end
end


Line 63: Line 63:
end
end


-- ── welcome() ────────────────────────────────────────────────────
-- ── hero() ────────────────────────────────────────────────────────
function p.welcome( frame )
    local articles  = mw.site.stats.articles
    local formatted = tostring( articles ):reverse():gsub( '(%d%d%d)', '%1,' ):reverse():gsub( '^,', '' )
 
    local logo = frame:preprocess( '[[File:BSG-WIKI SM.png|40px|link=Main Page|alt=Battlestar Wiki]]' )
 
    local desc = frame:preprocess(
        "The free, non-corporate encyclopedia on all things " ..
        "''Battlestar Galactica'' \226\128\148 " ..
        formatted .. "\194\160articles and counting."
    )
 
    local inner =
        '<div class="bsw-welcome-logo">' .. logo .. '</div>' ..
        '<div class="bsw-welcome-text">' ..
        '<div class="bsw-welcome-title">Battlestar Wiki</div>' ..
        '<div class="bsw-welcome-desc">' .. desc .. '</div>' ..
        '</div>' ..
        '<div class="bsw-welcome-links">' ..
        frame:preprocess( '[[Special:Random|Random article]]' ) ..
        frame:preprocess( '[[Battlestar_Wiki:About|About]]' ) ..
        frame:preprocess( '[[Battlestar_Wiki:Community_portal|Community]]' ) ..
        '</div>'
 
    return '<div class="bsw-welcome">' .. inner .. '</div>'
end
 
 
function p.hero( frame )
function p.hero( frame )
     local args  = frame.args
     local args  = frame.args
Line 244: Line 216:
-- ── photolab() ────────────────────────────────────────────────────
-- ── photolab() ────────────────────────────────────────────────────
function p.photolab( frame )
function p.photolab( frame )
     local args     = frame.args
     local args     = frame.args
     local content   = mw.text.trim( args.content or '' )
     local content = mw.text.trim( args.content or '' )
     local prev_potd = mw.text.trim( args.prev_url  or '' )
     local prev_url = mw.text.trim( args.prev_url  or '' )
     local prev_lbl = mw.text.trim( args.prev_label or '‹' )
     local prev_lbl = mw.text.trim( args.prev_label or '‹' )
     local next_potd = mw.text.trim( args.next_url  or '' )
     local next_url = mw.text.trim( args.next_url  or '' )
     local next_lbl = mw.text.trim( args.next_label or '›' )
     local next_lbl = mw.text.trim( args.next_label or '›' )


    -- Caption: use the parent frame's raw (unexpanded) argument to avoid
    -- double-processing strip markers from nowiki/apostrophe markup.
    -- frame.args values are already expanded by MW before Lua sees them,
    -- which corrupts complex markup. Getting via expandTemplate on the
    -- raw caption transclusion gives a clean single-pass expansion.
     local caption_page = mw.text.trim( args.caption_page or '' )
     local caption_page = mw.text.trim( args.caption_page or '' )
     local caption = ''
     local caption = ''
Line 256: Line 233:
         caption = frame:preprocess( '{{' .. caption_page .. '}}' )
         caption = frame:preprocess( '{{' .. caption_page .. '}}' )
     else
     else
        -- Fallback: use already-expanded value as-is (may have strip markers
        -- in complex captions, but simple text captions will be fine)
         caption = args.caption or ''
         caption = args.caption or ''
     end
     end
Line 267: Line 246:
         local filename = mw.text.trim( content )
         local filename = mw.text.trim( content )
         if filename ~= '' then
         if filename ~= '' then
            -- Use thumb syntax suppressed via frameless|none to avoid
            -- MW adding figure wrapper with extra margins
             rendered_content = frame:preprocess(
             rendered_content = frame:preprocess(
                 '[[File:' .. filename .. '|center|frameless|upright=1.5]]'
                 '[[File:' .. filename .. '|center|frameless|400px]]'
             )
             )
         end
         end
    end
    -- Resolve a Potd:MM-DD subpage to its bare filename,
    -- then build a [[File:filename|label]] link from it.
    local function potdFileLink( potd_page, label )
        if potd_page == '' then return label end
        local t = mw.title.new( potd_page )
        if t and t.exists then
            local fn = mw.text.trim( t:getContent() or '' )
            if fn ~= '' and not fn:match( '%[%[' ) then
                -- Use [[:File:...]] (colon prefix) to link TO the file page
                -- rather than [[File:...]] which would transclude/embed the image
                return frame:preprocess( '[[:File:' .. fn .. '|' .. label .. ']]' )
            end
        end
        return frame:preprocess( '[[' .. potd_page .. '|' .. label .. ']]' )
     end
     end


Line 295: Line 256:
         frame:preprocess( '[[BW:Potd|View project →]]' ) ..
         frame:preprocess( '[[BW:Potd|View project →]]' ) ..
         '</div>'
         '</div>'
    local prev_link = prev_url ~= '' and frame:preprocess( '[[' .. prev_url:gsub('^/','') .. '|' .. prev_lbl .. ']]' ) or prev_lbl
    local next_link = next_url ~= '' and frame:preprocess( '[[' .. next_url:gsub('^/','') .. '|' .. next_lbl .. ']]' ) or next_lbl


     local nav =
     local nav =
         '<div class="bsw-photo-nav">' ..
         '<div class="bsw-photo-nav">' ..
         potdFileLink( prev_potd, prev_lbl ) ..
         prev_link ..
         '<span class="bsw-photo-caption">' .. caption .. '</span>' ..
         '<span class="bsw-photo-caption">' .. caption .. '</span>' ..
         potdFileLink( next_potd, next_lbl ) ..
         next_link ..
         '</div>'
         '</div>'


Line 444: Line 408:
         '\226\136\158 Video of the Day' ..
         '\226\136\158 Video of the Day' ..
         '</span>' ..
         '</span>' ..
         frame:preprocess( '<span class="plainlinks">[https://battlestarpegasus.com battlestarpegasus.com \226\134\151]</span>' ) ..
         frame:preprocess( '[https://battlestarpegasus.com battlestarpegasus.com \226\134\151]' ) ..
         '</div>'
         '</div>'


To edit this page, please enter the words that appear below in the box (more info):

Refresh
Cancel Editing help (opens in new window)

  [] · [[]] · [[|]] · {{}} · · “” ‘’ «» ‹› „“ ‚‘ · ~ | ° &nbsp; · ± × ÷ ² ³ ½ · §
     [[Category:]] · [[:File:]] · [[Special:MyLanguage/]] · <code></code> · <nowiki></nowiki> <code><nowiki></nowiki></code> · <syntaxhighlight></syntaxhighlight> · <includeonly></includeonly> · <noinclude></noinclude> · #REDIRECT[[]] · <translate></translate> · <languages/> · {{#translation:}} · <tvar|></> · {{DEFAULTSORT:}} · <categorytree></categorytree> · <div style="clear:both;"></div> <s></s>


Your changes will be visible immediately.
  • For testing, please use the sandbox instead.
  • On talk pages, please sign your comment by typing four tildes (~~~~).

Page included on this page: