Creating a TODO list in MediaWiki with Cargo


When I'm editing items on ArchivesWiki I often want to leave notes about things that need to be followed up, and for a while have been using a simple {{todo}} template for this purpose. It just displayed a simple [TODO] superscript that linked to a category of pages. Its source was just:

<sup>''<nowiki>[</nowiki>[[:Category:To be done|TODO]]{{#if:{{{1|}}}|&nbsp;– {{{1|}}}}}]''</sup>{{#ifeq: {{NAMESPACE}} | Template | |[[Category:to be done]] }}

Which, as usual for anything using ParserFunctions conditionals, isn't very readable. It also didn't let me easily see a list of the pages along with what needed to be done with them. So I decided to add a 'comment' field to the template, and add a Cargo table so that the page name and comment could be displayed together on a todo overview page.

The template:

{{#cargo_declare: _table = todos | comment = String }}
{{#cargo_store: _table = todos | comment = {{{1|}}} }}
</includeonly>{{#invoke: todo | main | comment={{{1|}}} }}<noinclude>{{documentation}}</noinclude>

The module:

local p = {}
p.main = function ( frame )
    local args = frame.args

    local sup = mw.html.create( 'sup' )
    sup:attr( 'class', 'todo' )

    local em = sup:tag( 'em' )
    em:wikitext( mw.text.nowiki( '[' ), '[[Project:To be done|TODO]]' )
    if args.comment ~= nil and args.comment ~= '' then
        em:wikitext( '&nbsp;&ndash; ' .. args.comment )
    em:wikitext( mw.text.nowiki( ']' ) )

    return tostring( sup )
return p

The summary table:

{{#cargo_query: tables = todos
 | fields = _pageName=Page, comment=Comment
 | format = table

You can see it all in action here.

Retrieved from ‘