mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Sending data from python to javascript
This commit is contained in:
2
src/interface/static/css/main.css
vendored
2
src/interface/static/css/main.css
vendored
@@ -264,7 +264,7 @@ body {
|
||||
display: flex;
|
||||
grid-area: horiz_nav_main;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
/* justify-content: center; */
|
||||
padding: 5px 5px 0px 5px;
|
||||
min-width: max-content;
|
||||
color: deepskyblue;
|
||||
|
||||
2
src/interface/static/js/pyshelf_ux.js
vendored
2
src/interface/static/js/pyshelf_ux.js
vendored
@@ -12,7 +12,7 @@ $(document).ready(function(){
|
||||
var scr_height = window.outerHeight;
|
||||
var scr_width = window.outerWidth;
|
||||
var hdr_height = $('.app_hdr').height(); // Get our header height
|
||||
var ftr_height = $('.app_footer').height(); // Get our footer height
|
||||
var ftr_height = $('.app_footer').height(); // Get our footer height
|
||||
var nav_width = $('.nav_l').width(); // Get the width of our nav items
|
||||
var cmp_height = window.screen.availHeight;
|
||||
var max_height = win_height - (hdr_height + ftr_height) - (scr_height - win_height); // Set our available height
|
||||
|
||||
10
src/interface/templates/index.html
vendored
10
src/interface/templates/index.html
vendored
@@ -11,13 +11,13 @@
|
||||
<link type="text/css" rel="stylesheet" href="/static/css/all-fa.css" />
|
||||
<title>pyShelf E-Book Server</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Audiowide&family=Montserrat:wght@300&family=Gruppo&family=Cinzel+Decorative&family=Ubuntu+Mono&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css?family=Gruppo&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative&family=Ubuntu+Mono&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300&display=swap" rel="stylesheet">
|
||||
<script src="/static/js/jquery-3.4.1.min.js" type="text/javascript"></script>
|
||||
<script src="/static/js/pyshelf_ux.js" type="text/javascript"></script>
|
||||
<!-- Place this tag in your head or just before your close body tag. -->
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
<script src="/static/js/pyshelf_ux.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var collections={{ CollectionObject|safe }};
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -44,7 +44,7 @@
|
||||
</div>
|
||||
<div id="horiz_nav_main">
|
||||
<!--<i class="fas fa-chevron-left nav_icon prev_page" onclick="window.location.href = '/prev_page/{{ Set }}'"></i>-->
|
||||
{{ BookStats }} books | {{ CollectionStats }} collections
|
||||
{{ BookStats }} books | <script type="text/javascript">document.write(collections.length)</script> collections
|
||||
<!--<i class="fas fa-chevron-right nav_icon next_page" onclick="window.location.href = '/next_page/{{ Set }}'"></i>-->
|
||||
<!--<input class="nav_button search_submit" type="submit" value="Search">-->
|
||||
</div>
|
||||
|
||||
@@ -8,12 +8,14 @@ from django.db import models
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import HttpResponse, render # render_to_response
|
||||
from django.utils.text import slugify
|
||||
import json
|
||||
import jsonpickle
|
||||
|
||||
from .models import Books, Collections, Navigation
|
||||
|
||||
config = Config(Path("../"))
|
||||
|
||||
|
||||
collections = Collections.objects.all()
|
||||
def index(request):
|
||||
"""
|
||||
Return template index
|
||||
@@ -29,8 +31,8 @@ def index(request):
|
||||
"LeftNavCollections": menu("collections"),
|
||||
"LeftNavMenu0": menu("nav_l_0"),
|
||||
"BookStats": Books.objects.all().count,
|
||||
"CollectionStats": Collections.objects.all().count
|
||||
|
||||
"CollectionStats": Collections.objects.all().count,
|
||||
"CollectionObject": collections_list()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -48,6 +50,7 @@ def show_collection(request, _collection, _colset):
|
||||
"Version": config.VERSION,
|
||||
"LeftNavCollections": menu("collections"),
|
||||
"LeftNav": menu("collections"),
|
||||
"Collections": collections_list()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -239,8 +242,8 @@ def format_list(list_in):
|
||||
|
||||
def menu(which, _set=1, parent=None):
|
||||
if which == "collections":
|
||||
collection_list = Collections.objects.all()
|
||||
collections, collection_key, x = [], [], 0
|
||||
collection_list = collections
|
||||
_collections, collection_key, x = [], [], 0
|
||||
for i in collection_list:
|
||||
if i.collection not in collection_key:
|
||||
# Using c as the alternating row identifier
|
||||
@@ -259,12 +262,19 @@ def menu(which, _set=1, parent=None):
|
||||
else:
|
||||
collection_string = i.collection
|
||||
|
||||
collections.append(
|
||||
_collections.append(
|
||||
{"string": collection_string, "link": i.collection, "class": c}
|
||||
)
|
||||
collection_key.append(i.collection)
|
||||
return collections
|
||||
return _collections
|
||||
elif which == "nav_lvl_0":
|
||||
navigation_list = Navigation.objects.all()
|
||||
breakpoint()
|
||||
return navigation_list
|
||||
|
||||
def collections_list():
|
||||
collection_key = []
|
||||
for i in collections:
|
||||
if i.collection not in collection_key:
|
||||
collection_key.append(i.collection)
|
||||
return json.dumps(list(set(collection_key)))
|
||||
|
||||
Reference in New Issue
Block a user