Added view source for ViewCVS in both quickbox and dropdown
authorKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Mon, 7 Jan 2008 19:27:49 +0000 (20:27 +0100)
committerKristian Kræmmer Nielsen <jkkn@jkkn.dk>
Mon, 7 Jan 2008 19:27:49 +0000 (20:27 +0100)
Changed url in quickbox to textbox
Added support for all types for folders in ViewCVS

content/quickbox.js
content/quickbox.xul
content/tv2developer.js
locale/da-DK/tv2developer.dtd
locale/da-DK/tv2developer.properties
locale/en-US/tv2developer.dtd
locale/en-US/tv2developer.properties
version

index 885e91d34c65b15231267486e98b873d4d8928b4..3e0efd81976cfdf2790f013a1f741a6ab8d0ba42 100644 (file)
@@ -98,6 +98,7 @@ var TV2DeveloperQuickBox = {
         if (target.id == 'action') {
             document.getElementById('sitetype').disabled = !makeSiteURL;
             document.getElementById('php5branch').disabled = (action != 'go-viewcvs');
+            document.getElementById('viewsource').disabled = (action != 'go-viewcvs');
             document.getElementById('environment').disabled = (action == 'go-viewcvs');
         }
         document.getElementById('php4site').disabled = (!makeSiteURL || action == 'go-pdolog' || action == 'go-viewcvs')
@@ -109,6 +110,7 @@ var TV2DeveloperQuickBox = {
                            document.getElementById('othertest');
                }
                this.updateQuickbox(true);
+               document.getElementById('shorturl').focus();
            }
        },
 
