{"action":"created","comment":{"url":"https://api.github.com/repos/zotero/translators/pulls/comments/50038924","id":50038924,"diff_hunk":"@@ -0,0 +1,321 @@\n+{\n+    \"translatorID\": \"5cf8bb21-e350-444f-b9b4-f46d9fab7827\",\n+    \"label\": \"DABI\",\n+    \"creator\": \"Jens Mittelbach\",\n+    \"target\": \"^https?://dabi\\\\.ib\\\\.hu-berlin\\\\.de/\",\n+    \"minVersion\": \"1.0\",\n+    \"maxVersion\": \"\",\n+    \"priority\": 100,\n+    \"inRepository\": true,\n+    \"translatorType\": 4,\n+    \"browserSupport\": \"gcsibv\",\n+    \"lastUpdated\": \"2016-01-08 11:43:21\"\n+}\n+\n+function detectWeb(doc, url) {\n+    if (doc.title.trim().indexOf(\"DABI. Datensatz Vollanzeige\") == 0) {\n+        return \"journalArticle\";\n+    } else if (doc.title.trim().indexOf(\"DABI: Rechercheergebnis\") == 0) {\n+        var keinTreffer = doc.getElementsByTagName(\"br\")[7].nextSibling.data.indexOf(\"Keine Treffer für die Suche nach:\")\n+        if (keinTreffer == -1) {\n+            return \"multiple\";\n+        }\n+    }\n+}\n+\n+function doWeb(doc, url) {\n+    var ids = [];\n+\n+    //If Statement checks if page is a Search Result, then saves requested Items\n+    if (detectWeb(doc, url) == \"multiple\") {\n+        Z.selectItems(getSearchResults(doc), function(items) {\n+            if (!items) return true;\n+            for (var i in items) {\n+                ids.push(i);\n+            }\n+        });\n+    } else if (detectWeb(doc, url) == \"journalArticle\") {\n+        //saves single page items\n+        ids = [url];\n+    }\n+    ZU.processDocuments(ids, scrape);\n+}\n+\n+\n+function getSearchResults(doc) {\n+    var trs = doc.getElementsByTagName(\"tr\"),\n+        tds = null,\n+        items = {};\n+\n+    for (var i = 1; i < trs.length; i++) {\n+        tds = trs[i].getElementsByTagName(\"td\");\n+        for (var n = 0; n < tds.length; n++) {\n+            var url = doc.location.origin + \"/cgi-bin/dabi/\" + tds[0].firstChild.getAttribute(\"href\"),\n+                author = tds[1].innerHTML,\n+                title = tds[2].innerHTML.replace(/<br>/g, '. ');\n+\n+            if (!author == '') {\n+                var item = author.replace(/; <br>.*/, ' et al.') + \": \" + title;\n+            } else {\n+                var item = title;\n+            }\n+            if (!item || !url) continue;\n+\n+            items[url] = item;\n+        }\n+    }\n+    return items;\n+}\n+\n+function scrape(doc, url) {\n+    var newItem = new Zotero.Item('journalArticle');\n+    var trs = doc.getElementsByTagName(\"tr\"),\n+        headers,\n+        contents,\n+        items = {};\n+\n+    //For Loop to populate \"items\" Object and save tags to an Array.\n+    for (var i = 0; i < trs.length; i++) {\n+        headers = trs[i].getElementsByTagName(\"th\")[0].textContent;\n+        contents = trs[i].getElementsByTagName(\"td\")[0].innerHTML;\n+\n+        items[headers.replace(/\\s+/g, '')] = contents.trim();\n+    }\n+\n+    //set url to fulltext resource, if present; else to database item\n+    if (items[\"URL\"] == '') {\n+        newItem.url = url;\n+    } else {\n+        var link = doc.createElement('a');\n+        link.innerHTML = items[\"URL\"];\n+        newItem.url = link.firstChild.getAttribute(\"href\");\n+\n+        if (/\\.pdf(#.*)?$/.test(newItem.url)) {\n+            newItem.attachments = [{\n+                url: newItem.url,\n+                title: \"DABI Full Text PDF\",\n+                mimeType: \"application/pdf\"\n+            }];\n+        }\n+    }\n+\n+\n+    //Formatting and saving \"title\" fields\n+    if (items[\"Titel\"]) {\n+        newItem.title = items[\"Titel\"].replace(/\\*/g, '');\n+        var short = newItem.title.replace(/^\\W?(?:Die |Der |Das |\\.{3}\\s?)?/, '');\n+        short = short.replace(/\\W?(,|:|\\?|!|\\.|\\\"|\\')/, '').split(' ').slice(0, 6).join(' ');\n+        newItem.shortTitle = short.substring(0, 1).toUpperCase() + short.slice(1);\n+        if (items[\"Untertitel\"]) {\n+            if (/(\\?|!|\\.)\\W?$/.test(newItem.title)) {\n+                newItem.title += \" \" + items[\"Untertitel\"];\n+            } else {\n+                newItem.title += \": \" + items[\"Untertitel\"];\n+            }\n+        }\n+    }\n+\n+    //Sometimes titles are missing\n+    if (items[\"Untertitel\"] && !items[\"Titel\"]) {\n+        newItem.title = items[\"Untertitel\"].replace(/\\*/g, '');\n+        var short = newItem.title.replace(/^\\W?(?:Die |Der |Das |\\.{3}\\s?)?/, '');\n+        short = short.replace(/\\W?(,|:|\\?|!|\\.|\\\"|\\').*$/, '').split(' ').slice(0, 6).join(' ');\n+        newItem.shortTitle = short.substring(0, 1).toUpperCase() + short.slice(1);\n+    }\n+\n+    //Formatting and saving \"Author\" field\n+    if (items[\"Autoren\"]) {\n+        var authors = items[\"Autoren\"].split(\"; \");\n+        for (var i = 0; i < authors.length; i++) {\n+            newItem.creators.push(ZU.cleanAuthor(authors[i], \"author\", true));\n+        }\n+    }\n+\n+    //Formatting and saving \"pages\" field\n+    if (items[\"Anfangsseite\"]) {\n+        newItem.pages = items[\"Anfangsseite\"] + (items[\"Endseite\"] ? \"-\" + items[\"Endseite\"] : \"\");\n+    }\n+\n+    //Saving the tags to Zotero\n+    if (items[\"Schlagwörter\"]) {\n+        var tags = items[\"Schlagwörter\"].split(\"; \");\n+        for (var i = 0; i < tags.length; i++) {\n+            newItem.tags.push(tags[i]);\n+        }\n+    }\n+\n+    //Making the publication title orthographic\n+    if (items[\"Zeitschrift\"]) {\n+        newItem.publicationTitle = items[\"Zeitschrift\"].replace(/ : /g, \": \");\n+    }\n+\n+    //Associating and saving the well formatted data to Zotero\n+    var fieldMap = {\n+        \"date\": items[\"Jahr\"],\n+        \"issue\": items[\"Heft\"],\n+        \"volume\": items[\"Band\"],\n+        \"abstractNote\": items[\"Abstract\"]\n+    };\n+\n+    for (var key in fieldMap) {\n+        if (fieldMap.hasOwnProperty(key)) {\n+            newItem[key] = fieldMap[key];\n+        }\n+    };\n+\n+    newItem.libraryCatalog = \"DABI\";\n+\n+    //Scrape is COMPLETE!\n+    newItem.complete();\n+} /** BEGIN TEST CASES **/\n+var testCases = [{\n+        \"type\": \"web\",\n+        \"url\": \"http://dabi.ib.hu-berlin.de/cgi-bin/dabi/vollanzeige.pl?artikel_id=13028&modus=html\",\n+        \"items\": [{\n+            \"itemType\": \"journalArticle\",\n+            \"title\": \"\\\"Mich interessierten kostengünstige Alternativen zu Citavi\\\": Über den Fortbildungsworkshop \\\"Literaturverwaltung im Fokus\\\" im Rahmen der AGMB-Tagung 2012\",\n+            \"creators\": [{\n+                \"firstName\": \"Matti\",\n+                \"lastName\": \"Stöhr\",\n+                \"creatorType\": \"author\"\n+            }],\n+            \"date\": \"2012\",\n+            \"abstractNote\": \"Zum Programm der AGMB-Tagung 2012 in Aachen gehörte u.a. der zweistündige Fortbildungsworkshop \\\"Literaturverwaltung im Fokus - Softwaretypen, bibliothekarische Services und mehr\\\". Im Beitrag werden weniger die referierten Workshopinhalte beschrieben, als vielmehr die Perspektive der Teilnehmerinnen und Teilnehmer anhand einer eMail-basierten Umfrage vorgestellt. Die Kernfrage lautet hierbei: War der Workshop für sie gewinnbringend?\",\n+            \"issue\": \"3\",\n+            \"libraryCatalog\": \"DABI\",\n+            \"pages\": \"0-0\",","path":"DABI.js","position":186,"original_position":186,"commit_id":"8387c95ca68c754354e30adf1714eb56b7e7ec5f","original_commit_id":"8387c95ca68c754354e30adf1714eb56b7e7ec5f","user":{"login":"aurimasv","id":1381759,"avatar_url":"https://avatars.githubusercontent.com/u/1381759?v=3","gravatar_id":"","url":"https://api.github.com/users/aurimasv","html_url":"https://github.com/aurimasv","followers_url":"https://api.github.com/users/aurimasv/followers","following_url":"https://api.github.com/users/aurimasv/following{/other_user}","gists_url":"https://api.github.com/users/aurimasv/gists{/gist_id}","starred_url":"https://api.github.com/users/aurimasv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aurimasv/subscriptions","organizations_url":"https://api.github.com/users/aurimasv/orgs","repos_url":"https://api.github.com/users/aurimasv/repos","events_url":"https://api.github.com/users/aurimasv/events{/privacy}","received_events_url":"https://api.github.com/users/aurimasv/received_events","type":"User","site_admin":false},"body":"Check for this case and make sure it doesn't happen. (1) if it's just `0`, we should leave pages blank. (2) If start and end is the same, it should just be start.","created_at":"2016-01-18T20:04:32Z","updated_at":"2016-01-18T20:04:32Z","html_url":"https://github.com/zotero/translators/pull/979#discussion_r50038924","pull_request_url":"https://api.github.com/repos/zotero/translators/pulls/979","_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments/50038924"},"html":{"href":"https://github.com/zotero/translators/pull/979#discussion_r50038924"},"pull_request":{"href":"https://api.github.com/repos/zotero/translators/pulls/979"}}},"pull_request":{"url":"https://api.github.com/repos/zotero/translators/pulls/979","id":53747710,"html_url":"https://github.com/zotero/translators/pull/979","diff_url":"https://github.com/zotero/translators/pull/979.diff","patch_url":"https://github.com/zotero/translators/pull/979.patch","issue_url":"https://api.github.com/repos/zotero/translators/issues/979","number":979,"state":"open","locked":false,"title":"DABI translator","user":{"login":"jmiba","id":8625511,"avatar_url":"https://avatars.githubusercontent.com/u/8625511?v=3","gravatar_id":"","url":"https://api.github.com/users/jmiba","html_url":"https://github.com/jmiba","followers_url":"https://api.github.com/users/jmiba/followers","following_url":"https://api.github.com/users/jmiba/following{/other_user}","gists_url":"https://api.github.com/users/jmiba/gists{/gist_id}","starred_url":"https://api.github.com/users/jmiba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmiba/subscriptions","organizations_url":"https://api.github.com/users/jmiba/orgs","repos_url":"https://api.github.com/users/jmiba/repos","events_url":"https://api.github.com/users/jmiba/events{/privacy}","received_events_url":"https://api.github.com/users/jmiba/received_events","type":"User","site_admin":false},"body":"translator for http://dabi.ib.hu-berlin.de","created_at":"2015-12-15T19:11:10Z","updated_at":"2016-01-18T20:04:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"22126ccebc1fef72fbebae47bc5396fd58493b6a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zotero/translators/pulls/979/commits","review_comments_url":"https://api.github.com/repos/zotero/translators/pulls/979/comments","review_comment_url":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zotero/translators/issues/979/comments","statuses_url":"https://api.github.com/repos/zotero/translators/statuses/8387c95ca68c754354e30adf1714eb56b7e7ec5f","head":{"label":"jmiba:patch-1","ref":"patch-1","sha":"8387c95ca68c754354e30adf1714eb56b7e7ec5f","user":{"login":"jmiba","id":8625511,"avatar_url":"https://avatars.githubusercontent.com/u/8625511?v=3","gravatar_id":"","url":"https://api.github.com/users/jmiba","html_url":"https://github.com/jmiba","followers_url":"https://api.github.com/users/jmiba/followers","following_url":"https://api.github.com/users/jmiba/following{/other_user}","gists_url":"https://api.github.com/users/jmiba/gists{/gist_id}","starred_url":"https://api.github.com/users/jmiba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmiba/subscriptions","organizations_url":"https://api.github.com/users/jmiba/orgs","repos_url":"https://api.github.com/users/jmiba/repos","events_url":"https://api.github.com/users/jmiba/events{/privacy}","received_events_url":"https://api.github.com/users/jmiba/received_events","type":"User","site_admin":false},"repo":{"id":48063244,"name":"translators","full_name":"jmiba/translators","owner":{"login":"jmiba","id":8625511,"avatar_url":"https://avatars.githubusercontent.com/u/8625511?v=3","gravatar_id":"","url":"https://api.github.com/users/jmiba","html_url":"https://github.com/jmiba","followers_url":"https://api.github.com/users/jmiba/followers","following_url":"https://api.github.com/users/jmiba/following{/other_user}","gists_url":"https://api.github.com/users/jmiba/gists{/gist_id}","starred_url":"https://api.github.com/users/jmiba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmiba/subscriptions","organizations_url":"https://api.github.com/users/jmiba/orgs","repos_url":"https://api.github.com/users/jmiba/repos","events_url":"https://api.github.com/users/jmiba/events{/privacy}","received_events_url":"https://api.github.com/users/jmiba/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jmiba/translators","description":"Zotero Translators","fork":true,"url":"https://api.github.com/repos/jmiba/translators","forks_url":"https://api.github.com/repos/jmiba/translators/forks","keys_url":"https://api.github.com/repos/jmiba/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jmiba/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jmiba/translators/teams","hooks_url":"https://api.github.com/repos/jmiba/translators/hooks","issue_events_url":"https://api.github.com/repos/jmiba/translators/issues/events{/number}","events_url":"https://api.github.com/repos/jmiba/translators/events","assignees_url":"https://api.github.com/repos/jmiba/translators/assignees{/user}","branches_url":"https://api.github.com/repos/jmiba/translators/branches{/branch}","tags_url":"https://api.github.com/repos/jmiba/translators/tags","blobs_url":"https://api.github.com/repos/jmiba/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jmiba/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jmiba/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/jmiba/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jmiba/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/jmiba/translators/languages","stargazers_url":"https://api.github.com/repos/jmiba/translators/stargazers","contributors_url":"https://api.github.com/repos/jmiba/translators/contributors","subscribers_url":"https://api.github.com/repos/jmiba/translators/subscribers","subscription_url":"https://api.github.com/repos/jmiba/translators/subscription","commits_url":"https://api.github.com/repos/jmiba/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/jmiba/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/jmiba/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/jmiba/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/jmiba/translators/contents/{+path}","compare_url":"https://api.github.com/repos/jmiba/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jmiba/translators/merges","archive_url":"https://api.github.com/repos/jmiba/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jmiba/translators/downloads","issues_url":"https://api.github.com/repos/jmiba/translators/issues{/number}","pulls_url":"https://api.github.com/repos/jmiba/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/jmiba/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/jmiba/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jmiba/translators/labels{/name}","releases_url":"https://api.github.com/repos/jmiba/translators/releases{/id}","created_at":"2015-12-15T19:06:30Z","updated_at":"2015-12-15T19:06:34Z","pushed_at":"2016-01-08T11:50:41Z","git_url":"git://github.com/jmiba/translators.git","ssh_url":"git@github.com:jmiba/translators.git","clone_url":"https://github.com/jmiba/translators.git","svn_url":"https://github.com/jmiba/translators","homepage":"http://www.zotero.org/support/dev/translators","size":11694,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zotero:master","ref":"master","sha":"9dcca21fdc794c8c090876123436e16213f25f62","user":{"login":"zotero","id":891917,"avatar_url":"https://avatars.githubusercontent.com/u/891917?v=3","gravatar_id":"","url":"https://api.github.com/users/zotero","html_url":"https://github.com/zotero","followers_url":"https://api.github.com/users/zotero/followers","following_url":"https://api.github.com/users/zotero/following{/other_user}","gists_url":"https://api.github.com/users/zotero/gists{/gist_id}","starred_url":"https://api.github.com/users/zotero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zotero/subscriptions","organizations_url":"https://api.github.com/users/zotero/orgs","repos_url":"https://api.github.com/users/zotero/repos","events_url":"https://api.github.com/users/zotero/events{/privacy}","received_events_url":"https://api.github.com/users/zotero/received_events","type":"Organization","site_admin":false},"repo":{"id":1991863,"name":"translators","full_name":"zotero/translators","owner":{"login":"zotero","id":891917,"avatar_url":"https://avatars.githubusercontent.com/u/891917?v=3","gravatar_id":"","url":"https://api.github.com/users/zotero","html_url":"https://github.com/zotero","followers_url":"https://api.github.com/users/zotero/followers","following_url":"https://api.github.com/users/zotero/following{/other_user}","gists_url":"https://api.github.com/users/zotero/gists{/gist_id}","starred_url":"https://api.github.com/users/zotero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zotero/subscriptions","organizations_url":"https://api.github.com/users/zotero/orgs","repos_url":"https://api.github.com/users/zotero/repos","events_url":"https://api.github.com/users/zotero/events{/privacy}","received_events_url":"https://api.github.com/users/zotero/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zotero/translators","description":"Zotero Translators","fork":false,"url":"https://api.github.com/repos/zotero/translators","forks_url":"https://api.github.com/repos/zotero/translators/forks","keys_url":"https://api.github.com/repos/zotero/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zotero/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zotero/translators/teams","hooks_url":"https://api.github.com/repos/zotero/translators/hooks","issue_events_url":"https://api.github.com/repos/zotero/translators/issues/events{/number}","events_url":"https://api.github.com/repos/zotero/translators/events","assignees_url":"https://api.github.com/repos/zotero/translators/assignees{/user}","branches_url":"https://api.github.com/repos/zotero/translators/branches{/branch}","tags_url":"https://api.github.com/repos/zotero/translators/tags","blobs_url":"https://api.github.com/repos/zotero/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zotero/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zotero/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/zotero/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zotero/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/zotero/translators/languages","stargazers_url":"https://api.github.com/repos/zotero/translators/stargazers","contributors_url":"https://api.github.com/repos/zotero/translators/contributors","subscribers_url":"https://api.github.com/repos/zotero/translators/subscribers","subscription_url":"https://api.github.com/repos/zotero/translators/subscription","commits_url":"https://api.github.com/repos/zotero/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/zotero/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/zotero/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/zotero/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/zotero/translators/contents/{+path}","compare_url":"https://api.github.com/repos/zotero/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zotero/translators/merges","archive_url":"https://api.github.com/repos/zotero/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zotero/translators/downloads","issues_url":"https://api.github.com/repos/zotero/translators/issues{/number}","pulls_url":"https://api.github.com/repos/zotero/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/zotero/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/zotero/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zotero/translators/labels{/name}","releases_url":"https://api.github.com/repos/zotero/translators/releases{/id}","created_at":"2011-07-03T17:40:38Z","updated_at":"2016-01-04T20:25:52Z","pushed_at":"2016-01-17T18:27:03Z","git_url":"git://github.com/zotero/translators.git","ssh_url":"git@github.com:zotero/translators.git","clone_url":"https://github.com/zotero/translators.git","svn_url":"https://github.com/zotero/translators","homepage":"http://www.zotero.org/support/dev/translators","size":13093,"stargazers_count":161,"watchers_count":161,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":147,"mirror_url":null,"open_issues_count":141,"forks":147,"open_issues":141,"watchers":161,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/979"},"html":{"href":"https://github.com/zotero/translators/pull/979"},"issue":{"href":"https://api.github.com/repos/zotero/translators/issues/979"},"comments":{"href":"https://api.github.com/repos/zotero/translators/issues/979/comments"},"review_comments":{"href":"https://api.github.com/repos/zotero/translators/pulls/979/comments"},"review_comment":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zotero/translators/pulls/979/commits"},"statuses":{"href":"https://api.github.com/repos/zotero/translators/statuses/8387c95ca68c754354e30adf1714eb56b7e7ec5f"}}}}