1
0
Fork 0
mirror of synced 2024-07-02 21:10:25 +12:00
ArchiveBox/archivebox/core/views.py

48 lines
1.3 KiB
Python
Raw Normal View History

2019-04-03 09:36:41 +13:00
from django.shortcuts import render
2019-04-17 21:42:21 +12:00
from django.views import View
from legacy.config import OUTPUT_DIR
from legacy.index import load_main_index, load_main_index_meta
2019-04-17 21:42:21 +12:00
class MainIndex(View):
template = 'main_index.html'
def get(self, request):
all_links = load_main_index(out_dir=OUTPUT_DIR)
meta_info = load_main_index_meta(out_dir=OUTPUT_DIR)
context = {
'updated': meta_info['updated'],
'num_links': meta_info['num_links'],
'links': all_links,
}
return render(template_name=self.template, request=request, context=context)
class AddLinks(View):
template = 'add_links.html'
def get(self, request):
context = {}
return render(template_name=self.template, request=request, context=context)
def post(self, request):
import_path = request.POST['url']
2019-04-23 11:10:22 +12:00
# TODO: add the links to the index here using archivebox.legacy.main.update_archive_data
print(f'Adding URL: {import_path}')
2019-04-23 11:10:22 +12:00
return render(template_name=self.template, request=request, context={})
2019-04-17 21:42:21 +12:00
class LinkDetails(View):
template = 'link_details.html'
def get(self, request):
return render(template_name=self.template, request=request, context={})