Skip to content

Commit ca32ebc

Browse files
committed
fixes to Tagesspiegel - tests may still be unreliable since the website is shaky.
1 parent 72cd56c commit ca32ebc

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

Tagesspiegel.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"translatorID": "374ac2a5-dd45-461e-bf1f-bf90c2eb7085",
3-
"label": "Der Tagesspiegel",
4-
"creator": "Martin Meyerhoff",
3+
"label": "Tagesspiegel",
4+
"creator": "Martin Meyerhoff, Sebastian Karcher",
55
"target": "^https?://www\\.tagesspiegel\\.de",
66
"minVersion": "2.1.9",
77
"maxVersion": "",
88
"priority": 100,
99
"inRepository": true,
1010
"translatorType": 4,
1111
"browserSupport": "gcsib",
12-
"lastUpdated": "2012-06-10 09:27:00"
12+
"lastUpdated": "2012-10-06 13:16:15"
1313
}
1414

1515
/*
@@ -61,6 +61,8 @@ function scrape(doc, url) {
6161
// Date
6262
var date_XPath = "//span[contains(@class, 'date hcf')]";
6363
var date= ZU.xpathText(doc, date_XPath);
64+
//Today's articles just have a time. For these, we set the date to "today", which Zotero will interpret correctly
65+
if (date.search(/\d{2}\.\d{4}/)==-1) date = "today";
6466
newItem.date= date.replace(/(.{10,10}).*/, '$1');
6567

6668
// Summary
@@ -78,7 +80,7 @@ function scrape(doc, url) {
7880
Zotero.debug(author);
7981
if (author != null){
8082
author = author.replace(/^[Vv]on\s|Kommentar\svon\s/g, '');
81-
author = author.split(/,\s/);
83+
author = author.split(/,\s|\sund\s/);
8284
for (var i in author) {
8385
newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author"));
8486
}
@@ -89,13 +91,14 @@ function scrape(doc, url) {
8991

9092
// Tags
9193
var tags_XPath = "//meta[@name='keywords']";
92-
var tags = doc.evaluate(tags_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().content;
93-
var tags= tags.split(","); // this seems to work even if there's no |
94+
var tags = ZU.xpathText(doc, tags_XPath);
95+
if (tags) var tags= tags.split(","); // this seems to work even if there's no |
9496
for (var i in tags) {
9597
tags[i] = tags[i].replace(/^\s*|\s*$/g, '') // remove whitespace around the tags
9698
newItem.tags.push(tags[i]);
9799
}
98-
100+
newItem.language = "de-DE";
101+
newItem.ISSN = "1865-2263";
99102
newItem.complete();
100103

101104
}
@@ -136,45 +139,42 @@ Zotero.selectItems(items, function (items) {
136139
var testCases = [
137140
{
138141
"type": "web",
139-
"url": "http://www.tagesspiegel.de/berlin/statistik-radler-und-fussgaenger-leben-wieder-gefaehrlicher/5767876.html",
142+
"url": "http://www.tagesspiegel.de/",
143+
"items": "multiple"
144+
},
145+
{
146+
"type": "web",
147+
"url": "http://www.tagesspiegel.de/meinung/ddr-drama-der-turm-ich-leb-mein-leben/7216226.html",
140148
"items": [
141149
{
142150
"itemType": "newspaperArticle",
143151
"creators": [
144152
{
145-
"firstName": "Christoph",
146-
"lastName": "Stollowsky",
153+
"firstName": "Robert",
154+
"lastName": "Ide",
147155
"creatorType": "author"
148156
}
149157
],
150158
"notes": [],
151-
"tags": [
152-
"Verkehr",
153-
"Statistik",
154-
"Radfahrer",
155-
"Fahrrad"
156-
],
159+
"tags": [],
157160
"seeAlso": [],
158161
"attachments": [
159162
{
160-
"title": "Statistik: Radler und Fußgänger leben wieder gefährlicher - Berlin - Tagesspiegel",
163+
"title": "DDR-Drama \"Der Turm\": Ich leb’ mein Leben - Meinung - Tagesspiegel",
161164
"mimeType": "text/html"
162165
}
163166
],
164-
"url": "http://www.tagesspiegel.de/berlin/statistik-radler-und-fussgaenger-leben-wieder-gefaehrlicher/5767876.html",
165-
"title": "Radler und Fußgänger leben wieder gefährlicher",
166-
"date": "28.10.2011",
167-
"abstractNote": "Die Zahl der Verkehrstoten nimmt erneut zu. Die Polizei beklagt Unachtsamkeit von Autofahrern – und hofft auf mehr Radspuren.",
167+
"url": "http://www.tagesspiegel.de/meinung/ddr-drama-der-turm-ich-leb-mein-leben/7216226.html",
168+
"title": "Ich leb’ mein Leben",
169+
"date": "05.10.2012",
170+
"abstractNote": "Das DDR-Familiendrama \"Der Turm\" hat zwei Abende lang Deutschlands Fernsehzuschauer bewegt, die Gedanken flogen zurück in die gemeinsam geteilte Vergangenheit. 17 Millionen Menschen sind irgendwann einmal mit der Frage konfrontiert worden: Dafür oder dagegen? Verrat an Freunden oder der eigenen Karriere?",
168171
"publicationTitle": "Der Tagesspiegel Online",
169-
"libraryCatalog": "Der Tagesspiegel",
172+
"language": "de-DE",
173+
"ISSN": "1865-2263",
174+
"libraryCatalog": "Tagesspiegel",
170175
"accessDate": "CURRENT_TIMESTAMP"
171176
}
172177
]
173-
},
174-
{
175-
"type": "web",
176-
"url": "http://www.tagesspiegel.de/",
177-
"items": "multiple"
178178
}
179179
]
180180
/** END TEST CASES **/

0 commit comments

Comments
 (0)