Add archive.html (not linked anywhere)

This commit is contained in:
boyska 2014-04-15 01:35:14 +02:00
parent 3b8c12f3b2
commit 9940b908b6
5 changed files with 78 additions and 0 deletions

1
server/.gitignore vendored
View file

@ -1,2 +1,3 @@
*.db
*.mp3
.*.swo

61
server/pages/archive.html Normal file
View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>
<title>TechREC</title>
<link rel="icon" href="/static/img/icon.ico" />
<link rel="stylesheet" type="text/css" href="/static/css/pure-min.css" />
<link rel="stylesheet" type="text/css" href="/static/css/pure-skin-porpora.css" />
<link rel="stylesheet" type="text/css" href="/static/css/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/css/techrec.css">
<link rel="stylesheet" type="text/css" href="/static/css/font-awesome.css" />
<script src="/static/js/jquery-1.9.1.min.js"></script>
<script src="/static/js/jquery-ui.min.js"></script>
<script src="/static/js/jquery.ui.datepicker-it.min.js"></script>
<script src="/static/js/rec.js"></script>
<script>
$(function() {
"use strict";
RecAPI.get_archive().success(function(archive) {
$.each(archive, function(idx, rec) {
$('#ongoing-recs-table tbody')
.append($('<tr/>').append($('<td/>')
.append($('<a/>').prop('href', '/output/' + rec.filename).text(rec.filename))));
});
});
});
</script>
</head>
<body class="pure-skin-porpora">
<div class="pure-menu pure-menu-open pure-menu-horizontal">
<a href="#" class="pure-menu-heading">TechRec</a>
<ul>
<li><a href="new.html">Diretta</a></li>
<li><a href="old.html">Vecchie</a></li>
<li class="pure-menu-selected"><a href="archive.html">Archivio</a></li>
</ul>
</div>
<h1>Registrazioni gi&agrave; completate</h1>
<div id="rec-normal" class="pure-g-r">
<div class="pure-u-1-8"></div>
<div class="pure-u-3-4">
<table width="100%" class="pure-table pure-table-horizontal pure-table-striped"
id="ongoing-recs-table" style="margin-top: 3em;">
<tbody>
<tr>
<th>Filename</th>
</tr>
</tbody>
</table>
</div>
<div class="pure-u-1-8"></div>
</div>
</body>
</html>
<!-- vim: set ts=2 sw=2 noet: -->

View file

@ -84,6 +84,7 @@ class RecAPI(Bottle):
self.get('/', callback=self.help)
self.get('/get/search', callback=self.search)
self.get('/get/ongoing', callback=self.get_ongoing)
self.get('/get/archive', callback=self.get_archive)
self.get('/jobs', callback=self.running_jobs)
self.get('/jobs/<job_id:int>', callback=self.check_job)
@ -233,6 +234,10 @@ class RecAPI(Bottle):
return {rec.id: rec_sanitize(rec)
for rec in self.db.get_ongoing()}
def get_archive(self):
return {rec.id: rec_sanitize(rec)
for rec in self.db.get_archive_recent()}
# @route('/help')
def help(self):
return "<h1>help</h1><hr/>\
@ -283,6 +288,9 @@ class RecServer:
self._app.route('/old.html',
callback=partial(static_file, 'old.html',
root='pages/'))
self._app.route('/archive.html',
callback=partial(static_file, 'archive.html',
root='pages/'))
class DebugAPI(Bottle):

View file

@ -43,6 +43,9 @@ var RecAPI = {
id: rec.id
});
},
get_archive: function() {
return $.getJSON('/api/get/archive');
},
get_ongoing: function() {
return $.getJSON('/api/get/ongoing');
}

View file

@ -142,6 +142,11 @@ class RecDB:
query = self._query_older(timedelta(seconds=minseconds), query)
return query.all()
def get_archive_recent(self):
query = self._query_saved()
query = self._query_newer(timedelta(days=15), query)
return query.all()
def _query_ongoing(self, query=None):
'''
Not terminated AND recent.