{"action":"created","comment":{"url":"https://api.github.com/repos/zotero/translators/pulls/comments/39935806","id":39935806,"diff_hunk":"@@ -9,596 +9,130 @@\n \t\"inRepository\": true,\n \t\"translatorType\": 4,\n \t\"browserSupport\": \"gcsibv\",\n-\t\"lastUpdated\": \"2014-04-03 18:47:00\"\n+\t\"lastUpdated\": \"2015-09-20 18:13:00\"\n }\n \n-/**\n-\tOZON.ru translator. Only supports \"Book\" \"Item Type\".\n-\tCopyright (c) 2012 Victor Rybynok, v.rybynok@gmail.com\n \n-\tDescription\n-\t===========\n+function detectWeb(document, url) {\n+\tvar URLRegexp = /https?:\\/\\/www\\.ozon\\.ru\\/context\\/detail\\/id\\/\\d+\\//;\n+    var isURLValid = URLRegexp.test(url);\n+    var hasISBN = xpath('//*[@itemprop=\"isbn\"]/text()', document).iterateNext() !== null;\n \n-\tZotero translator for OZON.ru on-line store.\n+    if (isURLValid && hasISBN) {\n+        return 'book';\n+    }\n+}\n \n-\tComments\n-\t========\n+function doWeb(document, url) {\n+\tvar book = new Zotero.Item('book');\n \n-\tThis version of OZON.ru translator only supports \"Book\" \"Item Type\"\n-\tfor \"Книги\" and \"Цифровые книги\" ozon.ru site sections.\n+\tvar content = xpath('//div[@class=\"bContentBlock\"]', document).iterateNext();\n \n-\tChange log\n-\t==========\n+\t// basic info\n+\tbook.title = xpath('./h1[@itemprop=\"name\"]/text()', content).iterateNext().textContent;\n+\tbook.url = url;\n \n-\t2013-05-27\n+\tvar publisher = xpath('.//*[@itemprop=\"publisher\"]/a/text()', content).iterateNext();\n+\tif (publisher !== null)\n+\t\tbook.publisher = publisher.textContent;\n \n-\t* New page layout parsing.\n+\tvar numPages = xpath('.//*[@itemprop=\"numberOfPages\"]/text()', content).iterateNext();\n+\tif (numPages !== null)\n+\t\tbook.numPages = numPages.textContent;\n \n-\t2012-08-11\n+\tvar isbn = xpath('.//*[@itemprop=\"isbn\"]/text()', content).iterateNext();\n+\tif (isbn !== null) {\n+\t\tvar isbnMatch = /[\\d-]+/.exec(isbn);\n+\t\tif (isbnMatch !== null)\n+\t\t\tbook.ISBN = isbnMatch[0];\n+\t}\n \n-\t* Corrected detail description parsing to accommodate the new book\n-\t  description pages template.\n-\t* Corrected \"edition number\" recognition.\n-\t* Introduced change log and to do comment sections.\n-\t* Few minor issue fixes.\n+\t// volume (parsed from the title)\n+\tvar volume = /(т(\\.|ом)|vol(\\.|ume))\\s+\\d/i.exec(book.title);\n+\tbook.volume = volume[0].replace(/[^\\d]/g, '')\n \n-\t2012-04-02\n+\t// language\n+\tvar language = xpath('.//*[@itemprop=\"inLanguage\"]', content).iterateNext();\n \n-\t* Initial release.\n+\tif (language !== null)\n+\t\tbook.language = language.textContent.split(': ')[1];\n \n-\tTODO\n-\t====\n \n-\t* Develop more universal algorithm for \"edition number\" recognition.\n-\t  Currently it only recognises up to 10 editions in Russian verbal\n-\t  representation.\n+\t// description\n+\tvar abstractNote = xpath('//*[@itemprop=\"description\"]', document).iterateNext();\n+\tbook.abstractNote = abstractNote.textContent;\n \n-\tLegal notice\n-\t============\n+\tbook.creators = [];\n \n-\tThis program is free software: you can redistribute it and/or\n-\tmodify it under the terms of the GNU Affero General Public License\n-\tas published by the Free Software Foundation, either version 3 of\n-\tthe License, or (at your option) any later version.\n+\t// authors\n+\tvar authors = iteratorToArray(xpath('.//*[@itemprop=\"author\"]/a/text()', content));\n+\tfor (i in authors)\n+\t\tbook.creators.push(createCreator('author', authors[i].textContent));\n \n-\tThis program 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 GNU\n-\tAffero General Public License for more details.\n+\t// translator, editor, etc.\n+\tvar additionalProperties = iteratorToArray(\n+\t\txpath('.//p[not(@itemprop)]', content)\n+\t);\n+\tfor (i in additionalProperties) {\n+\t\tvar property = getAdditionalProperty(additionalProperties[i]);\n+\t\tif (typeof property === 'undefined')\n+\t\t\tcontinue;\n \n-\tYou should have received a copy of the GNU Affero General Public\n-\tLicense along with this program.  If not, see\n-\t<http://www.gnu.org/licenses/>.\n-*/\n+\t\tif (property.name === 'Переводчик')\n+\t\t\tbook.creators.push(createCreator('translate', property.value));\n \n-function detectWeb(doc, url) {\n-\tvar itemTypeXPath = '//ul[@class=\"navLine\"]/li[1]/a';\n-\tvar itemTypeDOMNode =\n-\tdoc.evaluate(itemTypeXPath, doc, null,\n-\tXPathResult.ANY_TYPE, null).iterateNext();\n-\tvar itemType;\n-\tif (itemTypeDOMNode) itemType = itemTypeDOMNode.textContent;\n-\telse return \"\";\n-\tif (itemType == \"Книги\") {\n-\t\tvar nameXPath = '//div[@class=\"techDescription\"]/div/div[2]/span';\n-\t\tvar valueXPath = '//div[@class=\"techDescription\"]/div/div[3]/span';\n-\t\tvar nameXPathRes = doc.evaluate(\n-\t\tnameXPath, doc, null, XPathResult.ANY_TYPE, null);\n-\t\tvar valueXPathRes = doc.evaluate(\n-\t\tvalueXPath, doc, null, XPathResult.ANY_TYPE, null);\n-\t\tif (!IsAudioBook(nameXPathRes, valueXPathRes)) return \"book\";\n-\t} else {\n-\t\titemTypeXPath = '//ul[@class=\"navLine\"]/li[2]/a';\n-\t\titemTypeDOMNode =\n-\t\tdoc.evaluate(itemTypeXPath, doc, null,\n-\t\tXPathResult.ANY_TYPE, null).iterateNext();\n-\t\tif (itemTypeDOMNode) itemType = itemTypeDOMNode.textContent;\n-\t\telse return \"\";\n-\t\tif (itemType == \"Цифровые книги\") return \"book\";\n-\t}\n-}\n-\n-function IsAudioBook(nameXPathRes, valueXPathRes) {\n-\tvar nameDOMNode;\n-\tvar valueDOMNode;\n-\twhile( (nameDOMNode = nameXPathRes.iterateNext()) &&\n-\t(valueDOMNode = valueXPathRes.iterateNext()) ) {\n-\t\tvar nameText = CleanText(nameDOMNode.textContent);\n-\t\tvar valueText = CleanText(valueDOMNode.textContent);\n-\t\tif (nameText == \"Формат аудиокниги\") return true;\n-\t}\n-\treturn false;\n-}\n+\t\tif (property.name === 'Редактор')\n+\t\t\tbook.creators.push(createCreator('editor', property.value));\n \n-function MergeObjects(obj1, obj2) {\n-\tvar result = new Object();\n-\tfor (var attrName in obj1) {\n-\t\tresult[attrName] = obj1[attrName];\n+\t\tif (property.name === 'Серия')\n+\t\t\tbook.series = property.value;\n \t}\n-\tfor (var attrName in obj2) {\n-\t\tresult[attrName] = obj2[attrName];\n-\t}\n-\treturn result;\n-}\n \n-function CleanText(text) {\n-\tvar result = text.replace(/^\\s*|\\s*$/g, '');\n-\tresult = result.replace(/\\s+/g, ' ');\n-\treturn result;\n+\tbook.complete();\n }\n \n-function CleanCreator(creatorStr) {\n-\treturn CleanText(creatorStr);\n+function xpath(expr, context) {\n+\t// executes standard XPath search on a document\n+    return document.evaluate(expr, context, null, XPathResult.ANY_TYPE, null);","path":"OZON.ru.js","position":193,"original_position":193,"commit_id":"9b0a57543877a6b771966b9e153c740657d6fa9b","original_commit_id":"9b0a57543877a6b771966b9e153c740657d6fa9b","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":"never refer to `document` directly. Use `doc` that is passed into `doWeb`, `detectWeb`, callback to `ZU.processDocuments`","created_at":"2015-09-20T22:37:14Z","updated_at":"2015-09-20T22:37:14Z","html_url":"https://github.com/zotero/translators/pull/947#discussion_r39935806","pull_request_url":"https://api.github.com/repos/zotero/translators/pulls/947","_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments/39935806"},"html":{"href":"https://github.com/zotero/translators/pull/947#discussion_r39935806"},"pull_request":{"href":"https://api.github.com/repos/zotero/translators/pulls/947"}}},"pull_request":{"url":"https://api.github.com/repos/zotero/translators/pulls/947","id":45504781,"html_url":"https://github.com/zotero/translators/pull/947","diff_url":"https://github.com/zotero/translators/pull/947.diff","patch_url":"https://github.com/zotero/translators/pull/947.patch","issue_url":"https://api.github.com/repos/zotero/translators/issues/947","number":947,"state":"open","locked":false,"title":"Fixed OZON.ru translator (actually, rewritten from scratch).","user":{"login":"roveo","id":5427958,"avatar_url":"https://avatars.githubusercontent.com/u/5427958?v=3","gravatar_id":"","url":"https://api.github.com/users/roveo","html_url":"https://github.com/roveo","followers_url":"https://api.github.com/users/roveo/followers","following_url":"https://api.github.com/users/roveo/following{/other_user}","gists_url":"https://api.github.com/users/roveo/gists{/gist_id}","starred_url":"https://api.github.com/users/roveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roveo/subscriptions","organizations_url":"https://api.github.com/users/roveo/orgs","repos_url":"https://api.github.com/users/roveo/repos","events_url":"https://api.github.com/users/roveo/events{/privacy}","received_events_url":"https://api.github.com/users/roveo/received_events","type":"User","site_admin":false},"body":"Hi there! OZON.ru translator wasn't working, so I took some time to rewrite it.\r\n\r\nThe only functionality missing from my version compared to the previous one (when it worked anyway) is parsing the edition numbers, which I do have plans to add. New functionality is volume number extraction and overall more readable and maintainable code. Will add test cases soon.\r\n\r\nI had some doubts regarding the filename and translator GUID, because, well, the code is completely different, so should the GUID stay the same? Does it identify a translator or a resource? Anyway I can put the old one into the code in a couple of seconds if needed, just tell me.","created_at":"2015-09-20T21:40:40Z","updated_at":"2015-09-20T22:37:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e2829ff1fe461a6905fde9e346730e25a115b396","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zotero/translators/pulls/947/commits","review_comments_url":"https://api.github.com/repos/zotero/translators/pulls/947/comments","review_comment_url":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zotero/translators/issues/947/comments","statuses_url":"https://api.github.com/repos/zotero/translators/statuses/9b0a57543877a6b771966b9e153c740657d6fa9b","head":{"label":"roveo:ozon","ref":"ozon","sha":"9b0a57543877a6b771966b9e153c740657d6fa9b","user":{"login":"roveo","id":5427958,"avatar_url":"https://avatars.githubusercontent.com/u/5427958?v=3","gravatar_id":"","url":"https://api.github.com/users/roveo","html_url":"https://github.com/roveo","followers_url":"https://api.github.com/users/roveo/followers","following_url":"https://api.github.com/users/roveo/following{/other_user}","gists_url":"https://api.github.com/users/roveo/gists{/gist_id}","starred_url":"https://api.github.com/users/roveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roveo/subscriptions","organizations_url":"https://api.github.com/users/roveo/orgs","repos_url":"https://api.github.com/users/roveo/repos","events_url":"https://api.github.com/users/roveo/events{/privacy}","received_events_url":"https://api.github.com/users/roveo/received_events","type":"User","site_admin":false},"repo":{"id":42816813,"name":"translators","full_name":"roveo/translators","owner":{"login":"roveo","id":5427958,"avatar_url":"https://avatars.githubusercontent.com/u/5427958?v=3","gravatar_id":"","url":"https://api.github.com/users/roveo","html_url":"https://github.com/roveo","followers_url":"https://api.github.com/users/roveo/followers","following_url":"https://api.github.com/users/roveo/following{/other_user}","gists_url":"https://api.github.com/users/roveo/gists{/gist_id}","starred_url":"https://api.github.com/users/roveo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roveo/subscriptions","organizations_url":"https://api.github.com/users/roveo/orgs","repos_url":"https://api.github.com/users/roveo/repos","events_url":"https://api.github.com/users/roveo/events{/privacy}","received_events_url":"https://api.github.com/users/roveo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/roveo/translators","description":"Zotero Translators","fork":true,"url":"https://api.github.com/repos/roveo/translators","forks_url":"https://api.github.com/repos/roveo/translators/forks","keys_url":"https://api.github.com/repos/roveo/translators/keys{/key_id}","collaborators_url":"https://api.github.com/repos/roveo/translators/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/roveo/translators/teams","hooks_url":"https://api.github.com/repos/roveo/translators/hooks","issue_events_url":"https://api.github.com/repos/roveo/translators/issues/events{/number}","events_url":"https://api.github.com/repos/roveo/translators/events","assignees_url":"https://api.github.com/repos/roveo/translators/assignees{/user}","branches_url":"https://api.github.com/repos/roveo/translators/branches{/branch}","tags_url":"https://api.github.com/repos/roveo/translators/tags","blobs_url":"https://api.github.com/repos/roveo/translators/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/roveo/translators/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/roveo/translators/git/refs{/sha}","trees_url":"https://api.github.com/repos/roveo/translators/git/trees{/sha}","statuses_url":"https://api.github.com/repos/roveo/translators/statuses/{sha}","languages_url":"https://api.github.com/repos/roveo/translators/languages","stargazers_url":"https://api.github.com/repos/roveo/translators/stargazers","contributors_url":"https://api.github.com/repos/roveo/translators/contributors","subscribers_url":"https://api.github.com/repos/roveo/translators/subscribers","subscription_url":"https://api.github.com/repos/roveo/translators/subscription","commits_url":"https://api.github.com/repos/roveo/translators/commits{/sha}","git_commits_url":"https://api.github.com/repos/roveo/translators/git/commits{/sha}","comments_url":"https://api.github.com/repos/roveo/translators/comments{/number}","issue_comment_url":"https://api.github.com/repos/roveo/translators/issues/comments{/number}","contents_url":"https://api.github.com/repos/roveo/translators/contents/{+path}","compare_url":"https://api.github.com/repos/roveo/translators/compare/{base}...{head}","merges_url":"https://api.github.com/repos/roveo/translators/merges","archive_url":"https://api.github.com/repos/roveo/translators/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/roveo/translators/downloads","issues_url":"https://api.github.com/repos/roveo/translators/issues{/number}","pulls_url":"https://api.github.com/repos/roveo/translators/pulls{/number}","milestones_url":"https://api.github.com/repos/roveo/translators/milestones{/number}","notifications_url":"https://api.github.com/repos/roveo/translators/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/roveo/translators/labels{/name}","releases_url":"https://api.github.com/repos/roveo/translators/releases{/id}","created_at":"2015-09-20T14:51:35Z","updated_at":"2015-09-20T14:51:37Z","pushed_at":"2015-09-20T21:09:58Z","git_url":"git://github.com/roveo/translators.git","ssh_url":"git@github.com:roveo/translators.git","clone_url":"https://github.com/roveo/translators.git","svn_url":"https://github.com/roveo/translators","homepage":"http://www.zotero.org/support/dev/translators","size":17187,"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":"a0ca6fc1039d8f1796ea582d56f24fc8fcf449bf","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":"2015-09-19T14:32:50Z","pushed_at":"2015-09-20T21:40:41Z","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":17187,"stargazers_count":152,"watchers_count":152,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":137,"mirror_url":null,"open_issues_count":130,"forks":137,"open_issues":130,"watchers":152,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zotero/translators/pulls/947"},"html":{"href":"https://github.com/zotero/translators/pull/947"},"issue":{"href":"https://api.github.com/repos/zotero/translators/issues/947"},"comments":{"href":"https://api.github.com/repos/zotero/translators/issues/947/comments"},"review_comments":{"href":"https://api.github.com/repos/zotero/translators/pulls/947/comments"},"review_comment":{"href":"https://api.github.com/repos/zotero/translators/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zotero/translators/pulls/947/commits"},"statuses":{"href":"https://api.github.com/repos/zotero/translators/statuses/9b0a57543877a6b771966b9e153c740657d6fa9b"}}}}