Commit 18e3afa0 authored by Thibault Ehrhart's avatar Thibault Ehrhart

Add TimeMapper button

Fixes: #2
parent fdb91000
......@@ -12,6 +12,7 @@
</div>
-->
<div class="header-buttons">
<a class="timemapper-button" (click)="openTimeMapper()">TimeMapper</a>
<!--<a class="fullscreen-button" (click)="toggleFullscreen()"><i class="fa fa-arrows-alt" aria-hidden="true"></i></a>-->
<a class="close-button" (click)="close()"><i class="fa fa-times" aria-hidden="true"></i></a>
</div>
......
......@@ -89,3 +89,8 @@
color: $dark-color;
}
}
.timemapper-button {
cursor: pointer;
text-decoration: underline;
}
......@@ -7,6 +7,7 @@ import { NgOption } from '@ng-select/ng-select';
import 'rxjs/add/operator/debounceTime';
import * as i18nIsoCountries from 'i18n-iso-countries'
import * as moment from 'moment';
@Component({
selector: 'app-home-details',
......@@ -66,6 +67,33 @@ export class HomeDetailsComponent implements OnInit {
this.isFullscreen = !this.isFullscreen;
}
openTimeMapper() {
const w = 900;
const h = 500;
const screenLeft = window.screenLeft != undefined ? window.screenLeft : window.screenX;
const screenTop = window.screenTop != undefined ? window.screenTop : window.screenY;
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
const left = ((width / 2) - (w / 2)) + screenLeft;
const top = ((height / 2) - (h / 2)) + screenTop;
let subjectCode = this.selectedItem.subjects.length > 0 ? this.selectedItem.subjects[0] : '';
if (subjectCode.indexOf('http://cv.iptc.org/newscodes/subjectcode/') === 0) {
subjectCode = subjectCode.substr('http://cv.iptc.org/newscodes/subjectcode/'.length);
}
const params = 'afp-4w?what_iptc=' + encodeURIComponent(subjectCode) + '&when=' + encodeURIComponent(moment(this.selectedItem.datePublished).format('YYYY-MM-DD')) + '&where=' + encodeURIComponent(this.selectedItem.dateline) + '&topic=' + encodeURIComponent('Top Stories');
const url = 'http://medialab.afp.com/afp4w/timemapper.php?newsMl=' + encodeURIComponent(params);
const newWindow = window.open(url, 'AFP-4W - Timemapper', 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
if (window.focus) {
newWindow.focus();
}
}
getCountryName(alpha3code: string) {
//TODO: move this to a pipe
return i18nIsoCountries.getName(alpha3code, "en");
......
......@@ -114,9 +114,10 @@ export class NewsService {
// Generate query
let query = `
${this.getPrefixes()}
SELECT DISTINCT ?s ?dateCreated ?dateModified ?datePublished ?description ?genre ?subject ?headline ?identifier ?language ?slug ?country ?locality (GROUP_CONCAT(DISTINCT ?annotations; separator="|") AS ?annotations)
SELECT DISTINCT ?s ?dateCreated ?dateModified ?datePublished ?description ?genre ?genreLabel (GROUP_CONCAT(?subject; separator="|") AS ?subjects) (GROUP_CONCAT(?subjectLabel; separator="|") AS ?subjectsLabels) ?dateline ?headline ?identifier ?language ?slug ?country ?locality ?annotations ?p1561 ?p1339 ?p1120 ?p137 ?p426 ?p3090
FROM <http://asrael.eurecom.fr/agencefrancepresse/news>
WHERE {
GRAPH <http://asrael.eurecom.fr/agencefrancepresse/news> { ?s a rnews:NewsItem . }
?s a rnews:NewsItem .
VALUES ?s { <${uri}> }
OPTIONAL { ?s rnews:dateCreated ?dateCreated . }
OPTIONAL { ?s rnews:dateModified ?dateModified . }
......@@ -124,8 +125,21 @@ export class NewsService {
OPTIONAL {
?s rnews:description ?description .
}
OPTIONAL { ?s rnews:genre ?genre . }
OPTIONAL { ?s dc:subject ?subject . }
OPTIONAL {
?s rnews:genre ?genre .
OPTIONAL {
?genre skos:prefLabel ?genreLabel .
FILTER (LANG(?genreLabel) = "en-gb")
}
}
OPTIONAL {
?s dc:subject ?subject .
OPTIONAL {
?subject skos:prefLabel ?subjectLabel .
FILTER (LANG(?subjectLabel) = "en-gb")
}
}
OPTIONAL { ?s rnews:dateline ?dateline . }
OPTIONAL { ?s rnews:headline ?headline . }
OPTIONAL { ?s rnews:identifier ?identifier . }
OPTIONAL { ?s rnews:inLanguage ?language . }
......@@ -177,6 +191,14 @@ export class NewsService {
binding[k] = binding[k].value;
}
// Split subjects
if (binding.subjects) {
binding.subjects = binding.subjects.split('|');
}
if (binding.subjectsLabels) {
binding.subjectsLabels = binding.subjectsLabels.split('|');
}
// Annotations
if (binding.annotations) {
// Split and decode the values
......
Markdown is supported
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