diff --git a/daapinterface.py b/daapinterface.py index 4f68779..8f5db80 100644 --- a/daapinterface.py +++ b/daapinterface.py @@ -19,6 +19,7 @@ import re # GETTING STARTED # # # # # # # # # # # # # # # # # # # # # # # # app = Flask(__name__, static_url_path='', static_folder="static", template_folder="templates") +app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 app.jinja_env.add_extension('jinja2.ext.loopcontrols') @@ -27,9 +28,6 @@ app.jinja_env.add_extension('jinja2.ext.loopcontrols') # # # # # # # # # # # # # # # # # # # # # # # # sparql = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdata/namespace/wdq/sparql") -sparql2 = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdata/namespace/wdq/sparql") -sparql3 = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdata/namespace/wdq/sparql") - # # # # # # # # # # # # # # # # # # # # # # # # # PAGES @@ -38,13 +36,33 @@ sparql3 = SPARQLWrapper("https://query.daap.bannerrepeater.org/proxy/wdqs/bigdat def home(): sparql.setQuery(''' SELECT ?work ?workLabel ?image ?date ?dateadded WHERE { + { + SELECT ?work ?workLabel (SAMPLE(?date) AS ?date) + WHERE + { ?work wdt:P1 wd:Q1; + wdt:P13 ?date. + FILTER(?work != wd:Q57) + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?work ?workLabel + ORDER BY ?workLabel + } + { + SELECT ?work ?workLabel (SAMPLE(?image) AS ?image) + WHERE + { ?work wdt:P1 wd:Q1; + p:P90 ?statement. + ?statement ps:P90 ?image; + pq:P54 wd:Q90. + FILTER(?work != wd:Q57) + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?work ?workLabel + ORDER BY ?workLabel + } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?work wdt:P1 wd:Q1; wdt:P87 ?dateadded. - ?work p:P90 ?statement. - ?statement ps:P90 ?image; - pq:P54 wd:Q90. - ?work wdt:P13 ?date. FILTER(?work != wd:Q57) } ORDER BY (?dateadded) @@ -71,15 +89,25 @@ def home(): def browsethearchive(): sparql.setQuery(''' SELECT ?work ?workLabel ?image ?date WHERE { - SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } - ?work wdt:P1 wd:Q1. - OPTIONAL { ?work p:P90 ?statement. + { + SELECT ?work ?workLabel (SAMPLE(?date) AS ?date) + WHERE + { ?work wdt:P1 wd:Q1; + wdt:P13 ?date. + FILTER(?work != wd:Q57) + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?work ?workLabel + ORDER BY ?workLabel + } + ?work wdt:P1 wd:Q1. + OPTIONAL {?work p:P90 ?statement. ?statement ps:P90 ?image; pq:P54 wd:Q90.} - OPTIONAL { ?work wdt:P13 ?date. } FILTER(?work != wd:Q57) + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } - ORDER BY (?workLabel) + ORDER BY ?workLabel ''') sparql.setReturnFormat(JSON) results = sparql.query().convert() @@ -182,13 +210,14 @@ def zinesindex(): WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?work wdt:P1 wd:Q1; - wdt:P10 wd:Q71. + wdt:P16 wd:Q152. OPTIONAL {?work p:P90 ?statement. ?statement ps:P90 ?image; pq:P54 wd:Q90.} OPTIONAL { ?work wdt:P13 ?date. } FILTER(?work != wd:Q57) } + ORDER BY ?workLabel ''') sparql.setReturnFormat(JSON) results = sparql.query().convert() @@ -232,21 +261,6 @@ def artwork(): SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} } ''') -# temp fix query - - # sparql.setQuery(''' - # SELECT ?image ?depictsLabel ?licenseLabel - # WHERE - # { - # VALUES ?work {wd:'''+artwork_id+'''} - # ?work wdt:P90 ?image. - # OPTIONAL { ?work p:P90 ?statement2. - # ?statement2 ps:P90 ?image; - # pq:P54 ?depicts; - # pq:P56 ?license.} - # FILTER(?depicts != wd:Q1897) - # SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} - # }''') sparql.setReturnFormat(JSON) artworkimages = sparql.query().convert() @@ -473,22 +487,7 @@ def artwork(): copiesincollection = sparql.query().convert() # related works - # sparql.setQuery(''' - # SELECT ?relatedWorks ?relatedWorksLabel ?image ?daterelatedWorks - # WHERE { - # { - # SELECT ?relatedWorks ?relatedWorksLabel (SAMPLE(?daterelatedWorks) AS ?daterelatedWorks) - # WHERE - # { VALUES ?work {wd:'''+artwork_id+'''} - # ?work wdt:P44 ?relatedWorks. - # OPTIONAL {?relatedWorks wdt:P13 ?daterelatedWorks.} - # SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } - # } - # GROUP BY ?relatedWorks ?relatedWorksLabel - # ORDER BY ?relatedWorksLabel - # } - # OPTIONAL {?relatedWorks wdt:P90 ?image.} - # } ''') + sparql.setQuery(''' SELECT ?relatedWorks ?relatedWorksLabel ?image ?daterelatedWorks WHERE { @@ -545,59 +544,168 @@ def artwork(): -######################### PERSON - FOR NOW THIS IS A MESS -@app.route("/person", methods=['GET']) -def person(): - person_id = request.args.get('id') +######################### CONTRIBUTOR : PERSON - ORGANISATION +@app.route("/contributor", methods=['GET']) +def contributor(): + contributor_id = request.args.get('id') + +# Intro sparql.setQuery(''' - SELECT ?item ?itemLabel ?itemDescription ?propLabel ?b ?bLabel - WHERE + SELECT ?item ?itemLabel ?itemDescription ?itemtypeLabel { - VALUES ?item {wd:'''+person_id+'''} - ?item ?a ?b. + VALUES ?item {wd:'''+contributor_id+'''} + ?item wdt:P1 ?itemtype. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } - ?prop wikibase:directClaim ?a . } ''') sparql.setReturnFormat(JSON) - person_details = sparql.query().convert() - print(person_details) + contributorintro = sparql.query().convert() + print("person intro") + print(contributorintro) + print("==========") + +# image + sparql.setQuery(''' + SELECT ?image ?depictsLabel ?licenseLabel + WHERE + { + VALUES ?item {wd:'''+contributor_id+'''} + ?item wdt:P30 ?image. + OPTIONAL { ?work p:P30 ?statement2. + ?statement2 ps:P30 ?image; + pq:P54 ?depicts; + pq:P56 ?license.} + SERVICE wikibase:label { bd:serviceParam wikibase:language "en".} + } + ''') + sparql.setReturnFormat(JSON) + contributorimage = sparql.query().convert() + print(contributorimage) + print("==========") +# biography sparql.setQuery(''' - SELECT ?work ?workLabel ?image ?date - WHERE { - SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } - ?work wdt:P1 wd:Q1. - ?work wdt:P9 wd:'''+person_id+'''. - OPTIONAL { ?work wdt:P90 ?image. } - OPTIONAL { ?work wdt:P13 ?date. } - FILTER(?work != wd:Q57) - } - ORDER BY (?workLabel) + SELECT ?accessURLbioPage ?authorBioPageLabel ?dateBioPage ?sourceBioPageLabel + WHERE + { + VALUES ?item {wd:'''+contributor_id+'''} + ?item wdt:P67 ?bioPage. + OPTIONAL { ?bioPage wdt:P4 ?accessURLbioPage. } + OPTIONAL { ?bioPage wdt:P9 ?authorBioPage. } + OPTIONAL { ?bioPage wdt:P13 ?dateBioPage. } + OPTIONAL { ?bioPage wdt:P50 ?sourceBioPage. } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + ''') + sparql.setReturnFormat(JSON) + contributorbiography = sparql.query().convert() + + for x in contributorbiography['results']['bindings']: + if "accessURLbioPage" in x: + accessURLbioURL = x["accessURLbioPage"]["value"] + desc_url = re.search(r':Q(.*)', accessURLbioURL, re.DOTALL) + desc_id=desc_url.group(1) + # # get the description content from wiki + contributorbiocontenturl = "https://daap.bannerrepeater.org/w/index.php?title=Biography:Q"+desc_id+"&action=render" + # # Make a GET request to fetch the raw HTML content + html_content = requests.get(contributorbiocontenturl).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") + # text=Markup(text) + # artworkdescriptiontext.append(text) + x["text"] = text + else: + # print("url for description absent") + text="

