Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
206 commits
Select commit Hold shift + click to select a range
b7e3270
Configure Flask app for proxy deployment
Sep 4, 2025
5f5ef5b
Issuing the `event_upcoming-deadlines.sparql` query to QLever
Sep 5, 2025
1417d59
Rewrite by transform-sparql.py
Sep 19, 2025
2ac71f4
More fixes (already works reasonably well now)
Sep 19, 2025
ce7856c
Add script `transform_sparql.py`
Sep 19, 2025
a1b305d
More fixes
Sep 19, 2025
658b8da
Serve via scholia.wiki domain
Sep 20, 2025
f9978aa
Added a README file for Apache configuration instructions
Sep 20, 2025
424b525
Minor improvement in link anchor text
Sep 20, 2025
d158dc1
Fix award template and query
Sep 20, 2025
2056728
Formatted all queries and fixed some more errors
Sep 20, 2025
705e59f
Update topic_context.sparql
Daniel-Mietchen Sep 22, 2025
b850eb0
Add missing `rdf:` prefix declaration to `topic_context.sparql` #2
hannahbast Sep 28, 2025
e610d8d
Update organizations_coauthorships.sparql
Daniel-Mietchen Oct 8, 2025
5486c42
added prefixes for redirect queries
Daniel-Mietchen Oct 19, 2025
ec6d04b
Add RDFS prefix to SPARQL query in organizations_coauthorships.sparql
Daniel-Mietchen Oct 19, 2025
bde08bc
Add OWL prefix to chemical_physchem-properties.sparql template
Daniel-Mietchen Oct 20, 2025
52fb128
Add DCT prefix to lexeme-index_lexemes.sparql template
Daniel-Mietchen Oct 20, 2025
abd04a0
Add wd prefix to lexeme_works.sparql
Daniel-Mietchen Oct 20, 2025
d7eb241
Fix regex escaping in SPARQL filter in software-curation_missing-desc…
Daniel-Mietchen Oct 20, 2025
2ac422c
Fix user agent (required by new Wikimedia policy)
Nov 8, 2025
3074ee1
Merge branch 'qlever' of github.com:ad-freiburg/scholia into qlever
Nov 8, 2025
48d7987
changed template wikidata vs bigdata usage according to the defined p…
KonradLinden Nov 10, 2025
378e8f2
uncommented and fixed relevant part of the sparql template authors_li…
KonradLinden Nov 12, 2025
41f5238
replaced SERVICE calls to gas
KonradLinden Nov 11, 2025
6f4ce0b
added missing wdsubgraph prefix in templates
KonradLinden Nov 10, 2025
7a1dbb3
added missing wdsubgraph PREFIX definition to template
KonradLinden Nov 12, 2025
c3265a7
fixed bracketing that was causing syntaxerror in template
KonradLinden Nov 12, 2025
4007d74
replaced or ('|') syntax with VALUES in templates
KonradLinden Nov 11, 2025
655ad75
fixed jinja2 replacement syntax in template: authors_co-author.sparql
KonradLinden Nov 10, 2025
a0c014e
Merge pull request #10 from ad-freiburg/feature_syntax_errors
KonradLinden Nov 18, 2025
2ff6895
changed bd to wd and fixed prefixes
KonradLinden Nov 19, 2025
7e6757c
Merge pull request #11 from ad-freiburg/feature_missing_prefixes
KonradLinden Nov 23, 2025
15de458
federated queries to gas replaced and tested
KonradLinden Nov 25, 2025
0fb9058
Fixed the labels
egonw Nov 30, 2025
a185b74
replaced and tested gas queries for remaining templates
KonradLinden Dec 1, 2025
5c0cef4
Accept venues with mul label too
egonw Nov 30, 2025
668a57c
removed federeated queries to subgraph and verified equality
KonradLinden Dec 8, 2025
c001b3a
Merge pull request #14 from egonw/qleverPatch/cito/aspect/updates
egonw Dec 9, 2025
42f4f1f
Merge pull request #18 from ad-freiburg/feature_gas
egonw Dec 9, 2025
dfdb826
Merge pull request #19 from ad-freiburg/feature_wdsubgraph
egonw Dec 9, 2025
9b7aa39
Implement language detection and label service macro
larsgw Dec 8, 2025
6631363
Update queries for taxon aspect
larsgw Dec 8, 2025
4747101
Omit unused prefix
larsgw Dec 8, 2025
ce5146b
Fix code styles issues
larsgw Dec 8, 2025
a4a09c3
Consistently use underscores for internal variables
larsgw Dec 8, 2025
3063359
Improve taxon tree query
larsgw Dec 9, 2025
4012837
Merge pull request #20 from larsgw/larsgw-patch-15
egonw Dec 9, 2025
ee2aaed
Run on QLever itself
egonw Dec 9, 2025
857ad56
Labels for the /retraction/ index page
egonw Dec 9, 2025
585b157
Updated two /retraciton/{{q}} panels
egonw Dec 9, 2025
0b57bc7
Labels for a few /author/ panels
egonw Dec 9, 2025
7d2cbf9
Fix and simplify retraction aspect queries
larsgw Dec 9, 2025
aacd450
Fix labels for and optimize queries of topic aspect
larsgw Dec 10, 2025
313d35c
Merge pull request #25 from larsgw/larsgw-patch-16
egonw Dec 10, 2025
0e49cc3
Merge pull request #23 from egonw/authorPanelLabels
egonw Dec 10, 2025
cea69ee
Update queries for aspect topic curation
larsgw Dec 10, 2025
dddf22e
Update queries for aspect topic use
larsgw Dec 10, 2025
8b6ffe2
Update queries for topics aspect
larsgw Dec 10, 2025
8323ee5
Update queries of use-related aspects
larsgw Dec 10, 2025
e81142b
Update queries for venue aspects
larsgw Dec 11, 2025
2efe935
Update queries for work aspects
larsgw Dec 11, 2025
8c5a116
Temporarily remove wikipedia mentions query
larsgw Dec 11, 2025
9e8971b
Merge pull request #26 from larsgw/larsgw-patch-17
egonw Dec 12, 2025
10e1bb0
Merge pull request #28 from larsgw/larsgw-patch-18
egonw Dec 12, 2025
0db1681
Everything should be runninig on QLever
egonw Dec 12, 2025
c0dea45
removed not functional bd:sample SERVICE call from 2 templates
KonradLinden Nov 11, 2025
0db9974
Fix and reenable queries with wikibase:mwapi from work and taxon
larsgw Dec 12, 2025
54ca196
Labels for /chemical-class/
egonw Dec 12, 2025
36edd05
Labels for /chemical-element/
egonw Dec 12, 2025
e3b7847
Merge pull request #30 from larsgw/larsgw-patch-19
egonw Dec 13, 2025
6f7e96e
Removed unused prefixes
egonw Dec 12, 2025
c91d8a2
Merge pull request #31 from egonw/hackdec/chemical-class/labels
egonw Dec 13, 2025
7984aa7
Removed an unused, defunct query
egonw Dec 13, 2025
322e22a
More labels (two panels take too much memory)
egonw Dec 13, 2025
e857df3
Use WDQS for the stats
egonw Dec 13, 2025
65d976d
Added labels
egonw Dec 13, 2025
fee526d
Labels for the /author/ aspect panels
egonw Dec 13, 2025
2445190
Merge pull request #32 from egonw/hackdec/chemical/labelsAndMore
egonw Dec 13, 2025
adefaf7
Merge pull request #33 from egonw/hackdec/author
egonw Dec 13, 2025
e1a54f4
Labels for the /series/ aspect panels
egonw Dec 13, 2025
04b5f67
fix label service for organization
pfps Dec 13, 2025
759ea2c
Merge pull request #36 from pfps/organization
egonw Dec 13, 2025
ee6ffa2
Merge pull request #34 from egonw/hackdec/series
egonw Dec 13, 2025
db361d6
fix label service calls in publisher
pfps Dec 13, 2025
69a5db9
Merge pull request #37 from pfps/publisher
egonw Dec 13, 2025
59644af
Updated two /disease/ panels for labels
egonw Dec 13, 2025
75bd56b
fix label service for printer and sponsor
pfps Dec 13, 2025
28a3836
Merge pull request #40 from pfps/printer
egonw Dec 13, 2025
a686683
Merge pull request #38 from egonw/hackdec/disease
egonw Dec 13, 2025
6cbd55f
fix label service for country and location
pfps Dec 13, 2025
0b13a67
fix label service replacement in country authors
pfps Dec 13, 2025
e67c674
Merge pull request #41 from pfps/location
egonw Dec 13, 2025
80f256c
use Hannah's suggestion for label service replacement and include mac…
pfps Dec 13, 2025
82bf7ce
Added missing prefixes for CEUR scraping
egonw Dec 14, 2025
f032e68
Added more missing prefix definitions
egonw Dec 14, 2025
e17cbac
removed mention of service bdsample calls
KonradLinden Dec 14, 2025
7e86cb8
Missing prefix definitions in the wikipedia test
egonw Dec 14, 2025
2c7c321
introduced new labelling makros
KonradLinden Dec 14, 2025
cc4d873
SPARQL 1.1 labels
egonw Dec 14, 2025
7aa66ab
More missing prefix definitions
egonw Dec 14, 2025
ac330de
Merge pull request #46 from ad-freiburg/service_bdsample
KonradLinden Dec 14, 2025
02b288e
Added a QLever version of the query
egonw Dec 14, 2025
646fba4
fix label service for organization
pfps Dec 14, 2025
bf138f4
use double __ as a better chance for an unused variable name
pfps Dec 14, 2025
d8fa696
Merge pull request #43 from pfps/macro
egonw Dec 14, 2025
6deba6d
Merge pull request #47 from pfps/organization
egonw Dec 14, 2025
c026846
fix damaged country co-organzation query
pfps Dec 14, 2025
4ddc241
Wrapped a few lines, to fix lint issues
egonw Dec 14, 2025
b925dbd
fix label service for event
pfps Dec 13, 2025
e22bea8
More shorter lines
egonw Dec 14, 2025
c7aedb4
fix label service; fix expensive query
pfps Dec 14, 2025
6bb54cf
Merge pull request #45 from egonw/hackdec/testFailFixes
egonw Dec 14, 2025
41c890d
Merge pull request #49 from pfps/country
egonw Dec 14, 2025
ca9a162
Merge pull request #51 from pfps/clinical
egonw Dec 14, 2025
8918e83
Merge pull request #50 from pfps/events
egonw Dec 14, 2025
de43a2d
fix label service; fix broken queries
pfps Dec 14, 2025
ff973ea
Merge pull request #52 from pfps/project
egonw Dec 14, 2025
fdfa524
fix award label service and a couple of queries
pfps Dec 14, 2025
76319b8
use different auxiliary variables for label and description
pfps Dec 14, 2025
fdc44ba
Merge pull request #56 from pfps/macro
egonw Dec 14, 2025
ea994b1
Merge pull request #54 from pfps/award
egonw Dec 14, 2025
41aa068
fixes 2743
WolfgangFahl Dec 12, 2025
2c92e0a
fixes superflous imports
WolfgangFahl Dec 13, 2025
55418ec
improves JSON Output
WolfgangFahl Dec 13, 2025
1c4b549
Reverted a patch from a different PR
egonw Dec 14, 2025
1489f85
Also report the sparql_editurl and sparql_embedurl
egonw Dec 14, 2025
8084f24
fix label service
pfps Dec 14, 2025
6c5cbed
fix label service in disease
pfps Dec 14, 2025
0dff464
Fixed (new) flake issues
egonw Dec 14, 2025
fa6cc2b
fix label service; fix broken queries
pfps Dec 14, 2025
5945d62
add some manual fixes
larsgw Dec 14, 2025
4b5a2a4
fix label service for pathway
pfps Dec 14, 2025
aa924cb
Fixed the query
egonw Dec 14, 2025
413c408
Fixed the query
egonw Dec 14, 2025
266f696
fix label service for chemical
pfps Dec 14, 2025
0ca031b
fix label service for proteins; improve one query
pfps Dec 14, 2025
a3d9eac
fix syntax in probably unused protein_similar-proteins
pfps Dec 14, 2025
c366806
Remove unnecessary language parameter from SPARQL
Daniel-Mietchen Dec 14, 2025
8154bf0
fix label service for lexeme
pfps Dec 14, 2025
698db6b
Moved remaining not functioning federated queries to mwapi to WDQS
KonradLinden Dec 15, 2025
e8a6262
fix label service for ontology
pfps Dec 14, 2025
217604d
fix label service for software
pfps Dec 14, 2025
8bd92e2
fix label service for countries
pfps Dec 14, 2025
a09c6ee
fix label service in organizations
pfps Dec 14, 2025
4fc9111
Moved remaining not functioning federated queries to mwapi to WDQS
KonradLinden Dec 15, 2025
001e548
With the new label macro, when no label is found, this script will sh…
egonw Dec 14, 2025
fbef472
Made it a local variable
egonw Dec 15, 2025
e726766
fix label service for podcast
pfps Dec 14, 2025
f182bbf
Restored the links
egonw Dec 15, 2025
58e832b
Do not make/change global variable qid
larsgw Dec 15, 2025
073acc9
fix label service in cito
pfps Dec 15, 2025
a1f378a
fix label service for property
pfps Dec 15, 2025
44c48b7
fix label service in catalogue
pfps Dec 15, 2025
cf42315
use _unbound label macro for printer_works template
pfps Dec 15, 2025
53a645a
fix label service for license
pfps Dec 15, 2025
e9ae1ff
fix label service for language; patch blank node check and date range
pfps Dec 15, 2025
823134c
fix label service for dataset
pfps Dec 15, 2025
0081b94
Fixed two Codacy minor issues
egonw Dec 16, 2025
4e0d087
Labels for complexes
egonw Dec 16, 2025
a4920bf
Merge branch 'qlever' into feature_mwapi
KonradLinden Dec 16, 2025
d718a9c
Merge pull request #91 from ad-freiburg/feature_mwapi
KonradLinden Dec 16, 2025
58e7c98
fix label service for author
pfps Dec 16, 2025
ef0ee44
improve performance of complex articles by year
pfps Dec 16, 2025
7354923
optimize location_nearby_organizations.sparql
pfps Dec 17, 2025
5d26b87
delegated the gas call to WDQS
KonradLinden Dec 19, 2025
7795ce9
Also read the SPARQL config for iframe content
egonw Aug 23, 2025
16d0eaf
Use the config info
egonw Dec 21, 2025
45bae05
reduce cost of organization_recent-literature.sparql
pfps Dec 21, 2025
0660425
fix distance selection in location_nearby-locations-as-topics-in-work…
pfps Dec 21, 2025
f054e3e
remove fake service from location-topic_nearby-researchers.sparql
pfps Dec 21, 2025
889181e
improve speed of event_co-authors.sparql
pfps Dec 21, 2025
3ddc854
Made faster
egonw Dec 21, 2025
ffebcff
fix chemical queries
pfps Dec 21, 2025
458f2da
add in fixed qualifiers to chemical_physchem-properties.sparql
pfps Dec 21, 2025
4ab90bb
Removed chemistry bits
egonw Dec 21, 2025
1ef2fa5
Rewritten to be faster
egonw Dec 21, 2025
d646aaa
Added missing prefix definition
egonw Dec 21, 2025
cd79176
speed up event_related-events-timelocation.sparql
pfps Dec 21, 2025
b370e90
add in date filter for coming deadlines
pfps Dec 21, 2025
a179b95
fix complex_articles-by-year.sparql
pfps Dec 21, 2025
97917fb
Updated the SPARQL query for the new Wikidata model (without 'of')
egonw Dec 22, 2025
1fde7b2
Link from the GUI to the correct repo/branch combo: ad-freiburg/schol…
egonw Dec 22, 2025
130d9be
Attempt to fix two codacy warnings
egonw Dec 22, 2025
c2ec36a
in authors_co-author: ensure difference of searched authors
KonradLinden Dec 22, 2025
e518a5f
Merge branch 'qlever' of https://github.com/ad-freiburg/scholia into …
KonradLinden Dec 22, 2025
db7d7ab
Easier (faster) in QLever
egonw Dec 29, 2025
51404fd
Used a trick Bast suggested to make OPTIONAL work better
egonw Dec 29, 2025
a6c11f1
The ?work is important here, as the labels get lost otherwise
egonw Dec 29, 2025
38cd5fc
Fixes the author labels
egonw Dec 29, 2025
ed35118
Same trick by Hannah to get the OPTIONALs working, and with thanks to…
egonw Dec 29, 2025
d74bda2
Limit to the organizations the page is about
egonw Dec 29, 2025
adb7c6a
No translation to string needed; use the lang macro
egonw Dec 29, 2025
ffa8135
Enabled the VALUES to limit the results to the selected organizations
egonw Dec 29, 2025
80d3e08
Only for the selected countries
egonw Dec 29, 2025
370fc08
Harmonized indentation
egonw Dec 29, 2025
8626f06
Renamed
egonw Dec 29, 2025
ab53058
More whitespace harmonization
egonw Dec 29, 2025
74caee3
Allow giving the IP from the command line
egonw Dec 29, 2025
4057ccd
Removed a lot of whitespace (same query), to make it fit the QLever U…
egonw Dec 30, 2025
d8b3bf6
Shortened the query, to fit the GET URL length limit
egonw Dec 31, 2025
e0d98f3
Restored the DISTINCT
egonw Dec 31, 2025
95e04e7
Shortened the query, to fit the GET URL length limit
egonw Dec 31, 2025
3c3d270
Rewritten to not depend on WDQS
egonw Jan 1, 2026
75c5aaa
fixed mismatched brackets
KonradLinden Jan 9, 2026
ad3d9f2
added missing Prefix and fixed bracketing
KonradLinden Jan 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
62 changes: 62 additions & 0 deletions README-apache-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Apache virtual host configuration

