From eadcb07279f884f57e20e93f47dcd80a7f564e55 Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 15 Feb 2012 18:02:38 +0530 Subject: [PATCH] fix migration script for subdomains; small fixes --- padmaTexts/migrations/migrate.py | 19 ++++++++++++------- padmaTexts/static/js/views/sidebar.js | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/padmaTexts/migrations/migrate.py b/padmaTexts/migrations/migrate.py index 74efab5..4c538b4 100644 --- a/padmaTexts/migrations/migrate.py +++ b/padmaTexts/migrations/migrate.py @@ -5,14 +5,17 @@ from texts.models import * NEXT = "http://next.pad.ma/" OLD = "http://pad.ma/" IdMapping = {} - - +regex = re.compile(r'(http:\/\/.*?pad.ma\/(V.*?))[\s\"\<\n]') +regex2 = re.compile(r'(http:\/\/.*?pad.ma\/(V.*?))$') def getNewUrl(oldUrl): - new = oldUrl.replace(OLD, NEXT) + new = re.sub(regex2, lambda pat: NEXT + pat.groups()[1], oldUrl) +# print new +# new = oldUrl.replace(OLD, NEXT) try: return urllib2.urlopen(new).url except: print "ERROR: " + oldUrl + return None def getNewId(oldId): oldId = oldId.group().replace(OLD, "")[:-1] @@ -26,11 +29,13 @@ def getNewId(oldId): return newId def replaceUrls(text): - regex = re.compile(r'(http:\/\/pad.ma\/V.*?)[\s\"\<]') + for f in re.findall(regex, text): - newUrl = getNewUrl(f) - print newUrl - text = text.replace(f, newUrl) + newUrl = getNewUrl(f[0]) + if newUrl is None: + continue +# print newUrl + text = text.replace(f[0], newUrl) return text # for m in re.findall(regex, text): # print getNewId(m) diff --git a/padmaTexts/static/js/views/sidebar.js b/padmaTexts/static/js/views/sidebar.js index d3b440a..b6653ae 100644 --- a/padmaTexts/static/js/views/sidebar.js +++ b/padmaTexts/static/js/views/sidebar.js @@ -196,7 +196,7 @@ function setupPadmaLink(videoObj, data) { var thisTrack = tracks[t]; var thisTrackLayers = filterLayersByTracks(currentLayers, [thisTrack]); if (thisTrackLayers.length > 0) { - annotHtml += '' + thisTrack + "s:
"; + annotHtml += '' + thisTrack + ":
"; } for (var i=0; i < thisTrackLayers.length; i++) { var thisTrack = thisTrackLayers[i];