Information not available

" + x["text"] = text + + +# creator of + sparql.setQuery(''' + SELECT ?Works ?WorksLabel ?image ?dateWorks + WHERE { + { + SELECT ?Works ?WorksLabel (SAMPLE(?dateWorks) AS ?dateWorks) + WHERE + { + VALUES ?item {wd:'''+contributor_id+'''} + ?Works wdt:P1 wd:Q1; + wdt:P9 ?item; + wdt:P13 ?dateWorks. + + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?Works ?WorksLabel + ORDER BY ?WorksLabel + } + { + SELECT ?Works ?WorksLabel (SAMPLE(?image) AS ?image) + WHERE + { + VALUES ?item {wd:'''+contributor_id+'''} + ?Works wdt:P1 wd:Q1; + wdt:P9 ?item. + OPTIONAL {?Works wdt:P30 ?image.} + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?Works ?WorksLabel + ORDER BY ?WorksLabel + } + } ''') sparql.setReturnFormat(JSON) - person_creatorof = sparql.query().convert() - + contributor_creatorof = sparql.query().convert() + print(contributor_creatorof) + print("==========") + +# publisher of sparql.setQuery(''' - SELECT ?work ?workLabel ?image ?date - WHERE { - SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } - ?work wdt:P1 wd:Q1. - ?work wdt:P10 wd:'''+person_id+'''. - OPTIONAL { ?work wdt:P90 ?image. } - OPTIONAL { ?work wdt:P13 ?date. } - FILTER(?work != wd:Q57) - } - ORDER BY (?workLabel) - ''') + SELECT ?Works ?WorksLabel ?image ?dateWorks + WHERE { + { + SELECT ?Works ?WorksLabel (SAMPLE(?dateWorks) AS ?dateWorks) + WHERE + { + VALUES ?item {wd:'''+contributor_id+'''} + ?Works wdt:P1 wd:Q1; + wdt:P10 ?item; + wdt:P13 ?dateWorks. + + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?Works ?WorksLabel + ORDER BY ?WorksLabel + } + { + SELECT ?Works ?WorksLabel (SAMPLE(?image) AS ?image) + WHERE + { + VALUES ?item {wd:'''+contributor_id+'''} + ?Works wdt:P1 wd:Q1; + wdt:P10 ?item. + OPTIONAL {?Works wdt:P30 ?image.} + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?Works ?WorksLabel + ORDER BY ?WorksLabel + } + } + ''') sparql.setReturnFormat(JSON) - person_publisherof = sparql.query().convert() + contributor_publisherof = sparql.query().convert() + print(contributor_publisherof) + print("============") + + - person_url = "" - person_name = "the name" - person_description = "short bio" - return render_template("person.html", person_id=person_id, person_creatorof=person_creatorof, person_publisherof=person_publisherof, person_details=person_details) + contributor_url = "" + contributor_name = "the name" + contributor_description = "short bio" + return render_template("contributor.html", contributor_id=contributor_id, contributor_creatorof=contributor_creatorof, contributor_publisherof=contributor_publisherof, contributorintro=contributorintro, contributorimage=contributorimage, contributorbiography=contributorbiography) ######################### ORGANISATION diff --git a/static/css/style.css b/static/css/style.css index 720686f..8acdc04 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -240,7 +240,7 @@ html { -webkit-box-sizing: inherit; -moz-box-sizing: inherit; box-sizing: inherit; - /*margin: 0*/ + margin: 0 } body { @@ -914,42 +914,40 @@ div#home-top-div{ /*#home-top-div img:nth-of-type(1)*/ .banner-image-0 { animation-delay: 0s; - padding-top: 200px; + padding-top: 100px; } /*#home-top-div img:nth-of-type(2) */ .banner-image-1 { animation-delay: 5s; - padding-top: 50px; + margin-top: -100px; } /*#home-top-div img:nth-of-type(3) */ .banner-image-2 { animation-delay: 10s; - padding-top: 20px; + padding-top: 150px; } /*#home-top-div img:nth-of-type(4)*/ .banner-image-3 { animation-delay: 15s; - padding-top: 100px; + padding-top: 50px; } /*#home-top-div img:nth-of-type(5) */ .banner-image-4 { animation-delay: 20s; - padding-top: -60px; + margin-top: -150px; } /*#home-top-div img:nth-of-type(6)*/ .banner-image-5 { animation-delay: 25s; - padding-top: 20px; + padding-top: 50px; } /*#home-top-div img:nth-of-type(7)*/ .banner-image-6{ animation-delay: 30s; - padding-top: 100px; } /*#home-top-div img:nth-of-type(8)*/ .banner-image-7 { animation-delay: 35s; - padding-top: -30px; } /*#home-top-div img:nth-of-type(9) */ .banner-image-8 { @@ -2114,14 +2112,14 @@ div#tutorials-intro h3, div#tutorials-intro p { } #footer-title-others {text-align: right;} - #footer-title-contact {text-align: left; padding-bottom: 20px;} + #footer-title-contact {text-align: left; margin-bottom: 20px;} #footer-socials {width: 100%; } #footer-socials-links { display: flex; flex-direction: row; justify-content: space-between; width: 100%; - padding-top: 10px; + margin-top: 10px; } a#footer-img-wiki { diff --git a/templates/artwork.html b/templates/artwork.html index 62b0b31..31e8959 100644 --- a/templates/artwork.html +++ b/templates/artwork.html @@ -197,7 +197,7 @@ {% for x in artworkcontributors['results']['bindings'] %}