Extension:HTML Tags/Implementing LRMI

HTML Tags was designed to support LRMI, or the Learning Resource Metadata Initiative, a metadata standard for open educational resources developed by Creative Commons. The full specification for LRMI can be found here. HTML Tags can also support the use of schema.org parameters with no additional work (except for adding schema.org parameters to the necessary templates,) and should be able to support most other metadata schemas with some tinkering.

Implementing LRMI with HTML Tags requires enabling two HTML tags, &lt;meta&gt; and &lt;span&gt;, since both of those tags are necessary to create LRMI metadata that verifies against Google’s rich text snippet testing tool. Although there are many ways to implement LRMI once these tags are enabled, we’ve written a series of templates that can be used for this purpose.

If you’d like to use LRMI on your wiki, you should be able to directly copy over these templates and successfully use them. If you try to implement this template structure and run in to any problems, please drop a note on the talk page here or email Max at isalix@undefinedgmail.com - we'd be more than happy to get you up and running with LRMI and HTML Tags.

LocalSettings.php
Add these lines to your LocalSettings.php file to set up HTML_Tags for LRMI: $wgHTMLTagsAttributes['meta'] = array( 'itemprop', 'content' ); $wgHTMLTagsAttributes['span'] = array( 'itemprop', 'itemscope', 'itemtype' );

is a template that can be used to tag a page with multiple LRMI properties at once. For most purposes, this is probably the template you will want to use to add LRMI data to your page. The template by default contains all LRMI properties, if any do not apply to your page you can simply leave them blank. This template is especially useful when used in conjunction with adding a button to the standard editing window with WikiEditor. It should be called in the following format:

Here’s the code for the template itself. It should work on any standard Mediawiki installation that has HTML Tags installed, meta and span tags enabled, and the dependent templates present.

is a template that can be used to tag a page with one specific LRMI property. In most situations it is desirable to use in place of this template, but we’ve included it anyway for comprehensiveness. It should be called in the following format:

Here’s the code for the template, which should work on any standard MediaWiki installation that has HTML Tags installed, the meta and span tags enabled, and the dependent templates present:

is a template called by and. It should be called in the following fashion:

Here’s the code for the template, which should work on any standard MediaWiki installation that has HTML Tags installed and the meta tag enabled:

is a template called by and. It should be called in the following fashion:

Here’s the code for the template, which should work on any standard MediaWiki installation that has HTML Tags installed and the meta tag enabled:

WikiEditor changes
Once you have implemented the LRMI template, you can add a button to the toolbar provided by the WikiEditor extension, so that users can easily add a stub call to this template on pages where they want to embed LRMI data. The easiest way to do this (though possibly not the ideal one) is to make changes directly to the WikiEditor code. Here is how you can do it; these changes work with at least WikiEditor version 0.3.1.

WikiEditor.php
Add the following lines, around line 140: 'wikieditor-toolbar-tool-file-insert', 'wikieditor-toolbar-tool-file-cancel', +                      'wikieditor-toolbar-tool-lrmi-insert', +                      'wikieditor-toolbar-tool-lrmi-insert-example', ),        ),

WikiEditor.i18n.php
Around line 274, add the following lines: 'wikieditor-toolbar-help-content-indent-syntax' => 'Normal text 'wikieditor-toolbar-help-content-indent-result' => 'Normal textIndented textIndented text 'Insert Learning Resource Metadata (LRMI) template', +      'wikieditor-toolbar-tool-lrmi-insert-example' => 'YY-YY', );
 * Indented text
 * Indented text',

modules/jquery.wikiEditor.toolbar.config.js
Add the following lines around line 182: 'options': { 'pre': "--~" }                                                        }                                                 }, +'lrmi-insert': { +'labelMsg': 'wikieditor-toolbar-tool-lrmi-insert', +       'type': 'button', +       'icon': { +               'default':'lrmi.png' +       }, +        'action': { +               'type': 'encapsulate', +               'options': { +                       'pre': "" +               } +        } +},                                         }                                 }

lrmi.png
Finally, download the image LRMI WikiEditor button.png, and save it as the file lrmi.png in the directory /modules/images/toolbar.