package votorola.s.gwt.mediawiki; // Copyright 2012-2014, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.dom.client.*; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.RootPanel; import votorola.a.voter.*; import votorola.a.web.gwt.*; import votorola.g.web.gwt.*; import votorola.s.gwt.stage.*; /** The GWT entry module for embedding the Crossforum Theatre {@linkplain * votorola.s.gwt.stage.Stage stage} in MediaWiki pages. An instance of this class is * automatically constructed and invoked per module definition MediaWikiIn.gwt.xml. * *
The following configuration properties are specific to this entry module. These * are properties of global JavaScript object {@linkplain GWTConfig window.voGWTConfig}. * The short name (SHORT) of each is fully qualified as * "window.voGWTConfig.s_gwt_mediawiki_SHORT".
* *Short name | *Form | *Value | *Default | *
---|---|---|---|
toTop | * *boolean | * *Specify true for {@linkplain #insertStageVTop(JavaScriptObject) top * insertion} of the stage. Otherwise the stage is placed as for * remote drafting. | * *false | * *
Injection embeds the stage in a web page. Common patterns of injection are * documented in the sections below.
* ** * // Crossforum Theatre stage. * // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * // module.css and gwt.js must load before boot script nocache.js * // http://reluk.ca/project/votorola/_/javadoc/votorola/s/gwt/mediawiki/MediaWikiIn.html * * if( $.client.profile().name != 'msie' ) // all but IE [1] * { * voInject = function() // implicitly declared so deletable below * { * if( !window.voGWTConfig ) voGWTConfig = {}; * else if( window.voGWTConfig.s_gwt_mediawiki_isInjected ) return; * // guard against double injection by both admin and user scripts * * window.voGWTConfig.s_gwt_mediawiki_isInjected = true; * window.voGWTConfig.s_gwt_mediawiki_toTop = true; * var context = '{@linkplain App#getServletContextLocation() CONTEXT}'; * document.write( "<link href='" + context // [2] * + "/mediawiki/module.css' rel='stylesheet' type='text/css'/>" ); * document.write( "<script src='" + context // [3] * + "/w/publicConfig/gwt.js' type='text/javascript'></script>" ); * document.write( "<script src='" + context // [3] * + "/votorola.s.gwt.mediawiki.MediaWikiIn/votorola.s.gwt.mediawiki.MediaWikiIn.nocache.js'" * + " type='text/javascript'></script>" ); * } * voInject(); * delete voInject; // clean up * } * * // * // NOTES * // * // [1] IE excluded by conditional compilation in MediaWiki 16 and earlier, thus: * // * // /*@cc_on @if( false ) @*/ * // /*@end @*/ * // * // And by JQuery in MediaWiki 17 and later, thus: * // * // if( $.client.profile().name != 'msie' ) * // * // [2] For MediaWiki 16 and earlier, would ordinarily use: importStylesheetURI( URL ) * // For MediaWiki 17 and later: mw.loader.load( URL, 'text/css' ) * // http://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_%28users%29 * // * // But instead write to ensure CSS link element precedes script element, else layout * // may be unstable: http://mail.zelea.com/list/votorola/2012-November/001540.html * // * // [3] Scripts might instead be injected asynchronously using MediaWiki's mw.loader or * // importScriptURI. We are no longer using the old cross-site linker ('xs') that * // writes to the document. But asynchronous injection has not been tested yet. * //* *
<ELEMENT id='bodyContent'/>
and inserts a newly
* constructed {@linkplain StageV stage view} as its first child, which will normally
* render just beneath the tabs and other navigation controls of the wiki (or if
* ELEMENT cannot be located, then it defaults to {@linkplain
* #insertStageVTop(JavaScriptObject) top insertion}). To install it add the following
* to MediaWiki:Common.js or your
* personal script/user script,
* substituting the correct value for CONTEXT:* * // Crossforum Theatre stage for remote drafting. * // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * // module.css and gwt.js must load before boot script nocache.js * // http://reluk.ca/project/votorola/_/javadoc/votorola/s/gwt/mediawiki/MediaWikiIn.html * * if( $.client.profile().name != 'msie' ) // all but IE [1] * { * voInject = function() // implicitly declared so deletable below * { * var toInject = false; * for( var c = wgCategories.length - 1; c >=0; --c ) * { * var category = wgCategories[c]; * if( category == 'Remote draft' ) * { * toInject = true; // inject regardless for a remote draft page * break; * } * } * if( toInject ) * { * if( !window.voGWTConfig ) voGWTConfig = {}; * else if( window.voGWTConfig.s_gwt_mediawiki_isInjected ) return; * // guard against double injection by both admin and user scripts * * window.voGWTConfig.s_gwt_mediawiki_isInjected = true; * var context = '{@linkplain App#getServletContextLocation() CONTEXT}'; * document.write( "<link href='" + context // [2] * + "/mediawiki/module.css' rel='stylesheet' type='text/css'/>" ); * document.write( "<script src='" + context // [3] * + "/w/publicConfig/gwt.js' type='text/javascript'></script>" ); * document.write( "<script src='" + context // [3] * + "/votorola.s.gwt.mediawiki.MediaWikiIn/votorola.s.gwt.mediawiki.MediaWikiIn.nocache.js'" * + " type='text/javascript'></script>" ); * } * } * voInject(); * delete voInject; // clean up * } * * // * // NOTES * // * // (same as farther above) * //* *
As mentioned, this will ordinarily inject the stage only in remote draft pages. * You may create such pages with the help of the template provided * in the working examples farther below.
* *Note that the username of the logged in Votorola/Outcast user is not currently * detectable in MediaWiki pages external to the pollwiki. This means that user-oriented * links such as "my draft" in the {@linkplain votorola.s.gwt.stage.link.LinkTrackV link * track} will not be properly disabled when they are redundant, e.g. when "my draft" is * already being shown.
* *