Module:Self
Appearance
![]() | This module depends on the following other modules: |
![]() | This module uses TemplateStyles: |
This module should not be used directly in the content namespace.
Usage
{{#invoke:Self|main}}
local p = {}
function p.decide_migration(args)
if args['migration'] then
return args['migration']
end
local licsense_migration_data = mw.loadJsonData( 'Module:Self/license_migration_data.json')
for _, template_name in ipairs(args) do
local migration_data = licsense_migration_data[string.lower(template_name)]
if migration_data == 'redundant' then
return licsense_migration_data
end
end
return ''
end
function p.setup_template_params(template_name, args)
return mw.ustring.format(
'{{%s|dw=%s|date=%s|migration=%s}}',
template_name,
args['dw'] or 'no',
args['date'] or '',
args['migration'])
end
function p.more_than_one(args)
local c = 0
for _, __ in ipairs(args) do
c = c + 1
if c == 2 then
return true
end
end
return false
end
function p.start_line(args)
local more_than_one = p.more_than_one(args)
return mw.ustring.format(
'%s , the copyright holder of this work,\'\'\' hereby publish%s, it under the following license%s:',
args['author'] or 'I',
args['author'] and 'es' or '',
more_than_one and 's' or ''
)
end
function p.categories(args)
local currentTitle = mw.title.getCurrentTitle()
local is_in_file_namespace = currentTitle.nsText == 'File'
if not is_in_file_namespace then
return ''
end
if args['author'] then
return mw.ustring.format('[[Category:Files licensed by third parties|%s]]', currentTitle.fullText)
else
return mw.ustring.format('[[Category:Self-published work|%s]]', currentTitle.fullText)
end
end
function p.main(frame)
local args = frame.args
local fmt_string_tmpl = '<div class="wp-tmpl-self-license-wrapper"><div class="center">%s</div><div class="center">%s</div>%s</div>%s'
local initial_text = p.start_line(args)
local final_line = p.more_than_one(args) and "<div class='center'>''You may select the license of your choice.''</div>" or ''
local categories = p.categories(args)
local templates = ''
args['migration'] = p.decide_migration(args)
for _, template_name in ipairs(args) do
templates = templates .. p.setup_template_params(template_name, args)
end
return mw.ustring.format(fmt_string_tmpl, initial_text, templates, final_line, categories)
end
return p