Content deleted Content added
more banner methods, expand the export method |
add main text and a few more banner methods |
||
Line 1:
local dts = require( 'Module:User:Anomie/deepToString' ).deepToString -- for debugging
local htmlBuilder = require( 'Module:HtmlBuilder' )
Line 793 ⟶ 790:
checkSelfQualityRow( self, 'setStandardQualityScale' )
local standard = qualityScale:new()
end
-- Sets the extended quality scale with default settings.
function qualityRow:setExtendedQualityScale()
local extended = qualityScale:new()
extended:setExtendedQualityScale()
Line 929 ⟶ 926:
end
-- Sets the
function banner:
checkSelfBanner( self, '
s = checkString( s )
if s then
self.
end
end
-- Gets the
function banner:
checkSelfBanner( self, '
return self.
end
-- Sets the main article.
function banner:setMainArticle( s )
checkSelfBanner( self, 'setMainArticle' )
s = checkString( s )
if s then
self.mainArticle = s
end
end
-- Gets the main article.
function banner:getMainArticle()
checkSelfBanner( self, 'getMainArticle' )
return self.mainArticle
end
-- Gets the main text.
function banner:getMainText()
checkSelfBanner( self, 'getMainText' )
return self.mainText
end
-- Sets the name of the image on the left-hand side of the banner.
function banner:setLeftImage( s )
checkSelfBanner( self, 'setLeftImage' )
s = checkString( s )
if s then
self.leftImage = s
end
end
-- Sets the name of the image on the left-hand side of the banner.
function banner:setLeftImage( s )
checkSelfBanner( self, 'setLeftImage' )
s = checkString( s )
if s then
self.leftImage = s
end
end
-- Gets the name of the image on the left-hand side of the banner.
function banner:getLeftImage()
checkSelfBanner( self, 'getLeftImage' )
return self.leftImage
end
-- Sets the name of the image on the right-hand side of the banner.
function banner:setRightImage( s )
checkSelfBanner( self, 'setRightImage' )
s = checkString( s )
if s then
self.rightImage = s
end
end
-- Gets the name of the image on the right-hand side of the banner.
function banner:getRightImage()
checkSelfBanner( self, 'getRightImage' )
return self.rightImage
end
-- Sets the size of the image on the left-hand side of the banner when it is displayed in small mode.
function banner:setLeftImageSizeSmall( s )
checkSelfBanner( self, 'setLeftImageSizeSmall' )
s = checkString( s )
if s then
self.leftImageSizeSmall = s
end
end
-- Gets the size of the image on the left-hand side of the banner when it is displayed in small mode.
function banner:getLeftImageSizeSmall()
checkSelfBanner( self, 'getLeftImageSizeSmall' )
return self.leftImageSizeSmall or '40px'
end
-- Sets the size of the image on the left-hand side of the banner when it is displayed in normal mode.
function banner:setLeftImageSizeLarge( s )
checkSelfBanner( self, 'setLeftImageSizeLarge' )
s = checkString( s )
if s then
self.leftImageSizeLarge = s
end
end
-- Gets the size of the image on the left-hand side of the banner when it is displayed in normal mode.
function banner:getLeftImageSizeLarge()
checkSelfBanner( self, 'getLeftImageSizeLarge' )
return self.leftImageSizeLarge or '80px'
end
-- Sets the size of the image on the right-hand side of the banner when it is displayed in small mode.
function banner:setRightImageSizeSmall( s )
checkSelfBanner( self, 'setRightImageSizeSmall' )
s = checkString( s )
if s then
self.rightImageSizeSmall = s
end
end
-- Gets the size of the image on the right-hand side of the banner when it is displayed in small mode.
function banner:getRightImageSizeSmall()
checkSelfBanner( self, 'getRightImageSizeSmall' )
return self.rightImageSizeSmall or '40px'
end
-- Sets the size of the image on the right-hand side of the banner when it is displayed in normal mode.
function banner:setRightImageSizeLarge( s )
checkSelfBanner( self, 'setRightImageSizeLarge' )
s = checkString( s )
if s then
self.rightImageSizeLarge = s
end
end
-- Gets the size of the image on the right-hand side of the banner when it is displayed in normal mode.
function banner:getRightImageSizeLarge()
checkSelfBanner( self, 'getRightImageSizeLarge' )
return self.rightImageSizeLarge or '80px'
end
Line 1,052 ⟶ 1,169:
checkSelfBanner( self, 'exportAssessmentHeader' )
-- TODO: add this code.
end
-- Gets the page type.
function banner:getPageType( args )
checkSelfBanner( self, 'getPageType' )
return 'page' -- TODO: add the proper code.
end
Line 1,058 ⟶ 1,181:
checkSelfBanner( self, 'export' )
args = type( args ) == 'table' and args or {}
-- Get external modules.
local makePortal = require( 'Module:Portal' ).portal
local makeNavbar = require( 'Module:Navbar' ).navbar
-- Get the page type.
local pageType = self:getPageType( args )
-- Get the row output.
local rowOutput = {}
self.rows = self.rows or {}
Line 1,064 ⟶ 1,196:
end
rowOutput = table.concat( rowOutput )
-- Get the main text.
local mainText = self:getMainText()
if not mainText then
local mainArticle = self:getMainArticle()
if mainArticle then
local mainArticleObj = mw.title.new( mainArticle )
if mainArticleObj.exists then
mainArticle = mw.ustring.format( '[[%s]]', mainArticle )
end
else
local projectObj = mw.title.new( self:getProject() )
if projectObj.exists then
mainArticle = mw.ustring.format( '[[%s]]', self:getProject() )
end
end
mainText = mw.ustring.format(
"This %s is within the scope of '''[[%s|%s]]''', a collaborative effort to improve the coverage of %s on Wikipedia.",
pageType, self:getProjectLink(), self:getProjectName(), mainArticle
)
if not yesno( args.small ) then
local projectLinkObj = mw.title.new( self:getProjectLink() )
local projectTalk = projectLinkObj.talkPageTitle
projectTalk = projectTalk and projectTalk.prefixedText
local discussionLink = projectTalk and mw.ustring.format( '[[%s|discussion]]', projectTalk ) or 'discussion'
mainText = mw.ustring.format(
'%s If you would like to participate, please visit the project page, where you can join the %s and see a list of open tasks.',
mainText, discussionLink
)
end
end
-- Build the banner table.
Line 1,124 ⟶ 1,287:
.addClass( 'wpb-assessment_cat' )
.wikitext( self:getAssessmentCategory() )
local mainDisplayArea = root
.tag( 'tr' )
.tag( 'td' )
Line 1,139 ⟶ 1,301:
.css( 'border-spacing', '0' ) -- html5 replacement for cellspacing="0"
.css( 'border-collapse', 'collapse' ) -- this (apparently) emulates cellspacing="0" in Internet Explorer 5-7
.tag( 'tr' )
if self:getLeftImage() then
mainDisplayArea
.tag( 'td' )
.addClass( 'mbox-image' )
.css( 'padding', '2px 0' )
.wikitext( mw.ustring.format(
'[[File:%s|%s|alt=WikiProject icon]]',
self:getLeftImage(),
yesno( args.small ) and self:getLeftImageSizeSmall() or self:getLeftImageSizeLarge()
) )
else
mainDisplayArea
.tag( 'td' )
.addClass( 'mbox-empty-cell' )
end
mainDisplayArea
.tag( 'td' )
.addClass( 'mbox-text' )
.wikitext( self:getPortal() and yesno( args.small ) and makePortal( getPortal() ) )
.wikitext( makeNavbar{
self:getBannerName(),
mini = '1',
style = 'float:right; clear:right; margin:-1em 0.1em; display:none;'
} )
.wikitext( mainText )
return tostring( root )
end
|