mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
Fix Query UI (#278)
* query fix: setup: ensure all static files included in package_data recursively to add new query assets test: add test for nested static asset query: correctly display 0 captures, 'capture' and 'captures' text moved to Text block
This commit is contained in:
parent
0c24f8a1c1
commit
85f093e356
@ -12,7 +12,9 @@ var Text = {
|
|||||||
'10': "October",
|
'10': "October",
|
||||||
'11': "November",
|
'11': "November",
|
||||||
'12': "December",
|
'12': "December",
|
||||||
}
|
},
|
||||||
|
version: "capture",
|
||||||
|
versions: "captures",
|
||||||
};
|
};
|
||||||
|
|
||||||
function RenderCalendar(prefix, url) {
|
function RenderCalendar(prefix, url) {
|
||||||
@ -81,13 +83,20 @@ function RenderCalendar(prefix, url) {
|
|||||||
data: {"url": url, "output": "json"},
|
data: {"url": url, "output": "json"},
|
||||||
dataType: "text",
|
dataType: "text",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
processAll(data.trim().split("\n"));
|
processAll(data.trim());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function processAll(cdxLines) {
|
function processAll(data) {
|
||||||
$("#count").text(cdxLines.length);
|
var cdxLines = [];
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
cdxLines = data.split("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#count").text(numVersionsText(cdxLines.length));
|
||||||
|
|
||||||
for (var i = 0; i < cdxLines.length; i++) {
|
for (var i = 0; i < cdxLines.length; i++) {
|
||||||
var obj = JSON.parse(cdxLines[i]);
|
var obj = JSON.parse(cdxLines[i]);
|
||||||
processUrl(prefix, obj.timestamp, obj.url);
|
processUrl(prefix, obj.timestamp, obj.url);
|
||||||
@ -96,6 +105,13 @@ function RenderCalendar(prefix, url) {
|
|||||||
handleClicks();
|
handleClicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function numVersionsText(count) {
|
||||||
|
var text = count + " ";
|
||||||
|
text += count == 1 ? Text.version : Text.versions;
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function processUrl(prefix, ts, url) {
|
function processUrl(prefix, ts, url) {
|
||||||
var currentYear = getYearTs(ts);
|
var currentYear = getYearTs(ts);
|
||||||
years.push(currentYear);
|
years.push(currentYear);
|
||||||
@ -124,8 +140,7 @@ function RenderCalendar(prefix, url) {
|
|||||||
|
|
||||||
for (var i = 0; i < years.length; i++) {
|
for (var i = 0; i < years.length; i++) {
|
||||||
numberofVersions = $('#year_' + years[i].toString()).parent().next().find(".day").length;
|
numberofVersions = $('#year_' + years[i].toString()).parent().next().find(".day").length;
|
||||||
numberofVersionsString = numberofVersions == 1 ? numberofVersions + " version " : numberofVersions + " versions ";
|
$('#' + years[i] + '_right').prepend(numVersionsText(numberofVersions));
|
||||||
$('#' + years[i] + '_right').prepend(numberofVersionsString);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2 class="text-center">pywb Query Results</h2>
|
<h2 class="text-center">pywb Query Results</h2>
|
||||||
<h3 class="text-center"><b id="count"></b> captures of <b>{{ url }}</b></h3>
|
<h3 class="text-center"><b id="count"></b> of <b>{{ url }}</b></h3>
|
||||||
<div id="captureYears"></div>
|
<div id="captureYears"></div>
|
||||||
<script>new RenderCalendar("{{ prefix }}", "{{ url }}");</script>
|
<script>new RenderCalendar("{{ prefix }}", "{{ url }}");</script>
|
||||||
</body>
|
</body>
|
||||||
|
15
setup.py
15
setup.py
@ -60,6 +60,19 @@ def load_requirements(filename):
|
|||||||
return fh.read().rstrip().split('\n')
|
return fh.read().rstrip().split('\n')
|
||||||
|
|
||||||
|
|
||||||
|
def get_package_data():
|
||||||
|
pkgs = ['static/*.*',
|
||||||
|
'templates/*',
|
||||||
|
'*.yaml']
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(os.path.join('pywb', 'static')):
|
||||||
|
for dir_ in dirs:
|
||||||
|
pkgs.append(os.path.relpath(os.path.join(root, dir_, '*'), 'pywb'))
|
||||||
|
|
||||||
|
return pkgs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
generate_git_hash_py('pywb')
|
generate_git_hash_py('pywb')
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +100,7 @@ setup(
|
|||||||
'pywb.apps',
|
'pywb.apps',
|
||||||
],
|
],
|
||||||
package_data={
|
package_data={
|
||||||
'pywb': ['static/flowplayer/*', 'static/*.*', 'templates/*', '*.yaml'],
|
'pywb': get_package_data(),
|
||||||
},
|
},
|
||||||
data_files=[
|
data_files=[
|
||||||
('sample_archive/cdx', glob.glob('sample_archive/cdx/*')),
|
('sample_archive/cdx', glob.glob('sample_archive/cdx/*')),
|
||||||
|
@ -397,6 +397,11 @@ class TestWbIntegration(BaseConfigTest):
|
|||||||
assert resp.content_type == 'text/css'
|
assert resp.content_type == 'text/css'
|
||||||
assert resp.content_length > 0
|
assert resp.content_length > 0
|
||||||
|
|
||||||
|
def test_static_nested_dir(self):
|
||||||
|
resp = self.testapp.get('/static/fonts/font-awesome/fontawesome-webfont.woff')
|
||||||
|
assert resp.status_int == 200
|
||||||
|
assert resp.content_length > 0
|
||||||
|
|
||||||
def test_static_not_found(self):
|
def test_static_not_found(self):
|
||||||
resp = self.testapp.get('/static/notfound.css', status = 404)
|
resp = self.testapp.get('/static/notfound.css', status = 404)
|
||||||
assert resp.status_int == 404
|
assert resp.status_int == 404
|
||||||
|
Loading…
x
Reference in New Issue
Block a user