Modul:Podrobná zpráva
Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:Podrobná zpráva
-- @brief
-- Backend for {{Podrobná zpráva}}
--
-- @author
-- [[meta:User:Danny B.]]
local _module = {}
----------------------------------------
local DateTime = require( "Module:DateTime" )
-- @brief
-- Generates the link to the article and below its lead.
--
-- @return
-- Preprocessed wikitext
function _module.print( frame )
local output
local html = mw.html.create()
local detailNewsTitle = mw.text.trim( frame:getParent().args[1] or "#" )
local detailNewsTitleObject
local detailNewsContent
local lead = "[[Kategorie:Monitoring:Denní přehledy obsahující podrobné zprávy bez perexu]]"
local redirectedDetailNews = ""
local nonmatchingDates = ""
detailNewsTitleObject = mw.title.new( detailNewsTitle )
-- expensive++
if detailNewsTitleObject.isRedirect then
-- expensive++
detailNewsTitleObject = detailNewsTitleObject.redirectTarget
-- expensive++
redirectedDetailNews = "[[Kategorie:Monitoring:Denní přehledy obsahující odkazy na přesměrované podrobné zprávy]]"
end
detailNewsContent = detailNewsTitleObject:getContent()
html = html
:wikitext( string.format( "[[%s]]", detailNewsTitle ) )
if detailNewsContent ~= nil then
for detailNewsContentPart in detailNewsContent:gmatch( "%b{}" ) do
local currentTitle = mw.title.getCurrentTitle()
if currentTitle.namespace == 0 and detailNewsContentPart:match( "%{%{Datum.-%}%}" ) then
local detailNewsDate = detailNewsContentPart:match( "%{%{Datum|(%d%d%d%d%-%d%d%-%d%d).*%}%}" )
local dailyDigestTitle = currentTitle.text
local dailyDigestDay, dailyDigestMonth, dailyDigestYear, dailyDigestForm = DateTime.parseVerbalDate( dailyDigestTitle )
if detailNewsDate ~= string.format( "%04d-%02d-%02d", dailyDigestYear, dailyDigestMonth, dailyDigestDay ) then
nonmatchingDates = "[[Kategorie:Monitoring:Denní přehledy obsahující podrobné zprávy z jiného data]]"
end
end
if detailNewsContentPart:match( "%{%{Perex.-%}%}" ) then
lead = detailNewsContentPart
:gsub( " *<ref.-</ref>", "" )
:gsub( " *<ref[^>]-/>", "" )
break
end
end
html = html
:wikitext( lead )
:wikitext( redirectedDetailNews )
:wikitext( nonmatchingDates )
end
html = html
:allDone()
output = frame:preprocess( tostring( html ) )
return output
end
----------------------------------------
return _module