Difference between revisions 21306660 and 21306661 on frwiktionarylocal export = {} local m_languages = require('Module:languages') -- The main entry point. -- This is the only function that can be invoked from a template. function export.show(frame) if mw.title.getCurrentTitle().nsText == "Template" then return "(This template should be used on pages in the Category: namespace.)" elseif mw.title.getCurrentTitle().nsText ~= "Category" then error("This template/module can only be used on pages in the Category: namespace.") end local args = frame.args -- Get all the parameters and the label data local info = {} for key, val in pairs(args) do info[key] = val; if info[key] == "" then info[key] = nil end end -- autofill parameters for topic cat if info.template == "topic cat" and not info.code and not info.label then pagename = mw.title.getCurrentTitle().text pagename = mw.text.split(pagename,':') if #pagename == 1 then info.label = pagename[1] elseif #pagename == 2 then info.code = pagename[1] info.label = pagename[2] end end if not info.template then error("The \"template\" parameter was not specified.") end local template = info.template info.template = nil local current = require("Module:category tree/" .. template).new(info, true) local boxes = {}⏎ local display = {} local categories = {} -- Check if the category is empty local isEmpty = mw.site.stats.pagesInCategory(mw.title.getCurrentTitle().text, "all") == 0 -- Are the parameters valid? if not current then (contracted; show full) end -- Add cleanup category for empty categories if isEmpty and not current:canBeEmpty() then table.insert(categories, "[[Category:Empty categories]]") end local editlink =table.insert(boxes, show_editlink(current)) table.insert(boxes, show_pagelist(info)) -- Generate the displayed information table.insert(display, show_breadcrumbs(current)) table.insert(display, show_description(current)) table.insert(display, show_children(current)) table.insert(display, show_TOC(info)) show_categories(current, categories) return table.concat(categories, "") .. editlinktable.concat(boxes, "\n") .. "\n" .. table.concat(display, "\n\n") .. "<br clear=\"all\"/>" end function show_error(text) return mw.getCurrentFrame():expandTemplate{title = "maintenance box", args = { "red", image = "[[File:Ambox warning pn.svg|50px]]", title = "The automatically-generated contents of this category has errors.", (contracted; show full) table.insert(categories, "[[Category:" .. umbrella:getCategoryName() .. "|" .. current:getCategoryName() .. "]]") end end end function show_editlink(current) return "<div class=\"noprint plainlinks category-edit-box\" style=\"float: right; clear: both; margin: 0 0 .5em 1em; background: #f9f9f9; border: 1px #aaaaaa solid; padding: 5px; font-weight: bold;\">[" .. mw.getCurrentFrame():callParserFunction{name = "fullurl", args = {current:getDataModule(), action = "edit"}} .. " Edit category data]</div>" end function show_pagelist(info) local namespace = "" if info.label == "citations" or info.label == "citations of undefined terms" then namespace = "Citations" elseif info.code then local lang = require("Module:languages").getByCode(info.code) if lang and (lang:getType() == "reconstructed" or lang:getType() == "appendix-constructed") then namespace = "Appendix" end end local recent = mw.getCurrentFrame():callParserFunction{ name = "#tag", args = { "DynamicPageList", "category=" .. mw.title.getCurrentTitle().text .. "\n" .. "namespace=" .. namespace .. "\n" .. "count=10\n" .. "mode=ordered\n" .. "ordermethod=categoryadd\n" .. "order=descending" } } local oldest = mw.getCurrentFrame():callParserFunction{ name = "#tag", args = { "DynamicPageList", "category=" .. mw.title.getCurrentTitle().text .. "\n" .. "namespace=" .. namespace .. "\n" .. "count=10\n" .. "mode=ordered\n" .. "ordermethod=lastedit\n" .. "order=ascending" } } return [=[ {| class="wikitable" style="float: right; clear: both; margin: 0 0 .5em 1em;" ! Recent additions to the category |- | style="font-size:0.9em;" | ]=] .. recent .. [=[ |- ! Oldest pages ordered by last edit |- | style="font-size:0.9em;" | ]=] .. oldest .. [=[ |}]=] end⏎ ⏎ -- Show navigational "breadcrumbs" at the top of the page. function show_breadcrumbs(current) local steps = {} -- Start at the current label and move our way up the "chain" from child to parent, until we can't go further. while current do local category = nil local display_name = nil (contracted; show full) return mw.getCurrentFrame():expandTemplate{title = TOC_template.text, args = {}} end end return nil end return export All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://fr.wiktionary.org/w/index.php?diff=prev&oldid=21306661.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|