feat: app inside project with custom command

This commit is contained in:
eneller
2025-03-16 15:31:45 +01:00
parent 52998fa280
commit 0589148b6f
14 changed files with 73 additions and 21 deletions

View File

@@ -14,6 +14,7 @@ from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
PROJ_DIR = BASE_DIR / 'epub2go_web'
# Quick-start development settings - unsuitable for production
@@ -37,6 +38,7 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"core",
]
MIDDLEWARE = [
@@ -55,7 +57,7 @@ TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [
"epub2go_web/templates/"
PROJ_DIR / "templates/"
],
"APP_DIRS": True,
"OPTIONS": {
@@ -119,9 +121,12 @@ USE_TZ = True
STATIC_URL = "static/"
STATICFILES_DIRS = [
BASE_DIR / "epub2go_web/static",
PROJ_DIR / "static/",
]
MEDIA_URL = "media/"
MEDIA_ROOT = PROJ_DIR / "media/"
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

View File

@@ -12,7 +12,7 @@
<a href="javascript:void(window.open('./?t='+encodeURIComponent(window.location.toString())))" title="Add this to your bookmarks"> <!--TODO fix domain part as variable-->
<img src="{% static 'bookmark.svg' %}" alt="Bookmarklet" class="header-icon">
</a>
<a href="https://github.com/eneller/epub2go.py">
<a href="https://github.com/eneller/epub2go-web">
<img src="{% static 'github.svg' %}" alt="GitHub" class="header-icon">
</a></div>
<search>

View File

@@ -16,29 +16,13 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render, redirect
from epub2go.convert import get_all_books, GBConvert, Book
def root(request:HttpRequest):
title = 'epub2go'
targetParam = request.GET.get('t', None)
books = get_all_books()
if targetParam is not None:
getEpub(targetParam)
return render(request, 'index.html', locals())
urlpatterns = [
path("admin/", admin.site.urls),
path('',root, name='root')
path('',include('core.urls'))
]
def getEpub(param):
print(param)
# TODO validate / sanitize input
# TODO check for existing file and age
# TODO download
# TODO redirect to loading page
# TODO redirect to download page
raise NotImplementedError