if (target.id == 'action') {
document.getElementById('sitetype').disabled = !makeSiteURL;
document.getElementById('php4branch').disabled = (action != 'go-gitweb');
- document.getElementById('viewsource').disabled = (action != 'go-gitweb');
+ document.getElementById('viewcontent').disabled = (action != 'go-gitweb');
document.getElementById('environment').disabled = (action == 'go-gitweb');
}
document.getElementById('php4site').disabled = (!makeSiteURL || action == 'go-pdolog' || action == 'go-gitweb')
_reg_extract_nums: /([0-9]+)/g,
_reg_shortlink: /^((https?):\/?\/?)?([^/]*?)(tv2\.dk)?((\/[^#\?]*).*)?$/,
_reg_classname: /^[A-Z][a-zA-Z0-9_/]*(\.(p(hp?)?)?)?$/,
+ _reg_onlyingit: /^conf(\/.*)?/,
_reg_git_nopostfix: /^(?:archive|conf|default|phpincludes|symfoni|titoonic-includes)$/,
_reg_git_rootfolders: /^\/(((Java|build|inc|opdatering|robot|scripts|sql|template|views|php|php5|fonts|webroot)(\/|$)|\/))/,
+ _reg_git_indexphpfolders: /^\/(((opdatering|webroot)(\/|$)|\/))/,
_reg_git_dnsdomains: /^\/(tv2|tv2news|tv2film|sputnik|charlie|zulu)(\.|\.d|\.dk)?$/,
_sitetypes: ['opdatering', 'robot', 'template'],
_envs: ['test', 'snapshot'],
// defaults
if (!protocol) protocol = 'http';
- if (!uri) uri = '/';
+ if (!uri) uri = '';
if (!site) site = '';
// determind action and options set
auto_action = 'go-node';
} else if (this._reg_classname.exec(shorturl)) {
auto_action = 'go-gitweb';
+ } else if (this._reg_onlyingit.exec(shorturl)) {
+ auto_action = 'go-gitweb';
} else {
// if we are using the user input as an url we keep an eventually already selected action
if (!this._shouldMakeURL(cur_action.id)) {
// Magically handle classnames (Enter as e.x. Tree_Node)
var classname = this._reg_classname.exec(shorturl);
var php4branch = document.getElementById('php4branch').checked;
- var git_viewsource = document.getElementById('viewsource').checked;
+ var git_viewcontent = document.getElementById('viewcontent').checked;
if (classname) { // may want to move this section up a bit due to entered_url already set
var clsname = classname[0];
// remove ".php" :
clsname = clsname.replace(/_/g,'/');
// add php if not entered path ends on a slash:
if (clsname.substr(-1) != '/') clsname += '.php'
- else git_viewsource = false; // if ending with slash, always show directory listing
+ else {
+ // if ending with slash, always show directory listing
+ clsname = clsname.substr(0, clsname.length-1);
+ git_viewcontent = false;
+ }
uri = uriOnly = '/' + clsname;
site = 'globals';
// must update entered url manually since it was stored before these changes
var git_sitename = (!site) ? 'www' : site.replace(/-(static|dyn)/, '');
url = 'http://flimmer.tv2.dk/git/';
var git_root = '/' + sitetype;
+ var magicChangeView = (!manual);
+ var magicChangeViewTo = (uriOnly ? 'content' : 'summary');
if (git_sitename == 'globals') {
// special support for globals
url += git_sitename;
git_root = '';
if (git_sitename == 'conf') {
// Magic shortcuts for the 'conf' project:
- var magicChangeShowSource = true;
- var magicToShowSource = true;
- if (uriOnly=='/dns') {
- uriOnly = '/hosts/dns-master/master/';
- magicToShowSource = false;
+ var matched = true;
+ // Shortcuts for apache configurations
+ if (uriOnly=='/httpd') {
+ uriOnly = '/hosts/dn/httpd.conf';
+ } else if (uriOnly=='/vhosts' || uriOnly=='/public') {
+ uriOnly = '/hosts/dn/vhosts.d/public.conf';
+ } else if (uriOnly=='/symfoni') {
+ uriOnly = '/hosts/dn/vhosts.d/symfoni.m4';
+ } else if (uriOnly=='/softlaunch') {
+ uriOnly = '/hosts/dn/vhosts.d/softlaunch.conf';
+ } else if (uriOnly=='/php') {
+ uriOnly = '/hosts/dn/php.ini';
+ // Shortcuts for DNS information
+ } else if (uriOnly=='/dns') {
+ uriOnly = '/hosts/dns-master/master';
} else if (dns_domain=this._reg_git_dnsdomains.exec(uriOnly)) {
uriOnly = '/hosts/dns-master/master/'+dns_domain[1]+'.dk';
+ // Shortcuts for Crontab Information
} else if (uriOnly=='/cron') {
uriOnly = '/hosts/robot-new/cronrun.crontab';
} else if (uriOnly=='/cron4') {
uriOnly = '/hosts/robot/cronrun.crontab';
+ // Shortcuts for scripts
} else if (uriOnly=='/flimmer') {
- uriOnly = '/hosts/flimmer/';
- magicToShowSource = false;
+ uriOnly = '/hosts/flimmer/scripts';
} else {
- magicChangeShowSource = false;
- }
- if (magicChangeShowSource && !manual && git_viewsource != magicToShowSource) {
- // auto default to show source for files, not for directories
- this._autoChange = true;
- git_viewsource = document.getElementById('viewsource').checked = magicToShowSource;
- this._autoChange = false;
+ matched = false;
}
+ if (matched) magicChangeViewTo = 'content';
}
} else {
url += git_sitename + '.tv2.dk';
}
+ // automatic set defaults for the selection of viewcontent:
+ if (magicChangeView) {
+ // how do we want to set the checkboxes?
+ var checkContent = (magicChangeViewTo == 'content');
+ if (git_viewcontent != checkContent) {
+ // auto defaults
+ this._autoChange = true;
+ git_viewcontent = document.getElementById('viewcontent').checked = checkContent;
+ this._autoChange = false;
+ }
+ }
+
url += '.git'; // .git extension
var entered_root = null;
if (uriOnly && (entered_root=this._reg_git_rootfolders.exec(uriOnly))) {
if (entered_root[1]=='/') {
// you can exclude 'webroot/opdatering' by written two slashes: '//'
uriOnly = uriOnly.substr(1);
- } else if (entered_root[4]!='/') {
- // be clever and add the missing slash
- uriOnly += '/';
}
+ } else if (!uriOnly) {
+ // if no uri entered and we are going to show history, we will do this by default for the entire project
+ git_root = '';
}
- var git_view = (!git_viewsource ? 'history' : 'blob')
- if (!uriOnly) uriOnly = '/';
+ var git_view = (!git_viewcontent ? 'history' : '') // empty let gitweb default to blob or tree
+
+ if (!uriOnly) uriOnly = '';
uriOnly = git_root + uriOnly; // webroot, opdatering, robot,...
var php = /^(.*\.php)/.exec(uriOnly);
if (php) {
- urlOnly = php[1];
+ uriOnly = php[1];
} else if (uriOnly.substr(-1) == '/') {
- if (git_viewsource) {
+ // we added index.php only inside webroot, opdatering:
+ if (this._reg_git_indexphpfolders.exec(uriOnly)) {
uriOnly += 'index.php';
} else {
- git_view = 'tree';
- // we show the directory listing :-)
- }
- }
- if (uriOnly.length > 1) {
- if (uriOnly.substr(-1) == '/') { // strip slash
+ // remove slash
uriOnly = uriOnly.substr(0, uriOnly.length-1);
}
- if (uriOnly.length > 1) {
- url += '?f=' + uriOnly.substr(1);
- }
+ } else if (uriOnly.substr(-2) == '/.') {
+ // this allows directory listings
+ uriOnly = uriOnly.substr(0, uriOnly.length-2);
}
- url += (url.indexOf('?')!=-1?';':'?') + 'a=' + git_view + ';';
- if (php4branch) {
- url += 'hb=php4';
- } else {
- url += 'hb=HEAD';
+
+ if (uriOnly.length > 1) {
+ url += '?f=' + uriOnly.substr(1);
+ if (!git_viewcontent) {
+ url += ';a=history';
+ }
+ } else if (git_viewcontent) {
+ // project tree
+ url += '?a=tree';
}
+ url += (url.indexOf('?')!=-1?';':'?') + 'hb=' + (php4branch ? 'php4' : 'HEAD');
break;
case 'go-pdolog':
uri = '/tool/pdo_log/frameset.php?url='+action_on_url_encoded+'&autostop=1&prefix='+current_user;
break;
}
- // assmble url
+ // assemble url
if (env == 'test' && username == '') {
validState = false;
username = '?';
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;
+ if (document.getElementById('shorturl').value != entered_url) {
+ // also change url in field
+ document.getElementById('shorturl').value = entered_url;
+ }
}
// are we using the alternativ initials?
},
/* method to extract short url */
- _reg_fromgitweb: /^https?:\/\/flimmer\.tv2\.dk\/git\/([^/]+)(?:\.tv2\.dk)?\.git.*?(?:f=(?:(webroot|robot|opdatering|template|([^;/&]+)))([^;&]*))/,
+ _reg_fromgitweb: /^https?:\/\/flimmer\.tv2\.dk\/git\/([^/]+)(?:\.tv2\.dk)?\.git.*?/,
+ _reg_viewgitfile: /[?;&]f=(?:(webroot|robot|opdatering|template|([^;/&]+)))([^;&#]*)[&;#]?/,
_reg_viewgitbranch1: /[?;&]hb=php4[&;#]?/,
_reg_viewgitbranch2: /[?;&]h=refs\/heads\/php4[&;#]?/,
- _reg_viewgitviewtype: /[?;&]a=(blob|tree)[&;#]?/,
+ _reg_viewgitviewtype: /[?;&]a=(blob|tree|history)[&;#]?/,
_reg_fromi2if: /^http:\/\/i2\.(?:[^.]+\.)?opdatering\.(?:php5\.(?:test|snapshot)\.)?tv2\.dk\/(tango\/(entry|requeue|dynamic)|tool\/pdo_log\/frameset)\.php.*?(?:\?|&)url=([^&]+)/,
_reg_fromloginif: /^http:\/\/login\.(?:([^.]+)\.)?opdatering\.(?:php5\.(test|snapshot)\.)?tv2\.dk\/opslag\.php.*?(?:\?|&)(user_id|username)=([^&]+)/,
_reg_frombugzilla: /^http:\/\/bugzilla\.tv2\.dk\/(show_bug.cgi.*?(?:\?|&)id=([0-9]+))?/,
var fromgitweb = this._reg_fromgitweb.exec(paramUrl);
if (fromgitweb) {
var tv2_sitename = fromgitweb[1];
- var tv2_sitetype = fromgitweb[2];
- var tv2_rootfolder = fromgitweb[3];
- var tv2_uri = fromgitweb[4];
+ var tv2_sitetype = null;
+ var tv2_rootfolder = null;
+ var tv2_uri = null;
+
+ // extract f= part of url
+ var fromgitfile = this._reg_viewgitfile.exec(paramUrl);
+ if (fromgitfile) {
+ tv2_sitetype = fromgitfile[1];
+ tv2_rootfolder = fromgitfile[2];
+ tv2_uri = fromgitfile[3];
+ }
action = 'go-gitweb';
if (tv2_sitename) {
}
url = tv2_sitename;
if (!tv2_rootfolder) {
- if (this._reg_git_nopostfix.exec(tv2_sitename)) {
- // always include sitetype
- url += '/'+tv2_sitetype;
- } else {
- url += (tv2_sitetype == 'webroot' ? '' : '.'+tv2_sitetype);
+ if (tv2_sitetype) {
+ if (this._reg_git_nopostfix.exec(tv2_sitename)) {
+ // always include sitetype
+ url += '/'+tv2_sitetype;
+ } else {
+ if (tv2_sitetype != 'webroot') {
+ url += '.'+tv2_sitetype;
+ if (!tv2_uri) url += '/';
+ }
+ }
}
} else if (this._reg_git_rootfolders.exec(tv2_rootfolder)) {
url += tv2_rootfolder;
} else {
url += '//' + tv2_rootfolder;
}
- url += tv2_uri;
+ if (tv2_uri) url += tv2_uri;
+
if (this._reg_viewgitbranch1.exec(paramUrl) || this._reg_viewgitbranch2.exec(paramUrl)) {
document.getElementById('php4branch').checked = true;
}
var viewtype = this._reg_viewgitviewtype.exec(paramUrl)
- if (viewtype) {
- if (viewtype[1] == 'tree') {
- url += '/';
- } else { // blob
- document.getElementById('viewsource').checked = true;
- }
+ if (viewtype && viewtype[1] == 'tree') {
+ url += '/';
}
+
+ document.getElementById('viewcontent').checked = (
+ // default is to show content if a url exists
+ !viewtype ? (tv2_uri ? true : false) :
+ // explicit
+ viewtype[1] == 'blob' || viewtype[1] == 'tree');
+
} else {
url = '';
}
function() { TV2DeveloperQuickBox.setManuel(this); }, false);
document.getElementById('php4branch').addEventListener('CheckboxStateChange',
function() { TV2DeveloperQuickBox.setManuel(this); }, false);
- document.getElementById('viewsource').addEventListener('CheckboxStateChange',
+ document.getElementById('viewcontent').addEventListener('CheckboxStateChange',
function() { TV2DeveloperQuickBox.setManuel(this); }, false);
// auto go (ALT+4)
if (window.arguments && window.arguments[1]) {