「モジュール:Protection banner」を編集中

警告: ログインしていません。編集を行うと、あなたの IP アドレスが公開されます。ログインまたはアカウントを作成すれば、あなたの編集はその利用者名とともに表示されるほか、その他の利点もあります。

この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。

最新版 編集中の文章
13行目: 13行目:
  
 
-- Set constants.
 
-- Set constants.
local CONFIG_MODULE = 'モジュール:Protection banner/config'
+
local CONFIG_MODULE = 'Module:Protection banner/config'
  
 
--------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------
169行目: 169行目:
 
end
 
end
 
return setmetatable(obj, Protection)
 
return setmetatable(obj, Protection)
 +
end
 +
 +
function Protection:isUserScript()
 +
-- Whether the page is a user JavaScript or CSS page.
 +
local title = self.title
 +
return title.namespace == 2 and (
 +
title.contentModel == 'javascript' or title.contentModel == 'css'
 +
)
 
end
 
end
  
174行目: 182行目:
 
return self.level ~= '*'
 
return self.level ~= '*'
 
end
 
end
 +
 +
function Protection:shouldShowLock()
 +
-- Whether we should output a banner/padlock
 +
return self:isProtected() and not self:isUserScript()
 +
end
 +
 +
-- Whether this page needs a protection category.
 +
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
  
 
function Protection:isTemporary()
 
function Protection:isTemporary()
180行目: 196行目:
  
 
function Protection:makeProtectionCategory()
 
function Protection:makeProtectionCategory()
 +
if not self:shouldHaveProtectionCategory() then
 +
return ''
 +
end
 +
 
local cfg = self._cfg
 
local cfg = self._cfg
 
local title = self.title
 
local title = self.title
 
-- Exit if the page is not protected.
 
if not self:isProtected() then
 
return ''
 
end
 
 
 
 
-- Get the expiry key fragment.
 
-- Get the expiry key fragment.
201行目: 216行目:
 
namespaceFragment = 'talk'
 
namespaceFragment = 'talk'
 
end
 
end
+
 
 
-- Define the order that key fragments are tested in. This is done with an
 
-- Define the order that key fragments are tested in. This is done with an
 
-- array of tables containing the value to be tested, along with its
 
-- array of tables containing the value to be tested, along with its
309行目: 324行目:
 
function Protection:isIncorrect()
 
function Protection:isIncorrect()
 
local expiry = self.expiry
 
local expiry = self.expiry
return not self:isProtected()
+
return not self:shouldHaveProtectionCategory()
 
or type(expiry) == 'number' and expiry < os.time()
 
or type(expiry) == 'number' and expiry < os.time()
end
 
 
-- 日本語版独自
 
function Protection:isMismatched()
 
return self.reason == 'dispute' and self.level ~= 'sysop'
 
 
end
 
end
  
329行目: 339行目:
 
function Protection:makeCategoryLinks()
 
function Protection:makeCategoryLinks()
 
local msg = self._cfg.msg
 
local msg = self._cfg.msg
local ret = { self:makeProtectionCategory() }
+
local ret = {self:makeProtectionCategory()}
 
if self:isIncorrect() then
 
if self:isIncorrect() then
 
ret[#ret + 1] = makeCategoryLink(
 
ret[#ret + 1] = makeCategoryLink(
 
msg['tracking-category-incorrect'],
 
msg['tracking-category-incorrect'],
self.title.text
 
)
 
elseif self:isMismatched() then
 
ret[#ret + 1] = makeCategoryLink(
 
msg['tracking-category-mismatch'],
 
 
self.title.text
 
self.title.text
 
)
 
)
695行目: 700行目:
 
local imageFilename = protectionObj.bannerConfig.image
 
local imageFilename = protectionObj.bannerConfig.image
 
if imageFilename then
 
if imageFilename then
+
obj._imageFilename = imageFilename
-- 日本語版独自の条件分岐
 
if type(imageFilename) == 'string' then
 
obj._imageFilename = imageFilename
 
elseif type(imageFilename) == 'function' then
 
obj._imageFilename = imageFilename(protectionObj)
 
end
 
 
else
 
else
 
-- If an image filename isn't specified explicitly in the banner config,
 
-- If an image filename isn't specified explicitly in the banner config,
854行目: 853行目:
 
 
 
-- Render the banner
 
-- Render the banner
if protectionObj:isProtected() then
+
if protectionObj:shouldShowLock() then
 
ret[#ret + 1] = tostring(
 
ret[#ret + 1] = tostring(
 
(yesno(args.small) and Padlock or Banner)
 
(yesno(args.small) and Padlock or Banner)

北大Wikiへの投稿はすべて、クリエイティブ・コモンズ 表示-継承 (詳細は北大Wiki:著作権を参照)のもとで公開したと見なされることにご注意ください。 自分が書いたものが他の人に容赦なく編集され、自由に配布されるのを望まない場合は、ここに投稿しないでください。
また、投稿するのは、自分で書いたものか、パブリック ドメインまたはそれに類するフリーな資料からの複製であることを約束してください。 著作権保護されている作品は、許諾なしに投稿しないでください!

このページを編集するには、下記の確認用の質問に回答してください (詳細):

取り消し 編集の仕方 (新しいウィンドウで開きます)

このページで使用されているテンプレート: