الفرق بين الصفحتين: «وحدة:توثيق» و«وحدة:توثيق/ملعب»

(الفرق بين الصفحتين)
اذهب إلى التنقل اذهب إلى البحث
صفحة 1
صفحة 2
ط (غيّر إعدادات حماية »وحدة:توثيق«: بوت: [https://w.wiki/7NGP تحسين مستوي الحماية] ([تعديل=السماح للمحررين فقط] (غير محدد) [النقل=السماح للمحررين فقط] (غير محدد)))
 
(للتجربة)
 
سطر 11: سطر 11:
-- Often-used functions.
-- Often-used functions.
local ugsub = mw.ustring.gsub
local ugsub = mw.ustring.gsub
local format = mw.ustring.format


----------------------------------------------------------------------------
----------------------------------------------------------------------------
سطر 51: سطر 50:
local function makeWikilink(page, display)
local function makeWikilink(page, display)
if display then
if display then
return format('[[%s|%s]]', page, display)
return mw.ustring.format('[[%s|%s]]', page, display)
else
else
return format('[[%s]]', page)
return mw.ustring.format('[[%s]]', page)
end
end
end
end
سطر 67: سطر 66:


local function makeUrlLink(url, display)
local function makeUrlLink(url, display)
return format('[%s %s]', url, display)
return mw.ustring.format('[%s %s]', url, display)
end
end


سطر 82: سطر 81:
end
end
-- 'documentation-toolbar'
-- 'documentation-toolbar'
return format(
return '<span class="' .. message('toolbar-class') .. '">('
'<span class="%s">(%s)</span>',
.. table.concat(ret, ' &#124; ') .. ')</span>'
message('toolbar-class'),
table.concat(ret, ' &#124; ')
)
end
end


سطر 120: سطر 116:


function p.nonexistent(frame)
function p.nonexistent(frame)
if mw.title.getCurrentTitle().subpageText == 'مختبر' then
if mw.title.getCurrentTitle().subpageText == 'testcases' then
return frame:expandTemplate{title = 'ملاحظة مختبر الوحدة'}
return frame:expandTemplate{title = 'module test cases notice'}
else
else
return p.main(frame)
return p.main(frame)
سطر 317: سطر 313:
local sandboxTitle = env.sandboxTitle
local sandboxTitle = env.sandboxTitle
if templateTitle.exists and sandboxTitle.exists then
if templateTitle.exists and sandboxTitle.exists then
local compareUrl = mw.uri.canonicalUrl(
local compareUrl = mw.uri.fullUrl(
'Special:ComparePages',
'Special:ComparePages',
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
سطر 509: سطر 505:
end
end


local data = {}
data.title = title
data.docTitle = docTitle
-- View, display, edit, and purge links if /doc exists.
data.viewLinkDisplay = message('view-link-display')
data.editLinkDisplay = message('edit-link-display')
data.historyLinkDisplay = message('history-link-display')
data.purgeLinkDisplay = message('purge-link-display')
-- Create link if /doc doesn't exist.
-- Create link if /doc doesn't exist.
local preload = args.preload
local preload = args.preload
سطر 518: سطر 522:
end
end
end
end
data.preload = preload
return {
data.createLinkDisplay = message('create-link-display')
title = title,
return data
docTitle = docTitle,
-- View, display, edit, and purge links if /doc exists.
viewLinkDisplay = message('view-link-display'),
editLinkDisplay = message('edit-link-display'),
historyLinkDisplay = message('history-link-display'),
purgeLinkDisplay = message('purge-link-display'),
--#Added 2 lines
usageLinkDisplay = message('usage-link-display'),
TemplateUsage = message('template-usage'),
preload = preload,
createLinkDisplay = message('create-link-display')
}
end
end


سطر 540: سطر 532:
-- @data - a table of data generated by p.makeStartBoxLinksData
-- @data - a table of data generated by p.makeStartBoxLinksData
--]]
--]]
local function escapeBrackets(s)
-- Escapes square brackets with HTML entities.
s = s:gsub('%[', '&#91;') -- Replace square brackets with HTML entities.
s = s:gsub('%]', '&#93;')
return s
end
local ret
local docTitle = data.docTitle
local docTitle = data.docTitle
-- #Added block:This block added by Mr.Ibrahim to view [استخدامات] link
local ret
local title = data.title
local title = data.title
local usageUrl = "https://templatecount.toolforge.org/index.php?lang=ar&namespace=" .. title.namespace .. "&name=" .. mw.uri.encode( title.text , 'PATH')
local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
local usageLink = makeUrlLink(usageUrl , data.usageLinkDisplay)
local templates_use_module = "//ar.wikipedia.org/w/index.php?title=خاص:بحث&fulltext=Search&ns10=1&ns8=1&search=insource%3A%2F(invoke%7Cاستدعاء)%3A+%2A" .. mw.uri.encode( title.text , 'PATH') .. "%5C%7C%2F"
local templates_use_moduleLink = makeUrlLink(templates_use_module , data.TemplateUsage)
-- yes, we do intend to purge the template page on which the documentation appears
local purgeLink = makeWikilink("Special:Purge/" .. data.title.prefixedText, data.purgeLinkDisplay)
if docTitle.exists then
if docTitle.exists then
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, data.editLinkDisplay)
local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, data.historyLinkDisplay)
local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
-- #Edited line
ret = '[%s] [%s] [%s] [%s]'
return "&#91;" .. viewLink .. "&#93; &#91;" .. editLink .. "&#93; &#91;" .. historyLink .. "&#93; &#91;" .. purgeLink .. "&#93; &#91;" .. usageLink .. "&#93;" .. (title.namespace == 828 and (" &#91;" .. templates_use_moduleLink .. "&#93;") or '')
ret = escapeBrackets(ret)
ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
else
else
local createLink = makeUrlLink(docTitle:canonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
-- #Edited line
ret = '[%s] [%s]'
return  "&#91;" .. createLink .. "&#93; &#91;" .. purgeLink .. "&#93;&#91;" .. usageLink .. "&#93;" .. (title.namespace == 828 and (" &#91;" .. templates_use_moduleLink .. "&#93;") or '')
ret = escapeBrackets(ret)
ret = mw.ustring.format(ret, createLink, purgeLink)
end
end
return ret
return ret
سطر 661: سطر 655:
env = env or p.getEnvironment(args)
env = env or p.getEnvironment(args)
local docTitle = env.docTitle
local docTitle = env.docTitle
local content = args.content or args["محتوى"]
local content = args.content
if not content and docTitle and docTitle.exists then
if not content and docTitle and docTitle.exists then
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
سطر 777: سطر 771:
-- /doc exists; link to it.
-- /doc exists; link to it.
local docLink = makeWikilink(docTitle.prefixedText)
local docLink = makeWikilink(docTitle.prefixedText)
local editUrl = docTitle:fullUrl{action = 'edit'}
local editDisplay = message('edit-link-display')
local editDisplay = message('edit-link-display')
local editLink = makeWikilink("Special:EditPage/" .. docTitle.prefixedText, editDisplay)
local editLink = makeUrlLink(editUrl, editDisplay)
local historyUrl = docTitle:fullUrl{action = 'history'}
local historyDisplay = message('history-link-display')
local historyDisplay = message('history-link-display')
local historyLink = makeWikilink("Special:PageHistory/" .. docTitle.prefixedText, historyDisplay)
local historyLink = makeUrlLink(historyUrl, historyDisplay)
ret = message('transcluded-from-blurb', {docLink})
ret = message('transcluded-from-blurb', {docLink})
.. ' '
.. ' '
سطر 787: سطر 783:
elseif env.subjectSpace == 828 then
elseif env.subjectSpace == 828 then
-- /doc does not exist; ask to create it.
-- /doc does not exist; ask to create it.
local createUrl = docTitle:canonicalUrl{action = 'edit', preload = message('module-preload')}
local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
local createDisplay = message('create-link-display')
local createDisplay = message('create-link-display')
local createLink = makeUrlLink(createUrl, createDisplay)
local createLink = makeUrlLink(createUrl, createDisplay)
سطر 838: سطر 834:
local sandboxDisplay = message('sandbox-link-display')
local sandboxDisplay = message('sandbox-link-display')
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
local sandboxEditDisplay = message('sandbox-edit-link-display')
local sandboxEditDisplay = message('sandbox-edit-link-display')
local sandboxEditLink = makeWikilink("Special:EditPage/" .. sandboxPage, sandboxEditDisplay)
local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
local compareUrl = env.compareUrl
local compareUrl = env.compareUrl
local compareLink
local compareLink
سطر 854: سطر 851:
sandboxPreload = message('template-sandbox-preload')
sandboxPreload = message('template-sandbox-preload')
end
end
local sandboxCreateUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = sandboxPreload}
local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}
local sandboxCreateDisplay = message('sandbox-create-link-display')
local sandboxCreateDisplay = message('sandbox-create-link-display')
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
local mirrorPreload = message('mirror-link-preload')
local mirrorPreload = message('mirror-link-preload')
local mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
if subjectSpace == 828 then
if subjectSpace == 828 then
mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
end
end
local mirrorDisplay = message('mirror-link-display')
local mirrorDisplay = message('mirror-link-display')
سطر 871: سطر 868:
local testcasesDisplay = message('testcases-link-display')
local testcasesDisplay = message('testcases-link-display')
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
local testcasesEditUrl = testcasesTitle:canonicalUrl{action = 'edit'}
local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditDisplay = message('testcases-edit-link-display')
local testcasesEditLink = makeWikilink("Special:EditPage/" .. testcasesPage, testcasesEditDisplay)
local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
-- for Modules, add testcases run link if exists
-- for Modules, add testcases run link if exists
if testcasesTitle.contentModel == "Scribunto"  and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
if testcasesTitle.contentModel == "Scribunto"  and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
سطر 889: سطر 886:
testcasesPreload = message('template-testcases-preload')
testcasesPreload = message('template-testcases-preload')
end
end
local testcasesCreateUrl = testcasesTitle:canonicalUrl{action = 'edit', preload = testcasesPreload}
local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}
local testcasesCreateDisplay = message('testcases-create-link-display')
local testcasesCreateDisplay = message('testcases-create-link-display')
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)