mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
add filesizes and stray files in snapshot dir to snapshot_live ui
This commit is contained in:
parent
c570674798
commit
1cd62ecc61
2 changed files with 48 additions and 1 deletions
|
@ -85,9 +85,47 @@ class SnapshotView(View):
|
|||
'name': result.extractor,
|
||||
'path': embed_path,
|
||||
'ts': ts_to_date_str(result.end_ts),
|
||||
'size': abs_path.stat().st_size or '?',
|
||||
}
|
||||
archiveresults[result.extractor] = result_info
|
||||
|
||||
existing_files = {result['path'] for result in archiveresults.values()}
|
||||
min_size_threshold = 128 # bytes
|
||||
allowed_extensions = {
|
||||
'txt',
|
||||
'html',
|
||||
'htm',
|
||||
'png',
|
||||
'jpg',
|
||||
'jpeg',
|
||||
'gif',
|
||||
'webp'
|
||||
'svg',
|
||||
'webm',
|
||||
'mp4',
|
||||
'mp3',
|
||||
'pdf',
|
||||
'md',
|
||||
}
|
||||
|
||||
# iterate through all the files in the snapshot dir and add the biggest ones to the result list
|
||||
for result_file in Path(snapshot.link_dir).glob('*/*/*'):
|
||||
extension = result_file.suffix.lstrip('.').lower()
|
||||
if result_file.is_dir() or result_file.name.startswith('.') or extension not in allowed_extensions:
|
||||
continue
|
||||
if result_file.name in existing_files:
|
||||
continue
|
||||
|
||||
file_size = result_file.stat().st_size or 0
|
||||
|
||||
if file_size > min_size_threshold:
|
||||
archiveresults[result_file.name] = {
|
||||
'name': result_file.stem,
|
||||
'path': result_file.relative_to(snapshot.link_dir),
|
||||
'ts': ts_to_date_str(result_file.stat().st_mtime or 0),
|
||||
'size': file_size,
|
||||
}
|
||||
|
||||
preferred_types = ('singlefile', 'wget', 'screenshot', 'dom', 'media', 'pdf', 'readability', 'mercury')
|
||||
all_types = preferred_types + tuple(result_type for result_type in archiveresults.keys() if result_type not in preferred_types)
|
||||
|
||||
|
|
|
@ -395,12 +395,14 @@
|
|||
</div>
|
||||
<div class="header-bottom container-fluid">
|
||||
<div class="row header-bottom-frames">
|
||||
|
||||
|
||||
{% for result in archiveresults %}
|
||||
<div class="col-lg-2">
|
||||
<div class="card {% if forloop.first %}selected-card{% endif %}">
|
||||
<div class="card-body">
|
||||
<a href="{{result.path}}" target="preview" title="./{{result.path}} (downloaded {{result.ts}})">
|
||||
<h4>{{result.name}}</h4>
|
||||
<h4>{{result.name}} <small>({{result.size|filesizeformat}})</small></h4>
|
||||
<!-- <p class="card-text" ><code>./{{result.path|truncatechars:30}}</code></p> -->
|
||||
</a>
|
||||
<!--<a href="{{result.path}}" target="preview"><h4 class="card-title">{{result.name}}</h4></a>-->
|
||||
|
@ -409,6 +411,8 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<div class="col-lg-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
@ -423,8 +427,13 @@
|
|||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
<iframe id="main-frame" sandbox="allow-same-origin allow-top-navigation-by-user-activation allow-scripts allow-forms" class="full-page-iframe" src="{{best_result.path}}" name="preview"></iframe>
|
||||
|
||||
|
||||
|
||||
<script src="{% static 'jquery.min.js' %}" type="text/javascript"></script>
|
||||
|
||||
<script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue