Изменения

Перейти к навигации Перейти к поиску
упрощение обработки комментариев
Строка 39: Строка 39:  
end
 
end
   −
-- Форматирование даты как в шаблоне
+
-- Форматирование комментария как в шаблоне
local function getDate( date )
+
local function getComment( comment, link, date )
if isEmpty( date ) then
+
if isEmpty( comment ) and isEmpty( date ) then
return ''
+
return nil
 +
end
 +
 +
-- «Википедия:Нейтральная точка зрения (2 мая 2015)»
 +
if isEmpty( comment ) and not isEmpty( date ) then
 +
comment = link
 +
end
 +
 +
if isEmpty( comment ) then
 +
return nil
 +
end
 +
 +
local delink = require( 'Module:Delink' )._delink
 +
comment = delink( { comment } )
 +
 +
if not isEmpty( date ) then
 +
comment = comment .. mwLang:formatDate( ' (j xg Y)', date )
 
end
 
end
 
 
return mwLang:formatDate( ' (j xg Y)', date )
+
return comment
 
end
 
end
   −
-- Форматирование ссылок как в шаблоне
+
-- Форматирование ссылки как в шаблоне
local function getLink( link, text, comment, hasComment )
+
local function getLink( link, text, comment, hasCustomComment )
 
if isEmpty( link ) then
 
if isEmpty( link ) then
 
return text
 
return text
Строка 55: Строка 71:  
 
 
if not isEmpty( comment ) then
 
if not isEmpty( comment ) then
local delink = require( 'Module:Delink' )._delink
+
local html = mw.html.create( 'span' )
comment = delink( { comment } )
+
:attr( 'title', comment )
if comment then
+
:wikitext( text )
local html = mw.html.create( 'span' )
  −
:attr( 'title', comment )
  −
:wikitext( text )
   
 
if hasComment then
+
if hasCustomComment then
html:attr( 'style', 'border-bottom:1px dotted;' )
+
html:attr( 'style', 'border-bottom:1px dotted;' )
end
  −
  −
text = tostring( html )
   
end
 
end
 +
 +
text = tostring( html )
 
end
 
end
 
 
Строка 182: Строка 194:  
 
 
-- Поддержка параметра {{{comment|}}}
 
-- Поддержка параметра {{{comment|}}}
local comment = args.comment or args[ 'comment-default' ] or args.link
+
local comment = getComment( args.comment or args[ 'comment-default' ], args.link, date )
if not isEmpty( comment ) then
  −
comment = comment .. getDate( date )
  −
end
   
 
 
tag
 
tag
Анонимный участник

Реклама:

Навигация