Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd translator for sverigesradio.se #1567
Conversation
adam3smith
requested changes
Feb 27, 2018
Thanks -- looks good in general, some small nits
Sveriges radio.js
"translatorID": "caa8f42c-9dbf-446e-963b-6ee18e3133d2", | ||
"label": "Sveriges radio", | ||
"creator": "Sebastian Berlin", | ||
"target": "^https?://sverigesradio\\.se/sida/artikel.aspx", |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
adam3smith
Feb 27, 2018
Collaborator
This doesn't seem right -- it wouldn't detect multiples if your code below is correct (please add some multiples as tests, if possible)
adam3smith
Feb 27, 2018
Collaborator
This doesn't seem right -- it wouldn't detect multiples if your code below is correct (please add some multiples as tests, if possible)
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Sveriges radio.js
item.creators = []; | ||
var nameNodes = ZU.xpath(doc, '//p[@class="byline"]/text()'); | ||
for(var node of nameNodes) { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Sveriges radio.js
// those. | ||
continue; | ||
} | ||
var names = nameString.split(" "); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
adam3smith
Feb 27, 2018
Collaborator
It seems like you're just generating a crude version of ZU.cleanAuthor
here -- I'd recommend using that.
adam3smith
Feb 27, 2018
Collaborator
It seems like you're just generating a crude version of ZU.cleanAuthor
here -- I'd recommend using that.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sebastian-berlin-wmse
Feb 28, 2018
Contributor
I missed that function. Replaced the logic I had written, but some preprocessing was still required due to how the byline string can be formatted.
sebastian-berlin-wmse
Feb 28, 2018
Contributor
I missed that function. Replaced the logic I had written, but some preprocessing was still required due to how the byline string can be formatted.
Sveriges radio.js
// The title from the meta is in the format: | ||
// Australierna säger ja till samkönade äktenskap - Nyheter (Ekot) | ||
var titleString = | ||
ZU.xpath(doc, '//meta[@name="twitter:title"]')[0] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Sveriges radio.js
item.section = titleParts[1]; | ||
var dateString = | ||
ZU.xpath(doc, '//meta[@name="displaydate"]')[0] |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Sveriges radio.js
var dateString = | ||
ZU.xpath(doc, '//meta[@name="displaydate"]')[0] | ||
.getAttribute("content"); | ||
item.date = dateString.replace(/(....)(..)(..)/, "$1-$2-$3"); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Sveriges radio.js
translator.getTranslatorObject(function(trans) { | ||
trans.itemType = "newspaperArticle"; | ||
// TODO map additional meta tags here, or delete completely |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Sveriges radio.js
"title": "Australierna säger ja till samkönade äktenskap", | ||
"creators": [ | ||
{ | ||
"firstName": "Ekot", |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
adam3smith
Feb 27, 2018
Collaborator
using Zotero's built in function will solve this, but the right way to handle single-name and institutional authors is to use lastName
only and set fieldMode: true
adam3smith
Feb 27, 2018
Collaborator
using Zotero's built in function will solve this, but the right way to handle single-name and institutional authors is to use lastName
only and set fieldMode: true
Sveriges radio.js
"title": "Snapshot" | ||
} | ||
], | ||
"tags": [ |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sebastian-berlin-wmse
Feb 28, 2018
Contributor
I wasn't sure what tags did, so I kept them as they were. As you say, at least some of them are quite general and don't seem to relate to the article. Happy to get rid of them.
sebastian-berlin-wmse
Feb 28, 2018
Contributor
I wasn't sure what tags did, so I kept them as they were. As you say, at least some of them are quite general and don't seem to relate to the article. Happy to get rid of them.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sebastian-berlin-wmse
Feb 28, 2018
Contributor
Thanks for the feedback, @adam3smith. I've fixed the issues you mentioned. Let me know if there's anything else.
Thanks for the feedback, @adam3smith. I've fixed the issues you mentioned. Let me know if there's anything else. |
adam3smith
merged commit 11e78ea
into
zotero:master
Mar 4, 2018
1 check passed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Great, thanks! |
sebastian-berlin-wmse commentedFeb 26, 2018
This is the website for the Swedish public service radio.