Skip to content
Aa
Reading appearance
Browse
Browse the wiki
Books
Characters
Houses
Places
History
Culture
More topics
Images
Television
Chapters
Timeline
Random Article
Community
Community Portal
Recent Changes
Our Sites
Westeros
Forum of Ice and Fire
Blood of Dragons MUSH
Login
Talk
Interact
Interact
Edit source
View history
More page tools
What links here
Related changes
Page information
Special pages
Editing
Module
:
Main Page redesign
Jump to:
navigation
,
search
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!
local p = {} local data = mw.loadData( 'Module:Main Page redesign/data' ) local function unixDay( frame ) local supplied = tonumber( frame.args.day ) if supplied then return math.floor( supplied ) end return tonumber( frame:preprocess( '{{unix day}}' ) ) or 0 end local function entryAt( list, index ) return list and ( list[index] or list[tostring( index )] ) or nil end local function creditMarkup( item ) local imageFile = item.imageFile or item.file local credit = '[[:File:' .. imageFile .. '|Image details]]' if item.artist then credit = 'Art by ' .. item.artist .. ( item.creditSuffix or '' ) .. ' Β· ' .. credit end if item.artistCategory and item.artistCategory ~= '' and not item.artistCategory:find( 'οΏ½', 1, true ) then local category = item.artistCategory:gsub( '^Category:', '' ) credit = credit .. ' Β· [[:Category:' .. category .. '|More by this artist]]' end return credit end local function imageMarkup( item, width, className, linkTarget ) local imageFile = item and ( item.imageFile or item.file ) if not imageFile then return '' end local link = linkTarget or item.imageSubject or item.article or '' local alt = item.imageAlt or item.title or item.speakerLabel or '' return '<div class="' .. className .. '">[[File:' .. imageFile .. '|' .. width .. 'px|link=' .. link .. '|alt=' .. alt .. ']]</div>' end function p.feature( frame ) local index = ( unixDay( frame ) % 61 ) + 1 local item = entryAt( data.articles, index ) if not item then return '' end local fragment = item.articleFragment or '' if fragment ~= '' and fragment:sub( 1, 1 ) ~= '#' then fragment = '#' .. fragment end local target = item.article .. fragment local image = item.imageFile and imageMarkup( item, 400, 'mp-redesign__feature-art', target ) or '' local media = '' local withImage = '' if image ~= '' then withImage = ' mp-redesign__feature--with-image' media = '<div class="mp-redesign__feature-media">' .. image .. '<div class="mp-redesign__feature-credit">' .. creditMarkup( item ) .. '</div></div>' end return '<div class="mp-redesign__feature' .. withImage .. '" data-feature-slot="' .. index .. '">' .. '<div class="mp-redesign__feature-copy">' .. '<p class="mp-redesign__eyebrow">' .. ( item.eyebrow or 'Selected reading' ) .. '</p>' .. '<h2>[[' .. target .. '|' .. item.title .. ']]</h2>' .. media .. '<p>' .. item.teaser .. '</p>' .. '<p>[[' .. target .. '|Read the article β]]</p></div></div>' end function p.hero( frame ) local day = unixDay( frame ) local hero = data.hero or {} local pool = {} for _, item in ipairs( data.artPool or {} ) do if item.enabled ~= false then table.insert( pool, item ) end end if #pool == 0 or hero.mode == 'pending' then return '' end local item if hero.mode == 'featured' then local article = entryAt( data.articles, ( day % 61 ) + 1 ) item = article and entryAt( data.artByKey, article.heroKey ) or nil if not item then return '' end elseif hero.mode ~= 'independent' then return '' end if hero.mode == 'independent' then local period = math.max( 1, tonumber( hero.artPeriodDays ) or 1 ) item = pool[( math.floor( day / period ) % #pool ) + 1] end return '<div class="mp-redesign__hero-art" data-hero-key="' .. ( item.key or '' ) .. '" role="group">' .. '<div class="mp-redesign__hero-media">[[File:' .. ( item.imageFile or item.file ) .. '|800px|link=' .. item.article .. '|alt=' .. ( item.imageAlt or item.title or '' ) .. ']]</div>' .. '<div class="mp-redesign__hero-caption"><h2 id="mp-redesign-title" class="mp-redesign__hero-title">[[' .. item.article .. '|' .. item.title .. ']]</h2><div class="mp-redesign__hero-credit">' .. creditMarkup( item ) .. '</div></div></div>' end local function quoteImageIsCurrent( frame, item, page ) if not item.imageFile or not item.sourceRevision then return false end local latest = tonumber( frame:preprocess( '{{REVISIONID:' .. page .. '}}' ) ) return latest and latest == tonumber( item.sourceRevision ) end function p.quotes( frame ) local day = unixDay( frame ) local indexes = { ( day % 280 ) + 1, ( ( day + 93 ) % 280 ) + 1 } local rendered = {} for _, index in ipairs( indexes ) do local page = 'Feature quote/' .. index local item = entryAt( data.quotations, index ) or {} local image = quoteImageIsCurrent( frame, item, page ) and imageMarkup( item, 400, 'mp-redesign__quote-art' ) or '' local noImage = image == '' and ' mp-redesign__quote--text-only' or '' local credit = image ~= '' and '<div class="mp-redesign__quote-credit">' .. creditMarkup( item ) .. '</div>' or '' table.insert( rendered, '<div class="mp-redesign__quote' .. noImage .. '" data-quote-slot="' .. index .. '">' .. image .. '<div><blockquote>' .. frame:expandTemplate{ title = ':' .. page } .. '</blockquote>' .. '<p>[[' .. page .. '|Quotation & source β]]</p></div>' .. credit .. '</div>' ) end return table.concat( rendered ) end return p
Summary:
Please note that all contributions to A Wiki of Ice and Fire may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, 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 (see
A Wiki of Ice and Fire:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Page included on this page:
Module:Main Page redesign/doc
(
edit
)