Jump to content

Template talk:Track listing

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Template talk:Tracklist)

Change ids to classes?

[edit]

@User:Gonnym: You added a feature 4 years ago, where ids where added. This causes an issue where there is more than one track listing for an album, like when an album is slightly different in different continents (one or more songs added/removed). Those albums now show up at Special:LintErrors/duplicate-ids as unsupported by Parsoid, the new parser. Can this use classes instead, like shown below? line 166:

:attr('id', string.format(cfg.track_id, self.number))
+
:attr('class', string.format(cfg.track_id, self.number))

Snævar (talk) 16:42, 26 November 2024 (UTC)[reply]

Did you test to see if changing to class still allows using it as a anchor? Gonnym (talk) 14:15, 29 November 2024 (UTC)[reply]

The quotes

[edit]

I want to know how the " quotes came out automatically.. Camilasdandelions (talk!) 23:26, 22 March 2025 (UTC)[reply]

Incomplete sentence structures?

[edit]

It appears that whenever the "all_writing = " part of the template is used, the sentence that comes out always lacks a period. Liam Gallagher John Squire, for example, lacks the full stop after "All tracks are written by John Squire". Could this issue be properly addressed? Frank(has DemoCracy DeprivaTion) 12:37, 13 April 2025 (UTC)[reply]

Fixed. I didn't test this at all, so there may be unintended consequences. – Jonesey95 (talk) 08:23, 14 April 2025 (UTC)[reply]
Is this to be permanently implemented? There are now countless articles with this template containing ".." at the end. I feel like this change was too late.
Is it possible to alter the template to ignore periods/full stops at the end of the text in the parameter altogether so that a single instance is guaranteed? Otherwise, I think the change should be reversed. Fundgy (talk) 19:37, 8 May 2025 (UTC)[reply]
Additional comment pertaining to unintended consequences: see The_Car_(album). When forcing a period/full stop at the end, that includes periods/full stops after citations. Fundgy (talk) 19:42, 8 May 2025 (UTC)[reply]
This looks like it was inadequate design from the start. Perhaps the change should be undone, but what should the guidance be on putting full stops in the parameter values? This is what some of the code in Module:Track listing and Module:Track listing/configuration looks like now:
[Track listing:]
function TrackListing:makeIntro()
	if self.all_writing then
		return string.format(cfg.tracks_written, self.all_writing)
	elseif self.all_lyrics and self.all_music then
		return mw.message.newRawMessage(
			cfg.lyrics_written_music_composed,
			self.all_lyrics,
			self.all_music
		):plain()
	elseif self.all_lyrics then
		return string.format(cfg.lyrics_written, self.all_lyrics)
	elseif self.all_music then
		return string.format(cfg.music_composed, self.all_music)
	else
		return nil
	end
end

[Track listing/configuration:]
    tracks_written = 'All tracks are written by %s.',
	lyrics_written_music_composed = 'All lyrics are written by $1; all music is composed by $2.',
	lyrics_written = 'All lyrics are written by %s.',
	music_composed = 'All music is composed by %s.',
Another option is for some clever programmer to strip duplicate full stops, and to also account for the possibility of references at the end of the parameter value. – Jonesey95 (talk) 20:23, 8 May 2025 (UTC)[reply]
To my understanding, this uses Lua which I'm not horribly familiar with, but with that in mind, here's a code that I hope fixes it, or at least is in the right direction. The drawback of this method are the cases where "< ... >" exists in the middle of the string, and I have not addressed the "lyrics_written_music_composed" parameter. Feel free to change the name of the function if there's a more suitable one.
::::[Track listing:]
::::function fullstop(a)
::::  local pattern = '%<.*%>'
::::  x, y = a:gsub(pattern,""):gsub('%.*$',''), a:match(pattern)
::::  if not y then
::::    return x .. '.'
::::  else
::::    return x .. '.' .. y
::::  end
::::end
::::function TrackListing:makeIntro()
::::	if self.all_writing then
::::		return string.format(cfg.tracks_written, fullstop(self.all_writing))
::::	elseif self.all_lyrics and self.all_music then
::::		return mw.message.newRawMessage(
::::			cfg.lyrics_written_music_composed,
::::			self.all_lyrics,
::::			self.all_music
::::		):plain()
::::	elseif self.all_lyrics then
::::		return string.format(cfg.lyrics_written, fullstop(self.all_lyrics))
::::	elseif self.all_music then
::::		return string.format(cfg.music_composed, fullstop(self.all_music))
::::	else
::::		return nil
::::	end
::::end
::::[Track listing/configuration:]
::::    tracks_written = 'All tracks are written by %s',
::::	lyrics_written_music_composed = 'All lyrics are written by $1; all music is composed by $2.',
::::	lyrics_written = 'All lyrics are written by %s',
::::	music_composed = 'All music is composed by %s',
::::
Fundgy (talk) 23:11, 8 May 2025 (UTC)[reply]
Go to my user page: User:Fundgy if you want a cleaner version of the code since it turned out messy here. I also make an attempt at the "lyrics_written_music_composed" parameter. Fundgy (talk) 23:19, 8 May 2025 (UTC)[reply]
Module:Track listing/sandbox is available for you to edit. You can then put examples in Template:Track listing/testcases to compare the current live template and module with the sandbox version. – Jonesey95 (talk) 00:42, 9 May 2025 (UTC)[reply]
I just noticed a bunch of pages which now have All music is composed by [Composer], except where noted:. Do these changes take colons into account, or just periods? - adamstom97 (talk) 07:59, 9 May 2025 (UTC)[reply]
Working on it. That problem isn't hard to address in my code. Fundgy (talk) 08:13, 9 May 2025 (UTC)[reply]
Something to consider: it might be easier to make the instructions clear and then track instances that do not end in a period (full stop). – Jonesey95 (talk) 15:52, 9 May 2025 (UTC)[reply]
Have you seen the sandbox/testcases yet? All I have is the one issue of citations being included in the middle of the text, but it's endlessly frustrating. See Test Case 4. The code is a matter of parsing the tags in the string, and I'm not entirely sure how to do it without using other Wikipedia modules that may change on their own. Lua patterns just don't appear to be good enough.
I do have a suggestion though, one which I'm going to start doing, which I doubt will take long:
In all the cases without parser tags (i.e. <ref>, <nowiki>, etc.), what if I make it so the colons and periods are implied? No matter what, it's still a better situation than the current one, I don't currently see any bugs happening this way.
Sorry for the delay, btw. Fundgy (talk) 16:42, 9 May 2025 (UTC)[reply]
Done! Test cases turned out like I thought they would. Let me know what you think. I do think that the cases where citations arerer included are likely to be small in number, anyway, so I don't think it's much of an issue that those don't get the automatic punctuation. Fundgy (talk) 17:09, 9 May 2025 (UTC)[reply]
FYI, I submitted a request to the config page. Fundgy (talk) 19:42, 9 May 2025 (UTC)[reply]