Currently runs on <https://qlever.scholia.wiki> and
<https://wikidata-query-gui.scholia.wiki> with the following
Apache configurations.

## qlever.scholia.wiki

```apache
<VirtualHost *:443>
ServerName qlever.scholia.wiki
ServerAdmin webmaster@localhost

SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/qlever.scholia.wiki/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/qlever.scholia.wiki/privkey.pem
# SSLCertificateFile /etc/letsencrypt/live/qlever.cs.uni-freiburg.de/fullchain.pem
# SSLCertificateKeyFile /etc/letsencrypt/live/qlever.cs.uni-freiburg.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

ProxyPass / http://tajo.informatik.privat:8100/

<Directory />
Options Indexes
Options FollowSymLinks
AllowOverride None
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/scholia-error.log
CustomLog ${APACHE_LOG_DIR}/scholia-access.log combined
</VirtualHost>
```

## wikidata-query-gui.scholia.wiki

```apache
<VirtualHost *:443>
ServerName wikidata-query-gui.scholia.wiki
ServerAdmin webmaster@localhost

SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/wikidata-query-gui.scholia.wiki/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/wikidata-query-gui.scholia.wiki/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf

ProxyPass / http://tajo.informatik.privat:8080/

<Directory />
Options Indexes
Options FollowSymLinks
AllowOverride None
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/wikidata-query-gui-error.log
CustomLog ${APACHE_LOG_DIR}/wikidata-query-gui.log combined
</VirtualHost>
```



