From 60000792a8c8014925531c43d8b749cee511535d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20Kr=E6mmer=20Nielsen?= Date: Sat, 29 Dec 2007 02:24:51 +0100 Subject: [PATCH] Added lots of new functionalities to Quickbox, lookup in CVS, lookup in Tango, back from CVS, Tango, and more, see index.html changes --- content/quickbox.xul | 43 +- content/tv2developer-quickbox.js | 791 +++++++++++++++++++------------ content/tv2developer.js | 5 +- locale/da-DK/tv2developer.dtd | 32 +- locale/en-US/tv2developer.dtd | 32 +- version | 2 +- webroot/index.html | 13 + 7 files changed, 593 insertions(+), 325 deletions(-) diff --git a/content/quickbox.xul b/content/quickbox.xul index 6874288..146bb3f 100755 --- a/content/quickbox.xul +++ b/content/quickbox.xul @@ -20,7 +20,7 @@ @@ -49,17 +49,34 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/content/tv2developer-quickbox.js b/content/tv2developer-quickbox.js index 5aa5067..4943653 100644 --- a/content/tv2developer-quickbox.js +++ b/content/tv2developer-quickbox.js @@ -1,297 +1,494 @@ -/* Functionality for the quick link box */ -/* @author Kristian Kræmmer Nielsen */ - -var TV2DeveloperQuickBox = { - - _addCheckbox: function(here, id, label, accesskey) { - var radio = document.createElement('radio'); - radio.setAttribute('id', id); - radio.setAttribute('label', label); - radio.setAttribute('accesskey', accesskey); - here.appendChild(radio); - }, - - _autoChange: false, - _saveInitials: false, /* save the alternative initials field */ - - setManuel: function(target) { - if (target.id == 'environment') { - document.getElementById('testname').disabled = (target.selectedItem.id != 'othertest'); - if (!this._autoChange) { - document.getElementById('testname').select(); - document.getElementById('testname').focus(); - } - } - if (target.id == 'action') { - document.getElementById('sitetype').disabled = (target.selectedItem.id != 'go-site'); - document.getElementById('php4site').disabled = (target.selectedItem.id != 'go-site'); - } - if (!this._autoChange) { /* avoid updating if this was trigged by updateQuickbox() */ - if (target.id == 'testname' && - document.getElementById('environment').selectedItem.id != 'othertest') { - document.getElementById('environment').selectedItem = - document.getElementById('othertest'); - } - this.updateQuickbox(true); - } - }, - - _reg_nodeid: /^(?!1234$)[0-9]+$/, - _reg_ttv: /^[0-9]{3}$/, - _reg_extract_nums: /([0-9]+)/g, - _reg_shortlink: /^((https?):\/?\/?)?([^/]*?)(tv2\.dk)?(\/.*)?$/, - _sitetypes: ['opdatering', 'robot', 'template'], - _envs: ['test', 'snapshot'], - updateQuickbox: function(manual) { - if (!manual) manual = false; - var current_user = TV2Util.getPref('developer-initials'); - var username = current_user; - var shorturl = document.getElementById('shorturl').value; - var auto_action; - - var tv2 = this._reg_shortlink.exec(shorturl); - if (tv2) { - var protocol = tv2[2]; - var domain = tv2[3]; - var uri = tv2[5]; - var url = ''; - - var site = null; - var auto_sitetype = 'webroot'; - var auto_env = 'live'; - var auto_username = null; - var auto_php4 = false; - var validState = true; - - var parts = domain.split('.'); - for (var i=0; i max_len) { - max_len = cur_id[1].length; - longest_id = cur_id[1]; - } - } - if (!longest_id) { - validState = false; - longest_id = '?'; - } - break; - } - switch (action) { - case 'go-node': - uri = '/tool/node/?id=' + longest_id; - break; - case 'go-content-id': - uri = '/tool/query/?id=&2=&3=&_checkbox=1&content_id='+longest_id+'&4=&5=0&6=&action=Query&timeout=1'; - break; - case 'go-ttv-page': - uri = '/tool/ttv/?1=' + longest_id + '&2=0'; - break; - } - - // Assemble domain - // handle www.tv2.dk - if (env == 'live' && sitetype == 'webroot') { - if (site == '' || site == 'www') { - domain = ''; - } else { - domain = site + '.'; - } - } else { - if (site == '') { - domain = 'www.'; - } else { - domain = site + '.'; - } - } - // handle environment - if (env == 'test') { - if (username == '') { - validState = false; - username = '?'; - } - domain += username + '.'; - } - // handle site type - if (sitetype != 'webroot') domain += sitetype + '.'; - if (env != 'live') { - domain += env; - if (php4) domain += '3'; - domain += '.'; - } - // finish url - domain += 'tv2.dk'; - url = protocol + '://' + domain + uri; - - document.getElementById('url').value = url; - if (manual && action=='go-site') { - // also change url in field - document.getElementById('shorturl').value = url; - } - - // are we using the alternativ initials? - this._saveInitials = (env == 'test' && username != current_user); - - document.getElementById('tv2developer_quickbox').getButton('accept').disabled = !validState; - } - }, - - /* onload */ - setupQuickbox: function() { - if (window.arguments && window.arguments[0]) { - document.getElementById('shorturl').value = window.arguments[0]; - } - this.updateQuickbox(); - document.getElementById('php4site').addEventListener('CheckboxStateChange', - function() { TV2DeveloperQuickBox.setManuel(this); }, false); - // init saved fields - document.getElementById('testname').value = TV2Util.getPref('alternativ-initials', ''); - // auto go (ALT+4) - if (window.arguments && window.arguments[1]) { - this.goQuickbox(); - } - }, - - goQuickbox: function() { - // init saved fields - if (this._saveInitials) { - TV2Util.setPref('alternativ-initials', document.getElementById('testname').value); - } - window.close(); - opener.openUILink(document.getElementById('url').value, 'current', false, false, false); - /* allow ctrl, alt, but don't google */ - } - -}; +/* Functionality for the quick link box */ +/* @author Kristian Kræmmer Nielsen */ + +var TV2DeveloperQuickBox = { + + _addCheckbox: function(here, id, label, accesskey) { + var radio = document.createElement('radio'); + radio.setAttribute('id', id); + radio.setAttribute('label', label); + radio.setAttribute('accesskey', accesskey); + here.appendChild(radio); + }, + + _autoChange: false, + _saveInitials: false, /* save the alternative initials field */ + + /* assemble a final url */ + _makeUrl: function(protocol, env, sitetype, php4, username, site, uri, dynsite) { + var domain; + // Assemble domain + // Always remove -dyn on test and -static on live + if (env != 'live' && site.substr(-4) == '-dyn') { + site = site.substr(0, site.length-4); + } + if (env == 'live' && site.substr(-7) == '-static') { + site = site.substr(0, site.length-7); + } + // Remove -static or add dyn + if (dynsite) { + if (site.substr(-7) == '-static') { + site = site.substr(0, site.length-7); + } + if (env == 'live' && sitetype == 'webroot') { + if (site == '') site = 'www'; + if (site.substr(-4) != '-dyn') { + site += '-dyn'; + } + } + } + // handle www.tv2.dk + if (env == 'live' && sitetype == 'webroot') { + if (site == '' || site == 'www') { + domain = ''; + } else { + domain = site + '.'; + } + } else { + if (site == '') { + domain = 'www.'; + } else { + domain = site + '.'; + } + } + // handle environment + if (env == 'test') { + domain += username + '.'; + } + // handle site type + if (sitetype != 'webroot') domain += sitetype + '.'; + if (env != 'live') { + domain += env; + if (php4) domain += '3'; + domain += '.'; + } + // finish url + domain += 'tv2.dk'; + + return protocol + '://' + domain + uri; + }, + + /* determind if action requires us to create a site URL */ + _shouldMakeURL: function(action) { + switch (action) { + case 'go-site': + case 'go-tango-page': + case 'go-tango-requeue': + case 'go-dynamic': + case 'go-viewcvs': + case 'go-pdolog': + return true; + default: + return false; + } + }, + + /* Change action manually */ + setManuel: function(target) { + var action = document.getElementById('action').selectedItem.id; + var makeSiteURL = this._shouldMakeURL(action); + var environment = document.getElementById('environment').selectedItem; + if (target.id == 'environment') { + document.getElementById('testname').disabled = (target.selectedItem.id != 'othertest'); + if (!this._autoChange) { + document.getElementById('testname').select(); + document.getElementById('testname').focus(); + } + } + if (target.id == 'action') { + document.getElementById('sitetype').disabled = !makeSiteURL; + document.getElementById('php5branch').disabled = (action != 'go-viewcvs'); + document.getElementById('environment').disabled = (action == 'go-viewcvs'); + } + document.getElementById('php4site').disabled = (!makeSiteURL || action == 'go-pdolog' || action == 'go-viewcvs') + || (environment && environment.id == 'live'); + if (!this._autoChange) { /* avoid updating if this was triggered by updateQuickbox() */ + if (target.id == 'testname' && + document.getElementById('environment').selectedItem.id != 'othertest') { + document.getElementById('environment').selectedItem = + document.getElementById('othertest'); + } + this.updateQuickbox(true); + } + }, + + _reg_nodeid: /^(?!1234$)[0-9]+$/, + _reg_ttv: /^[0-9]{3}$/, + _reg_extract_nums: /([0-9]+)/g, + _reg_shortlink: /^((https?):\/?\/?)?([^/]*?)(tv2\.dk)?((\/[^#\?]*).*)?$/, + _reg_classname: /^[A-Z][a-zA-Z0-9_/]*(\.(p(hp?)?)?)?$/, + _sitetypes: ['opdatering', 'robot', 'template'], + _envs: ['test', 'snapshot'], + updateQuickbox: function(manual) { + if (!manual) manual = false; + var current_user = TV2Util.getPref('developer-initials'); + var username = current_user; + var shorturl = document.getElementById('shorturl').value; + var auto_action; + + var tv2 = this._reg_shortlink.exec(shorturl); + if (tv2) { + var protocol = tv2[2]; + var domain = tv2[3]; + var uri = tv2[5]; + var uriOnly = tv2[6]; + var url = ''; + + var site = null; + var auto_sitetype = 'webroot'; + var auto_env = 'live'; + var auto_username = null; + var auto_php4 = false; + var validState = true; + + var parts = domain.split('.'); + for (var i=0; i max_len) { + max_len = cur_id[1].length; + longest_id = cur_id[1]; + } + } + if (!longest_id) { + validState = false; + longest_id = '?'; + } + action_uses_i2_opdatering = true; + break; + case 'go-pdolog': + php4 = false; // not allowed + case 'go-tango-page': + case 'go-tango-requeue': + case 'go-dynamic': + action_on_url_encoded = encodeURIComponent(this._makeUrl(protocol, env, sitetype, php4, username, site, uri, true)); + action_uses_i2_opdatering = true; + break; + case 'go-viewcvs': + break; + } + if (action_uses_i2_opdatering) { + protocol='http'; + site = 'i2'; + sitetype = 'opdatering'; + php4 = false; + } + // Handle actions - part two set uri + switch (action) { + case 'go-node': + uri = '/tool/node/?id=' + longest_id; + break; + case 'go-content-id': + uri = '/tool/query/?id=&2=&3=&_checkbox=1&content_id='+longest_id+'&4=&5=0&6=&action=Query&timeout=1'; + break; + case 'go-ttv-page': + uri = '/tool/ttv/?1=' + longest_id + '&2=0'; + break; + case 'go-tango-page': + uri = '/tango/entry.php?url='+action_on_url_encoded; + break; + case 'go-tango-requeue': + uri = '/tango/requeue.php?url='+action_on_url_encoded; + break; + case 'go-dynamic': + uri = '/tango/dynamic.php?url='+action_on_url_encoded; + break; + case 'go-viewcvs': + // Magically handle classnames (Enter as e.x. Tree_Node) + var classname = this._reg_classname.exec(shorturl); + if (classname) { // way 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 entering 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 + } + 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/'; + if (cvs_sitename == 'globals') { + // special support for globals + url += 'globals/php/TV2'; + } else { + url += cvs_sitename + '.tv2.dk/' + sitetype; + } + if (uriOnly) { + var php = /^(.*\.php)/.exec(uriOnly); + if (php) { + url += php[1] + '?view=log'; + } else if(uriOnly.substr(-1) == '/') { + // we show the directory listing :-) + url += uriOnly; + } else { + url += uriOnly + '?view=log'; + } + } else { + url += '/'; + } + if (php5branch) { + url += (url.indexOf('?')!=-1?'&':'?') + 'pathrev=PHP5'; + } + break; + case 'go-pdolog': + uri = '/tool/pdo_log/frameset.php?url='+action_on_url_encoded+'&autostop=1&prefix='+current_user; + break; + } + + // assmble url + if (env == 'test' && username == '') { + validState = false; + username = '?'; + } + + if (url=='') { + url = this._makeUrl(protocol, env, sitetype, php4, username, site, uri, false); + } + + document.getElementById('url').setAttribute('tooltiptext', + document.getElementById('url').value = url); + if (manual && this._shouldMakeURL(action)) { + // also change url in field + document.getElementById('shorturl').value = entered_url; + } + + // are we using the alternativ initials? + this._saveInitials = (env == 'test' && username != current_user); + + document.getElementById('tv2developer_quickbox').getButton('accept').disabled = !validState; + } + }, + + /* 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_viewcvsbranch: /^\?(?:.*&)?pathrev=PHP5(?:&|$)/, + _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'; + + // Check if we are on an Tango or I2 interface, then we can extract the URL again + var tangoif = this._reg_fromi2if.exec(url); + if (tangoif) { + switch (tangoif[1]) { + case 'tango/entry': + action = 'go-tango-page'; + break; + case 'tango/requeue': + action = 'go-tango-requeue'; + break; + case 'tango/dynamic': + action = 'go-dynamic'; + break; + case 'tool/pdo_log/frameset': + action = 'go-pdolog'; + break; + } + url = decodeURIComponent(tangoif[4]); + } + /* 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]; + + 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; + } + } + + this._autoChange = true; + document.getElementById('action').selectedItem = document.getElementById(action); + document.getElementById('shorturl').value = url; + this._autoChange = false; + + }, + + /* onload */ + setupQuickbox: function() { + if (window.arguments && window.arguments[0]) { + this._extractURL(window.arguments[0]); + } + this.updateQuickbox(); + document.getElementById('php4site').addEventListener('CheckboxStateChange', + function() { TV2DeveloperQuickBox.setManuel(this); }, false); + document.getElementById('php5branch').addEventListener('CheckboxStateChange', + function() { TV2DeveloperQuickBox.setManuel(this); }, false); + // init saved fields + document.getElementById('testname').value = TV2Util.getPref('alternativ-initials', ''); + // auto go (ALT+4) + if (window.arguments && window.arguments[1]) { + this.goQuickbox(); + } + }, + + goQuickbox: function() { + // init saved fields + if (this._saveInitials) { + TV2Util.setPref('alternativ-initials', document.getElementById('testname').value); + } + window.close(); + opener.openUILink(document.getElementById('url').value, 'current', false, false, false); + /* allow ctrl, alt, but don't google */ + } + +}; diff --git a/content/tv2developer.js b/content/tv2developer.js index 72c1df3..020d561 100755 --- a/content/tv2developer.js +++ b/content/tv2developer.js @@ -255,13 +255,14 @@ var TV2Developer = { + cvs_sitename + '.tv2.dk/' + (tv2_sitetype?tv2_sitetype:'webroot'); var php = this._reg_php.exec(tv2_uriOnly); if (php) { - viewcvs += php[1] + '?view=log'; + viewcvs += php[1]; } else if(tv2_uriOnly.substr(-1) == '/') { // we add 'index.php' and say that's it! :-) - viewcvs += tv2_uriOnly + 'index.php' + '?view=log'; + viewcvs += tv2_uriOnly + 'index.php'; } else { viewcvs += tv2_uriOnly; } + viewcvs += '?view=log'; // we set a nice type so we can swap between using the button (test<>viewcvs, live<>viewcvs,...) var viewcvs_type; if (!tv2_testsite) { diff --git a/locale/da-DK/tv2developer.dtd b/locale/da-DK/tv2developer.dtd index 09b9942..00c4c89 100755 --- a/locale/da-DK/tv2developer.dtd +++ b/locale/da-DK/tv2developer.dtd @@ -39,15 +39,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + diff --git a/locale/en-US/tv2developer.dtd b/locale/en-US/tv2developer.dtd index c8d5ad7..7af883d 100755 --- a/locale/en-US/tv2developer.dtd +++ b/locale/en-US/tv2developer.dtd @@ -39,15 +39,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + diff --git a/version b/version index 100435b..ac39a10 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.8.2 +0.9.0 diff --git a/webroot/index.html b/webroot/index.html index 729a1a9..a858e5c 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -75,6 +75,19 @@
  • Links opfører sig som normale links, således CTRL kan bruges til at åbne i ny tab, CTRL+SHIFT i en ny tab i baggrunden, SHIFT i ny vindue, osv..
  • (Bemærk at på mac er det nødvendigt at slå accesskeys til - dette kan gøres under indstillingerne i pluginen).
  • +

    Quick box features

    +
      +
    • Indtast korte url'er i adresselinjen så som: nyhederne.o.t/nyheder/
    • +
    • Slå en TTV-side op blot ved at skrive sidenumret
    • +
    • Slå en node-id op blot ved at skrive numret
    • +
    • Skift mellem test, snapshot ved at bruge forkortelser så som: t, s, t3 eller s
    • +
    • Skift mellem opdatering, robot, template ved at bruge forkortelser så som: o, r eller tem
    • +
    • Genkender andres test webs hvis der indtastes initialer på 4 bogstaver, eller der angives .t.
    • +
    • Slå sider op i Tango, vis den dynamiske version eller slå op i CVS direkte fra en forkortet URL
    • +
    • Genkender klasse-navne (start med stort bogstav) og slår dem op i CVS i globals, indtast f.eks.: ORM
    • +
    • Navigér videre rundt i ViewCVS let ved hjælp af korte url'er, prøv ALT+3 i ViewCVS
    • +
    • Genkender URL angivet som parameter i fleste i2-interfaces
    • +
    -- 2.52.0