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 40: Line 40:
         a('onclick', onclick) ..
         a('onclick', onclick) ..
         '>' .. (label or '') .. '</span>'
         '>' .. (label or '') .. '</span>'
end
-- Check if transcluded content is just a red link (page doesn't exist).
-- Returns true if content should be hidden.
local function isRedlink( content )
    if not content or mw.text.trim( content ) == '' then return true end
    -- MW renders missing transclusions as red links with class="new"
    -- Check if content is ONLY a red link and nothing else meaningful
    local stripped = mw.text.trim( content )
    -- If it starts with the page title link pattern for a missing page
    -- (the whole content is just one red link), hide it
    if stripped:match( '^<a[^>]+class="[^"]*new[^"]*"' ) and
      not stripped:match( '</a>%s*%S' ) then
        return true
    end
    return false
end
-- Wrap a card so JS can hide it if content is a red link
local function conditionalCard( id, html )
    return '<div class="bsw-conditional-card"' .. a('id', id) .. '>' .. html .. '</div>'
end
end


Line 185: Line 164:
     local lurl    = mw.text.trim( args.linkurl  or '' )
     local lurl    = mw.text.trim( args.linkurl  or '' )
     local content = args.content or ''
     local content = args.content or ''
    -- Hide card entirely if content resolved to only a red link
    if isRedlink( content ) then return '' end


     return '<div class="bsw-card">' ..
     return '<div class="bsw-card">' ..
Line 217: Line 193:
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  = args.content   or ''
     local prev_url = 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 caption  = mw.text.trim( args.caption    or '' )
     local next_url = 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 = ''
    if caption_page ~= '' then
        caption = frame:preprocess( '{{' .. caption_page .. '}}' )
    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 ''
    end
    -- Hide if today's PotD subpage doesn't exist yet
    if isRedlink( content ) then return '' end
    -- The Potd: subpage stores just the bare filename without "File:" prefix.
    local rendered_content = content
    if content ~= '' and not content:match( '%[%[' ) and not content:match( '<' ) then
        local filename = mw.text.trim( content )
        if filename ~= '' then
            rendered_content = frame:preprocess(
                '[[File:' .. filename .. '|center|frameless|400px]]'
            )
        end
    end


     local hd =
     local hd =
Line 263: Line 211:
         '<div class="bsw-photo-nav">' ..
         '<div class="bsw-photo-nav">' ..
         prev_link ..
         prev_link ..
         '<span class="bsw-photo-caption">' .. caption .. '</span>' ..
         '<span class="bsw-photo-caption">' .. e(caption) .. '</span>' ..
         next_link ..
         next_link ..
         '</div>'
         '</div>'


     return '<div class="bsw-card">' .. hd .. rendered_content .. nav .. '</div>'
     return '<div class="bsw-card">' .. hd .. content .. nav .. '</div>'
end
end


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: