|
@ -252,7 +252,68 @@ def artwork(): |
|
|
|
|
|
|
|
|
sparql.setReturnFormat(JSON) |
|
|
sparql.setReturnFormat(JSON) |
|
|
artworkimages = sparql.query().convert() |
|
|
artworkimages = sparql.query().convert() |
|
|
print(artworkimages) |
|
|
# print(artworkimages) |
|
|
|
|
|
|
|
|
|
|
|
# Links and downloads |
|
|
|
|
|
sparql.setQuery(''' |
|
|
|
|
|
SELECT ?DownloadDigitalFacsimile ?DigitalFacsimileExternalLink ?DigitalFacsimileExternalLink2 |
|
|
|
|
|
WHERE |
|
|
|
|
|
{ |
|
|
|
|
|
VALUES ?work {wd:'''+artwork_id+'''} |
|
|
|
|
|
OPTIONAL {?work wdt:P32 ?DownloadDigitalFacsimile.} |
|
|
|
|
|
OPTIONAL {?work wdt:P34 ?DigitalFacsimileExternalLink.} |
|
|
|
|
|
OPTIONAL {?work wdt:P33 ?DigitalFacsimileExternalLink2.} |
|
|
|
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} |
|
|
|
|
|
}''') |
|
|
|
|
|
sparql.setReturnFormat(JSON) |
|
|
|
|
|
artworklinksanddownloads = sparql.query().convert() |
|
|
|
|
|
print(artworklinksanddownloads) |
|
|
|
|
|
|
|
|
|
|
|
# Other digital artefacts |
|
|
|
|
|
sparql.setQuery(''' |
|
|
|
|
|
SELECT ?ImageFile ?AudioFile ?VideoFile |
|
|
|
|
|
WHERE |
|
|
|
|
|
{ |
|
|
|
|
|
{ |
|
|
|
|
|
SELECT ?ImageFile WHERE { |
|
|
|
|
|
VALUES ?work {wd:Q57} |
|
|
|
|
|
OPTIONAL {?work p:P35 ?statement. |
|
|
|
|
|
?statement ps:P35 ?ImageFile; |
|
|
|
|
|
pq:P16 wd:Q85.} |
|
|
|
|
|
}} |
|
|
|
|
|
{ |
|
|
|
|
|
SELECT ?AudioFile WHERE { |
|
|
|
|
|
OPTIONAL {?work p:P35 ?statement. |
|
|
|
|
|
?statement ps:P35 ?AudioFile; |
|
|
|
|
|
pq:P16 wd:Q28.} |
|
|
|
|
|
}} |
|
|
|
|
|
{ |
|
|
|
|
|
SELECT ?VideoFile WHERE { |
|
|
|
|
|
OPTIONAL {?work p:P35 ?statement. |
|
|
|
|
|
?statement ps:P35 ?VideoFile; |
|
|
|
|
|
pq:P16 wd:Q27.} |
|
|
|
|
|
}} |
|
|
|
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} |
|
|
|
|
|
} |
|
|
|
|
|
''') |
|
|
|
|
|
sparql.setReturnFormat(JSON) |
|
|
|
|
|
artworkartefacts = sparql.query().convert() |
|
|
|
|
|
# print(artworkartefacts) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Distributor Links |
|
|
|
|
|
sparql.setQuery(''' |
|
|
|
|
|
SELECT ?distributorLinks |
|
|
|
|
|
WHERE |
|
|
|
|
|
{ |
|
|
|
|
|
VALUES ?work {wd:'''+artwork_id+'''} |
|
|
|
|
|
OPTIONAL {?work wdt:P37 ?distributorLinks.} |
|
|
|
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} |
|
|
|
|
|
} |
|
|
|
|
|
''') |
|
|
|
|
|
sparql.setReturnFormat(JSON) |
|
|
|
|
|
artworkdistributorlinks = sparql.query().convert() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######### Right top |
|
|
######### Right top |
|
|
# contributors |
|
|
# contributors |
|
@ -332,21 +393,15 @@ def artwork(): |
|
|
''') |
|
|
''') |
|
|
sparql.setReturnFormat(JSON) |
|
|
sparql.setReturnFormat(JSON) |
|
|
artworkdescriptiondata = sparql.query().convert() |
|
|
artworkdescriptiondata = sparql.query().convert() |
|
|
# print("hello") |
|
|
|
|
|
# print(artwork_id) |
|
|
|
|
|
# print(artworkdescriptiondata) |
|
|
|
|
|
# print("bye") |
|
|
|
|
|
|
|
|
|
|
|
dictionary = artworkdescriptiondata |
|
|
|
|
|
# print(type(dictionary)) |
|
|
|
|
|
|
|
|
|
|
|
# get the description text or say there isn't any |
|
|
# get the description text or say there isn't any |
|
|
artworkdescriptiontext = None |
|
|
# artworkdescriptiontext = [] |
|
|
|
|
|
|
|
|
for x in dictionary['results']['bindings']: |
|
|
for x in artworkdescriptiondata['results']['bindings']: |
|
|
if "accessURLdescriptionPage" in x: |
|
|
if "accessURLdescriptionPage" in x: |
|
|
print("url for description present") |
|
|
# print("url for description present") |
|
|
print(x["accessURLdescriptionPage"]["value"]) |
|
|
# print(x["accessURLdescriptionPage"]["value"]) |
|
|
accessURLdescriptionUrl = x["accessURLdescriptionPage"]["value"] |
|
|
accessURLdescriptionUrl = x["accessURLdescriptionPage"]["value"] |
|
|
desc_url = re.search(r':Q(.*)', accessURLdescriptionUrl, re.DOTALL) |
|
|
desc_url = re.search(r':Q(.*)', accessURLdescriptionUrl, re.DOTALL) |
|
|
# print(desc_url.group(1)) |
|
|
# print(desc_url.group(1)) |
|
@ -360,56 +415,60 @@ def artwork(): |
|
|
# # print(soup.prettify()) # print the parsed data of html |
|
|
# # print(soup.prettify()) # print the parsed data of html |
|
|
text=soup.find("div" , {"class" : "mw-parser-output"}) |
|
|
text=soup.find("div" , {"class" : "mw-parser-output"}) |
|
|
# text=soup.find_all("p") |
|
|
# text=soup.find_all("p") |
|
|
artworkdescriptiontext=Markup(text) |
|
|
# text=Markup(text) |
|
|
|
|
|
# artworkdescriptiontext.append(text) |
|
|
|
|
|
x["text"] = text |
|
|
else: |
|
|
else: |
|
|
print("url for description absent") |
|
|
# print("url for description absent") |
|
|
text="<p>Information not available</p>" |
|
|
text="<p>Information not available</p>" |
|
|
artworkdescriptiontext=Markup(text) |
|
|
x["text"] = text |
|
|
|
|
|
|
|
|
#description Q427 for testing purposes |
|
|
|
|
|
# artworkdescriptioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Description:Q427&action=render" |
|
|
|
|
|
# Make a GET request to fetch the raw HTML content |
|
|
|
|
|
# html_content = requests.get(artworkdescriptioncontenturl).text |
|
|
|
|
|
# Parse the html content |
|
|
|
|
|
# soup = BeautifulSoup(html_content, "lxml") |
|
|
|
|
|
# print(soup.prettify()) # print the parsed data of html |
|
|
|
|
|
# text=soup.find("div" , {"class" : "mw-parser-output"}) |
|
|
|
|
|
# text=soup.find_all("p") |
|
|
|
|
|
# artworkdescriptiontext=Markup(text) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# print(artworkdescriptiontext) |
|
|
|
|
|
|
|
|
|
|
|
############ right bottom LATER |
|
|
|
|
|
# exhibitions + id to be changed |
|
|
# exhibitions + id to be changed |
|
|
sparql.setQuery(''' |
|
|
sparql.setQuery(''' |
|
|
SELECT ?accessURLexhibitionHisPage ?authorexhibitionHisPageLabel ?dateexhibitionHisPage ?sourceexhibitionHisPage |
|
|
SELECT ?accessURLexhibitionHisPage ?authorexhibitionHisPageLabel ?dateexhibitionHisPage ?sourceexhibitionHisPage |
|
|
WHERE |
|
|
WHERE |
|
|
{ |
|
|
{ |
|
|
VALUES ?work {wd:Q57} |
|
|
VALUES ?work {wd:'''+artwork_id+'''} |
|
|
?work wdt:P66 ?exhibitionHisPage. |
|
|
?work wdt:P66 ?exhibitionHisPage. |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P4 ?accessURLexhibitionHisPage. } |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P4 ?accessURLexhibitionHisPage. } |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P9 ?authorexhibitionHisPage. } |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P9 ?authorexhibitionHisPage. } |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P13 ?dateexhibitionHisPage. } |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P13 ?dateexhibitionHisPage. } |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P50 ?sourceexhibitionHisPage. } |
|
|
OPTIONAL { ?exhibitionHisPage wdt:P50 ?sourceexhibitionHisPage. } |
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } |
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } |
|
|
} |
|
|
} |
|
|
''') |
|
|
''') |
|
|
sparql.setReturnFormat(JSON) |
|
|
sparql.setReturnFormat(JSON) |
|
|
artworkexhibitiondata = sparql.query().convert() |
|
|
artworkexhibitiondata = sparql.query().convert() |
|
|
|
|
|
|
|
|
# description content from wiki |
|
|
# get the text from the url |
|
|
artworkexhibitioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=History:"+artwork_id+"&action=render" |
|
|
for x in artworkexhibitiondata['results']['bindings']: |
|
|
# Make a GET request to fetch the raw HTML content |
|
|
if "accessURLexhibitionHisPage" in x: |
|
|
html_content = requests.get(artworkexhibitioncontenturl).text |
|
|
# print("url for description present") |
|
|
# Parse the html content |
|
|
# print(x["accessURLexhibitionHisPage"]["value"]) |
|
|
soup = BeautifulSoup(html_content, "lxml") |
|
|
accessURLexhibitionHisPage = x["accessURLexhibitionHisPage"]["value"] |
|
|
# print(soup.prettify()) # print the parsed data of html |
|
|
desc_url = re.search(r':Q(.*)', accessURLexhibitionHisPage, re.DOTALL) |
|
|
|
|
|
# print(desc_url.group(1)) |
|
|
|
|
|
desc_id=desc_url.group(1) |
|
|
|
|
|
# # get the description content from wiki |
|
|
|
|
|
artworkexhibitioncontenturl = "https://daap.bannerrepeater.org/w/index.php?title=History:Q"+desc_id+"&action=render" |
|
|
|
|
|
# # Make a GET request to fetch the raw HTML content |
|
|
|
|
|
html_content = requests.get(artworkexhibitioncontenturl).text |
|
|
|
|
|
# # Parse the html content |
|
|
|
|
|
soup = BeautifulSoup(html_content, "lxml") |
|
|
|
|
|
# # print(soup.prettify()) # print the parsed data of html |
|
|
|
|
|
text=soup.find("div" , {"class" : "mw-parser-output"}) |
|
|
|
|
|
# text=soup.find_all("p") |
|
|
|
|
|
# artworkexhibitiontext=Markup(text) |
|
|
|
|
|
x['text']=text |
|
|
|
|
|
else: |
|
|
|
|
|
# print("url for description absent") |
|
|
|
|
|
text="<p>Information not available</p>" |
|
|
|
|
|
# artworkexhibitiontext=Markup(text) |
|
|
|
|
|
x['text']=text |
|
|
|
|
|
|
|
|
|
|
|
# print(artworkexhibitiondata) |
|
|
|
|
|
|
|
|
text=soup.find("div" , {"class" : "mw-parser-output"}) |
|
|
|
|
|
# text=soup.find_all("p") |
|
|
|
|
|
artworkexhibitiontext=Markup(text) |
|
|
|
|
|
# print(artworkexhibitiontext) |
|
|
|
|
|
|
|
|
|
|
|
############## bottom |
|
|
############## bottom |
|
|
# copies in collection |
|
|
# copies in collection |
|
@ -425,7 +484,6 @@ def artwork(): |
|
|
} ''') |
|
|
} ''') |
|
|
sparql.setReturnFormat(JSON) |
|
|
sparql.setReturnFormat(JSON) |
|
|
copiesincollection = sparql.query().convert() |
|
|
copiesincollection = sparql.query().convert() |
|
|
# print(copiesincollection) |
|
|
|
|
|
|
|
|
|
|
|
# related works |
|
|
# related works |
|
|
sparql.setQuery(''' |
|
|
sparql.setQuery(''' |
|
@ -446,12 +504,29 @@ def artwork(): |
|
|
} ''') |
|
|
} ''') |
|
|
sparql.setReturnFormat(JSON) |
|
|
sparql.setReturnFormat(JSON) |
|
|
relatedworks = sparql.query().convert() |
|
|
relatedworks = sparql.query().convert() |
|
|
# print(relatedworks) |
|
|
|
|
|
|
|
|
# lists |
|
|
|
|
|
sparql.setQuery(''' |
|
|
|
|
|
SELECT ?list ?listLabel ?image ?date |
|
|
|
|
|
WHERE |
|
|
|
|
|
{ |
|
|
|
|
|
VALUES ?work {wd:'''+artwork_id+'''} |
|
|
|
|
|
?work wdt:P45 ?list. |
|
|
|
|
|
OPTIONAL {?list wdt:P13 ?date.} |
|
|
|
|
|
OPTIONAL {?list wdt:P30 ?image.} |
|
|
|
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} |
|
|
|
|
|
} |
|
|
|
|
|
''') |
|
|
|
|
|
sparql.setReturnFormat(JSON) |
|
|
|
|
|
artworklists = sparql.query().convert() |
|
|
|
|
|
# print(artworklists) |
|
|
|
|
|
|
|
|
|
|
|
return render_template('artwork.html', artwork_id=artwork_id, artworkintro=artworkintro, artworkimages=artworkimages, artworklinksanddownloads=artworklinksanddownloads, artworkartefacts=artworkartefacts, artworkdistributorlinks=artworkdistributorlinks, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, artworkdescriptiondata=artworkdescriptiondata, artworkexhibitiondata=artworkexhibitiondata, artworklists=artworklists, copiesincollection=copiesincollection, relatedworks=relatedworks) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return render_template('artwork.html', artwork_id=artwork_id, artworkintro=artworkintro, artworkimages=artworkimages, artworkcontributors=artworkcontributors, artworkdate=artworkdate, artworkpublisher=artworkpublisher, artworkdescriptiondata=artworkdescriptiondata, artworkdescriptiontext=artworkdescriptiontext, copiesincollection=copiesincollection, relatedworks=relatedworks) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######################### ORGANISATION |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -462,13 +537,11 @@ def artwork(): |
|
|
def person(): |
|
|
def person(): |
|
|
person_id = request.args.get('id') |
|
|
person_id = request.args.get('id') |
|
|
sparql.setQuery(''' |
|
|
sparql.setQuery(''' |
|
|
|
|
|
|
|
|
SELECT ?item ?itemLabel ?itemDescription ?propLabel ?b ?bLabel |
|
|
SELECT ?item ?itemLabel ?itemDescription ?propLabel ?b ?bLabel |
|
|
WHERE |
|
|
WHERE |
|
|
{ |
|
|
{ |
|
|
VALUES ?item {wd:'''+person_id+'''} |
|
|
VALUES ?item {wd:'''+person_id+'''} |
|
|
?item ?a ?b. |
|
|
?item ?a ?b. |
|
|
|
|
|
|
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } |
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } |
|
|
?prop wikibase:directClaim ?a . |
|
|
?prop wikibase:directClaim ?a . |
|
|
} |
|
|
} |
|
@ -478,7 +551,7 @@ def person(): |
|
|
print(person_details) |
|
|
print(person_details) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sparql2.setQuery(''' |
|
|
sparql.setQuery(''' |
|
|
SELECT ?work ?workLabel ?image ?date |
|
|
SELECT ?work ?workLabel ?image ?date |
|
|
WHERE { |
|
|
WHERE { |
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } |
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } |
|
@ -490,10 +563,10 @@ def person(): |
|
|
} |
|
|
} |
|
|
ORDER BY (?workLabel) |
|
|
ORDER BY (?workLabel) |
|
|
''') |
|
|
''') |
|
|
sparql2.setReturnFormat(JSON) |
|
|
sparql.setReturnFormat(JSON) |
|
|
person_creatorof = sparql2.query().convert() |
|
|
person_creatorof = sparql.query().convert() |
|
|
|
|
|
|
|
|
sparql3.setQuery(''' |
|
|
sparql.setQuery(''' |
|
|
SELECT ?work ?workLabel ?image ?date |
|
|
SELECT ?work ?workLabel ?image ?date |
|
|
WHERE { |
|
|
WHERE { |
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } |
|
|
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } |
|
@ -505,8 +578,8 @@ def person(): |
|
|
} |
|
|
} |
|
|
ORDER BY (?workLabel) |
|
|
ORDER BY (?workLabel) |
|
|
''') |
|
|
''') |
|
|
sparql3.setReturnFormat(JSON) |
|
|
sparql.setReturnFormat(JSON) |
|
|
person_publisherof = sparql2.query().convert() |
|
|
person_publisherof = sparql.query().convert() |
|
|
|
|
|
|
|
|
person_url = "" |
|
|
person_url = "" |
|
|
person_name = "the name" |
|
|
person_name = "the name" |
|
@ -541,12 +614,11 @@ def about(): |
|
|
# print(soup.prettify()) # print the parsed data of html |
|
|
# print(soup.prettify()) # print the parsed data of html |
|
|
|
|
|
|
|
|
text=soup.find("html") |
|
|
text=soup.find("html") |
|
|
# adapt the path to img with regex |
|
|
# A problem with image src obtention was solved by using absolute paths rather than traditional wiki syntax |
|
|
|
|
|
|
|
|
# replaceString = "wiki/Special:Redirect/file/" |
|
|
# replaceString = "wiki/Special:Redirect/file/" |
|
|
# cleanSoup = BeautifulSoup(str(text).replace("wiki/File:", replaceString)) |
|
|
# cleanSoup = BeautifulSoup(str(text).replace("wiki/File:", replaceString)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# for a in soup.find_all('a', href=True): |
|
|
# for a in soup.find_all('a', href=True): |
|
|
# if a.text: |
|
|
# if a.text: |
|
|
# print(a['href']) |
|
|
# print(a['href']) |
|
@ -626,21 +698,6 @@ def codeofconduct(): |
|
|
######################### LOGIN |
|
|
######################### LOGIN |
|
|
#Goes to wikibase page |
|
|
#Goes to wikibase page |
|
|
|
|
|
|
|
|
# ################### |
|
|
|
|
|
# TEST |
|
|
|
|
|
|
|
|
|
|
|
response = requests.get( |
|
|
|
|
|
'https://daap.bannerrepeater.org/w/api.php', |
|
|
|
|
|
params={ |
|
|
|
|
|
'action': 'parse', |
|
|
|
|
|
'page': 'Test', |
|
|
|
|
|
'format': 'json', |
|
|
|
|
|
}).json() |
|
|
|
|
|
raw_html = response['parse']['text']['*'] |
|
|
|
|
|
document = html.document_fromstring(raw_html) |
|
|
|
|
|
first_p = document.xpath('//p')[0] |
|
|
|
|
|
intro_text = first_p.text_content() |
|
|
|
|
|
# print(intro_text) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ALL NAME |
|
|
# ALL NAME |
|
|