GitHub PullRequestReviewCommentEvent at 2014-04-02 02:05:02
Repository: translators
Actor: adam3smith
Payload: {"comment":{"url":"https://api.github.com/repos/zotero/translators/pulls/comments/11190356","id":11190356,"diff_hunk":"@@ -0,0 +1,345 @@\n+{\n+\t\"translatorID\": \"e8544423-1515-4daf-bb5d-3202bf422b58\",\n+\t\"label\": \"beck-online\",\n+\t\"creator\": \"Philipp Zumstein\",\n+\t\"target\": \"https?://beck-online\\\\.beck\\\\.de\",\n+\t\"minVersion\": \"3.0\",\n+\t\"maxVersion\": \"\",\n+\t\"priority\": 100,\n+\t\"inRepository\": true,\n+\t\"translatorType\": 4,\n+\t\"browserSupport\": \"gcsv\",\n+\t\"lastUpdated\": \"2014-04-01 16:36:49\"\n+}\n+\n+/*\n+\t***** BEGIN LICENSE BLOCK *****\n+\n+\tbeck-online Translator, Copyright © 2014 Philipp Zumstein\n+\tThis file is part of Zotero.\n+\n+\tZotero is free software: you can redistribute it and/or modify\n+\tit under the terms of the GNU Affero General Public License as published by\n+\tthe Free Software Foundation, either version 3 of the License, or\n+\t(at your option) any later version.\n+\n+\tZotero is distributed in the hope that it will be useful,\n+\tbut WITHOUT ANY WARRANTY; without even the implied warranty of\n+\tMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+\tGNU Affero General Public License for more details.\n+\n+\tYou should have received a copy of the GNU Affero General Public License\n+\talong with Zotero. If not, see <http://www.gnu.org/licenses/>.\n+\n+\t***** END LICENSE BLOCK *****\n+*/\n+\n+//Disclaimer:\n+//This is written mainly for articles/cases in the journals in beck-online\n+//Probably, it might work further on other material (e.g. ebooks) in beck-online.\n+\n+\n+var mappingClassNameToItemType = {\n+\t'ZAUFSATZ' : 'journalArticle',\n+\t'ZRSPR' : 'case',//Rechtssprechung\n+\t'ZENTB' : 'journalArticle',//Entscheidungsbesprechung\n+\t'ZBUCHB' : 'journalArticle',//Buchbesprechung\n+\t'ZSONST' : 'journalArticle',//Sonstiges, z.B. Vorwort\n+\t'ZINHALTVERZ' : 'multiple'//Inhaltsverzeichnis\n+}\n+\n+\n+function detectWeb(doc, url) {\n+\tvar documentClassName = doc.getElementById(\"dokument\").className;\n+\t//Z.debug(documentClassName);\n+\tif (mappingClassNameToItemType[documentClassName.toUpperCase()]) {\n+\t\treturn mappingClassNameToItemType[documentClassName.toUpperCase()];\n+\t}\n+}\n+\n+\n+function doWeb(doc, url) {\n+\tif (detectWeb(doc, url) == \"multiple\") {\n+\t\t\n+\t\tvar items = new Object();\n+\t\tvar articles = new Array();\n+\t\t\n+\t\tvar rows = ZU.xpath(doc, '//div[@class=\"inh\"]//span[@class=\"inhdok\"]//a | //div[@class=\"autotoc\"]//a');\n+\t\tfor(var i=0; i<rows.length; i++) {\n+\t\t\t//rows[i] contains an invisible span with some text, which we have to exclude, e.g.\n+\t\t\t//   <span class=\"unsichtbar\">BKR Jahr 2014 Seite </span>\n+\t\t\t//   Dr. iur. habil. Christian Hofmann: Haftung im Zahlungsverkehr\n+\t\t\tvar title = ZU.trimInternal( ZU.xpathText(rows[i], './text()[1]') );\n+\t\t\tvar link = rows[i].href;\n+\t\t\titems[link] = title;\n+\t\t}\n+\t\tZotero.selectItems(items, function (items) {\n+\t\t\tif (!items) {\n+\t\t\t\treturn true;\n+\t\t\t}\n+\t\t\tfor (var i in items) {\n+\t\t\t\tarticles.push(i);\n+\t\t\t}\n+\t\t\tZU.processDocuments(articles, scrape);\n+\t\t});\n+\t} else {\n+\t\tscrape(doc, url);\n+\t}\n+\t\n+}\n+\n+\n+function scrape(doc, url) {\n+\tvar documentClassName = doc.getElementById(\"dokument\").className;\n+\tvar item;\n+\tif (mappingClassNameToItemType[documentClassName.toUpperCase()]) {\n+\t\titem = new Zotero.Item(mappingClassNameToItemType[documentClassName.toUpperCase()]);\n+\t}\n+\t\n+\tvar titleNode = ZU.xpath(doc, '//div[@class=\"titel\"]')[0] || ZU.xpath(doc, '//div[@class=\"dk2\"]//span[@class=\"titel\"]')[0];\n+\titem.title = ZU.trimInternal(titleNode.textContent);\n+\t\n+\tvar authorNode = ZU.xpath(doc, '//div[@class=\"autor\"]');\n+\tfor (var i=0; i<authorNode.length; i++) {\n+\t\t//normally several authors are under the same authorNode\n+\t\t//and they occur in pairs with first and last names\n+\t\tvar authorFirstNames = ZU.xpath(authorNode[i], './/span[@class=\"vname\"]');\n+\t\tvar authorLastNames = ZU.xpath(authorNode[i], './/span[@class=\"nname\"]');\n+\t\tfor (var j=0; j<authorFirstNames.length; j++) {\n+\t\t\titem.creators.push({\n+\t\t\t\tlastName : authorLastNames[j].textContent , \n+\t\t\t\tfirstName : authorFirstNames[j].textContent ,\n+\t\t\t\tcreatorType: \"author\"\n+\t\t\t});\n+\t\t}\n+\t}\n+\tif (authorNode.length == 0) {\n+\t\tauthorNode = ZU.xpath(doc, '//p[@class=\"authorline\"]/text() | //div[@class=\"authorline\"]/p/text()');\n+\t\tfor (var j=0; j<authorNode.length; j++) {\n+\t\t\t//first we delete some prefixes\n+\t\t\tvar authorString = authorNode[j].textContent.replace(/\\/|Dr\\.|Professor|wiss\\.? Mitarbeiter(in)?|RA,?|FAArbR|Fachanwalt für Insolvenzrecht|Rechtsanwalt|Rechtsanwältin|Rechtsanwälte|Richter am AG|Richter am BGH/g,\"\");\n+\t\t\t//authors can be seperated by \"und\" and \",\" if there are 3 or more authors\n+\t\t\t//a comma can also mark the beginning of suffixes, which we want to delete\n+\t\t\t//therefore we have to distinguish these two cases in the following\n+\t\t\tvar posUnd = authorString.indexOf(\"und\");\n+\t\t\tvar posComma = authorString.indexOf(\",\");\n+\t\t\tif (posUnd > posComma) {\n+\t\t\t\tvar posComma = authorString.indexOf(\",\",posUnd);\n+\t\t\t}\n+\t\t\tif (posComma > 0) {\n+\t\t\t\tauthorString = authorString.substr(0,posComma);\n+\t\t\t}\n+\t\t\t//Z.debug(authorString);\n+\t\t\t\n+\t\t\tauthorArray = authorString.split(/und|,/);\n+\t\t\tfor (var k=0; k<authorArray.length; k++) {\n+\t\t\t\titem.creators.push(ZU.cleanAuthor(ZU.trimInternal(authorArray[k])));\n+\t\t\t}\n+\t\t\t\n+\t\t\t\n+\t\t}\n+\t\t\n+\t}\n+\t\n+\t\n+\titem.publicationTitle = ZU.xpathText(doc, '//li[@class=\"breadcurmbelemenfirst\"]');\n+\titem.journalAbbreviation = ZU.xpathText(doc, '//div[@id=\"doktoc\"]/ul/li/a[2]');\n+\t\n+\titem.date = ZU.xpathText(doc, '//div[@id=\"doktoc\"]/ul/li/ul/li/a[2]');\n+\t\n+\t//e.g. Heft 6 (Seite 141-162)\n+\titem.issue = ZU.xpathText(doc, '//div[@id=\"doktoc\"]/ul/li/ul/li/ul/li/a[2]').replace(/\\([^\\)]*\\)/,\"\").match(/\\d+/)[0];\n+\t\n+\t//e.g. ArbrAktuell 2014, 150\n+\tvar shortCitation = ZU.xpathText(doc, '//div[@class=\"dk2\"]//span[@class=\"citation\"]');\n+\tvar pagesStart = ZU.trimInternal(shortCitation.substr(shortCitation.lastIndexOf(\",\")+1));\n+\tvar pagesEnd = ZU.xpathText(doc, '(//span[@class=\"pg\"])[last()]');\n+\tif (pagesEnd) {\n+\t\titem.pages = pagesStart + \"-\" + pagesEnd;\n+\t} else {\n+\t\titem.pages = pagesStart\n+\t}\n+\t\n+\titem.abstractNote = ZU.xpathText(doc, '//div[@class=\"abstract\"]') || ZU.xpathText(doc, '//div[@class=\"leitsatz\"]');\n+\tif (item.abstractNote){\n+\t\titem.abstractNote = item.abstractNote.replace(/\\n\\s*\\n/g, \"\\n\");\n+\t}\n+\t\n+\tif (item.itemType == \"case\") {\n+\t\tvar courtLine = ZU.xpath(doc, '//div[contains(@class, \"gerzeile\")]/p');\n+\t\t//Z.debug(courtLine);\n+\t\titem.court = ZU.xpathText(courtLine, './span[@class=\"gericht\"]');\n+\t\titem.dateDecided = ZU.xpathText(courtLine, './span[@class=\"edat\"] | ./span[@class=\"datum\"]');\n+\t\tif (item.dateDecided){//e.g. 24. 9. 2001\n+\t\t\titem.dateDecided = item.dateDecided.replace(/(\\d\\d?)\\.\\s*(\\d\\d?)\\.\\s*(\\d\\d\\d\\d)/, \"$3-$2-$1\");\n+\t\t}\n+\t\t//item.dateDecided.replace(/(\\d\\d?)\\.\\s*(\\d\\d?)\\.\\s(\\d\\d\\d\\d)/, \"\\3-\\2-\\1\");\n+\t\titem.docketNumber = ZU.xpathText(courtLine, './span[@class=\"az\"]');\n+\t\titem.history = ZU.xpathText(courtLine, './span[@class=\"vorinst\"]');\n+\t\t\n+\t\titem.shortTitle = shortCitation;\n+\t\t\n+\t\tvar otherCitations = ZU.xpath(doc, '//li[contains(@id, \"Parallelfundstellen\")]');\n+\t\titem.extra = \"Parallelfundstellen: \" + ZU.xpathText(otherCitations[0], './ul/li',  null, \" ; \");\n+\t\t\n+\t\tvar basedOnRegulations = ZU.xpathText(doc, '//div[contains(@class,\"normenk\")]');\n+\t\tif (basedOnRegulations) {\n+\t\t\titem.notes.push( ZU.trimInternal(basedOnRegulations) );\n+\t\t}\n+\t\t\n+\t}\n+\t\n+\tif (documentClassName == \"ZBUCHB\") {\n+\t\titem.extra = ZU.xpathText(doc, '//div[@class=\"biblio\"]');\n+\t}\n+\t\t\n+\titem.attachments = [{\n+\t\ttitle: \"Snapshot\",\n+\t\tdocument:doc\n+\t}];\n+\n+\titem.complete();\n+}/** BEGIN TEST CASES **/\n+var testCases = [\n+\t{\n+\t\t\"type\": \"web\",\n+\t\t\"url\": \"https://beck-online.beck.de/?vpath=bibdata%2fzeits%2fDNOTZ-SONDERH%2f2012%2fcont%2fDNOTZ-SONDERH%2e2012%2e88%2e1%2ehtm\",\n+\t\t\"items\": [\n+\t\t\t{\n+\t\t\t\t\"itemType\": \"journalArticle\",\n+\t\t\t\t\"creators\": [\n+\t\t\t\t\t{\n+\t\t\t\t\t\t\"lastName\": \"Roth\",\n+\t\t\t\t\t\t\"firstName\": \"Günter H.\",\n+\t\t\t\t\t\t\"creatorType\": \"author\"\n+\t\t\t\t\t}\n+\t\t\t\t],\n+\t\t\t\t\"notes\": [],\n+\t\t\t\t\"tags\": [],\n+\t\t\t\t\"seeAlso\": [],\n+\t\t\t\t\"attachments\": [\n+\t\t\t\t\t{\n+\t\t\t\t\t\t\"title\": \"Snapshot\"\n+\t\t\t\t\t}\n+\t\t\t\t],\n+\t\t\t\t\"title\": \"Best practice – Grundstrukturen des kontinentaleuropäischen Gesellschaftsrechts\",\n+\t\t\t\t\"publicationTitle\": \"Sonderheft der Deutschen Notar-Zeitschrift\",\n+\t\t\t\t\"journalAbbreviation\": \"DNotZ-Sonderheft\",\n+\t\t\t\t\"date\": \"2012\",\n+\t\t\t\t\"issue\": \"1\",\n+\t\t\t\t\"pages\": \"88-95\",\n+\t\t\t\t\"libraryCatalog\": \"beck-online\"\n+\t\t\t}\n+\t\t]\n+\t},\n+\t{\n+\t\t\"type\": \"web\",\n+\t\t\"url\": \"https://beck-online.beck.de/default.aspx?typ=reference&y=300&z=BKR&b=2001&s=99&n=1\",\n+\t\t\"items\": [\n+\t\t\t{\n+\t\t\t\t\"itemType\": \"case\",\n+\t\t\t\t\"creators\": [],\n+\t\t\t\t\"notes\": [\n+\t\t\t\t\t\"§ WPHG § 15 WpHG; § BOERSG § 88 BörsG; §§ BGB § 823, BGB § 826 BGB\"\n+\t\t\t\t],\n+\t\t\t\t\"tags\": [],\n+\t\t\t\t\"seeAlso\": [],\n+\t\t\t\t\"attachments\": [\n+\t\t\t\t\t{\n+\t\t\t\t\t\t\"title\": \"Snapshot\"\n+\t\t\t\t\t}\n+\t\t\t\t],\n+\t\t\t\t\"title\": \"Schadensersatz wegen fehlerhafter Ad-hoc-Mitteilungen („Infomatec”)\",\n+\t\t\t\t\"publicationTitle\": \"Zeitschrift für Bank- und Kapitalmarktrecht\",","path":"beck-online.js","position":253,"original_position":253,"commit_id":"b1e83628ec02b0c66a42ff71486ebd44ec7c7260","original_commit_id":"b1e83628ec02b0c66a42ff71486ebd44ec7c7260","user":{"login":"adam3smith","id":128986,"avatar_url":"https://avatars.githubusercontent.com/u/128986?","gravatar_id":"e4d8fe780ddd33be2f1b86dad9c16def","url":"https://api.github.com/users/adam3smith","html_url":"https://github.com/adam3smith","followers_url":"https://api.github.com/users/adam3smith/followers","following_url":"https://api.github.com/users/adam3smith/following{/other_user}","gists_url":"https://api.github.com/users/adam3smith/gists{/gist_id}","starred_url":"https://api.github.com/users/adam3smith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adam3smith/subscriptions","organizations_url":"https://api.github.com/users/adam3smith/orgs","repos_url":"https://api.github.com/users/adam3smith/repos","events_url":"https://api.github.com/users/adam3smith/events{/privacy}","received_events_url":"https://api.github.com/users/adam3smith/received_events","type":"User","site_admin":false},"body":"There is no perfect translation for reporter, but I'd use \"Sammlung\" - it's the collection of decisions, though, not of laws. Given how the citations look, I'd say let's put the journal title in reporter and issue in reporter volume. Given the not-ideal situation we have for legal cites that seems like the best solution. ","created_at":"2014-04-02T02:05:02Z","updated_at":"2014-04-02T02:05:02Z","html_url":"https://github.com/zotero/translators/pull/707#discussion_r11190356","pull_request_url":"https://api.github.com/repos/zotero/translators/pulls/707","_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments/11190356"},"html":{"href":"https://github.com/zotero/translators/pull/707#discussion_r11190356"},"pull_request":{"href":"https://api.github.com/repos/zotero/translators/pulls/707"}}}}