Browse Source

rcent index homepage buttons etc

master
zeroth 3 years ago
parent
commit
1b7224956d
  1. 31
      daapinterface.py
  2. 5
      templates/browsebycategory.html
  3. 4
      templates/home.html
  4. 2
      templates/newestindex.html
  5. 2
      templates/oldestindex.html
  6. 149
      templates/recentindex.html

31
daapinterface.py

@ -131,6 +131,37 @@ def browsebycategory():
# CATEGORIES TO BE BROWSED
#########################
######################### RECENT INDEX
@app.route("/datesindex_recent")
def datesindex_recent():
sparql.setQuery('''
SELECT ?work ?workLabel ?image ?date 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
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?work wdt:P1 wd:Q1;
wdt:P87 ?dateadded.
OPTIONAL {?work p:P90 ?statement.
?statement ps:P90 ?image;
pq:P54 wd:Q90.}
FILTER(?work != wd:Q57)
}
ORDER BY DESC(?dateadded)
''')
sparql.setReturnFormat(JSON)
results = sparql.query().convert()
return render_template('recentindex.html', results=results)
######################### OLDEST INDEX
@app.route("/datesindex_asc")
def datesindex_asc():

5
templates/browsebycategory.html

@ -5,8 +5,9 @@
<div id="browsebycategory-listcategories">
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('datesindex_asc') }}">BROWSE BY DATE FROM OLDEST</a></div>
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('datesindex_desc') }}">BROWSE BY DATE FROM NEWEST</a></div>
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('datesindex_recent') }}">BROWSE ALL RECENTLY ADDED</a></div>
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('datesindex_asc') }}">BROWSE BY PUBLICATION DATE FROM OLDEST</a></div>
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('datesindex_desc') }}">BROWSE BY PUBLICATION DATE FROM NEWEST</a></div>
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('artistsindex') }}">BROWSE BY CREATOR/CONTRIBUTOR</a></div>
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('publishersindex') }}">BROWSE BY PUBLISHER</a></div>
<div class="browsebycategory-categories primary-button"><a href="{{ url_for('selfpublishedindex') }}">BROWSE ALL SELF-PUBLISHED</a></div>

4
templates/home.html

@ -27,7 +27,7 @@
<div id="wrapper-bt">
<a id="wrapper-top-buttons" class="primary-button" href="{{ url_for('zinesindex') }}">SEE EXAMPLE SEARCH FOR ZINES</a>
<a id="wrapper-top-buttons" class="primary-button" href="{{ url_for('browsethearchive') }}">BROWSE THE ARCHIVE FROM A-Z</a>
<a id="wrapper-top-buttons" class="secondary-button" href="{{ url_for('casestudy') }}">CAROLEE SCHNEEMANN CASE STUDY</a>
</div>
<!-- <div id="wrapper-vid">
@ -83,7 +83,7 @@
</div>
<div class="home-show-wrapper"><a href="{{ url_for('browsethearchive') }}" class="home-show primary-button">BROWSE THE FULL ARCHIVE</a></div>
<div class="home-show-wrapper"><a href="{{ url_for('datesindex_recent') }}" class="home-show primary-button">BROWSE ALL RECENTLY ADDED</a></div>
</div>

2
templates/newestindex.html

@ -2,7 +2,7 @@
{% block content %}
<div id="selfpublishedindex-all">
<div class="pagetitle" id="selfpublishedindex-title">INDEX BY DATE FROM NEWEST</div>
<div class="pagetitle" id="selfpublishedindex-title">INDEX BY PUBLICATION DATE FROM NEWEST</div>
<div id="selfpublishedindex-grid">

2
templates/oldestindex.html

@ -2,7 +2,7 @@
{% block content %}
<div id="selfpublishedindex-all">
<div class="pagetitle" id="selfpublishedindex-title">INDEX BY DATE FROM OLDEST</div>
<div class="pagetitle" id="selfpublishedindex-title">INDEX BY PUBLICATION DATE FROM OLDEST</div>
<div id="selfpublishedindex-grid">

