fahrplan_download.js: moar link mangling for srsly broken pentabarf exports

does not affect links to static pentabarf assets, they are fucked up
beyond repair
This commit is contained in:
Astro 2010-10-21 20:06:56 +02:00
parent 5d132a207a
commit a1fb5a31ad
1 changed files with 10 additions and 4 deletions

View File

@ -141,7 +141,8 @@ function Spider() {
this.see('/schedule/' + conference_id + '/index.de.html');
}
var normalizePath = function(path, from) {
/* link to download location */
function normalizePath(path, from) {
from = from || 'https://cccv.pentabarf.org/';
var uri = URL.parse(URL.resolve('https://cccv.pentabarf.org/', path));
if (uri.hostname !== 'cccv.pentabarf.org')
@ -149,11 +150,12 @@ var normalizePath = function(path, from) {
return uri.pathname;
};
var manglePath = function(path) {
/* link rewriting for xhtml files */
function manglePath(path) {
var m;
if ((m = path.match(/^\/schedule\/\d+\/(.+)$/)))
if ((m = path.match(/^\/schedule\/\d+\/(.+)$/))) {
return baseDir + '/' + m[1];
else if ((m = path.match(/^\/(xml|ical|xcal)\/(schedule|conference)\/\d+/))) {
} else if ((m = path.match(/^\/(xml|ical|xcal)\/(schedule|conference)\/\d+/))) {
var ext;
switch(m[1]) {
case 'ical':
@ -166,6 +168,10 @@ var manglePath = function(path) {
ext = m[1];
}
return baseDir + '/schedule.' + ext;
} else if ((m = path.match(/datenspuren\.de\/fahrplan\/(.*)$/))) {
var f = m[1];
f = f.replace(/day_(.+)\.html/, 'day/$1.html');
return '/fahrplan/' + f;
} else if (path.indexOf('://') >= 0)
return path;
else