mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Django secret generated per install,
This commit is contained in:
2
config.json
Executable file → Normal file
2
config.json
Executable file → Normal file
@@ -1 +1 @@
|
|||||||
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.6.0", "BOOKPATH": "/home/raelon/Books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "hostname": "localhost", "webport": "8000", "wsgiport": "8001"}
|
{"TITLE": "pyShelf E-Book Server", "VERSION": "0.6.0", "BOOKPATH": "/home/raelon/Books", "DB_HOST": "localhost", "DB_PORT": "5432", "DATABASE": "pyshelf", "USER": "pyshelf", "PASSWORD": "pyshelf", "BOOKSHELF": "data/shelf.json", "ALLOWED_HOSTS": "*", "hostname": "localhost", "webport": "8000", "wsgiport": "8001", "SECRET": "r0m#@$d(cs^si9_jmm)z-z#6-4-(snoctd)l(4becso9k=dwvs"}
|
||||||
@@ -38,13 +38,13 @@ PROJECT_NAME = "pyShelf Open Source Ebook Server"
|
|||||||
# could be handy for archiving the generated documentation or if some version
|
# could be handy for archiving the generated documentation or if some version
|
||||||
# control system is used.
|
# control system is used.
|
||||||
|
|
||||||
PROJECT_NUMBER = 0.4.1
|
PROJECT_NUMBER = 0.6.0
|
||||||
|
|
||||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||||
# for a project that appears at the top of each page and should give viewer a
|
# for a project that appears at the top of each page and should give viewer a
|
||||||
# quick idea about the purpose of the project. Keep the description short.
|
# quick idea about the purpose of the project. Keep the description short.
|
||||||
|
|
||||||
PROJECT_BRIEF = "Open source, console based E-book server"
|
PROJECT_BRIEF = "FOSS E-Book Server, https://pyshelf.com"
|
||||||
|
|
||||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||||
# in the documentation. The maximum height of the logo should not exceed 55
|
# in the documentation. The maximum height of the logo should not exceed 55
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import sys
|
|||||||
|
|
||||||
from src.backend.lib.storage import Storage
|
from src.backend.lib.storage import Storage
|
||||||
from src.backend.pyShelf_ScanLibrary import execute_scan
|
from src.backend.pyShelf_ScanLibrary import execute_scan
|
||||||
|
from src.backend.pyShelf_MakeCollections import MakeCollections
|
||||||
PRG_PATH = pathlib.Path.cwd()
|
PRG_PATH = pathlib.Path.cwd()
|
||||||
LIB_PATH = pathlib.Path.joinpath(PRG_PATH, "src", "backend", "lib")
|
LIB_PATH = pathlib.Path.joinpath(PRG_PATH, "src", "backend", "lib")
|
||||||
sys.path.insert(0, PRG_PATH)
|
sys.path.insert(0, PRG_PATH)
|
||||||
print("\n")
|
print("\n")
|
||||||
execute_scan(PRG_PATH)
|
execute_scan(PRG_PATH)
|
||||||
|
MakeCollections(PRG_PATH)
|
||||||
|
|||||||
10
installer
10
installer
@@ -1,12 +1,9 @@
|
|||||||
#!/usr/bin/ env python
|
#!/usr/bin/ env python3
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import platform
|
import platform
|
||||||
import pprint
|
from django.core.management.utils import get_random_secret_key
|
||||||
import subprocess as sp
|
|
||||||
import sys
|
|
||||||
from shutil import copyfile
|
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
from src.backend.lib.display import TerminalDisplay
|
from src.backend.lib.display import TerminalDisplay
|
||||||
@@ -34,6 +31,8 @@ class Configuration:
|
|||||||
json.dump(data, backup_file)
|
json.dump(data, backup_file)
|
||||||
return data
|
return data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
f = open(str(self._cp),"w")
|
||||||
|
f
|
||||||
print(e)
|
print(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -225,6 +224,7 @@ for key in install_answers:
|
|||||||
config[key["name"]] = key["answer"]
|
config[key["name"]] = key["answer"]
|
||||||
# config["USER"] = os.environ["USER"]
|
# config["USER"] = os.environ["USER"]
|
||||||
config["USER"] = "pyshelf"
|
config["USER"] = "pyshelf"
|
||||||
|
config["SECRET"] = get_random_secret_key()
|
||||||
# Write configuration
|
# Write configuration
|
||||||
Configuration().write_file(config)
|
Configuration().write_file(config)
|
||||||
# Start checking for our list of required services
|
# Start checking for our list of required services
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Config:
|
|||||||
"""
|
"""
|
||||||
_cp = pathlib.Path.joinpath(root, self._fp)
|
_cp = pathlib.Path.joinpath(root, self._fp)
|
||||||
_data = self.open_file(_cp)
|
_data = self.open_file(_cp)
|
||||||
|
breakpoint()
|
||||||
self.book_path = _data["BOOKPATH"]
|
self.book_path = _data["BOOKPATH"]
|
||||||
self.TITLE = _data["TITLE"]
|
self.TITLE = _data["TITLE"]
|
||||||
self.VERSION = _data["VERSION"]
|
self.VERSION = _data["VERSION"]
|
||||||
@@ -36,6 +37,7 @@ class Config:
|
|||||||
self.allowed_hosts = _data["ALLOWED_HOSTS"]
|
self.allowed_hosts = _data["ALLOWED_HOSTS"]
|
||||||
self.db_user = _data["USER"]
|
self.db_user = _data["USER"]
|
||||||
self.db_pass = _data["PASSWORD"]
|
self.db_pass = _data["PASSWORD"]
|
||||||
|
self.SECRET = _data["SECRET"]
|
||||||
|
|
||||||
def open_file(self, _cp):
|
def open_file(self, _cp):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||||||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = "@(9b9jslgg41u1u=mr)-2*-n2x0vef0zsy39*z@sz18&tvow18"
|
# SECRET_KEY = "@(9b9jslgg41u1u=mr)-2*-n2x0vef0zsy39*z@sz18&tvow18"
|
||||||
|
SECRET_KEY = CONFIG.SECRET
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = TEMPLATE_DEBUG = True
|
DEBUG = TEMPLATE_DEBUG = True
|
||||||
if DEBUG is True:
|
if DEBUG is True:
|
||||||
|
|||||||
@@ -15,17 +15,17 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path, re_path
|
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.shortcuts import HttpResponse
|
from django.shortcuts import HttpResponse
|
||||||
|
from django.urls import include, path, re_path
|
||||||
from interface import views
|
from interface import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path("home", views.home, name="home"),
|
path("home", views.home, name="home"),
|
||||||
re_path("^live", views.live, name="liverequest"),
|
re_path("^live$", views.live, name="live"),
|
||||||
path("sort/<_order>", views.index, name="index"),
|
path("sort/<_order>", views.index, name="index"),
|
||||||
path("flip_sort/<_order>", views.flip_sort, name="index"),
|
path("flip_sort/<_order>", views.flip_sort, name="index"),
|
||||||
path("download/<pk>", views.download, name="download"),
|
path("download/<pk>", views.download, name="download"),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class CustomUserAdmin(UserAdmin):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
admin.site.register(Books)
|
admin.site.register(Books)
|
||||||
admin.site.register(Collections)
|
admin.site.register(Collections)
|
||||||
admin.site.register(Favorites)
|
admin.site.register(Favorites)
|
||||||
|
|||||||
@@ -10755,3 +10755,7 @@ a.nav_link {
|
|||||||
width: fit-content !important;
|
width: fit-content !important;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.collection {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
@@ -618,3 +618,6 @@ a.nav_link {
|
|||||||
width: fit-content !important;
|
width: fit-content !important;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
.collection{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|||||||
@@ -185,20 +185,26 @@ $(document).ready(function(){
|
|||||||
success: function(response){
|
success: function(response){
|
||||||
// Set the dialog title
|
// Set the dialog title
|
||||||
$('#pop_over_0').dialog({
|
$('#pop_over_0').dialog({
|
||||||
title: "Collections",
|
title: response.data['title'],
|
||||||
maxHeight: (win_height-100),
|
maxHeight: (win_height-100),
|
||||||
minWidth: $("#horiz_nav_main").width(),
|
minWidth: $("#horiz_nav_main").width(),
|
||||||
hide: { effect: "blind", duration: 1000 },
|
hide: { effect: "blind", duration: 1000 },
|
||||||
show: { effect: "blind", duration: 1000 },
|
show: { effect: "blind", duration: 1000 },
|
||||||
position: { my: "top", at: "bottom", of: $("#horiz_nav_main")
|
position: { my: "center center", at: "center center", of: window
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// clear and create a new container
|
// clear and create a new container
|
||||||
$('#pop_over_0').html('<div id=collections>');
|
$('#pop_over_0').html('<div id=book_expanded>');
|
||||||
// Populate the container from response.data
|
// Populate the container from response.data
|
||||||
$.each(response.data, function(index, value){
|
$('#book_expanded').append('<div class=row><div class="col-auto">Title</div><div class="col-auto text-muted">'+response.data['title']+'</div></div>')
|
||||||
$('#collections').append("<div class=collection data='"+value+"/"+$('#_set').val()+"'>"+value+"</div>");
|
$('#book_expanded').append('<div class=row><div class="col-auto">Author</div><div class="col-auto text-muted">'+response.data['author']+'</div></div>')
|
||||||
});
|
if (response.data['description']!== null){
|
||||||
|
$('#book_expanded').append('<div class=row><div class="col-auto">Expanded Description</div><div class="col-auto text-muted">'+response.data['description']+'</div></div>')
|
||||||
|
|
||||||
|
}
|
||||||
|
if (response.data['tags'] !== null){
|
||||||
|
$('#book_expanded').append('<div class=row><div class="col-auto">Tags</div><div class="col-auto text-muted">'+response.data['tags']+'</div></div>')
|
||||||
|
}
|
||||||
// Close the container
|
// Close the container
|
||||||
$('#pop_over').append('</div>');
|
$('#pop_over').append('</div>');
|
||||||
// Now open this dialog
|
// Now open this dialog
|
||||||
|
|||||||
@@ -393,8 +393,11 @@ def live(request, **kwargs):
|
|||||||
if hook == "collection_listing":
|
if hook == "collection_listing":
|
||||||
collections = collections_list()
|
collections = collections_list()
|
||||||
return JsonResponse({"data": collections}, status=200)
|
return JsonResponse({"data": collections}, status=200)
|
||||||
elif hook == "book_details":
|
elif hook == "details":
|
||||||
return JsonResponse({"data": Books.objects.get(pk=kwargs['pk'])}, status=200)
|
try: _pk = request.GET['pk']
|
||||||
|
except KeyError as e: return False
|
||||||
|
book = book_details(Books.objects.get(pk=_pk))
|
||||||
|
return JsonResponse({"data": book}, status=200)
|
||||||
elif hook == "register":
|
elif hook == "register":
|
||||||
html = render_to_string('signup.html', {'form': SignUpForm}, request)
|
html = render_to_string('signup.html', {'form': SignUpForm}, request)
|
||||||
html += render_to_string('login.html', {'form': UserLoginForm}, request)
|
html += render_to_string('login.html', {'form': UserLoginForm}, request)
|
||||||
@@ -403,7 +406,15 @@ def live(request, **kwargs):
|
|||||||
|
|
||||||
return JsonResponse({"data": "Response sent"}, status=200)
|
return JsonResponse({"data": "Response sent"}, status=200)
|
||||||
|
|
||||||
|
def book_details(book):
|
||||||
|
return {
|
||||||
|
'title': book.title,
|
||||||
|
'author': book.author,
|
||||||
|
'description': book.description,
|
||||||
|
'tags': book.tags,
|
||||||
|
'rights': book.rights,
|
||||||
|
'pk': book.id
|
||||||
|
}
|
||||||
def payload(request, query, _set, _limit, _order, **kwargs):
|
def payload(request, query, _set, _limit, _order, **kwargs):
|
||||||
"""
|
"""
|
||||||
Return formatted data to template
|
Return formatted data to template
|
||||||
|
|||||||
Reference in New Issue
Block a user