http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95420

Revision: 95420
Author:   wikinaut
Date:     2011-08-24 19:20:03 +0000 (Wed, 24 Aug 2011)
Log Message:
-----------
+detecting also VIAF, VIAF1, VIAF2 .. VIAF9. someone needs that

Modified Paths:
--------------
    trunk/tools/viaf/README
    trunk/tools/viaf/viaf.user.js

Modified: trunk/tools/viaf/README
===================================================================
--- trunk/tools/viaf/README     2011-08-24 19:18:03 UTC (rev 95419)
+++ trunk/tools/viaf/README     2011-08-24 19:20:03 UTC (rev 95420)
@@ -3,16 +3,19 @@
 
 *** detailed information page will follow ***
 
-Version: 0.200
+Version: 0.203
 
-VIAF numbers:
+What are VIAF numbers ?
+
   http://en.wikipedia.org/wiki/Wikipedia:Authority_control#VIAF
   "The VIAF ID corresponding to the subject of the article can be found on
   http://viaf.org, which combines authority records from many organizations
   worldwide into single datasets..."
   
 The viaf.user.js script tries to generously detect VIAF numbers as part of a 
web
-page's text, and also as part of links (urls).
+page's text, and also as part of links (urls). It detects them also as part
+of texts like " ... VIAF2= ..." (see program code of viaf.user.js for details)
+by applying some magic regular expressions.
 
 Detected numbers are indicated with bright cyan colour to attract the
 user's attention.
@@ -23,11 +26,14 @@
 url, i.e. are deep links (single-click solution).
 
 Those VIAF numbers which are only part of a url (i.e not in the text) are not
-apparent without this script. Numbers as part of urls are treated in the same
-way as numbers in the text. The script adds a dotted red underline to urls 
which
-contain a VIAF which is detected by matching a magic regular expression
+apparent - without using this script. Numbers as part of urls are treated in 
the
+same way as numbers in the text. The script adds a dotted red underline to urls
+which contain a VIAF and when matching a magic regular expression
 (see program code for details).
 
+The VIAF number is then extracted from the url and also shown on the page
+in cyan colour with a black dotted underline as indication.
+
 A summary box (6) lists all distinct VIAF numbers to facilitate cut & paste of
 the extracted numbers; this can be disabled in the program code.
 
@@ -37,3 +43,8 @@
 versions of it and prompts the user in such case.
 
 It does not automatically install a newer version.
+
+== To Do ==
+* revise and enable the update mechanism
+* add a user-interface or mechanism to enable/disable the summary alert box
+  without the need to change program code

Modified: trunk/tools/viaf/viaf.user.js
===================================================================
--- trunk/tools/viaf/viaf.user.js       2011-08-24 19:18:03 UTC (rev 95419)
+++ trunk/tools/viaf/viaf.user.js       2011-08-24 19:20:03 UTC (rev 95420)
@@ -4,7 +4,7 @@
 // @require       
https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
 // @require        
http://svn.wikimedia.org/svnroot/mediawiki/trunk/tools/viaf/jquery.cookie.js
 // @require        
http://svn.wikimedia.org/svnroot/mediawiki/trunk/tools/viaf/jquery.ba-replacetext.js
-// @description    locate VIAF numbers in texts and urls on web pages. (c) 
T.Gries Version 0.201 201108240720
+// @description    locate VIAF numbers in texts and urls on web pages. (c) 
T.Gries Version 0.203 201108242100
 // @include        *
 // ==/UserScript==
 
@@ -28,7 +28,7 @@
  * 20110824     added google link
  *              imported as a new project to svn.wikimedia.org;
  *              updated the require paths to pull required javascripts from 
there
- *
+ *              detection of VIAF, VIAF2 .. VIAF9
  ***/
 
 // wrapper see http://www.mediawiki.org/wiki/JQuery
@@ -42,7 +42,7 @@
 var maxVIAFNumbers = 30;
 
 // Script update checker source: http://a32.me/2009/11/greasemonkey/
-var VERSION = "0.201";
+var VERSION = "0.203";
 var SCRIPT_NAME = "viaf"
 var SCRIPT_URL = "http://$$$yourhost$$$/"+SCRIPT_NAME+".user.js";
 
@@ -105,9 +105,8 @@
 // but don't look in an active textareas like mediawiki input textarea
 
 $("body *:not(textarea)")
-       .replaceText( /(viaf)(:|\/|%3A|%2F|\s|ID:|=|%3D)*([0-9]+)/gi, 
"$1$2<span class='viaf' viaf='$3'>$3</span" );
+       .replaceText( /(viaf[1-9]?)(:|\/|%3A|%2F|\s|ID:|=|%3D)+([0-9]+)/gi, 
"<span class='viaf viaf-in-text' viaf='$3'>$1$2$3</span>" );
 
-
 // PASS 2
 // try to retrieve viaf numbers in urls
 
@@ -121,7 +120,7 @@
        if ( typeof url != "undefined" && url.match( magicUrlRegExp ) ) {
                if ( markUrlDetectedItems ) $this.css( markUrlDetectedItemsCSS 
);
                var viaf = RegExp.$1.replace( /[\D]*/g, '' );
-               $this.after( $("<span class='viaf' 
viaf='"+viaf+"'>&nbsp;"+viaf+"</span>") );
+               $this.after( $("<span class='viaf viaf-in-url' 
viaf='"+viaf+"'>&nbsp;"+viaf+"</span>") );
        }
 
 })
@@ -142,7 +141,7 @@
        newLink.unshift( $( "<span> <a 
href='http://yi.librarything.com/commonknowledge/search.php?f=13&exact=1&q=VIAF%3A"+viaf+";'
 class='addedlink viaf' viaf='"+viaf+"'>yi</a></span>" ) );
        newLink.unshift( $( "<span> <a 
href='http://toolserver.org/%7Eapper/pd/person/viaf/"+viaf+";' class='addedlink 
viaf' viaf='"+viaf+"'>TS</a></span>" ) );
        newLink.unshift( $( "<span> <a 
href='http://www.google.com/search?num=100&q=viaf+"+viaf+";' class='addedlink 
viaf' viaf='"+viaf+"'>G</a></span>" ) );
-        // newLink.unshift( $( "<label class='show-summary'><input 
type='checkbox' class='show-summary-checkbox' checked='checked'><span 
id='show-summary-text'></span></label>" ) );
+       // newLink.unshift( $( "<label class='show-summary'><input 
type='checkbox' class='show-summary-checkbox' checked='checked'><span 
id='show-summary-text'></span></label>" ) );
 
        // add a space as the last character after the last added links
         newLink.unshift( $("<span> </span>") );
@@ -167,6 +166,9 @@
 // style all detected numbers
 $( ".viaf" ).css( { "background":"cyan", "color":"black" } );
 
+// style all detected numbers in urls
+$( ".viaf-in-url" ).css( "border-bottom", "1px dotted black" );
+
 // style all added links
 $( ".addedlink" ).css( { "background":"yellow" , "color":"black" } );
 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to