149
templates/recentindex.html

@ -0,0 +1,149 @@
{% extends "layout.html" %}
{% block content %}
<div id="selfpublishedindex-all">
<div class="pagetitle" id="selfpublishedindex-title">INDEX BY RECENTLY ADDED WORKS</div>
<div id="selfpublishedindex-grid">
{% for x in results['results']['bindings']%}
<div class="selfpublishedindex-items">
<div class="selfpublishedindex-items-top">
{% if "image" in x %}
<a href='/artwork?id={{ x["work"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<img class="selfpublishedindex-imgs" src='{{ x["image"]["value"] | replace("wiki/File:","wiki/Special:Redirect/file/") }}'>
</a> <br>
{% else %}
<a href='/artwork?id={{ x["work"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
<img class="selfpublishedindex-imgs" src="{{ url_for('static', filename='/imgs/Icons/placeholder_no-image2.png') }}"><br>
</a>
{% endif %}
</div>
<div class="selfpublishedindex-items-bottom">
<a class="title" href='/artwork?id={{ x["work"]["value"] | replace("http://daap.bannerrepeater.org/entity/", "") }}'>
{{ x["workLabel"]["value"]}}
</a> <br>
<span class="date">
{% if "date" in x %}
{{ x["date"]["value"] | replace("T00:00:00Z", "") }}
</span>
{% endif %}
</div>
</div>
{% endfor %}
</div>
<ul id="pagin" class="browsethearchive-pagination">
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
// pagination script w/ support from @biberman on stackoverflow - big thanks!
let startPage;
const pageSize = 24;
const totalSlidePage = 5;
const pageCount = Math.ceil($(".selfpublishedindex-items").length / pageSize);
const slideRange = Math.floor(totalSlidePage / 2);
slide = function() {
startPage = $("#pagin li a.current").parent().index();
let paginationStart = (startPage - slideRange) <= 1 ? 0 :
(startPage >= (pageCount - slideRange) ? (pageCount - totalSlidePage) :
(startPage - slideRange - 1));
$("#pagin li").hide();
for (let t = paginationStart; t < (paginationStart + totalSlidePage); t++) {
$("#pagin li").eq(t + 1).show();
}
next.show();
prev.show();
if (startPage == 1) {
prev.hide();
}
if (startPage == pageCount ) {
next.hide();
}
}
showPage = function() {
console.log(startPage);
$(".selfpublishedindex-items").hide();
$(".selfpublishedindex-items").each(function(n) {
if (n >= pageSize * (startPage - 1) && n < pageSize * startPage)
$(this).show();
});
}
for (let i = 0 ; i < pageCount; i++) {
$("#pagin").append('<li><a href="#">' + (i + 1) + '</a></li> ');
if (i > pageSize) {
$("#pagin li").eq(i).hide();
}
}
let prev = $("<li/>").addClass("prev").html("Prev").click(function() {
let prevLi = $("#pagin li a.current").parent().prev().find("a");
if (prevLi[0]) {
$("#pagin li a.current").removeClass("current");
prevLi.addClass("current");
}
slide();
if (startPage != 0) {
showPage();
}
});
let next = $("<li/>").addClass("next").html("Next").click(function() {
let nextLi = $("#pagin li a.current").parent().next().find("a");
if (nextLi[0]) {
$("#pagin li a.current").removeClass("current");
nextLi.addClass("current");
}
slide();
if (startPage <= pageCount) {
showPage();
}
});
$("#pagin").prepend(prev).append(next);
$("#pagin li a").click(function() {
$('#pagin li a').removeClass('current');
$(this).addClass('current');
slide();
showPage();
});
$("#pagin li a").eq(0).addClass("current");
slide();
showPage();
</script>
</div>
{% endblock content %}
Loading…
Cancel
Save