Modulis:Dzēst
Moduļa dokumentācija[izveidot]
Iespējams, vēlies izveidot dokumentāciju šim modulim Vari eksperimentēt šī moduļa smilšu kastes (izveidot | spoguļversija) un testu (izveidot) lapā Lūdzu, kategorijas pievieno dokumentācijas apakšlapā. Moduļa apakšlapas. |
require("Module:No globals")
local getArgs = require("Module:Arguments").getArgs
local messageBox = require("Module:Message box")
local categoryHandler = require("Module:Category handler").main
local p = {}
local namespaces = {0, 2, 4, 6, 10, 14}
local texts = {
page = {
[0] = "rakstu",
[1] = "diskusiju",
[2] = "dalībnieka lapu",
[4] = "projekta lapu",
[6] = "attēlu",
[10] = "veidni",
[14] = "kategoriju",
[-999] = "lapu"
},
page2 = {
[0] = "raksta",
[1] = "diskusijas",
[2] = "dalībnieka lapas",
[4] = "projekta lapas",
[6] = "attēla",
[10] = "veidnes",
[14] = "kategorijas",
[-999] = "lapas"
},
it = {
[0] = "tas",
[1] = "tā",
[2] = "tā",
[4] = "tā",
[6] = "tas",
[10] = "tā",
[14] = "tā",
[-999] = "tā"
},
unimproved = {
[0] = "raksts nav uzlabots",
[1] = "diskusija nav uzlabota",
[2] = "dalībnieka lapa nav uzlabota",
[4] = "projekta lapa nav uzlabota",
[6] = "attēls nav uzlabots",
[10] = "veidne nav uzlabota",
[14] = "kategorija nav uzlabota",
[-999] = "lapa nav uzlabota"
}
}
local function getNs(nsData)
if nsData.isTalk == true then
return 1
end
local nsID = nsData.id
for i = 0, #namespaces do
if namespaces[i] == nsID then
return nsID
end
end
return -999
end
function p._main(args)
local reason = args[1] or nil
local user = args["lietotājs"] or args["dalībnieks"] or args["user"] or nil
local timestamp = args["laiks"] or args["timestamp"] or nil
local term = args["termiņš"] or args["term"] or nil
local due = args["due"] or nil
local dueDate = args["due_date"] or nil
local nocat = args["nocat"] or nil
local title = mw.title.getCurrentTitle()
local pageNamespace = title.nsText
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ""
local message = mw.html.create():tag("div")
local nsData = mw.site.namespaces[pageNamespace]
local nsForMsgs = getNs(nsData)
message:tag("div"):addClass("center"):tag("span"):css("font-weight", "bold"):wikitext(
"Šo " .. texts.page[nsForMsgs] .. " ir ierosināts dzēst"
):done():wikitext(" (skatīt [[Vikipēdija:Rakstu dzēšanas vadlīnijas|Vikipēdijas dzēšanas vadlīnijas]])."):done()
local dueTextReason = ""
if due ~= nil then
dueTextReason = "termiņš: " .. due .. " dienas" .. (dueDate and " jeb " .. dueDate or "")
end
if reason ~= nil then
local dueText = ""
if dueTextReason ~= "" then
dueText = " (" .. dueTextReason .. ")"
end
message:tag("div"):addClass("center"):wikitext("Iemesls: "):tag("span"):css("font-style", "italic"):wikitext(
reason .. dueText
):done():done()
elseif due ~= nil then
message:tag("div"):addClass("center"):tag("span"):css("font-style", "italic"):wikitext(dueTextReason):done():done(
)
end
local dueDateMessage = ""
local dueDateMessageObjection = ""
if due ~= nil then
dueDateMessage =
"Šāds termiņš izvēlēts, kritiski novērtējot lapas saturu. Ja šajā termiņā lapa tiks pietiekami uzlabota, lai to nevajadzētu dzēst, šī veidne var tikt noņemta. "
dueDateMessageObjection = " vai dzēšanas termiņu"
end
if nsData.isTalk then
message:tag("small"):wikitext(
dueDateMessage ..
"Ja iebilstat pret lapas dzēšanu" .. dueDateMessageObjection .. ", lūdzu, apspriediet to šajā lapā. "
)
else
local talkPageExists = title.talkPageTitle and title.talkPageTitle.exists or false
local talkPagePart = "[[" .. talkpage .. "|diskusiju lapā]]"
if talkPageExists == false then
talkPagePart = talkPagePart .. " (spiediet uz sarkanās saites, lai izveidotu diskusiju lapu)"
end
message:tag("small"):wikitext(
dueDateMessage ..
"Ja iebilstat pret " ..
texts.page2[nsForMsgs] ..
" dzēšanu" ..
dueDateMessageObjection ..
", lūdzu, apspriediet to " .. texts.page2[nsForMsgs] .. " " .. talkPagePart .. ". "
)
end
message:tag("small"):wikitext(
"Jūs joprojām varat uzlabot šo " ..
texts.page[nsForMsgs] ..
", lai " ..
texts.it[nsForMsgs] ..
" nebūtu jādzēš. Lūdzu, nedzēsiet " ..
texts.page2[nsForMsgs] ..
" saturu, neievietojiet to citā lapā un nepārvietojiet šo " ..
texts.page[nsForMsgs] ..
". Lūdzu, nedzēsiet šo paziņojumu, kamēr " ..
texts.unimproved[nsForMsgs] ..
" līdz atbilstošam līmenim vai kamēr notiek diskusija par tā dzēšanu."
):done()
if due ~= nil then
message:tag("div"):css("font-weight", "bold"):addClass("center"):wikitext(
"Iespējamie termiņi — 5 dienas, 15 dienas, 30 dienas."
):done()
end
if user ~= nil and timestamp ~= nil then
message:tag("hr"):done():tag("div"):wikitext(
mw.getCurrentFrame():expandTemplate {title = "paziņojuma autors un laiks", args = {user, timestamp}}
):done()
end
local box =
messageBox.main(
"ambox",
{
type = "serious",
image = "[[Attēls:Fairytale Trash Questionmark-05.svg|40px|Miskaste|link=Kategorija:Lapas, kas izvirzītas dzēšanai]]",
text = tostring(message:done())
}
)
local category =
categoryHandler {
nocat = nocat,
file = "[[Kategorija:Dzēšanai izvirzītie attēli]]",
other = "[[Kategorija:Dzēšanai izvirzītās lapas]]"
}
category = category or "" -- Check that we don't have a nil value for the category variable.
return box .. category
end
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
return p