Module:Format work
| This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
| This module depends on the following other modules: |
This module is invoked by {{format work}} |
Usage
This module returns details supplied about a creative work, formatted inline with MOS:DISCOGRAPHY or MOS:FILMOGRAPHY of MOS:WORKS, and suitable for display in an article list.
{{#invoke:Format work|main
| act = <!-- required; "Pink Floyd" or "[[Pink Floyd (band)|Pink Floyd]]" -->
| title = <!-- required; "The Dark Side of the Moon" or "[[The Dark Side of the Moon (album)|The Dark Side of the Moon]]" -->
| type = <!-- "minor" to override the default "major" -->
| label = <!-- for a musical release; "Harvest Records" or "[[Harvest Records|Harvest]]" -->
| distributor = <!-- for a film release; "Lionsgate Studios" or "[[Lionsgate Studios|Lionsgate]]" -->
| year = <!-- "1973" -->
| month = <!-- "3" -->
| day = <!-- "1" -->
| page = <!-- only if |day= is provided; "Pink Floyd discography" -->
| notes = <!-- "There is no dark side in the moon, really. Matter of fact, it's all dark." -->
}}
act and title
Required
|act=should be an artist, group, ensemble, actor etc.|title=should be the title of the creative work
Both values may be plain text or wikilinks; plain text will be automatically linked if a suitable matching article exists.
For example:{{#invoke:Format work|main
| act = Pink Floyd
| title = The Dark Side of the Moon
}}
Returns: Pink Floyd: The Dark Side of the Moon
{{#invoke:Format work|main
| act = [[Pink Floyd (band)|Pink Floyd]]
| title = [[The Dark Side of the Moon (album)|The Dark Side of the Moon]]
}}
Returns: Pink Floyd: The Dark Side of the Moon
type
By default, the |type= of the work is treated as "major"; use |type=minor to override this. See MOS:NAT for guidance.
{{#invoke:Format work|main
| act = Pink Floyd
| title = [[Eclipse (Pink Floyd song)|Eclipse]]
| type = minor
}}
Returns: Pink Floyd: "Eclipse"
label or distributor
For musical works, |label= may be used, and |distributor= may be used for films, if suitable.
{{#invoke:Format work|main
| act = Pink Floyd
| title = The Dark Side of the Moon
| label = [[Harvest Records|Harvest]]
}}
Returns: Pink Floyd: The Dark Side of the Moon (Harvest)
year and month
Providing a date must include a |year=; if no year is provided, |month= and |day= will be ignored.
{{#invoke:Format work|main
| act = Pink Floyd
| title = The Dark Side of the Moon
| year = 1973
}}
Returns: Pink Floyd: The Dark Side of the Moon (1973)
{{#invoke:Format work|main
| act = Pink Floyd
| title = The Dark Side of the Moon
| year = 1973
| month = 3
}}
Returns: Pink Floyd: The Dark Side of the Moon (March 1973)
day and page
If the |day= is provided, the date format will be automatically established via Module:Get article date format, which will return its default (day month year) unless an article |page= is provided. The article will be probed for explicit date formatting requirements established by use of {{use dmy dates}} or {{use mdy dates}}, or for implicit expectations due to an established English variant. The practical upshot should be for formatting lists of works on articles with established date formats, just provide the {{FULLPAGENAME}}.
{{#invoke:Format work|main
| act = Pink Floyd
| title = The Dark Side of the Moon
| year = 1973
| month = 3
| day = 1
}}
Returns: Pink Floyd: The Dark Side of the Moon (1 March 1973)
{{#invoke:Format work|main
| act = Captain Beefheart
| title = Trout Mask Replica
| year = 1969
| month = 6
| day = 16
| page = Captain Beefheart
}}
Returns: Captain Beefheart: Trout Mask Replica (June 16, 1969)
notes
{{#invoke:Format work|main
| act = Pink Floyd
| title = The Dark Side of the Moon
| notes = There is no dark side in the moon, really. Matter of fact, it's all dark.
}}
Returns: Pink Floyd: The Dark Side of the Moon – There is no dark side in the moon, really. Matter of fact, it's all dark.
Complete examples
{{#invoke:Format work|main
| act = Pink Floyd
| title = The Dark Side of the Moon
| label = [[Harvest Records|Harvest]]
| year = 1973
| month = 3
| day = 1
| page = Pink Floyd
| notes = There is no dark side in the moon, really. Matter of fact, it's all dark.
}}
Returns: Pink Floyd: The Dark Side of the Moon (Harvest, 1 March 1973) – There is no dark side in the moon, really. Matter of fact, it's all dark.
{{#invoke:Format work|main
| act = Captain Beefheart
| title = Trout Mask Replica
| label = [[Straight Records|Straight]]
| year = 1969
| month = 6
| day = 16
| page = Captain Beefheart
| notes = produced by [[Frank Zappa]]
}}
Returns: Captain Beefheart: Trout Mask Replica (Straight, June 16, 1969) – produced by Frank Zappa
Alarming messages
Alarming messages will be returned if values for the required |act= and |title= are not provided.
local MONTH_NAMES = {
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
}
local function _isEmpty(value) return value == nil or value == '' end
local function _notEmpty(value) return not _isEmpty(value) end
local function _unnilify(value) return value or '' end
local function _alarmingMessage(message)
return '<span class="error">[[Module:Format work]] '..message..'.</span>'
-- TODO .. '[[Category:Pages displaying alarming messages about Module:Format work]]'
end
-- TODO option to disable automatic linking in the event the result is incorrect
local function _link(name)
if mw.ustring.match(name, '%[%[.-%]%]') then
return name
end
-- Checking if there's content is cheaper than testing title_table.exists,
-- but still don't getContent of non-article title_tables.
local title_table = mw.title.new(name)
if _isEmpty(title_table) or not title_table:inNamespace(0) or _isEmpty(title_table:getContent()) then
return name
end
return '[['..name..']]'
end
local function _formatWork(args)
local act = _link(args.act)
local title = _link(args.title)
local release_type = args.type
if _isEmpty(release_type) or release_type:lower() == 'major' then
title = "''"..title.."''"
else
title = '"'..title..'"'
end
local parenthesized = {}
local label_distributor = _unnilify(args.label or args.distributor)
if _notEmpty(label_distributor) then
table.insert(parenthesized, _link(label_distributor))
end
local full_date = _unnilify(args.year)
if _notEmpty(full_date) then
local month = tonumber(args.month)
if month then
if _notEmpty(args.day) then
full_date = mw.getCurrentFrame():callParserFunction{
name = '#time',
args = {
require('Module:Get article date format').main({
page = args.page
}),
full_date..'-'..month..'-'..args.day
}
}
else
full_date = MONTH_NAMES[month]..' '..full_date
end
end
table.insert(parenthesized, full_date)
end
if #parenthesized > 0 then
parenthesized = ' ('..table.concat(parenthesized, ', ')..')'
else
parenthesized = ''
end
local notes = _unnilify(args.notes)
if _notEmpty(notes) then
notes = ' – '..notes
end
return act..': '..title..parenthesized..notes
end
local function _main(args)
if _isEmpty(args.act) then
return _alarmingMessage('requires an |act= value')
end
if _isEmpty(args.title) then
return _alarmingMessage('requires a |title= value')
end
-- TODO allow a format_string to sculpt the output?
return _formatWork(args)
end
local p = {}
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
if _isEmpty(args) then
return _alarmingMessage('could not getArgs') -- This really would be alarming.
end
return _main(args)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.