Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix style issue in Faresh9 title modification #2440

Merged
merged 9 commits into from
Mar 20, 2024
27 changes: 26 additions & 1 deletion scholia/app/static/scholia.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,37 @@ function sparqlToDataTable(sparql, element, filename, options = {}) {
function sparqlToIframe(sparql, element, filename) {
let $iframe = $(element);
var url = "https://query.wikidata.org/embed.html#" + encodeURIComponent(sparql);
$iframe.attr('src', url);
$iframe.attr('data-src', url);
$iframe.attr('loading', 'lazy');

const wikidata_sparql = "https://query.wikidata.org/sparql?query=" + encodeURIComponent(sparql);
const wikidata_query = "https://query.wikidata.org/#" + encodeURIComponent(sparql);

// Define the options for the Intersection Observer
const options = {
root: null,
rootMargin: '0px',
threshold: 0.1 // Trigger when 10% of the element is visible
};

// Create a new Intersection Observer instance
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
// If the iframe enters the viewport, load its content
if (entry.isIntersecting) {
const src = $iframe.data('src');
if (src) {
$iframe.attr('src', src);
// Unobserve the iframe to stop observing once loaded
observer.unobserve($iframe[0]);
}
}
});
}, options);

// Start observing the iframe
observer.observe($iframe[0]);

$.ajax({
url: wikidata_sparql,
success: function (data) {
Expand Down
2 changes: 1 addition & 1 deletion scholia/app/templates/podcast-index_languages.sparql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SELECT ?language ?languageLabel (CONCAT("/podcast/language/", SUBSTR(STR(?language), 32)) AS ?languageUrl)
SELECT ?language ?languageLabel (CONCAT("/language/", SUBSTR(STR(?language), 32), "/podcast") AS ?languageUrl)
(COUNT(DISTINCT ?podcast) AS ?podcasts)
WHERE {
?podcast wdt:P31 wd:Q24634210 ; wdt:P407 ?language .
Expand Down
2 changes: 1 addition & 1 deletion scholia/app/templates/podcast_data.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ WHERE {
?iri rdfs:label ?value_string .
FILTER (LANG(?value_string) = 'en')
BIND(STR(?value_string) AS ?value)
BIND(CONCAT("../podcast/language/", ?q) AS ?valueUrl)
BIND(CONCAT("../language/", ?q, "/podcast") AS ?valueUrl)
}
UNION
{
Expand Down
2 changes: 1 addition & 1 deletion scholia/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ def show_podcast_random():
return redirect(url_for('app.show_podcast', q=q), code=302)


@main.route('/podcast/language/' + q_pattern)
@main.route('/language/' + q_pattern + '/podcast')
def show_podcast_in_language(q):
"""Redirect to random podcast.

Expand Down
17 changes: 16 additions & 1 deletion scholia/scrape/ojs.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,22 @@ def _fields_to_content(fields):
title = _fields_to_content(['citation_title', 'DC.Title',
'DC.Title.Alternative'])
if title is not None:
entry['title'] = title
q = paper_to_q(entry)
if not q: # If not identified before modification
# Replace dash or colon without altering surrounding spaces
modified_title = title.replace(" –", ":").replace("– ", ":")
if modified_title != title: # Check if replacement is made
entry['title'] = modified_title
q = paper_to_q(entry)
if q: # If identified after modification
# Plug in the modified title
entry['title'] = modified_title
else:
entry['title'] = title # Plug in the original title
else:
entry['title'] = title
else:
entry['title'] = title

citation_date = _fields_to_content(['citation_date', 'DC.Date.issued'])
if citation_date is not None:
Expand Down
Loading