mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 23:54:27 -04:00
feat: Handle empty URL case
This commit is contained in:
parent
c971e00c9c
commit
364c5752d8
2 changed files with 218 additions and 235 deletions
|
@ -57,6 +57,7 @@ class AddLinks(View):
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
url = request.POST['url']
|
url = request.POST['url']
|
||||||
|
if url:
|
||||||
print(f'[+] Adding URL: {url}')
|
print(f'[+] Adding URL: {url}')
|
||||||
add_stdout = StringIO()
|
add_stdout = StringIO()
|
||||||
with redirect_stdout(add_stdout):
|
with redirect_stdout(add_stdout):
|
||||||
|
@ -70,6 +71,8 @@ class AddLinks(View):
|
||||||
context = {
|
context = {
|
||||||
"stdout": ansi_to_html(add_stdout.getvalue())
|
"stdout": ansi_to_html(add_stdout.getvalue())
|
||||||
}
|
}
|
||||||
|
else:
|
||||||
|
context = {"stdout": "Please enter a URL"}
|
||||||
|
|
||||||
return render(template_name=self.template, request=request, context=context)
|
return render(template_name=self.template, request=request, context=context)
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,9 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Archived Sites</title>
|
<title>Archived Sites</title>
|
||||||
<meta
|
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
|
||||||
charset="utf-8"
|
|
||||||
name="viewport"
|
|
||||||
content="width=device-width, initial-scale=1"
|
|
||||||
/>
|
|
||||||
<style>
|
<style>
|
||||||
html,
|
html, body {
|
||||||
body {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
|
@ -39,7 +34,7 @@
|
||||||
border-bottom: 3px solid #aa1e55;
|
border-bottom: 3px solid #aa1e55;
|
||||||
background-color: #aa1e55;
|
background-color: #aa1e55;
|
||||||
}
|
}
|
||||||
input[type="search"] {
|
input[type=search] {
|
||||||
width: 22vw;
|
width: 22vw;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid #aeaeae;
|
border: 1px solid #aeaeae;
|
||||||
|
@ -73,8 +68,7 @@
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
#table-bookmarks_length,
|
#table-bookmarks_length, #table-bookmarks_filter {
|
||||||
#table-bookmarks_filter {
|
|
||||||
padding-top: 12px;
|
padding-top: 12px;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
padding-left: 24px;
|
padding-left: 24px;
|
||||||
|
@ -105,8 +99,7 @@
|
||||||
table tr td a {
|
table tr td a {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
table tr td img,
|
table tr td img, table tr td object {
|
||||||
table tr td object {
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
|
@ -124,7 +117,7 @@
|
||||||
.dataTables_wrapper {
|
.dataTables_wrapper {
|
||||||
background-color: #fafafa;
|
background-color: #fafafa;
|
||||||
}
|
}
|
||||||
table tr a span[data-archived~="False"] {
|
table tr a span[data-archived~=False] {
|
||||||
opacity: 0.4;
|
opacity: 0.4;
|
||||||
}
|
}
|
||||||
.files-spinner {
|
.files-spinner {
|
||||||
|
@ -136,7 +129,7 @@
|
||||||
.in-progress {
|
.in-progress {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
body[data-status~="finished"] .files-spinner {
|
body[data-status~=finished] .files-spinner {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
/*body[data-status~=running] .in-progress {
|
/*body[data-status~=running] .in-progress {
|
||||||
|
@ -155,9 +148,9 @@
|
||||||
tr td a.title small {
|
tr td a.title small {
|
||||||
background-color: #efefef;
|
background-color: #efefef;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
float: right;
|
float:right
|
||||||
}
|
}
|
||||||
input[type="search"]::-webkit-search-cancel-button {
|
input[type=search]::-webkit-search-cancel-button {
|
||||||
-webkit-appearance: searchfield-cancel-button;
|
-webkit-appearance: searchfield-cancel-button;
|
||||||
}
|
}
|
||||||
.title-col {
|
.title-col {
|
||||||
|
@ -167,23 +160,19 @@
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<link rel="stylesheet" href="{% static 'bootstrap.min.css' %}" />
|
<link rel="stylesheet" href="{% static 'bootstrap.min.css' %}">
|
||||||
<link rel="stylesheet" href="{% static 'jquery.dataTables.min.css' %}"/>
|
<link rel="stylesheet" href="{% static 'jquery.dataTables.min.css' %}"/>
|
||||||
<script src="{% static 'jquery.min.js' %}"></script>
|
<script src="{% static 'jquery.min.js' %}"></script>
|
||||||
<script src="{% static 'jquery.dataTables.min.js' %}"></script>
|
<script src="{% static 'jquery.dataTables.min.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener(
|
document.addEventListener('error', function(e) {
|
||||||
"error",
|
|
||||||
function (e) {
|
|
||||||
e.target.style.opacity = 0;
|
e.target.style.opacity = 0;
|
||||||
},
|
}, true)
|
||||||
true
|
|
||||||
);
|
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
jQuery("#table-bookmarks").DataTable({
|
jQuery('#table-bookmarks').DataTable({
|
||||||
stateSave: true, // save state (filtered input, number of entries shown, etc) in localStorage
|
stateSave: true, // save state (filtered input, number of entries shown, etc) in localStorage
|
||||||
dom: "<lf<t>ip>", // how to show the table and its helpers (filter, etc) in the DOM
|
dom: '<lf<t>ip>', // how to show the table and its helpers (filter, etc) in the DOM
|
||||||
order: [[0, "desc"]],
|
order: [[0, 'desc']],
|
||||||
iDisplayLength: 100,
|
iDisplayLength: 100,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -194,16 +183,12 @@
|
||||||
<div class="header-top container-fluid">
|
<div class="header-top container-fluid">
|
||||||
<div class="row nav">
|
<div class="row nav">
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<a
|
<a href="/" class="header-archivebox" title="Last updated: {{updated}}">
|
||||||
href="/"
|
|
||||||
class="header-archivebox"
|
|
||||||
title="Last updated: {{updated}}"
|
|
||||||
>
|
|
||||||
<img src="{% static 'archive.png' %}" alt="Logo"/>
|
<img src="{% static 'archive.png' %}" alt="Logo"/>
|
||||||
ArchiveBox: Add
|
ArchiveBox: Add
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10" style="text-align: right;">
|
<div class="col-sm-10" style="text-align: right">
|
||||||
<a href="/">Main Index</a> |
|
<a href="/">Main Index</a> |
|
||||||
<a href="/admin/">Admin</a> |
|
<a href="/admin/">Admin</a> |
|
||||||
<a href="https://github.com/pirate/ArchiveBox/wiki">Docs</a>
|
<a href="https://github.com/pirate/ArchiveBox/wiki">Docs</a>
|
||||||
|
@ -214,19 +199,14 @@
|
||||||
<center>
|
<center>
|
||||||
{{ stdout | safe }}
|
{{ stdout | safe }}
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<form action="?" method="POST">
|
<form action="?" method="POST">{% csrf_token %}
|
||||||
{% csrf_token %} Add new links...<br />
|
Add new links...<br/>
|
||||||
<input
|
<input type="text" name="url" placeholder="URL of page or feed..."/><br/>
|
||||||
type="text"
|
|
||||||
name="url"
|
|
||||||
placeholder="URL of page or feed..."
|
|
||||||
/><br />
|
|
||||||
<button role="submit">Add</button>
|
<button role="submit">Add</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<a href="{% url 'admin:core_snapshot_changelist' %}"
|
|
||||||
>Go back to Snapshot list</a
|
|
||||||
>
|
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
|
<a href="{% url 'admin:core_snapshot_changelist' %}">Go back to Snapshot list</a>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue