Commit a80b86da authored by Daniel Suarez Souto's avatar Daniel Suarez Souto
Browse files

Fixed problem with url resources

parent a4a1e41c
Pipeline #860 passed with stages
in 22 seconds
......@@ -45,36 +45,41 @@
<h4 class="modal-title" id="myModalLabel">{{getHeadline(news)}}</h4>
</div>
<div class="modal-body" style="height: 520px" >
<div class="col-md-5" style=" overflow-x: hidden; overflow-y: auto; height: 100%;">
<h4 class="modal-title" id="myModalLabel" style="margin-top: 12px">Entities</h4>
<div class="content" style="text-align:center; margin: 0 auto;">
<br>
<br>
<template is="dom-repeat" items="{{news.entities}}" as="entity">
<span class="badge badge-secondary" on-tap="highlightEntity" data-id$= "{{getID(news)}}" data-text$="{{getNew(news)}}" style$="{{getBg(entity)}} cursor:pointer;">{{entity.schema:name}}</span>
</template>
<br>
<div class="leyend" style="display: flex; flex-direction: row; justify-content: center; margin-bottom: 5px">
<div class="leyend_place" style="display: flex; flex-direction: row;">
<div style="width: 7px;height: 7px;background-color: #f90; float: left; margin-top: 7px;margin-right: 3px; margin-left: 6px" class="style-scope news-chart"></div>
Places
</div>
<div class="leyend_org" style="display: flex; flex-direction: row;">
<div style="width: 7px;height: 7px;background-color: #dd4b39; float: left; margin-top: 7px;margin-right: 3px; margin-left: 6px" class="style-scope news-chart"></div>
Organization
</div>
<div class="leyend_person" style="display: flex; flex-direction: row;">
<div style="width: 7px;height: 7px;background-color: #00c0ef; float: left; margin-top: 7px;margin-right: 3px; margin-left: 6px" class="style-scope news-chart"></div>
Person
</div>
</div>
<template is="dom-repeat" items="{{news.entities}}" as="entity">
<span class="badge badge-secondary" on-tap="highlightEntity" data-id$= "{{getID(news)}}" data-text$="{{getNew(news)}}" style$="{{getBg(entity)}} cursor:pointer;">{{entity.schema:name}}</span>
</template>
</div>
</div>
<div class="col-md-7" style="overflow: hidden; height: 100%;">
<ul class="nav nav-tabs" role="tablist" style="height: 45px;">
<li class="active"><a data-toggle="tab" href$="#text[[index]]">Text</a></li>
<li><a data-toggle="tab" href$="#frame[[index]]">New</a></li>
</ul>
<div class="tab-content">
<div id$="text[[index]]" class="tab-pane fade in active" style="background-color: #eeeeee96; float: right; border: 1px solid #B3BFC7; padding: 20px; overflow-y: auto; height: calc(100% - 45px); ">
<div id$="{{getID(news)}}" class="text-hightlight" style="text-align: justify; white-space: pre-line;">
{{getNew(news)}}
</div>
</div>
<div id$="frame[[index]]" class="tab-pane fade" iframe-src$="{{setIframe(news, index)}}">
<!-- <iframe src="{{getID(news)}}" style="width: 100%; height: 90%;"></iframe> -->
<div id$="text[[index]]" class="tab-pane fade in active" style="background-color: #eeeeee96; float: right; border: 1px solid #B3BFC7; padding: 20px; padding-top: 0px; overflow-y: auto; height: fit-content; max-height: 100%; ">
<div id$="{{getID(news)}}" class="text-hightlight" style="text-align: justify; white-space: pre-line;">
{{getNew(news)}}
</div>
</div>
</div>
</div>
......@@ -239,13 +244,12 @@
if(!("@type" in entity)){
return "background-color: brown;margin-bottom:5px;"
} else if(entity["@type"] == "schema:Place") {
return "background-color: orange;margin-bottom:5px;"
return "background-color: #f90;margin-bottom:5px;"
} else if(entity["@type"] == "schema:Organization") {
return "background-color: red;margin-bottom:5px;"
return "background-color: #dd4b39;margin-bottom:5px;"
} else {
return "background-color: blue;margin-bottom:5px;"
return "background-color: #00c0ef;margin-bottom:5px;"
}
},
checkSentiment: function(sentiment) {
//console.log(sentiment[0]['marl:hasPolarity'])
......@@ -310,26 +314,15 @@
}
},
highlightEntity: function(e) {
/*console.log(e.model.__data__)
console.log(e.model.__data__.entity["schema:name"])
var myfilters = [e.model.__data__.entity["schema:name"]]
console.log("filtering")
this.push('filters', { terms: { 'entities.schema:name.keyword': myfilters}})*/
var id = e.target.dataset.id
var element = document.getElementById(id)
var text = e.target.dataset.text
var beginIndex = e.model.__data__.entity["nif:beginIndex"]
var endIndex = e.model.__data__.entity["nif:endIndex"] + 1
//console.log(beginIndex)
//console.log(endIndex)
var subtext = text.substring(0,beginIndex)
//var nbreaks=(subtext.match(/\n/g) || []).length/2
//var nbreaks=0
//beginIndex+=nbreaks
//endIndex+=nbreaks
// console.log(beginIndex)
// console.log(endIndex)
// console.log(e.model.__data__.entity["schema:name"])
if (beginIndex >= 0) {
text = text.substring(0,beginIndex) + "<span class='highlight' style='background-color:yellow'>" + text.substring(beginIndex,endIndex) + "</span>" + text.substring(endIndex)
element.innerHTML = text
......@@ -339,24 +332,7 @@
$('#'+element.parentElement.id).animate({scrollTop: $('#'+element.parentElement.id).scrollTop() + $('#'+element.parentElement.id + ' span').position().top - 200}, 400)
}
},
/*setIframe: function(news, index) {
function loadIframe() {
$('#subitem'+index).off();
$('#subitem'+index).on('shown.bs.modal', function(event) {
var iframe = $('<iframe>').attr('src', news['@id']).width('100%').height('91%');
$('#subitem'+index+' #frame'+index).html(iframe);
});
}
if (window.loaded) {
loadIframe();
} else {
$('#subitem'+index).ready(function() {
loadIframe();
});
}
return news['@id'];
},*/
});
</script>
......
......@@ -35,7 +35,8 @@
<img src={{checkSource(news)}} style="width: 100%; display:block; position: relative;" align="left">
</div>
<div class="col-md-7">
<a class="text" style="font-size: 15px; display: inline-block; vertical-align: middle;"> {{getHeadline(news)}}</a>
<a class="text" style="font-size: 15px; display: inline-block; vertical-align: middle;"> {{getHeadline(news)}}</a>
</div>
</div>
</button>
......@@ -49,21 +50,35 @@
</div>
<div class="modal-body" style="height: 520px" >
<div class="col-md-5" style=" overflow-x: hidden; overflow-y: auto; height: 100%;">
<h4 class="modal-title" id="myModalLabel" style="margin-top: 12px">Entities</h4>
<div class="content" style="text-align:center; margin: 0 auto;">
<br>
<br>
<br>
<div class="leyend" style="display: flex; flex-direction: row; justify-content: center; margin-bottom: 5px">
<div class="leyend_place" style="display: flex; flex-direction: row;">
<div style="width: 7px;height: 7px;background-color: #f90; float: left; margin-top: 7px;margin-right: 3px; margin-left: 6px" class="style-scope news-chart"></div>
Places
</div>
<div class="leyend_org" style="display: flex; flex-direction: row;">
<div style="width: 7px;height: 7px;background-color: #dd4b39; float: left; margin-top: 7px;margin-right: 3px; margin-left: 6px" class="style-scope news-chart"></div>
Organization
</div>
<div class="leyend_person" style="display: flex; flex-direction: row;">
<div style="width: 7px;height: 7px;background-color: #00c0ef; float: left; margin-top: 7px;margin-right: 3px; margin-left: 6px" class="style-scope news-chart"></div>
Person
</div>
</div>
<template is="dom-repeat" items="{{news.entities}}" as="entity">
<span class="badge badge-secondary" on-tap="highlightEntity" data-id$= "{{getID(news)}}" data-text$="{{getArticle(news)}}" style$="{{getBg(entity)}} cursor:pointer;">{{entity.schema:name}}</span>
</template>
</div>
</div>
</div>
<div class="col-md-7" style="overflow-x: hidden; overflow-y: auto; height: 100%;">
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a data-toggle="tab" href$="#propaganda[[index]]">Text</a></li>
<li><a data-toggle="tab" href$="#pdf[[index]]">Magazine</a></li>
<li class="active" id="tabText"><a data-toggle="tab" href$="#propaganda[[index]]">Text</a></li>
<li id="tabArticle"><a data-toggle="tab" href$="#pdf[[index]]">Magazine</a></li>
</ul>
<div class="tab-content">
<div id$="propaganda[[index]]" class="tab-pane fade in active" style="background-color: #eeeeee96; float: right; border: 1px solid #B3BFC7; padding: 20px; overflow-y: auto; height: calc(100% - 45px);">
......@@ -73,51 +88,11 @@
</div>
<div id$="pdf[[index]]" class="tab-pane fade" iframe-src$="{{setPDF(news, index)}}">
{{getUri(news)}}
</div>
</div>
</div>
</div>
<script type="text/javascript">
function loadPDF(uri,canvas_id) {
var pdfjsLib = window['pdfjs-dist/build/pdf'];
var loadingTask=pdfjsLib.getDocument(uri)
loadingTask.promise.then(function(pdf) {
console.log('PDF loaded');
// Fetch the first page
var pageNumber = 1;
pdf.getPage(pageNumber).then(function(page) {
console.log('Page loaded');
var scale = 1.5;
var viewport = page.getViewport(scale);
// Prepare canvas using PDF page dimensions
var canvas = document.getElementById(canvas_id);
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
// Render PDF page into canvas context
var renderContext = {
canvasContext: context,
viewport: viewport
};
var renderTask = page.render(renderContext);
renderTask.then(function () {
console.log('Page rendered');
});
});
}, function (reason) {
// PDF loading error
console.error(reason);
});
}
</script>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
......@@ -246,7 +221,22 @@
},
getArticle: function(news){
//console.log(news['http://schema.org/headline'][0]['@value'])
return news['schema:articleBody']
text = news['schema:articleBody']
//console.log(text)
//text=text.replace('↵','\n')
text=text.replace(' \n','\n')
text=text.replace('\n\f','\n')
text=text.replace('', '')
text=text.replace(/\s{2,}/g, ' ')
text=text.replace('', '')
text=text.replace('', '')
text=text.replace('', '')
text=text.replace('','')
text=text.replace('', '')
text=text.replace('', '')
text=text.replace('','')
//console.log(text)
return text
},
getID: function(news){
//console.log(news['@id'])
......@@ -292,7 +282,8 @@
//var uri= "/magazines/"+news['magazine'].toLowerCase()+"/data/"+news['magazine'].toLowerCase()+news['number']+".pdf";
//console.log(uri)
return uri;
//return uri;
return '/resources/'+(news['@id'].split('/')[4]);
},
getemotion: function(emotion) {
//console.log(emotion)
......@@ -336,44 +327,32 @@
},
highlightEntity: function(e) {
/*console.log(e.model.__data__)
console.log(e.model.__data__.entity["schema:name"])
var myfilters = [e.model.__data__.entity["schema:name"]]
console.log("filtering")
this.push('filters', { terms: { 'entities.schema:name.keyword': myfilters}})*/
var id = e.target.dataset.id
var element = document.getElementById(id)
var text = e.target.dataset.text
var beginIndex = e.model.__data__.entity["nif:beginIndex"]
var endIndex = e.model.__data__.entity["nif:endIndex"] + 1
//console.log(beginIndex)
//console.log(endIndex)
var subtext = text.substring(0,beginIndex)
//var nbreaks=(subtext.match(/\n/g) || []).length/2
//var nbreaks=0
//beginIndex+=nbreaks
//endIndex+=nbreaks
// console.log(beginIndex)
// console.log(endIndex)
// console.log(e.model.__data__.entity["schema:name"])
if (beginIndex >= 0) {
text = text.substring(0,beginIndex) + "<span class='highlight' style='background-color:yellow'>" + text.substring(beginIndex,endIndex) + "</span>" + text.substring(endIndex)
element.innerHTML = text
//console.log(text)
//console.log($('#'+element.parentElement.id+' span').position().top)
//Dynamic Scroll
$('#'+element.parentElement.id).animate({scrollTop: $('#'+element.parentElement.id).scrollTop() + $('#'+element.parentElement.id + ' span').position().top - 200}, 400)
}
},
setPDF: function(news, index) {
function loadPDF() {
var uri= "http://trivalent-resources.cluster.gsi.dit.upm.es/"+news['magazine'].toLowerCase()+"/"+news['magazine'].toLowerCase()+news['number']+".pdf#page="+news['schema:pageStart']+"&view=FitB";
var uri= "http://trivalent-resources.cluster.gsi.dit.upm.es/"+news['magazine'].toLowerCase()+"/"+news['magazine'].toLowerCase()+news['number']+".pdf#page="+news['schema:pageStart']+1;
$('#article'+index).off();
$('#article'+index).on('shown.bs.modal', function(event) {
var iframe = $('<iframe>').attr('src', uri).width('100%').height('91%');
$('#article'+index+' #pdf'+index).html(iframe);
});
}
if (window.loaded) {
loadPDF();
} else {
......
......@@ -23,7 +23,7 @@
<app-location route="{{route}}"></app-location>
<elastic-client
config='{"host": "${ES_ENDPOINT_EXTERNAL}"}'
config='{"host": "http://sefarad-elasticsearch.cluster.gsi.dit.upm.es"}'
client="{{client}}"
cluster-status="{{myStatus}}">
</elastic-client>
......
......@@ -18,7 +18,7 @@ cd demo
bower link $APP_NAME --allow-root
envsubst < /usr/src/app/demo/index.env.html > /usr/src/app/demo/index.html || exit 1;
http-server .
#http-server .
#polymer serve --hostname 0.0.0.0
polymer serve --hostname 0.0.0.0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment