From: Kristian Kræmmer Nielsen Date: Mon, 7 Jan 2008 19:27:49 +0000 (+0100) Subject: Added view source for ViewCVS in both quickbox and dropdown X-Git-Url: https://git.jkkn.net/?a=commitdiff_plain;h=0a5e22724eacfb2f940db597ffb8f79996757559;p=tv2developer Added view source for ViewCVS in both quickbox and dropdown Changed url in quickbox to textbox Added support for all types for folders in ViewCVS --- diff --git a/content/quickbox.js b/content/quickbox.js index 885e91d..3e0efd8 100644 --- a/content/quickbox.js +++ b/content/quickbox.js @@ -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) diff --git a/content/quickbox.xul b/content/quickbox.xul index 2584af7..67e297b 100755 --- a/content/quickbox.xul +++ b/content/quickbox.xul @@ -20,7 +20,7 @@ @@ -64,9 +64,12 @@ - + - + + + + diff --git a/content/tv2developer.js b/content/tv2developer.js index 020d561..66e746c 100755 --- a/content/tv2developer.js +++ b/content/tv2developer.js @@ -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); diff --git a/locale/da-DK/tv2developer.dtd b/locale/da-DK/tv2developer.dtd index 00c4c89..16cb94b 100755 --- a/locale/da-DK/tv2developer.dtd +++ b/locale/da-DK/tv2developer.dtd @@ -58,6 +58,9 @@ + + + diff --git a/locale/da-DK/tv2developer.properties b/locale/da-DK/tv2developer.properties index 6b7508c..5b9fb76 100755 --- a/locale/da-DK/tv2developer.properties +++ b/locale/da-DK/tv2developer.properties @@ -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 diff --git a/locale/en-US/tv2developer.dtd b/locale/en-US/tv2developer.dtd index 7af883d..b6c48df 100755 --- a/locale/en-US/tv2developer.dtd +++ b/locale/en-US/tv2developer.dtd @@ -58,6 +58,9 @@ + + + diff --git a/locale/en-US/tv2developer.properties b/locale/en-US/tv2developer.properties index 1c40dac..0fd4a5f 100755 --- a/locale/en-US/tv2developer.properties +++ b/locale/en-US/tv2developer.properties @@ -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 ac39a10..f374f66 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.9.0 +0.9.1