I had time between 1:1s today to solve a wiki problem that’s been nagging me. My codes, let me show you them.
Problem: We have meetings.
What’s worse, we persist in having them every week. Being the kind of project we are, we keep agendas and notes from those meetings publicly and invite the community to participate (does your browser? Great!)
What you want, then, is for each week’s meeting notes to link to next week’s and last week’s, like such:
And so, we do. But those links have to be hand-edited every week. Indeed, the pages for various meeting notes have earnest, heart-wrenching pleas in HTML comments, like
<!– REPLACE YYYY-MM-DD with the previous and next week’s year-month-date –>
No one should have to live like that.
Solution: ParserFunctions
Our mediawiki install includes the ParserFunctions extension, which has a whole bag of tricks. One of these tricks is {{#time}}. #time lets you produce various kinds of time/date strings, to wit:
{{#time: Y-m-d }}
Particularly nice, though, is that you can specify relative times, e.g.
{{#time: Y-m-d|+1 week}}
The relative syntax is so flexible, in fact, that I can utter this monstrosity:
[[Platform/{{#time: Y-m-d|tuesday last week}}|« previous week]]
to link to last week’s notes from a given page!
Still with me? Because there’s one snag left. The above works for people who have a static front page with this week’s info, and only ever want to link one week back. But those relative dates are relative to now — what if I want each link in the chain to link to the week prior?
No problem — our pages are named according to their dates, so just make the link relative to that, instead:
[[Platform/{{#time: Y-m-d | {{SUBPAGENAME}} -1 week}}|« previous week]]
Presto.
The things you learn while waiting for a phone call. If you want to get really exciting, you can do all this in transclusion tags, to have last week’s notes automatically added to this week, but that’s left as a terrifyingly-recursive exercise for the reader.
What’s your favourite mediawiki hack?
(PS – Full credit to Melissa for giving me the idea in the first place. I am naught but the implementor.)
Just the fact that somebody can write something as impossible to read as http://dnd-wiki.org/wiki/Template:Pipe_Trick&action=edit is my favorite aspect of Mediawiki. (We are trying to install LISP and replace it with something readable)
The date portion of parser functions looks awesome.
Yeah, you can do pretty crazy stuff with MediaWiki template programming. You’ve only scratched the tip of the iceberg. Unfortunately, it’s one of the most ugly and inefficient programming languages known to man. If you ever want help, #mediawiki on freenode will probably provide it.
(I expect people to be enthusiastic if you make sure to mention you’re a Mozilla developer and are doing it for the Mozilla wiki — we always like to help out other open-source projects. Most of the people who ask for help are doing it for an internal company wiki, or a wiki about, like, shoes. Or furries. Really. Actually, I think the guy with the furries wiki got commit access a while back.)
I still want to copy what metrics does on the intranet, check /Metrics#Meeting_Notes. They actually fill out a template from a form, sounds like the two would nicely complement each other.
Sadly, this doesn’t work on the Mozilla intranet..