13 changes: 11 additions & 2 deletions runserver.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from scholia.app import create_app
import sys
import logging

# Enable debug logging
logging.basicConfig(level=logging.DEBUG)

app = create_app(
text_to_topic_q_text_enabled=False,
third_parties_enabled=True)
app.config['APPLICATION_ROOT'] = '/'

if __name__ == '__main__':
if len(sys.argv) == 3:
hostIP = port=sys.argv[2]
else :
hostIP = '0.0.0.0'

if len(sys.argv) == 2:
app.run(debug=True, port=sys.argv[1])
app.run(debug=True, host=hostIP, port=sys.argv[1])
else:
app.run(debug=True, port=8100)
app.run(debug=True, host=hostIP, port=8100)
6 changes: 6 additions & 0 deletions scholia/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from flask import Flask
from flask_bootstrap import Bootstrap, StaticCDN
from werkzeug.middleware.proxy_fix import ProxyFix

from ..text import TextToTopicQText

Expand Down Expand Up @@ -33,6 +34,11 @@ def create_app(text_to_topic_q_text_enabled=True, third_parties_enabled=False):
"""
app = Flask(__name__)

# Configure for proxy deployment
app.wsgi_app = ProxyFix(
app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1
)

Bootstrap(app)

# Serve assets from wmflabs for privacy reasons
Expand Down
152 changes: 86 additions & 66 deletions scholia/app/static/scholia.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,69 +96,74 @@ function convertDataTableData(data, columns) {
}
}
for (var i = 0 ; i < data.length ; i++) {
var convertedRow = {};
for (var key in data[i]) {
if (key.slice(-11) == 'Description') {
convertedRow[key.slice(0, key.length - 11) + ' description'] = data[i][key];
var convertedRow = {};
for (var key in data[i]) {
if (key.slice(-11) == 'Description') {
convertedRow[key.slice(0, key.length - 11) + ' description'] = data[i][key];

} else if (
key + 'Label' in data[i] &&
} else if (
key + 'Label' in data[i] &&
key + 'Url' in data[i]
) {
) {
convertedRow[key] = '<a href="' +
data[i][key + 'Url'] +
'">' + data[i][key + 'Label'] + '</a>';
data[i][key + 'Url'] +
'">' + data[i][key + 'Label'] + '</a>';

} else if (key.slice(-17) == 'ChemicalStructure') {
} else if (key.slice(-17) == 'ChemicalStructure') {
convertedRow[key.slice(0, key.length - 17) + ' structure'] = '<img loading="lazy" src="' +
'https://cdkdepict.toolforge.org/depict/bow/svg?smi=' +
encodeURIComponent(data[i][key]) +
encodeURIComponent(data[i][key]) +
'&abbr=on&hdisp=bridgehead&showtitle=false&zoom=2&annotate=cip' +
'" />';
'" />';

} else if (
key + 'Label' in data[i] &&
/^http/.test(data[i][key]) &&
data[i][key].length > 30
) {
convertedRow[key] = '<a href="../' +
data[i][key].slice(31) +
'">' + data[i][key + 'Label'] + '</a>';
} else if (
key + 'Label' in data[i] &&
/^http/.test(data[i][key]) &&
data[i][key].length > 30
) {
convertedRow[key] = '<a href="../' +
data[i][key].slice(31) +
'">' + data[i][key + 'Label'] + '</a>';

} else if (key.slice(-5) == 'Label') {
// pass

} else if (key + 'Url' in data[i]) {
convertedRow[key] = '<a href="' +
data[i][key + 'Url'] +
'">' + data[i][key] + '</a>';

} else if (key.slice(-3) == 'Url') {
// pass

} else if (key.slice(-3) == 'url') {
// Convert URL to a link
convertedRow[key] = "<a href='" +
data[i][key] + "'>" +
$("<div>").text(data[i][key]).html() + '</a>';

} else if (key == 'orcid') {
// Add link to ORCID website
convertedRow[key] = '<a href="https://orcid.org/' +
data[i][key] + '">' +
data[i][key] + '</a>';

} else if (key == 'doi') {
// Add link to Crossref
convertedRow[key] = '<a href="https://doi.org/' +
encodeURIComponent(data[i][key]) + '">' +
$("<div>").text(data[i][key]).html() + '</a>';

} else {
convertedRow[key] = data[i][key];
}
}
convertedData.push(convertedRow);
// pass

} else if (key + 'Url' in data[i]) {
convertedRow[key] = '<a href="' +
data[i][key + 'Url'] +
'">' + data[i][key] + '</a>';

} else if (key.slice(-3) == 'Url') {
// pass

} else if (key.slice(-3) == 'url') {
// Convert URL to a link
convertedRow[key] = "<a href='" +
data[i][key] + "'>" +
$("<div>").text(data[i][key]).html() + '</a>';

} else if (key == 'orcid') {
// Add link to ORCID website
convertedRow[key] = '<a href="https://orcid.org/' +
data[i][key] + '">' +
data[i][key] + '</a>';

} else if (key == 'doi') {
// Add link to Crossref
convertedRow[key] = '<a href="https://doi.org/' +
encodeURIComponent(data[i][key]) + '">' +
$("<div>").text(data[i][key]).html() + '</a>';

} else {
var convertedRowValue = data[i][key];
if (convertedRowValue.startsWith("http://www.wikidata.org/entity/Q")) {
var qid = convertedRowValue.slice(31);
convertedRowValue = '<a href="../' + qid + '">' + qid + '</a>';
}
convertedRow[key] = convertedRowValue;
}
}
convertedData.push(convertedRow);
}
return { data: convertedData, columns: convertedColumns };
}
Expand Down Expand Up @@ -260,7 +265,7 @@ function sparqlToDataTablePost2(url, editURL, sparql, element, filename, options
var paging = (typeof options.paging === 'undefined') ? true : options.paging;
var sDom = (typeof options.sDom === 'undefined') ? 'lfrtip' : options.sDom;
var sparqlEndpointName = (typeof options.sparqlEndpointName === 'undefined')
? window.jsConfig.sparqlEndpointName : options.sparqlEndpointName;
? window.jsConfig.sparqlEndpointName : options.sparqlEndpointName;

$(element).html("<div class='loader'><div></div><div></div><div></div></div>");

Expand All @@ -277,7 +282,7 @@ function sparqlToDataTablePost2(url, editURL, sparql, element, filename, options
};
columns.push(column);
}

if (convertedData.data.length <= 10) {
paging = false;
}
Expand All @@ -299,7 +304,7 @@ function sparqlToDataTablePost2(url, editURL, sparql, element, filename, options
'<caption><span style="float:left; font-size:smaller;"><a href="' + editURL +
encodeURIComponent(sparql) +
'">' + sparqlEndpointName + '</a></span>' +
'<span style="float:right; font-size:smaller;"><a href="https://github.com/WDscholia/scholia/blob/main/scholia/app/templates/' +
'<span style="float:right; font-size:smaller;"><a href="https://github.com/ad-freiburg/scholia/blob/qlever/scholia/app/templates/' +
filename + '">' +
filename.replace("_", ": ") +
'</a></span></caption>'
Expand Down Expand Up @@ -359,7 +364,7 @@ function sparqlToDataTable2(url, editURL, sparql, element, filename, options = {
var paging = (typeof options.paging === 'undefined') ? true : options.paging;
var sDom = (typeof options.sDom === 'undefined') ? 'lfrtip' : options.sDom;
var sparqlEndpointName = (typeof options.sparqlEndpointName === 'undefined')
? window.jsConfig.sparqlEndpointName : options.sparqlEndpointName;
? window.jsConfig.sparqlEndpointName : options.sparqlEndpointName;

// overwrite the central URLs of SPARQL specific URLs are found
configFromSPARQL = extractConfig(sparql);
Expand All @@ -372,7 +377,7 @@ function sparqlToDataTable2(url, editURL, sparql, element, filename, options = {
const datatableFooter =
'<caption><span style="float:left; font-size:smaller;"><a href="' + editURL +
encodeURIComponent(sparql) + '">' + sparqlEndpointName + '</a></span>' +
'<span style="float:right; font-size:smaller;"><a href="https://github.com/WDscholia/scholia/blob/main/scholia/app/templates/' +
'<span style="float:right; font-size:smaller;"><a href="https://github.com/ad-freiburg/scholia/blob/qlever/scholia/app/templates/' +
filename +
'">' +
filename.replace('_', ': ') +
Expand Down Expand Up @@ -484,11 +489,15 @@ function sparqlToDataTable2(url, editURL, sparql, element, filename, options = {
}
$(element).append(datatableFooter);
}
}).fail(function () {
}).fail(function (jqXHR, textStatus, errorThrown) {
$('#' + loaderID).remove(); // remove loader
$(element).prepend(
'<p>This query has timed out, we recommend that you follow the link to the Wikidata Query Service below to modify the query to be less intensive. </p> '
);
let error_message = "";
try {
error_message = "QLever execption: " + JSON.parse(jqXHR.responseText).exception;
} catch (e) {
error_message = "getJSON query failed: " + textStatus + " " + errorThrown;
}
$(element).prepend("<p style='color:red;'>" + escapeHTML(error_message) + "</p>");
const reloadButton = document.getElementById(element.slice(1) + '-reload');
reloadButton.classList.add('btn-secondary');
reloadButton.classList.remove('btn-outline-secondary');
Expand Down Expand Up @@ -516,6 +525,13 @@ function sparqlToIframe2(url, editURL, embedURL, sparql, element, filename) {

if (!embedURL) embedURL = "https://query.wikidata.org/embed.html#";

// overwrite the central URLs of SPARQL specific URLs are found
configFromSPARQL = extractConfig(sparql);
if (configFromSPARQL["url"]) url = configFromSPARQL["url"];
if (configFromSPARQL["editURL"]) editURL = configFromSPARQL["editURL"];
if (configFromSPARQL["embedURL"]) embedURL = configFromSPARQL["embedURL"];
if (configFromSPARQL["endpointName"]) sparqlEndpointName = configFromSPARQL["endpointName"];

const wikidata_sparql = url + "?query=" + encodeURIComponent(sparql);
const wikidata_query = editURL + encodeURIComponent(sparql);
var url = embedURL + encodeURIComponent(sparql);
Expand Down Expand Up @@ -549,6 +565,7 @@ function sparqlToIframe2(url, editURL, embedURL, sparql, element, filename) {

$.ajax({
url: wikidata_sparql,
headers: { Accept: "application/sparql-results+xml" },
success: function (data) {
let $xml = $(data);
let results = $xml.find('results');
Expand All @@ -559,7 +576,7 @@ function sparqlToIframe2(url, editURL, embedURL, sparql, element, filename) {
}
$iframe.parent().after(
'<span style="float:right; font-size:smaller">' +
'<a href="https://github.com/WDscholia/scholia/blob/main/scholia/app/templates/' + filename + '">' +
'<a href="https://github.com/ad-freiburg/scholia/blob/qlever/scholia/app/templates/' + filename + '">' +
filename.replace("_", ": ") +
'</a>' +
'</span>'
Expand Down Expand Up @@ -796,9 +813,12 @@ function askQuery(panel, askQuery, callback) {


function askQuery2(endpointUrl, panel, askQuery, callback) {
if (!endpointUrl) endpointUrl = "https://query.wikidata.org/sparql";

var settings = {
if (!endpointUrl) endpointUrl = "https://query.wikidata.org/sparql";
// overwrite the central URLs of SPARQL specific URLs are found
configFromSPARQL = extractConfig(askQuery);
if (configFromSPARQL["url"]) endpointUrl = configFromSPARQL["url"];

var settings = {
headers: { Accept: 'application/sparql-results+json' },
data: { query: askQuery },
};
Expand Down
31 changes: 14 additions & 17 deletions scholia/app/templates/404-chemical_related.sparql
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
SELECT ?mol ?molLabel ?InChIKey ?CAS ?ChemSpider ?PubChem_CID WITH {
SELECT ?mol ?InChIKey WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:endpoint "www.wikidata.org";
wikibase:api "Search";
mwapi:srsearch "_shortkey_ haswbstatement:P235";
mwapi:srlimit "max".
?mol wikibase:apiOutputItem mwapi:title.
}
?mol wdt:P235 ?InChIKey .
FILTER (regex(str(?InChIKey), "^_shortkey_"))
{% import 'sparql-helpers.sparql' as sparql_helpers -%}
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?mol ?molLabel ?InChIKey ?CAS ?ChemSpider ?PubChem_CID {
?mol wdt:P235 ?InChIKey .
FILTER (REGEX(?InChIKey,"^_shortkey_"))
OPTIONAL {
?mol wdt:P231 ?CAS
}
} AS %MOLS {
INCLUDE %MOLS
OPTIONAL { ?mol wdt:P231 ?CAS }
OPTIONAL { ?mol wdt:P661 ?ChemSpider }
OPTIONAL { ?mol wdt:P662 ?PubChem_CID }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
OPTIONAL {
?mol wdt:P661 ?ChemSpider
}
OPTIONAL {
?mol wdt:P662 ?PubChem_CID
}
{{ sparql_helpers.labels(["?mol"], languages) }}
}
14 changes: 12 additions & 2 deletions scholia/app/templates/ask_author_retractions.sparql
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
ASK {
?work wdt:P50 wd:{{q}} . BIND("author-retractions" AS ?aspectsubpage)
{ ?work wdt:P31 wd:Q45182324 } UNION { ?work wdt:P793 wd:Q7316896 . } UNION { ?work wdt:P5824 [] . }
# ?work wdt:P50 wd:{{q}} . BIND("author-retractions" AS ?aspectsubpage)
{
?work wdt:P31 wd:Q45182324
}
UNION {
?work wdt:P793 wd:Q7316896 .
}
UNION {
?work wdt:P5824 [] .
}
}
Loading