Template-protected edit request on 9 May 2025

[edit]

Change lines 41-44 from:

	tracks_written = 'All tracks are written by %s.',
	lyrics_written_music_composed = 'All lyrics are written by $1; all music is composed by $2.',
	lyrics_written = 'All lyrics are written by %s.',
	music_composed = 'All music is composed by %s.',

to:

    tracks_written = 'All tracks are written by %s',
	lyrics_written_music_composed = 'All lyrics are written by $1; all music is composed by $2',
	lyrics_written = 'All lyrics are written by %s',
	music_composed = 'All music is composed by %s',

The ultimate purpose is to both fix and upgrade the punctuation system for the above parameters, which is currently bugged, resulting in sitations where the output text graft periods/full stops to possibly existing punctuation. Some (as of this request) examples:

This edit to the config, along with the intended companion edit to Module:Track listing, would not negatively affect articles where editors have individually corrected the current bug since its implementation, as it mostly serves as a revert. The only catch is that the proposed edits must be done in the correct order (i.e. the config first). Fundgy (talk) 19:42, 9 May 2025 (UTC)[reply]

@Fundgy:  Done. Est. 2021 (talk · contribs) 01:36, 11 May 2025 (UTC)[reply]

Template-protected edit request on 11 May 2025

[edit]

Description of suggested change:

Change lines 295-311 of Module:Track listing from:

function TrackListing:makeIntro()
	if self.all_writing then
		return string.format(cfg.tracks_written, self.all_writing)
	elseif self.all_lyrics and self.all_music then
		return mw.message.newRawMessage(
			cfg.lyrics_written_music_composed,
			self.all_lyrics,
			self.all_music
		):plain()
	elseif self.all_lyrics then
		return string.format(cfg.lyrics_written, self.all_lyrics)
	elseif self.all_music then
		return string.format(cfg.music_composed, self.all_music)
	else
		return nil
	end
end

to:

--------------------------------------------------------------------------------
-- Function for automatic punctuation for parameters:
--      all_writing, all_lyrics, all_music
-- Punctuation defaults to '.' unless ':' or '.' already exist
-- Automatic punctuation limited to parameter values not containing parser tags
--      i.e. <ref>Text</ref>, <nowiki></nowiki>, etc.
--------------------------------------------------------------------------------
function fullstop(a)
  if a ~= mw.text.killMarkers(mw.getCurrentFrame():preprocess(a)) or 
     a:sub(-1,-1) == ":" or 
     a:sub(-1,-1) == "." then
  	return a
  else
  	return a .. '.'
  end
end

function TrackListing:makeIntro()
	if self.all_writing then
		return string.format(cfg.tracks_written, fullstop(self.all_writing))
	elseif self.all_lyrics and self.all_music then
		return mw.message.newRawMessage(
			cfg.lyrics_written_music_composed,
			self.all_lyrics,
			fullstop(self.all_music)
		):plain()
	elseif self.all_lyrics then
		return string.format(cfg.lyrics_written, fullstop(self.all_lyrics))
	elseif self.all_music then
		return string.format(cfg.music_composed, fullstop(self.all_music))
	else
		return nil
	end
end

This is the edit to the primary module which required the recently-implemented edit to the config. This upgrades the parameters all_writing, all_lyrics, and all_music to output with automatic punctuation in most cases. The added function, "fullstop", works as such:

  • If parameter value contains any parser tags, or if the parameter already ends with ":" or ".", then don't alter anything.
  • Otherwise, add "." to the end of the parameter value.

The function is then applied to the aforementioned parameters within the already-existing function "TrackListing:makeIntro()". Note: in the case where all_lyrics and all_music are both present, it is important to only apply the function to all_music as shown above.

If implemented, feel free to alter the comments at the top or the function name for clarity if necessary. Fundgy (talk) 14:21, 11 May 2025 (UTC)[reply]

@Fundgy:  Done. Est. 2021 (talk · contribs) 04:37, 12 May 2025 (UTC)[reply]