Extension:Mw(Ubiquity Script)
From MediaWiki.org
| mw | |
|---|---|
| Ubiquity Script | |
| Author | User:Plindenbaum |
| www | http://plindenbaum.blogspot.com |
| Download | http://yokofakun.googlepages.com/ubiquity.html |
This Mozilla ubiquity script creates a contextual menu and suggests an internal link in the current wikimedia installation. The keyword mw is the ubiquity keyword used by the extension.
Contents |
[edit] Requirements
- The API with the opensearch action must be enabled.
- The ubiquity extension must be installed.
[edit] Installation
Install this script from http://yokofakun.googlepages.com/ubiquity.html, or you can copy and paste the script below in the Ubiquity Editor.
[edit] Source
function apiurl() { var url=CmdUtils.getDocument( ).location.toString() ; var i= url.indexOf("/wiki/"); if(i!=-1) { url= url.substr(0,i); //try to find the best place where the api.php is installed, customization may be needed. if(url=="http://openwetware.org") return url+"/api.php"; url+="/w/api.php"; return url; } return "http://en.wikipedia.org/w/api.php"; } var noun_type_mwkw = { _name: "wikipedia keyword", suggest: function suggest( text, html, callback ) { jQuery.ajax( { url: apiurl(), dataType: "json", data: { "action":"opensearch", "search": text, "format":"json", "namespace":"0|14" }, success: function suggestTopics( content ) { var i; if(content==null || content.length!=2) return; for ( i = 0; i < content[1].length; i++ ) {Utils.reportInfo("C"+i); var result = "[["+content[1][i]+"]]"; callback( CmdUtils.makeSugg( result, result, result ) ); } } } ); return []; } } CmdUtils.CreateCommand({ name: "mw", icon: "http://upload.wikimedia.org/wikipedia/commons/3/3d/Mediawiki-logo.png", homepage: "http://plindenbaum.blogspot.com/", author: { name: "Pierre LIndenbaum", email: "plindenbaum@yahoo.fr"}, license: "GPL", description: "Insert a link for mediawiki/wikipedia", help: "help to do ", takes: {"input": noun_type_mwkw}, preview: function( pblock, input ) { var template = "[${name} ${name}]"; pblock.innerHTML = CmdUtils.renderTemplate(template, {name: "link"}); }, execute: function(input) { if(input==null || !input.data) return; CmdUtils.setSelection(input.data); } });
