Files
arxiv-sanity-lite/templates/index.html
T

143 lines
5.4 KiB
HTML

{% extends "base.html" %}
{% block variables %}
<script>
var papers = {{ papers | tojson }};
var tags = {{ tags | tojson }};
var words = {{ words | tojson }};
var words_desc = {{ words_desc | tojson }};
var gvars = {{ gvars | tojson }};
</script>
{% endblock %}
<script>
/*
The JS code in here handles pagination. I really quite dislike it,
if anyone can think of a cleaner and shorter way please let me know.
*/
// mod from https://stackoverflow.com/questions/13063838/add-change-parameter-of-url-and-redirect-to-the-new-url/13064060
function setGetParameter(paramName, paramValue)
{
var url = window.location.href;
var hash = location.hash;
url = url.replace(hash, ''); // ?
if (url.indexOf(paramName + "=") >= 0) {
var prefix = url.substring(0, url.indexOf(paramName + "="));
var suffix = url.substring(url.indexOf(paramName + "="));
suffix = suffix.substring(suffix.indexOf("=") + 1);
suffix = (suffix.indexOf("&") >= 0) ? suffix.substring(suffix.indexOf("&")) : "";
url = prefix + paramName + "=" + paramValue + suffix;
} else {
var pre = url.indexOf("?") < 0 ? "?" : "&";
url = url + pre + paramName + "=" + paramValue;
}
window.location.href = url + hash;
}
// handle pagination by overriding the a href= links
window.onload = function() {
document.getElementById("link-prev-page").onclick = function() {
setGetParameter("page", gvars.page - 1);
return true;
}
document.getElementById("link-next-page").onclick = function() {
setGetParameter("page", gvars.page + 1);
return true;
}
}
</script>
{% block content %}
{% if not user %}
<div id="log-fun-warn">(hi! just btw you have to be logged in to be able to add/delete/curate tags for papers and get recommendations)</div>
{% endif %}
<div id="controls">
<div>
<!-- the choice box, allowing us to sort, rank, slice and dice papers -->
<div id="cbox">
<form action="/" method="get">
<!-- the search box, allowing us to search by keywords -->
<input name="q" type="text" id="qfield" value="{{ gvars.search_query }}">
<!-- rank type: one of tags, pid, time, or random -->
<label for="rank_type">Rank by:</label>
<select name="rank" id="rank_select">
<option value="search" {{ gvars.rank == 'search' and 'selected' }}>search</option>
<option value="tags" {{ gvars.rank == 'tags' and 'selected' }}>tags</option>
<option value="pid" {{ gvars.rank == 'pid' and 'selected' }}>pid</option>
<option value="time" {{ gvars.rank == 'time' and 'selected' }}>time</option>
<option value="random" {{ gvars.rank == 'random' and 'selected' }}>random</option>
</select>
<!-- current tags, simply in a text field -->
<label for="tags">tags: </label>
<input name="tags" type="text" id="tags_field" value="{{ gvars.tags }}">
<!-- current pid, simply in a text field -->
<label for="pid">pid: </label>
<input name="pid" type="text" id="pid_field" value="{{ gvars.pid }}">
<!-- current time_filter, in a text field -->
<label for="time_filter">time_filter (days): </label>
<input name="time_filter" type="text" id="time_filter_field" value="{{ gvars.time_filter }}">
<!-- current svm_c, in a text field -->
<label for="svm_c">svm_c: </label>
<input name="svm_c" type="text" id="svm_c_field" value="{{ gvars.svm_c }}">
<!-- current skip_have: one of yes or no -->
<label for="skip_have">skip_have: </label>
<select name="skip_have" id="skip_have_select">
<option value="yes" {{ gvars.skip_have == 'yes' and 'selected' }}>yes</option>
<option value="no" {{ gvars.skip_have == 'no' and 'selected' }}>no</option>
</select>
<input type="submit" value="Submit">
</form>
</div>
<!-- some hand-coded common choices for faster and more convenient operation -->
<div id="cbox_fast">
Shortcuts:
<a href="/?rank=tags&tags=all&time_filter=7&skip_have=yes">recommend over last week</a>
<a href="/?rank=tags&tags=all&time_filter=3&skip_have=yes">recommend over last 3 days</a>
<a href="/?rank=time">recent</a>
<a href="/?rank=random&time_filter=7">random last week</a>
</div>
</div>
<div>
</div>
</div>
{% if user and tags %}
<div id="tagwrap">
</div>
{% endif %}
{% if user and words %}
<div id="wordwrap" style="display:none;">
</div>
{% endif %}
<!-- main content showing all the papers as a list -->
<div id="wrap">
</div>
<!-- links to previous and next pages -->
<div id="pagination">
<a href="/?page_number={{ gvars.prev_page_number }}" id="link-prev-page">prev</a>
<span>current page: {{ gvars.page_number }} </span>
<a href="/?page_number={{ gvars.next_page_number }}" id="link-next-page">next</a>
</div>
{% endblock %}
{% block elements %}
<script src="{{ url_for('static', filename='paper_list.js') }}" type="text/babel"></script>
<script src="{{ url_for('static', filename='word_list.js') }}" type="text/babel"></script>
{% endblock %}