Modul:Excerpt: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
k Sophivorus memindahkan halaman Modul:Extract ke Modul:Excerpt tanpa membuat pengalihan
Tidak ada ringkasan suntingan
Baris 3:
local yesno = require('Module:Yesno')
 
local ok, config = pcall(require, 'Module:ExtractExcerpt/config')
if not ok then config = {} end
 
Baris 33:
local ok, TNT = pcall(require, 'Module:TNT')
if not ok then return key end
return TNT.format('I18n/Module:ExtractExcerpt.tab', key)
end
 
Baris 50:
-- Set variables
local fragment = getArg('fragment')
local section = fragment or getArg(2, getArg('section', mw.ustring.match(getArg(1), '[^#]+#([^#]+)') ) )
local hat = yesno( getArg('hat', true) )
local this = getArg('this')
Baris 78:
hat = getMessage('section')
end
hat = hat .. ' ' .. getMessage('extractexcerpt') .. ' '
if section and not fragment then
hat = hat .. '[[' .. page .. '#' .. mw.uri.anchorEncode(section) .. '|' .. page
Baris 86:
end
hat = hat .. "''" .. '<span class="mw-editsection-like plainlinks"><span class="mw-editsection-bracket">[</span>['
hat = hat .. title:fullUrl('action=edit') .. ' edit' .. mw.message.new('editsection'):plain()
hat = hat .. ']<span class="mw-editsection-bracket">]</span></span>' .. "''"
local ok, Hatnote = pcall(require, 'Module:Hatnote')
if ok then
hat = Hatnote._hatnote( hat, { extraclasses = 'dablink extractexcerpt-hat', selfref = true } )
else
hat = mw.html.create('div'):addClass('dablink extractexcerpt-hat'):wikitext(hat)
end
else
Baris 101:
if more and not inline then
more = "'''[[" .. page .. '#' .. (section or '') .. "|" .. getMessage('more') .. "]]'''"
more = mw.html.create('div'):addClass('noprint extractexcerpt-more'):wikitext(more)
else
more = nil
Baris 119:
noBold = noBold,
noSelfLinks = true,
noNonFreeFiles = true,
noBehaviorSwitches = true,
fixReferences = true,
Baris 124 ⟶ 125:
}
 
-- Get the extractexcerpt itself
local title = page .. '#' .. (section or '')
local ok, extractexcerpt = pcall(Transcluder.get, title, options)
if not ok then return getError(extractexcerpt) end
if mw.text.trim(extractexcerpt) == '' then
if section then return getError('section-empty', section) else return getError('lead-empty') end
end
 
-- Add a line break in case the extractexcerpt starts with a table or list
extractexcerpt = '\n' .. extractexcerpt
 
-- If no file was found, try to extractexcerpt one from the removed infoboxes
local fileNamespaces = Transcluder.getNamespaces('File')
if (files ~= '0' or not files) and not Transcluder.matchAny(extractexcerpt, '%[%[', fileNamespaces, ':') and config.captions then
local templates = Transcluder.get(title, { only = 'templates', templates = templates, fixReferences = true } )
local parameters = Transcluder.getParameters(templates)
Baris 150 ⟶ 151:
if parameters[p] then caption = parameters[p] break end
end
extractexcerpt = '[[File:' .. file .. '|thumb|' .. (caption or '') .. ']]' .. extractexcerpt
break
end
Baris 157 ⟶ 158:
 
-- Remove nested categories
extractexcerpt = frame:preprocess(extractexcerpt)
local categories, extractexcerpt = Transcluder.getCategories(extractexcerpt, options.categories)
 
-- Add tracking categories
Baris 164 ⟶ 165:
local contentCategory = config.categories.content
if contentCategory and mw.title.getCurrentTitle().isContentPage then
message:node(excerpt = excerpt .. '[[Category:' .. contentCategory .. ']]')
end
local namespaceCategory = config.categories[ mw.title.getCurrentTitle().namespace ]
if namespaceCategory then
extractexcerpt = extractexcerpt .. '[[Category:' .. namespaceCategory .. ']]'
end
end
Baris 187 ⟶ 188:
tag2 = 'blockquote'
end
extractexcerpt = mw.html.create(tag1):addClass('extractexcerpt'):wikitext(extractexcerpt)
local block = mw.html.create(tag2):addClass('extractexcerpt-block'):addClass(class)
return block:node(styles):node(hat):node(extractexcerpt):node(more)
end
 
-- Entry points for backwards compatibility
function p.lead(frame) return p.main(frame) end
function p.excerpt(frame) return p.main(frame) end
 
return p