Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
509101394c |
|
|
@ -44,7 +44,6 @@ get_translators_to_check() {
|
||||||
else
|
else
|
||||||
# Gets parent commits. Either one or two hashes
|
# Gets parent commits. Either one or two hashes
|
||||||
parent_commits=($(git show --no-patch --format="%P" HEAD))
|
parent_commits=($(git show --no-patch --format="%P" HEAD))
|
||||||
echo "$parent_commits"
|
|
||||||
# Size of $parent_commits array
|
# Size of $parent_commits array
|
||||||
num_parent_commits=${#parent_commits[@]}
|
num_parent_commits=${#parent_commits[@]}
|
||||||
if [ $num_parent_commits -gt 1 ]; then
|
if [ $num_parent_commits -gt 1 ]; then
|
||||||
|
|
@ -53,9 +52,7 @@ get_translators_to_check() {
|
||||||
TRANSLATORS_TO_CHECK=$(git diff HEAD^2 $branch_point --name-only | { grep -e "^[^/]*.js$" || true; })
|
TRANSLATORS_TO_CHECK=$(git diff HEAD^2 $branch_point --name-only | { grep -e "^[^/]*.js$" || true; })
|
||||||
else
|
else
|
||||||
first_parent=$(git rev-list --first-parent ^master HEAD | tail -n1)
|
first_parent=$(git rev-list --first-parent ^master HEAD | tail -n1)
|
||||||
echo "First parent is $first_parent"
|
|
||||||
branch_point=$(git rev-list "$first_parent^^!")
|
branch_point=$(git rev-list "$first_parent^^!")
|
||||||
echo "Branch point is $branch_point"
|
|
||||||
TRANSLATORS_TO_CHECK=$(git diff $branch_point --name-only | { grep -e "^[^/]*.js$" || true; })
|
TRANSLATORS_TO_CHECK=$(git diff $branch_point --name-only | { grep -e "^[^/]*.js$" || true; })
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ jobs:
|
||||||
# and get more history on the current branch so we can find the branch point
|
# and get more history on the current branch so we can find the branch point
|
||||||
- run: git fetch origin master:master --depth=1
|
- run: git fetch origin master:master --depth=1
|
||||||
if: github.ref != 'refs/heads/master'
|
if: github.ref != 'refs/heads/master'
|
||||||
- run: git fetch --update-shallow --depth=25 origin $(git rev-parse --abbrev-ref HEAD)
|
- run: git fetch --update-shallow --depth=25 origin $(git rev-list HEAD)
|
||||||
|
|
||||||
- name: Install Node
|
- name: Install Node
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
|
|
@ -44,6 +44,7 @@ jobs:
|
||||||
|
|
||||||
#- name: Debugging with tmate
|
#- name: Debugging with tmate
|
||||||
# uses: mxschmitt/action-tmate@v3.1
|
# uses: mxschmitt/action-tmate@v3.1
|
||||||
|
# if: github.event_name == 'pull_request'
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: ./lint.sh
|
run: ./lint.sh
|
||||||
|
|
|
||||||
|
|
@ -9,120 +9,189 @@
|
||||||
"inRepository": true,
|
"inRepository": true,
|
||||||
"translatorType": 4,
|
"translatorType": 4,
|
||||||
"browserSupport": "gcsibv",
|
"browserSupport": "gcsibv",
|
||||||
"lastUpdated": "2015-06-02 11:18:49"
|
"lastUpdated": "2021-01-29 15:47:14"
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectWeb(doc,url)
|
/*
|
||||||
{
|
***** BEGIN LICENSE BLOCK *****
|
||||||
var namespace = doc.documentElement.namespaceURI;
|
|
||||||
var nsResolver = namespace ? function(prefix) {
|
|
||||||
if (prefix == 'x') return namespace; else return null;
|
|
||||||
} : null;
|
|
||||||
|
|
||||||
var xpath='//meta[@name="Story_type"]/@content';
|
Copyright © 2021 Sebastian Karcher
|
||||||
var temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext();
|
|
||||||
if (temp)
|
This file is part of Zotero.
|
||||||
{
|
|
||||||
if (temp.value=="Blog")
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
{return "blogPost";}
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
if (temp.value.indexOf("Story")>-1)
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
{return "magazineArticle";}
|
(at your option) any later version.
|
||||||
}
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
function detectWeb(doc, url) {
|
||||||
|
if (doc.getElementsByClassName('m-article-title').length) {
|
||||||
|
return "newspaperArticle";
|
||||||
|
}
|
||||||
|
else if (getSearchResults(doc, true)) {
|
||||||
|
return "multiple";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function associateMeta(newItem, metaTags, field, zoteroField) {
|
function getSearchResults(doc, checkOnly) {
|
||||||
if (metaTags[field]) {
|
var items = {};
|
||||||
newItem[zoteroField] = metaTags[field];
|
var found = false;
|
||||||
}
|
var rows = doc.querySelectorAll('a.m-promo__title');
|
||||||
|
for (let row of rows) {
|
||||||
|
let href = row.href;
|
||||||
|
let title = ZU.trimInternal(row.textContent);
|
||||||
|
if (!href || !title) continue;
|
||||||
|
if (checkOnly) return true;
|
||||||
|
found = true;
|
||||||
|
items[href] = title;
|
||||||
|
}
|
||||||
|
return found ? items : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doWeb(doc, url) {
|
||||||
|
if (detectWeb(doc, url) == "multiple") {
|
||||||
|
Zotero.selectItems(getSearchResults(doc, false), function (items) {
|
||||||
|
if (items) ZU.processDocuments(Object.keys(items), scrape);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scrape(doc, url);
|
||||||
|
}
|
||||||
|
}
|
||||||
function scrape(doc, url) {
|
function scrape(doc, url) {
|
||||||
|
var translator = Zotero.loadTranslator('web');
|
||||||
|
// Embedded Metadata
|
||||||
|
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
|
||||||
|
// translator.setDocument(doc);
|
||||||
|
|
||||||
|
translator.setHandler('itemDone', function (obj, item) {
|
||||||
|
// some garbage makes it into item tags
|
||||||
|
for (let i = item.tags.length - 1; i > -1; i--) {
|
||||||
|
if (item.tags[i].search(/premium\d|^lytics/) != -1) {
|
||||||
|
item.tags.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.title = item.title.replace(/\(.+?\)$/, "");
|
||||||
|
item.ISSN = "0277-4232";
|
||||||
|
item.publicationTitle = "Education Week";
|
||||||
|
item.complete();
|
||||||
|
});
|
||||||
|
|
||||||
var newItem = new Zotero.Item("magazineArticle");
|
translator.getTranslatorObject(function (trans) {
|
||||||
if (url&&url.indexOf("blogs.edweek.org")>-1)
|
trans.itemType = "newspaperArticle";
|
||||||
{newItem.itemType="blogPost";}
|
trans.doWeb(doc, url);
|
||||||
|
});
|
||||||
newItem.url = doc.location.href;
|
|
||||||
|
|
||||||
var metaTags = new Object();
|
|
||||||
|
|
||||||
var metaTagHTML = doc.getElementsByTagName("meta");
|
|
||||||
var i;
|
|
||||||
for (i = 0 ; i < metaTagHTML.length ; i++) {
|
|
||||||
metaTags[metaTagHTML[i].getAttribute("name")]=Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content"));
|
|
||||||
}
|
|
||||||
associateMeta(newItem, metaTags, "Title", "title");
|
|
||||||
associateMeta(newItem, metaTags, "Cover_date", "date");
|
|
||||||
associateMeta(newItem, metaTags, "Description", "abstractNote");
|
|
||||||
associateMeta(newItem, metaTags, "ArticleID", "accessionNumber");
|
|
||||||
associateMeta(newItem,metaTags,"Source","publicationTitle");
|
|
||||||
|
|
||||||
|
|
||||||
if (metaTags["Authors"]) {
|
|
||||||
var author = Zotero.Utilities.trimInternal(metaTags["Authors"]);
|
|
||||||
if (author.substr(0,3).toLowerCase() == "by ") {
|
|
||||||
author = author.substr(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
var authors = author.split(" and ");
|
|
||||||
for (var j=0; j<authors.length; j++) {
|
|
||||||
var author = authors[j];
|
|
||||||
var words = author.split(" ");
|
|
||||||
for (var i in words) {
|
|
||||||
words[i] = words[i][0].toUpperCase() +words[i].substr(1).toLowerCase();
|
|
||||||
}
|
|
||||||
author = words.join(" ");
|
|
||||||
|
|
||||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newItem.complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
function doWeb(doc,url)
|
|
||||||
{
|
|
||||||
var namespace = doc.documentElement.namespaceURI;
|
|
||||||
var nsResolver = namespace ? function(prefix) {
|
|
||||||
if (prefix == 'x') return namespace; else return null;
|
|
||||||
} : null;
|
|
||||||
|
|
||||||
var xpath='//meta[@name="Story_type"]/@content';
|
|
||||||
var temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext();
|
|
||||||
if (temp)
|
|
||||||
{
|
|
||||||
if (temp.value.indexOf("Story")>-1 || temp.value=="Blog")
|
|
||||||
{scrape(doc,url);}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** BEGIN TEST CASES **/
|
/** BEGIN TEST CASES **/
|
||||||
var testCases = [
|
var testCases = [
|
||||||
{
|
{
|
||||||
"type": "web",
|
"type": "web",
|
||||||
"url": "http://www.edweek.org/ew/articles/2011/10/28/10jobs.h31.html?tkn=PUOFjigAbQPNufjjHPxYeafVz7T5Tf16qNb4&cmp=clp-edweek",
|
"url": "https://www.edweek.org/policy-politics/obama-using-education-issue-as-political-sword/2011/10?tkn=PUOFjigAbQPNufjjHPxYeafVz7T5Tf16qNb4&cmp=clp-edweek",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"itemType": "magazineArticle",
|
"itemType": "newspaperArticle",
|
||||||
"title": "Obama Using Education Issue as Political Sword - Education Week",
|
"title": "Obama Using Education Issue as Political Sword",
|
||||||
"creators": [
|
"creators": [
|
||||||
{
|
{
|
||||||
"firstName": "Michele",
|
"firstName": "Michele",
|
||||||
"lastName": "Mcneil",
|
"lastName": "McNeil",
|
||||||
"creatorType": "author"
|
"creatorType": "author"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"date": "2011-11-02",
|
"date": "2011-10-28T00:01:02",
|
||||||
|
"ISSN": "0277-4232",
|
||||||
"abstractNote": "The Obama administration highlights its education record, while drawing a sharp contrast with the GOP in Congress.",
|
"abstractNote": "The Obama administration highlights its education record, while drawing a sharp contrast with the GOP in Congress.",
|
||||||
"libraryCatalog": "Education Week",
|
"language": "en",
|
||||||
|
"libraryCatalog": "www.edweek.org",
|
||||||
"publicationTitle": "Education Week",
|
"publicationTitle": "Education Week",
|
||||||
"url": "http://www.edweek.org/ew/articles/2011/10/28/10jobs.h31.html?tkn=PUOFjigAbQPNufjjHPxYeafVz7T5Tf16qNb4&cmp=clp-edweek",
|
"section": "Education Funding",
|
||||||
"attachments": [],
|
"url": "https://www.edweek.org/policy-politics/obama-using-education-issue-as-political-sword/2011/10",
|
||||||
"tags": [],
|
"attachments": [
|
||||||
|
{
|
||||||
|
"title": "Snapshot",
|
||||||
|
"mimeType": "text/html"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"tag": "Barack Obama"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "Elections"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "Federal Policy"
|
||||||
|
}
|
||||||
|
],
|
||||||
"notes": [],
|
"notes": [],
|
||||||
"seeAlso": []
|
"seeAlso": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "web",
|
||||||
|
"url": "https://www.edweek.org/leadership/opinion-a-better-turnaround-strategy/2011/10?qs=%22character%20education%22%20inmeta%3ACover_year%3D2011%20inmeta%3Agsaentity_Source%2520U%E2%80%A6",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"itemType": "newspaperArticle",
|
||||||
|
"title": "A Better Turnaround Strategy",
|
||||||
|
"creators": [
|
||||||
|
{
|
||||||
|
"firstName": "Sheldon H.",
|
||||||
|
"lastName": "Berman",
|
||||||
|
"creatorType": "author"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"firstName": "Arthur",
|
||||||
|
"lastName": "Camins",
|
||||||
|
"creatorType": "author"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"date": "2011-10-31T17:22:41",
|
||||||
|
"ISSN": "0277-4232",
|
||||||
|
"abstractNote": "Sheldon H. Berman and Arthur Camins describe a successful turnaround model which promotes a professionalized and collaborative teaching culture that is also student centered.",
|
||||||
|
"language": "en",
|
||||||
|
"libraryCatalog": "www.edweek.org",
|
||||||
|
"publicationTitle": "Education Week",
|
||||||
|
"section": "Equity & Diversity",
|
||||||
|
"url": "https://www.edweek.org/leadership/opinion-a-better-turnaround-strategy/2011/10",
|
||||||
|
"attachments": [
|
||||||
|
{
|
||||||
|
"title": "Snapshot",
|
||||||
|
"mimeType": "text/html"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"tag": "Innovation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "Underserved Students"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"notes": [],
|
||||||
|
"seeAlso": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "web",
|
||||||
|
"url": "https://www.edweek.org/search?q=testing#nt=navsearch",
|
||||||
|
"items": "multiple"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
/** END TEST CASES **/
|
/** END TEST CASES **/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue