Skip to content

Commit 5bd7f74

Browse files
committed
wikidata graphql movie browser demo: titles now link to the wikidata pages
1 parent 75ae455 commit 5bd7f74

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

docs/demos/movies/index.html

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,18 @@
4343
color: #666;
4444
}
4545

46-
.movie-card a {
46+
a.link {
47+
text-decoration: none;
48+
color: #007bff;
49+
transition: background-color 0.3s, color 0.3s;
50+
}
51+
52+
a.link:hover {
53+
background-color: #007bff;
54+
color: #ffffff;
55+
}
56+
57+
a.button {
4758
display: inline-block;
4859
margin-top: 10px;
4960
text-decoration: none;
@@ -54,7 +65,7 @@
5465
transition: background-color 0.3s, color 0.3s;
5566
}
5667

57-
.movie-card a:hover {
68+
a.button:hover {
5869
background-color: #007bff;
5970
color: #ffffff;
6071
}
@@ -118,7 +129,7 @@
118129

119130
<body>
120131
<div class="header">
121-
<h1 style="display: inline; margin-right: 20px;">Movie Browser</h1>
132+
<h1 style="display: inline; margin-right: 20px;">Wikidata Movie Browser</h1>
122133
<a id="endpointLink" href="" target="_blank">View JSON on Endpoint</a>
123134
</div>
124135
<div class="search-container">
@@ -144,6 +155,7 @@ <h1 style="display: inline; margin-right: 20px;">Movie Browser</h1>
144155
})
145156
{
146157
Movies(limit: 1000) @pattern(of: "SELECT ?s { ?s wdt:P31 wd:Q11424 . FILTER (exists { ?s rdfs:label ?l . FILTER(langMatches(lang(?l), 'en')) FILTER(CONTAINS(LCASE(STR(?l)), LCASE('SEARCH_TERM'))) }) }") {
158+
id @bind(of: "?s")
147159
label @one @pattern(of: "?s rdfs:label ?l. FILTER(LANG(?l) = 'en')")
148160
description @one @pattern(of: "?s schema:description ?l. FILTER(LANG(?l) = 'en')")
149161
depiction @one @pattern(of: "SELECT ?s ?o { ?s wdt:P18 ?o } ORDER BY ?o LIMIT 1")
@@ -210,8 +222,14 @@ <h1 style="display: inline; margin-right: 20px;">Movie Browser</h1>
210222
const movieCard = document.createElement('div');
211223
movieCard.className = 'movie-card';
212224

225+
const wikidataLink = document.createElement('a');
226+
wikidataLink.href = movie.id;
227+
wikidataLink.target = '_blank';
228+
wikidataLink.className = "link";
229+
wikidataLink.textContent = `${movie.label} (${movie.releaseYear})`;
230+
213231
const movieTitle = document.createElement('h3');
214-
movieTitle.textContent = `${movie.label} (${movie.releaseYear})`;
232+
movieTitle.appendChild(wikidataLink);
215233

216234
const movieDescription = document.createElement('p');
217235
movieDescription.textContent = movie.description;
@@ -231,11 +249,12 @@ <h1 style="display: inline; margin-right: 20px;">Movie Browser</h1>
231249
movieCard.appendChild(movieGenres);
232250

233251
if (movie.netflix) {
234-
const movieLink = document.createElement('a');
235-
movieLink.href = movie.netflix;
236-
movieLink.target = '_blank';
237-
movieLink.textContent = 'Watch on Netflix';
238-
movieCard.appendChild(movieLink);
252+
const netflixLink = document.createElement('a');
253+
netflixLink.href = movie.netflix;
254+
netflixLink.className = "button";
255+
netflixLink.target = '_blank';
256+
netflixLink.textContent = 'Watch on Netflix';
257+
movieCard.appendChild(netflixLink);
239258
}
240259

241260
container.appendChild(movieCard);

0 commit comments

Comments
 (0)