-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added phys.org translator #3238
base: master
Are you sure you want to change the base?
Conversation
Thanks @AbeJellinek for helping to fix up all the mistakes I made! I think i've fixed all the issues you raised (except for one i've asked for your advice on). I'd also however be gratefully if you could take a look at the async code i've added. It was created mainly through cannibalising other translators because i've never used async in javascript before, so its very possible some errors have crept in. |
Strip the tags, but otherwise, looks good! |
Done. Thanks @AbeJellinek! |
"translatorID": "e835ac2f-181b-41fe-a509-4f9d20797515", | ||
"label": "Phys.org", | ||
"creator": "Laurence Stevens", | ||
"target": "https?://(www\\.)?phys\\.org/news", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, the target matches /news
...
if (url.includes('/news')) { | ||
return 'blogPost'; | ||
} | ||
else if (url.includes('/search') && getSearchResults(doc, true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So won't this else if
never happen? The URL will always include /news
.
}); | ||
|
||
let em = await translator.getTranslatorObject(); | ||
em.itemType = type || "webpage"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just do
em.itemType = type || "webpage"; | |
em.itemType = "blogPost"; |
Added a translator for the site phys.org, for which we previously weren't getting all metadata from. Also added support for the sites search feature. This should fix issue #2897.
This is my first time working with this codebase so i'd be grateful if whoever approves this could take a look over my code to make sure I haven't done something stupid through inexperience!