mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 07:34: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,19 +57,22 @@ class AddLinks(View):
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
url = request.POST['url']
|
url = request.POST['url']
|
||||||
print(f'[+] Adding URL: {url}')
|
if url:
|
||||||
add_stdout = StringIO()
|
print(f'[+] Adding URL: {url}')
|
||||||
with redirect_stdout(add_stdout):
|
add_stdout = StringIO()
|
||||||
extracted_links = add(
|
with redirect_stdout(add_stdout):
|
||||||
import_str=url,
|
extracted_links = add(
|
||||||
update_all=False,
|
import_str=url,
|
||||||
out_dir=OUTPUT_DIR,
|
update_all=False,
|
||||||
)
|
out_dir=OUTPUT_DIR,
|
||||||
print(add_stdout.getvalue())
|
)
|
||||||
|
print(add_stdout.getvalue())
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
@ -2,231 +2,211 @@
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<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"
|
<style>
|
||||||
name="viewport"
|
html, body {
|
||||||
content="width=device-width, initial-scale=1"
|
width: 100%;
|
||||||
/>
|
height: 100%;
|
||||||
<style>
|
font-size: 18px;
|
||||||
html,
|
font-weight: 200;
|
||||||
body {
|
text-align: center;
|
||||||
width: 100%;
|
margin: 0px;
|
||||||
height: 100%;
|
padding: 0px;
|
||||||
font-size: 18px;
|
font-family: "Gill Sans", Helvetica, sans-serif;
|
||||||
font-weight: 200;
|
}
|
||||||
text-align: center;
|
.header-top small {
|
||||||
margin: 0px;
|
font-weight: 200;
|
||||||
padding: 0px;
|
color: #efefef;
|
||||||
font-family: "Gill Sans", Helvetica, sans-serif;
|
}
|
||||||
}
|
|
||||||
.header-top small {
|
.header-top {
|
||||||
font-weight: 200;
|
width: 100%;
|
||||||
color: #efefef;
|
height: auto;
|
||||||
}
|
min-height: 40px;
|
||||||
|
margin: 0px;
|
||||||
|
text-align: center;
|
||||||
|
color: white;
|
||||||
|
font-size: calc(11px + 0.84vw);
|
||||||
|
font-weight: 200;
|
||||||
|
padding: 4px 4px;
|
||||||
|
border-bottom: 3px solid #aa1e55;
|
||||||
|
background-color: #aa1e55;
|
||||||
|
}
|
||||||
|
input[type=search] {
|
||||||
|
width: 22vw;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #aeaeae;
|
||||||
|
padding: 3px 5px;
|
||||||
|
}
|
||||||
|
.nav > div {
|
||||||
|
min-height: 30px;
|
||||||
|
}
|
||||||
|
.header-top a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: rgba(0,0,0,0.6);
|
||||||
|
}
|
||||||
|
.header-top a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: rgba(0,0,0,0.9);
|
||||||
|
}
|
||||||
|
.header-top .col-lg-4 {
|
||||||
|
text-align: center;
|
||||||
|
padding-top: 4px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
.header-archivebox img {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 3px;
|
||||||
|
height: 30px;
|
||||||
|
margin-left: 12px;
|
||||||
|
margin-top: -4px;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
.header-archivebox img:hover {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
.header-top {
|
#table-bookmarks_length, #table-bookmarks_filter {
|
||||||
width: 100%;
|
padding-top: 12px;
|
||||||
height: auto;
|
opacity: 0.8;
|
||||||
min-height: 40px;
|
padding-left: 24px;
|
||||||
margin: 0px;
|
padding-right: 22px;
|
||||||
text-align: center;
|
margin-bottom: -16px;
|
||||||
color: white;
|
}
|
||||||
font-size: calc(11px + 0.84vw);
|
table {
|
||||||
font-weight: 200;
|
padding: 6px;
|
||||||
padding: 4px 4px;
|
width: 100%;
|
||||||
border-bottom: 3px solid #aa1e55;
|
}
|
||||||
background-color: #aa1e55;
|
table thead th {
|
||||||
}
|
font-weight: 400;
|
||||||
input[type="search"] {
|
}
|
||||||
width: 22vw;
|
table tr {
|
||||||
border-radius: 4px;
|
height: 35px;
|
||||||
border: 1px solid #aeaeae;
|
}
|
||||||
padding: 3px 5px;
|
tbody tr:nth-child(odd) {
|
||||||
}
|
background-color: #ffebeb !important;
|
||||||
.nav > div {
|
}
|
||||||
min-height: 30px;
|
table tr td {
|
||||||
}
|
white-space: nowrap;
|
||||||
.header-top a {
|
overflow: hidden;
|
||||||
text-decoration: none;
|
/*padding-bottom: 0.4em;*/
|
||||||
color: rgba(0, 0, 0, 0.6);
|
/*padding-top: 0.4em;*/
|
||||||
}
|
padding-left: 2px;
|
||||||
.header-top a:hover {
|
text-align: center;
|
||||||
text-decoration: none;
|
}
|
||||||
color: rgba(0, 0, 0, 0.9);
|
table tr td a {
|
||||||
}
|
text-decoration: none;
|
||||||
.header-top .col-lg-4 {
|
}
|
||||||
text-align: center;
|
table tr td img, table tr td object {
|
||||||
padding-top: 4px;
|
display: inline-block;
|
||||||
padding-bottom: 4px;
|
margin: auto;
|
||||||
}
|
height: 24px;
|
||||||
.header-archivebox img {
|
width: 24px;
|
||||||
display: inline-block;
|
padding: 0px;
|
||||||
margin-right: 3px;
|
padding-right: 5px;
|
||||||
height: 30px;
|
vertical-align: middle;
|
||||||
margin-left: 12px;
|
margin-left: 4px;
|
||||||
margin-top: -4px;
|
}
|
||||||
margin-bottom: 2px;
|
#table-bookmarks {
|
||||||
}
|
width: 100%;
|
||||||
.header-archivebox img:hover {
|
overflow-y: scroll;
|
||||||
opacity: 0.5;
|
table-layout: fixed;
|
||||||
}
|
}
|
||||||
|
.dataTables_wrapper {
|
||||||
#table-bookmarks_length,
|
background-color: #fafafa;
|
||||||
#table-bookmarks_filter {
|
}
|
||||||
padding-top: 12px;
|
table tr a span[data-archived~=False] {
|
||||||
opacity: 0.8;
|
opacity: 0.4;
|
||||||
padding-left: 24px;
|
}
|
||||||
padding-right: 22px;
|
.files-spinner {
|
||||||
margin-bottom: -16px;
|
height: 15px;
|
||||||
}
|
width: auto;
|
||||||
table {
|
opacity: 0.5;
|
||||||
padding: 6px;
|
vertical-align: -2px;
|
||||||
width: 100%;
|
}
|
||||||
}
|
.in-progress {
|
||||||
table thead th {
|
display: none;
|
||||||
font-weight: 400;
|
}
|
||||||
}
|
body[data-status~=finished] .files-spinner {
|
||||||
table tr {
|
display: none;
|
||||||
height: 35px;
|
}
|
||||||
}
|
/*body[data-status~=running] .in-progress {
|
||||||
tbody tr:nth-child(odd) {
|
|
||||||
background-color: #ffebeb !important;
|
|
||||||
}
|
|
||||||
table tr td {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
/*padding-bottom: 0.4em;*/
|
|
||||||
/*padding-top: 0.4em;*/
|
|
||||||
padding-left: 2px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
table tr td a {
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
table tr td img,
|
|
||||||
table tr td object {
|
|
||||||
display: inline-block;
|
|
||||||
margin: auto;
|
|
||||||
height: 24px;
|
|
||||||
width: 24px;
|
|
||||||
padding: 0px;
|
|
||||||
padding-right: 5px;
|
|
||||||
vertical-align: middle;
|
|
||||||
margin-left: 4px;
|
|
||||||
}
|
|
||||||
#table-bookmarks {
|
|
||||||
width: 100%;
|
|
||||||
overflow-y: scroll;
|
|
||||||
table-layout: fixed;
|
|
||||||
}
|
|
||||||
.dataTables_wrapper {
|
|
||||||
background-color: #fafafa;
|
|
||||||
}
|
|
||||||
table tr a span[data-archived~="False"] {
|
|
||||||
opacity: 0.4;
|
|
||||||
}
|
|
||||||
.files-spinner {
|
|
||||||
height: 15px;
|
|
||||||
width: auto;
|
|
||||||
opacity: 0.5;
|
|
||||||
vertical-align: -2px;
|
|
||||||
}
|
|
||||||
.in-progress {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
body[data-status~="finished"] .files-spinner {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
/*body[data-status~=running] .in-progress {
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}*/
|
}*/
|
||||||
tr td a.favicon img {
|
tr td a.favicon img {
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
padding-right: 12px;
|
padding-right: 12px;
|
||||||
vertical-align: -4px;
|
vertical-align: -4px;
|
||||||
}
|
}
|
||||||
tr td a.title {
|
tr td a.title {
|
||||||
font-size: 1.4em;
|
font-size: 1.4em;
|
||||||
text-decoration: none;
|
text-decoration:none;
|
||||||
color: black;
|
color:black;
|
||||||
}
|
}
|
||||||
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 {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.title-col a {
|
.title-col a {
|
||||||
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",
|
e.target.style.opacity = 0;
|
||||||
function (e) {
|
}, true)
|
||||||
e.target.style.opacity = 0;
|
jQuery(document).ready(function() {
|
||||||
},
|
jQuery('#table-bookmarks').DataTable({
|
||||||
true
|
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
|
||||||
jQuery(document).ready(function () {
|
order: [[0, 'desc']],
|
||||||
jQuery("#table-bookmarks").DataTable({
|
iDisplayLength: 100,
|
||||||
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
|
});
|
||||||
order: [[0, "desc"]],
|
</script>
|
||||||
iDisplayLength: 100,
|
</head>
|
||||||
});
|
<body data-status="finished">
|
||||||
});
|
<header>
|
||||||
</script>
|
<div class="header-top container-fluid">
|
||||||
</head>
|
<div class="row nav">
|
||||||
<body data-status="finished">
|
<div class="col-sm-2">
|
||||||
<header>
|
<a href="/" class="header-archivebox" title="Last updated: {{updated}}">
|
||||||
<div class="header-top container-fluid">
|
<img src="{% static 'archive.png' %}" alt="Logo"/>
|
||||||
<div class="row nav">
|
ArchiveBox: Add
|
||||||
<div class="col-sm-2">
|
</a>
|
||||||
<a
|
</div>
|
||||||
href="/"
|
<div class="col-sm-10" style="text-align: right">
|
||||||
class="header-archivebox"
|
<a href="/">Main Index</a> |
|
||||||
title="Last updated: {{updated}}"
|
<a href="/admin/">Admin</a> |
|
||||||
>
|
<a href="https://github.com/pirate/ArchiveBox/wiki">Docs</a>
|
||||||
<img src="{% static 'archive.png' %}" alt="Logo" />
|
</div>
|
||||||
ArchiveBox: Add
|
</div>
|
||||||
</a>
|
</div>
|
||||||
</div>
|
</header>
|
||||||
<div class="col-sm-10" style="text-align: right;">
|
<center>
|
||||||
<a href="/">Main Index</a> |
|
{{ stdout | safe }}
|
||||||
<a href="/admin/">Admin</a> |
|
<br/><br/>
|
||||||
<a href="https://github.com/pirate/ArchiveBox/wiki">Docs</a>
|
<form action="?" method="POST">{% csrf_token %}
|
||||||
</div>
|
Add new links...<br/>
|
||||||
</div>
|
<input type="text" name="url" placeholder="URL of page or feed..."/><br/>
|
||||||
</div>
|
<button role="submit">Add</button>
|
||||||
</header>
|
</form>
|
||||||
<center>
|
</center>
|
||||||
{{ stdout | safe }}
|
|
||||||
<br /><br />
|
|
||||||
<form action="?" method="POST">
|
|
||||||
{% csrf_token %} Add new links...<br />
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="url"
|
|
||||||
placeholder="URL of page or feed..."
|
|
||||||
/><br />
|
|
||||||
<button role="submit">Add</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<a href="{% url 'admin:core_snapshot_changelist' %}"
|
<a href="{% url 'admin:core_snapshot_changelist' %}">Go back to Snapshot list</a>
|
||||||
>Go back to Snapshot list</a
|
|
||||||
>
|
</body>
|
||||||
</center>
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue