Skip to content
Permalink
Browse files

Undo all spacing stuff

 * deleting all spacing stuff from before
 * delete also the test case in Agencia del ISBN.js because it seems that the url is not valid anymore
  • Loading branch information...
zuphilip committed Jun 10, 2015
1 parent c4b4cbb commit 94e4cae506a8d1c75b4e8cc314bc894a41e217d8
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcs",
"lastUpdated": "2015-06-02 06:04:02"
"lastUpdated": "2015-06-10 11:33:38"
}

function detectWeb(doc, url) {
@@ -46,69 +46,32 @@ function doWeb(doc, url) {
}


function scrape (doc, url){
var data = new Object();
var rows = doc.evaluate('//div[@class="fichaISBN"]/table/tbody/tr', doc, null, XPathResult.ANY_TYPE, null);
var next_row;
while (next_row = rows.iterateNext()) {
var heading = doc.evaluate('./th', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
var value = doc.evaluate('./td', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
data[heading.replace(/\W/g, "")] = value;
}
var isbn = Zotero.Utilities.trimInternal(doc.evaluate('//span[@class="cabTitulo"]/strong', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
var item = new Zotero.Item("book");
item.ISBN = isbn;
item.title = Zotero.Utilities.trimInternal(data['Ttulo']);
item.title= item.title.replace(/\s+:/, ":");
author = data['Autores'];
if (author) {
var authors = author.match(/\b.*,\s+\w+[^([]/g);
for (var i=0; i<authors.length; i++) {
var aut = Zotero.Utilities.trimInternal(authors[i]);
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true));
function scrape (doc, url){
var data = new Object();
var rows = doc.evaluate('//div[@class="fichaISBN"]/table/tbody/tr', doc, null, XPathResult.ANY_TYPE, null);
var next_row;
while (next_row = rows.iterateNext()) {
var heading = doc.evaluate('./th', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
var value = doc.evaluate('./td', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
data[heading.replace(/\W/g, "")] = value;
}
}
if (data['Publicacin']) item.publisher = Zotero.Utilities.trimInternal(data['Publicacin']);
if (data['FechaEdicin']) item.date = Zotero.Utilities.trimInternal(data['FechaEdicin']);
item.complete();
}

/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://www.mcu.es/webISBN/tituloDetalle.do?sidTitul=292802&action=busquedaInicial&noValidating=true&POS=0&MAX=50&TOTAL=0&prev_layout=busquedaisbn&layout=busquedaisbn&language=es",
"items": [
{
"itemType": "book",
"title": "La actitud intencional",
"creators": [
{
"firstName": "Daniel",
"lastName": "Dennett",
"creatorType": "author"
},
{
"firstName": "Daniel",
"lastName": "Dennett",
"creatorType": "author"
},
{
"firstName": "Gabriela",
"lastName": "Ventureira",
"creatorType": "author"
}
],
"date": "03/1991",
"ISBN": "9788474323955",
"libraryCatalog": "Agencia del ISBN",
"publisher": "GEDISA",
"attachments": [],
"tags": [],
"notes": [],
"seeAlso": []
var isbn = Zotero.Utilities.trimInternal(doc.evaluate('//span[@class="cabTitulo"]/strong', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
var item = new Zotero.Item("book");
item.ISBN = isbn;
item.title = Zotero.Utilities.trimInternal(data['Ttulo']);
item.title= item.title.replace(/\s+:/, ":");
author = data['Autores'];
if (author) {
var authors = author.match(/\b.*,\s+\w+[^([]/g);
for (var i=0; i<authors.length; i++) {
var aut = Zotero.Utilities.trimInternal(authors[i]);
item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(aut), "author", true));
}
]
}
if (data['Publicacin']) item.publisher = Zotero.Utilities.trimInternal(data['Publicacin']);
if (data['FechaEdicin']) item.date = Zotero.Utilities.trimInternal(data['FechaEdicin']);
item.complete();
}
]
/** BEGIN TEST CASES **/
var testCases = []
/** END TEST CASES **/
@@ -19,7 +19,7 @@ function detectWeb(doc, url) {
} : null;

var result = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]', doc, nsResolver,
XPathResult.ANY_TYPE, null).iterateNext();
XPathResult.ANY_TYPE, null).iterateNext();

var rows = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]/table/tbody/tr[@class="tblrow record"]',
doc, nsResolver, XPathResult.ANY_TYPE, null);
@@ -12,89 +12,88 @@
"lastUpdated": "2015-06-02 11:18:49"
}

function detectWeb(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=="Blog") {
return "blogPost";
}
if(temp.value.indexOf("Story")>-1) {
return "magazineArticle";
}
}
function detectWeb(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=="Blog")
{return "blogPost";}
if(temp.value.indexOf("Story")>-1)
{return "magazineArticle";}
}
}

function associateMeta(newItem, metaTags, field, zoteroField) {
if(metaTags[field]) {
newItem[zoteroField] = metaTags[field];
}
if(metaTags[field]) {
newItem[zoteroField] = metaTags[field];
}
}

function scrape(doc, url) {

var newItem = new Zotero.Item("magazineArticle");
if(url&&url.indexOf("blogs.edweek.org")>-1) {
newItem.itemType="blogPost";
}

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();
var newItem = new Zotero.Item("magazineArticle");
if(url&&url.indexOf("blogs.edweek.org")>-1)
{newItem.itemType="blogPost";}

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);
}
}
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 **/
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2015-06-02 16:52:39"
"lastUpdated": "2015-06-10 11:34:28"
}

function detectWeb(doc, url) {
@@ -108,9 +108,7 @@ function scrape(doc, url){
{url:pdfurl, title:item.publicationTitle + " Full Text PDF", mimeType:"application/pdf"}
];
item.complete();
}

/** BEGIN TEST CASES **/
}/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
@@ -147,7 +147,6 @@ function processor (obj) {
return true;
}


/** BEGIN TEST CASES **/
var testCases = [
{
@@ -67,9 +67,7 @@ function scrape(ids, host){
translator.translate();
});
}
}

/** BEGIN TEST CASES **/
}/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
@@ -71,7 +71,6 @@ function scrape(doc, url){
item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[5]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).substr(10);
item.complete();
}

/** BEGIN TEST CASES **/
var testCases = [
{
@@ -19,7 +19,7 @@ function detectWeb(doc, url) {
} : null;

if(doc.evaluate('//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]',
doc, nsResolver, XPathResult.ANY_TYPE, null)) {
doc, nsResolver, XPathResult.ANY_TYPE, null)) {


var xpath = '//table[@id="tableIndexTerms"]/tbody/tr/td[@class="textSmall"]';
@@ -114,7 +114,7 @@ function doWeb(doc, url) {


if(doc.evaluate('//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]',
doc, nsResolver, XPathResult.ANY_TYPE, null)) {
doc, nsResolver, XPathResult.ANY_TYPE, null)) {
if(doc.title.match("Results")) {

//Get Client ID
@@ -148,10 +148,10 @@ function scrape(doc, url) {
}

for (var i = 0; i < tagsContent.length; i++) {
if (tagsContent[i] != (" ") && tagsContent[i] != ("")) {
newItem.tags[i] = tagsContent[i];
}
}
if (tagsContent[i] != (" ") && tagsContent[i] != ("")) {
newItem.tags[i] = tagsContent[i];
}
}

associateMeta (newItem, metaTags, "headline", "title");
associateMeta (newItem, metaTags, "summary", "abstractNote");
@@ -55,9 +55,7 @@ function doWeb(doc, url) {
arts.push(i);
}

} else {
arts = [url];
}
} else { arts = [url]; }
for (var i=0; i<arts.length; i++) {
var art = arts[i];
Zotero.debug(art);
@@ -92,9 +90,7 @@ function doWeb(doc, url) {
});
Zotero.wait();
}
}

/** BEGIN TEST CASES **/
}/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",

0 comments on commit 94e4cae

Please sign in to comment.
You can’t perform that action at this time.