@@ -117,6 +119,8 @@ var TV2DeveloperQuickBox = {
     _reg_extract_nums: /([0-9]+)/g,
     _reg_shortlink: /^((https?):\/?\/?)?([^/]*?)(tv2\.dk)?((\/[^#\?]*).*)?$/,
     _reg_classname: /^[A-Z][a-zA-Z0-9_/]*(\.(p(hp?)?)?)?$/,
+    _reg_cvs_nopostfix: /^(?:archive|conf|default|phpincludes|symfoni|titoonic-includes)$/,
+    _reg_cvs_rootfolders: /^\/(((Java|build|inc|opdatering|robot|scripts|sql|template|views|php|php5|fonts|webroot)(\/|$)|\/))/,
     _sitetypes: ['opdatering', 'robot', 'template'],
     _envs:      ['test', 'snapshot'],
        updateQuickbox: function(manual) {
@@ -340,45 +344,68 @@ var TV2DeveloperQuickBox = {
             case 'go-viewcvs':
                 // Magically handle classnames (Enter as e.x. Tree_Node)
                 var classname = this._reg_classname.exec(shorturl);
+                var php5branch = document.getElementById('php5branch').checked;
+                var cvs_viewsource = document.getElementById('viewsource').checked;
                 if (classname) { // may want to move this section up a bit due to entered_url already set
                     var clsname = classname[0];
                     // remove ".php" :
                     if (classname[1]) {
                         clsname = clsname.substring(0, clsname.length-classname[1].length);
                     }
-                    clsname = clsname.replace(/_/,'/');
-                    // add php if not entered ends on a slash:
+                    clsname = clsname.replace(/_/g,'/');
+                    // add php if not entered path ends on a slash:
                     if (clsname.substr(-1) != '/') clsname += '.php';
                     uri = uriOnly = '/' + clsname;
                     site = 'globals';
                     // must update entered url manually since it was stored before these changes
                     entered_url = this._makeUrl(protocol, env, sitetype, php4, username, site, uri, false);
-                    php5branch = true; // may want this auto default
+                    //php5branch = true; // may want this auto default
                 }
                 var cvs_sitename = (!site) ? 'www' : site.replace(/-(static|dyn)/, '');
-                var php5branch = document.getElementById('php5branch').checked;
                 url = 'http://viewcvs.tv2.dk:7467/cgi-bin/viewvc.cgi/';
+                var cvs_root = '/' + sitetype;
                 if (cvs_sitename == 'globals') {
                     // special support for globals
-                    url += 'globals/php/TV2';
+                    url += cvs_sitename;
+                    cvs_root = '/php/TV2';
+                } else if (this._reg_cvs_nopostfix.exec(cvs_sitename)) {
+                    url += cvs_sitename;
+                    cvs_root = '';
                 } else {
-                    url += cvs_sitename + '.tv2.dk/' + sitetype;
+                    url += cvs_sitename + '.tv2.dk';
+                }
+                var entered_root = null;
+                if (uriOnly && (entered_root=this._reg_cvs_rootfolders.exec(uriOnly))) {
+                    cvs_root = '';
+                    if (entered_root[1]=='/') {
+                        // you can exclude 'webroot' by written two slashes: '//'
+                        uriOnly = uriOnly.substr(1);
+                    }
                 }
+                var cvs_view = (!cvs_viewsource ? 'log' : 'markup')
+                url += cvs_root; // webroot, opdatering, robot,...
                 if (uriOnly) {
                     var php = /^(.*\.php)/.exec(uriOnly);
                     if (php) {
-                        url += php[1] + '?view=log';
+                        url += php[1] + '?view=' + cvs_view;
                     } else if(uriOnly.substr(-1) == '/') {
-                        // we show the directory listing :-)
-                        url += uriOnly;
+                        if (cvs_viewsource) {
+                            url += uriOnly + 'index.php?view=' + cvs_view;
+                        } else {
+                            // we show the directory listing :-)
+                            url += uriOnly;
+                        }
                     } else {
-                        url += uriOnly + '?view=log';
+                        url += uriOnly + '?view=' + cvs_view;
                     }
                 } else {
                     url += '/';
                 }
                 if (php5branch) {
                     url += (url.indexOf('?')!=-1?'&':'?') + 'pathrev=PHP5';
+                    if (cvs_viewsource) {
+                        url += '&revision=PHP5';
+                    }
                 }
                 break;
             case 'go-pdolog':
@@ -411,8 +438,9 @@ var TV2DeveloperQuickBox = {
        },
        
        /* method to extract short url */
-    _reg_fromviewcvs: /^http:\/\/viewcvs\.tv2.dk:7467\/cgi-bin\/viewvc\.cgi\/(([^/]+)\.tv2\.dk\/(webroot|robot|opdatering|template)|globals\/php\/TV2)([^#?]+)(.*)?/,
+    _reg_fromviewcvs: /^http:\/\/viewcvs\.tv2.dk:7467\/cgi-bin\/viewvc\.cgi\/(([^/.]+)(?:\.tv2\.dk)?(?:\/(?:(webroot|robot|opdatering|template\/))|(\/[^/]*))([^#?]*)(.*)?)?/,
     _reg_viewcvsbranch: /^\?(?:.*&)?pathrev=PHP5(?:&|$)/,
+    _reg_viewcvsviewsource: /^\?(?:.*&)?view=markup(?:&|$)/,
     _reg_fromi2if: /^http:\/\/i2\.(?:[^.]+\.)?opdatering\.(?:(?:test|snapshot)\.)?tv2\.dk\/(tango\/(entry|requeue|dynamic)|tool\/pdo_log\/frameset)\.php.*?(\?|&)url=([^&]+)/,
     _extractURL: function(url) {
         var action = 'go-site';
@@ -439,20 +467,36 @@ var TV2DeveloperQuickBox = {
         /* Extract link from ViewCVS site */
         var fromviewcvs = this._reg_fromviewcvs.exec(url);
         if (fromviewcvs) {
-            var tv2_cvspath  = fromviewcvs[1];
-            var tv2_sitename = fromviewcvs[2];
-            var tv2_sitetype = fromviewcvs[3];
-            var tv2_uri      = fromviewcvs[4];
-            var tv2_php5branch = fromviewcvs[5];
+            var tv2_sitename    = fromviewcvs[2];
+            var tv2_sitetype    = fromviewcvs[3];
+            var tv2_rootfolder  = fromviewcvs[4];
+            var tv2_uri         = fromviewcvs[5];
+            var tv2_params      = fromviewcvs[6];
             
             action = 'go-viewcvs';
-            if (tv2_sitename && tv2_sitetype) {
-                url = tv2_sitename + (tv2_sitetype == 'webroot' ? '' : '.'+tv2_sitetype) + tv2_uri;
-            } else { // must be globals match
-                url = 'globals' + tv2_uri;
-            }
-            if (this._reg_viewcvsbranch.exec(tv2_php5branch)) {
-                document.getElementById('php5branch').checked = true;
+            if (tv2_sitename) {
+                if (tv2_sitename == 'globals' && tv2_uri.indexOf('/php/TV2')==0) {
+                    tv2_uri = '';
+                }
+                url = tv2_sitename;
+                if (tv2_sitetype) {
+                    url += (tv2_sitetype == 'webroot' ? '' : '.'+tv2_sitetype);
+                } else if (this._reg_cvs_rootfolders.exec(tv2_rootfolder)) {
+                    url += tv2_rootfolder;
+                } else {
+                    url += '/' + tv2_rootfolder;
+                }
+                url += tv2_uri;
+                if (tv2_params) {
+                    if (this._reg_viewcvsbranch.exec(tv2_params)) {
+                        document.getElementById('php5branch').checked = true;
+                    }
+                    if (this._reg_viewcvsviewsource.exec(tv2_params)) {
+                        document.getElementById('viewsource').checked = true;
+                    }
+                }
+            } else {
+                url = '';
             }
         }
         
@@ -473,6 +517,8 @@ var TV2DeveloperQuickBox = {
                function() { TV2DeveloperQuickBox.setManuel(this); }, false);
            document.getElementById('php5branch').addEventListener('CheckboxStateChange',
                function() { TV2DeveloperQuickBox.setManuel(this); }, false);
+           document.getElementById('viewsource').addEventListener('CheckboxStateChange',
+               function() { TV2DeveloperQuickBox.setManuel(this); }, false);
            // init saved fields
                document.getElementById('testname').value = TV2Util.getPref('alternativ-initials', '');
         // auto go (ALT+4)
index 2584af7ed5ec5710a4856237107a37a73e399c16..67e297b3b9768bffb960432d2c24bdf85232a640 100755 (executable)
@@ -20,7 +20,7 @@
 <vbox>
     <label value="&quickbox.entershorturl;" control="shorturl" accesskey="&quickbox.entershorturl.accesskey;"/>
     <textbox id="shorturl" size="80" oninput="TV2DeveloperQuickBox.updateQuickbox()" crop="end"/>
-    <label id="url" style="width:20em" value="" crop="end"/>
+    <textbox id="url" style="width:20em; border:0; -moz-appearance: none; padding: 0" value="" readonly="true"/>
 </vbox>
 
     <hbox>
             <radio id="go-dynamic" label="&quickbox.dynamic;" accesskey="&quickbox.dynamic.accesskey;"/>
           </vbox>
         </hbox>
-        <hbox>
+        <hbox align="start">
           <radio id="go-viewcvs" label="&quickbox.openinviewcvs;" accesskey="&quickbox.openinviewcvs.accesskey;"/>
-          <checkbox id="php5branch" label="&quickbox.php5branch;" accesskey="&quickbox.php5branch.accesskey;"/>
+          <vbox>
+            <checkbox id="php5branch" label="&quickbox.php5branch;" accesskey="&quickbox.php5branch.accesskey;"/>
+            <checkbox id="viewsource" label="&quickbox.viewsource;" accesskey="&quickbox.viewsource.accesskey;"/>
+          </vbox>
         </hbox>
         <radio id="go-pdolog" label="&quickbox.examinedbqueries;" accesskey="&quickbox.examinedbqueries.accesskey;"/>
       </groupbox>
index 020d5615d012a273614663c81bbf45977338829a..66e746c99437ad8b11b462465057b4978826fe61 100755 (executable)
@@ -12,6 +12,7 @@
 // E = Node info
 // F = Tango interface
 // G = Look in tango
+// H = View source in ViewCVS
 // I = I2 tree
 // K = Lookup content
 // L = Live
@@ -28,6 +29,7 @@
 // V = W3C markup validator
 // W = Webroot
 // X = Examine database queries
+// Y = Flush cache
 
 var TV2Developer = {
     
@@ -262,6 +264,7 @@ var TV2Developer = {
             } else {
                 viewcvs += tv2_uriOnly;
             }
+            var viewcvs_source = viewcvs + '?view=markup';
             viewcvs += '?view=log';
             // we set a nice type so we can swap between using the button (test<>viewcvs, live<>viewcvs,...)
             var viewcvs_type;
@@ -274,6 +277,8 @@ var TV2Developer = {
             }
             links.push(new this.TV2LinkWithLabel(viewcvs_type, TV2Util.getStr('lookupInViewCVS'), viewcvs,
                                                  TV2Util.getStr('lookupInViewCVS.accesskey')));
+            links.push(new this.TV2LinkWithLabel(viewcvs_type, TV2Util.getStr('lookupInViewCVSSource'), viewcvs_source,
+                                                 TV2Util.getStr('lookupInViewCVSSource.accesskey')));
 
             // Update and I2 base URL
             var updatepostfix = (tv2_user ? '.' + tv2_user : '')
@@ -398,7 +403,7 @@ var TV2Developer = {
                 var tv2_uri      = fromviewcvs[3];
                 
                 // cut off 'index.php'
-                if (tv2_uri.substr(-9) == 'index.php') {
+                if (tv2_uri.substr(-10) == '/index.php') {
                     tv2_uri = tv2_uri.substr(0, tv2_uri.length-9);
                 }
 
@@ -429,6 +434,9 @@ var TV2Developer = {
         links.push(new this.TV2LinkWithLabel('tango/entry', TV2Util.getStr('tangoInterface'), 'http://i2.opdatering.tv2.dk/tango/', TV2Util.getStr('tangoInterface.accesskey')));
         links.push(new this.TV2LinkWithLabel('w3c', TV2Util.getStr('w3c'),
             'http://validator.w3.org/check?uri=' + encodedURL, TV2Util.getStr('w3c.accesskey')));
+        links.push(new this.TV2LinkWithLabel('flushcache', TV2Util.getStr('flushCache'),
+           '', TV2Util.getStr('flushCache.accesskey'), 'flushCache'));
+
         return links;
         
     },
@@ -533,7 +541,9 @@ var TV2Developer = {
                 }
             }
             /* follow link */
-            openUILink(url, event, false, true, false); /* allow ctrl, not alt, and don't google */
+            if (url != '') {
+                openUILink(url, event, false, true, false); /* allow ctrl, not alt, and don't google */
+            }
             if (tv2linktype) {
                 this._lastAction = tv2linktype;
                 TV2Util.setPref('lastaction-linktype', tv2linktype);
index 00c4c8983447fd47d9896cc8610dad1efd5f3888..16cb94b739d5408f3b693a6d6e0fc595dd52e469 100755 (executable)
@@ -58,6 +58,9 @@
 <!ENTITY quickbox.php5branch "PHP 5 branch">
 <!ENTITY quickbox.php5branch.accesskey "b">
 
+<!ENTITY quickbox.viewsource "Vis kildekoden">
+<!ENTITY quickbox.viewsource.accesskey "h">
+
 <!ENTITY quickbox.examinedbqueries "Undersøg database forespørgsler på siden">
 <!ENTITY quickbox.examinedbqueries.accesskey "x">
 
index 6b7508ce461ccf7b42bd85e74ea118608820a3c5..5b9fb7625e96130f845206938749dd7db6fa40e6 100755 (executable)
@@ -1,6 +1,9 @@
-lookupInViewCVS=Slå denne side op i ViewCVS
+lookupInViewCVS=ViewCVS: Vis loggen for siden
 lookupInViewCVS.accesskey=c
 
+lookupInViewCVSSource=ViewCVS: Vis kildekoden for siden
+lookupInViewCVSSource.accesskey=h
+
 viewDynamicVersion=Vis den dynamiske version af siden
 viewDynamicVersion.accesskey=d
 
@@ -39,6 +42,9 @@ tangoInterface.accesskey=f
 w3c=W3C Markup Validator
 w3c.accesskey=v
 
+flushCache=Tøm browser cachen
+flushCache.accesskey=y
+
 live.accesskey=l
 test.accesskey=t
 snapshot.accesskey=s
index 7af883d88da9595a1923da9af1c2c3948334bbdb..b6c48df93985ec59bce635b008b74c63e2614560 100755 (executable)
@@ -58,6 +58,9 @@
 <!ENTITY quickbox.php5branch "PHP 5 branch">
 <!ENTITY quickbox.php5branch.accesskey "b">
 
+<!ENTITY quickbox.viewsource "View source">
+<!ENTITY quickbox.viewsource.accesskey "h">
+
 <!ENTITY quickbox.examinedbqueries "Examine database queries">
 <!ENTITY quickbox.examinedbqueries.accesskey "x">
 
index 1c40dace2c500c203180661bd01e0c32d1f6165f..0fd4a5f3b6c5704d95916348e32715c9be41a912 100755 (executable)
@@ -1,6 +1,9 @@
-lookupInViewCVS=Lookup this page in ViewCVS
+lookupInViewCVS=ViewCVS: Lookup this page
 lookupInViewCVS.accesskey=c
 
+lookupInViewCVSSource=ViewCVS: View source of page
+lookupInViewCVSSource.accesskey=h
+
 viewDynamicVersion=View dynamic version of this page
 viewDynamicVersion.accesskey=d
 
@@ -39,6 +42,9 @@ tangoInterface.accesskey=f
 w3c=W3C Markup Validator
 w3c.accesskey=v
 
+flushCache=Flush browser cache
+flushCache.accesskey=y
+
 live.accesskey=l
 test.accesskey=t
 snapshot.accesskey=s
diff --git a/version b/version
index ac39a106c48515b621e90c028ed94c6f71bc03fa..f374f6662e9a1983e9b8a534a3295df618772ffe 100644 (file)
--- a/version
+++ b/version
@@ -1 +1 @@
-0.9.0
+0.9.1