模組:Fullurl
外观
![]() | 此模块被引用於約5,800個頁面。 為了避免造成大規模的影響,所有對此模块的編輯應先於沙盒或測試樣例上測試。 測試後無誤的版本可以一次性地加入此模块中,但是修改前請務必於討論頁發起討論。 模板引用數量會自動更新。 |
![]() | 此模块被引用於約5,800個頁面。 為了避免造成大規模的影響,所有對此模块的編輯應先於沙盒或測試樣例上測試。 測試後無誤的版本可以一次性地加入此模块中,但是修改前請務必於討論頁發起討論。 模板引用數量會自動更新。 |
![]() | 此模块使用Lua语言: |
概要
由於技術限制,使用{{fullurl}}
時皆須要把等號用{{=}}
替換,或是寫成{{fullurl|title|2=a=b&c=d|3=文字}}
,因此寫了這個模板。
參數及使用方法
有幾個特殊參數:
參數 | 別名 | 意義 |
---|---|---|
title |
1 |
標題,未填寫時自動讀取當前頁面名。 |
text |
2 |
連結文字,未填寫時自動讀取title 的值。
|
onlyurl |
不適用 | 只生成連結,不過如果是這這樣最好直接使用魔術字{{fullurl:params}} 。
|
其餘的參數皆會在生成的連結中生成形如參數名=值
。
範例
- 原始碼:
{{fullurl2|User:Example}}
- 結果:
- Module:Fullurl
- 原始碼:
{{fullurl2|User:Example|示範用戶}}
- 結果:
- Module:Fullurl
- 原始碼:
{{fullurl2|Wikipedia:互助客栈/求助|action=edit§ion=new&preload=Template:Sign}}
或
{{fullurl2|Wikipedia:互助客栈/求助|action=edit|section=new|preload=Template:Sign}}
- 結果:
- Module:Fullurl
- 原始碼:
{{fullurl2|Wikipedia:互助客栈/求助|action=edit§ion=new&preload=Template:Sign|解決在維基百科中所遇疑難}}
或
{{fullurl2|Wikipedia:互助客栈/求助|action=edit|section=new|preload=Template:Sign|解決在維基百科中所遇疑難}}
- 結果:
- Module:Fullurl
重定向
注意事项
模板编辑说明
參見
local fullurl = {}
local yesno = require('Module:Yesno')
function fullurl.fullurl(frame)
if frame == mw.getCurrentFrame() then
args = frame.args
else
args = frame
if type(args) ~= type({}) then args = {frame} end
end
local title = args['title'] or args[1] or tostring(mw.title.getCurrentTitle())
local linktext = args['text'] or args[2] or title
local action = (args['action'] and 'action=' or '') .. (args['action'] or '')
local viewpaid = ''
local editpaid = (args['oldid'] and '&oldid=' or '') .. (args['oldid'] or '') ..
(args['section'] and '§ion=' or '') .. (args['section'] or '') ..
(args['summary'] and '&summary=' or '') .. (args['summary'] or '') ..
(args['preload'] and '&preload=' or '') .. (args['preload'] or '') ..
(args['preloadtitle'] and '&preloadtitle=' or '') .. (args['preloadtitle'] or '')
local historypaid = ''
local deletepaid = ''
local protectpaid = ''
local other = args['other'] or ''
local paid = ((args['action'] == '') and viewpaid or '') .. ((args['action'] == 'view') and viewpaid or '') ..
((args['action'] == 'edit') and editpaid or '') ..
((args['action'] == 'history') and historypaid or '') ..
((args['action'] == 'delete') and deletepaid or '') ..
((args['action'] == 'protect') and protectpaid or '')
local text = ''
if yesno(args['onlyurl']) then
text = tostring(mw.uri.fullUrl(title,action .. paid .. other))
else
text = '<span class="plainlinks">[' .. tostring(mw.uri.fullUrl(title,action .. paid .. other)) .. ' ' .. linktext .. ']</span>'
end
return text
end
return fullurl