www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 93ffca6833906e80d822739d8d958cff17d9dba6
parent b2bcff1dacf5a7a6b9a86fcf7172149b62d01637
Author: Avram Lyon <ajlyon@gmail.com>
Date:   Mon, 22 Nov 2010 19:24:48 +0000

Trans: Fix for the new blog URLs layout of CHE


Diffstat:
Mtranslators/The Chronicle of Higher Education.js | 28+++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/translators/The Chronicle of Higher Education.js b/translators/The Chronicle of Higher Education.js @@ -1,14 +1,14 @@ { - "translatorID":"1e6d1529-246f-4429-84e2-1f1b180b250d", - "translatorType":4, - "label":"The Chronicle of Higher Education", - "creator":"Simon Kornblith, Avram Lyon", - "target":"^http://chronicle\\.com/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-05-27 17:30:00" + "translatorID":"1e6d1529-246f-4429-84e2-1f1b180b250d", + "label":"The Chronicle of Higher Education", + "creator":"Simon Kornblith, Avram Lyon", + "target":"^http://chronicle\\.com/", + "minVersion":"1.0.0b3.r1", + "maxVersion":"", + "priority":100, + "inRepository":"1", + "translatorType":4, + "lastUpdated":"2010-11-22 22:19:41" } /* @@ -38,7 +38,7 @@ function detectWeb(doc, url) { /* The /daily/ and /weekly/ sections are leftover from the previous version of the translator; they don't appear to still be on the Chronicle site, but they might persist in older URLs. */ - var articleRegexp = /^http:\/\/chronicle\.com\/(daily|weekly|article|blogPost)\/[^/]+\// ; + var articleRegexp = /^http:\/\/chronicle\.com\/(daily|weekly|article|blogPost|blogs\/\w+)\/[^/]+\// ; if(articleRegexp.test(url)) { var section = url.match(articleRegexp); switch (section[1]) { @@ -49,6 +49,8 @@ function detectWeb(doc, url) { case "blogPost": return "blogPost"; default: + if (section[1].indexOf("blogs") !== -1) + return "blogPost"; return false; } } else { @@ -73,7 +75,7 @@ function doWeb (doc, url) { var items = {}; var aTags = doc.getElementsByTagName("a"); for(var i=0; i<aTags.length; i++) { - var articleRegexp = /^http:\/\/chronicle\.com\/(daily|weekly|article|blogPost)\/[^/]+\//; + var articleRegexp = /^http:\/\/chronicle\.com\/(daily|weekly|article|blogPost|blogs\/\w+)\/[^/]+\//; if(articleRegexp.test(aTags[i].href)) { items[aTags[i].href] = aTags[i].textContent; } @@ -110,7 +112,7 @@ function doWeb (doc, url) { if (dateline !== null) { item.date = dateline.textContent; } - item.title = doc.evaluate('//div[@class="blog-mod"]/h1[@class="title"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; + item.title = doc.evaluate('//div[@class="blog-mod"]//h1[@class="entry-title"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; // We keep the Chronicle as the Website Type, for lack of a better place item.websiteType = item.publicationTitle;