mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-31 23:08:25 -04:00
fix pending titles and favicons, improve add page, custom admin
This commit is contained in:
parent
022231b362
commit
3aeca0e450
23 changed files with 387 additions and 316 deletions
archivebox/core
|
@ -7,9 +7,6 @@ from django.views import View, static
|
|||
|
||||
from core.models import Snapshot
|
||||
|
||||
from contextlib import redirect_stdout
|
||||
from io import StringIO
|
||||
|
||||
from ..index import load_main_index, load_main_index_meta
|
||||
from ..config import (
|
||||
OUTPUT_DIR,
|
||||
|
@ -18,10 +15,7 @@ from ..config import (
|
|||
PUBLIC_INDEX,
|
||||
PUBLIC_SNAPSHOTS,
|
||||
)
|
||||
from ..util import base_url, ansi_to_html
|
||||
from .. main import add
|
||||
|
||||
from .forms import AddLinkForm
|
||||
from ..util import base_url
|
||||
|
||||
|
||||
class MainIndex(View):
|
||||
|
@ -45,48 +39,6 @@ class MainIndex(View):
|
|||
return render(template_name=self.template, request=request, context=context)
|
||||
|
||||
|
||||
class AddLinks(View):
|
||||
template = 'add_links.html'
|
||||
|
||||
def get(self, request):
|
||||
if not request.user.is_authenticated and not PUBLIC_INDEX:
|
||||
return redirect(f'/admin/login/?next={request.path}')
|
||||
|
||||
context = {
|
||||
"form": AddLinkForm()
|
||||
}
|
||||
|
||||
return render(template_name=self.template, request=request, context=context)
|
||||
|
||||
def post(self, request):
|
||||
if not request.user.is_authenticated and not PUBLIC_INDEX:
|
||||
return redirect(f'/admin/login/?next={request.path}')
|
||||
form = AddLinkForm(request.POST)
|
||||
if form.is_valid():
|
||||
url = form.cleaned_data["url"]
|
||||
print(f'[+] Adding URL: {url}')
|
||||
depth = 0 if form.cleaned_data["depth"] == "0" else 0
|
||||
input_kwargs = {
|
||||
"urls": url,
|
||||
"depth": depth,
|
||||
"update_all": False,
|
||||
"out_dir": OUTPUT_DIR,
|
||||
}
|
||||
add_stdout = StringIO()
|
||||
with redirect_stdout(add_stdout):
|
||||
add(**input_kwargs)
|
||||
print(add_stdout.getvalue())
|
||||
|
||||
context = {
|
||||
"stdout": ansi_to_html(add_stdout.getvalue()),
|
||||
"form": AddLinkForm()
|
||||
}
|
||||
else:
|
||||
context = {"form": form}
|
||||
|
||||
return render(template_name=self.template, request=request, context=context)
|
||||
|
||||
|
||||
class LinkDetails(View):
|
||||
def get(self, request, path):
|
||||
# missing trailing slash -> redirect to index
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue