Compare commits

..

No commits in common. "071b82121cdf616e941a3bf5d2855b815700426b" and "777e949c9f9d10b4b3c54b700468b428b457e0ba" have entirely different histories.

11 changed files with 92 additions and 97 deletions

View File

@ -11,48 +11,13 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
import json
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
with open( BASE_DIR + "/settings.json", "r") as userfile:
usersettings = json.load(userfile)
CALIBRE_DIR = os.path.abspath(usersettings["CALIBRE_DIR"])
SECRET_KEY = usersettings["SECRET_KEY"]
ALLOWED_HOSTS = usersettings["ALLOWED_HOSTS"]
INTERNAL_IPS = usersettings["INTERNAL_IPS"]
# CALIBRE_DIR = os.path.abspath(
# "C:\\Users\\MassiveAtoms\\Documents\\Calibre Library")
# SECRET_KEY = 'u(8^+rb%rz5hsx4v^^y(ul7g(4n7a8!db@s*9(m5cs*2_ppy8+'
# ALLOWED_HOSTS = ['127.0.0.1', ]
# INTERNAL_IPS = ['127.0.0.1', ]
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CALIBRE_DIR = os.path.abspath(
"C:\\Users\\MassiveAtoms\\Documents\\Calibre Library")
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# optimisation stuff ###############################################3
# #
CONN_MAX_AGE = 60 * 5
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake',
"TIMEOUT" : 60 * 5,
}
}
## ##
########################################################################
## STATIC FILES ##
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
@ -63,9 +28,23 @@ STATICFILES_DIRS = [
]
STATIC_URL = '/static/'
## ##
########################################################################
## DERUG ##
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'u(8^+rb%rz5hsx4v^^y(ul7g(4n7a8!db@s*9(m5cs*2_ppy8+'
ALLOWED_HOSTS = ['127.0.0.1', ]
INTERNAL_IPS = [
# ...
'127.0.0.1',
# ...
]
# Don't change things beyond this
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@ -83,9 +62,9 @@ DEBUG_TOOLBAR_PANELS = [
]
## ##
########################################################################
## DERUG ##
LOGIN_REDIRECT_URL = '/books'
@ -104,7 +83,6 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'debug_toolbar.middleware.DebugToolbarMiddleware', # DEBUG purposes
'django.middleware.cache.UpdateCacheMiddleware', # cache
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
@ -112,7 +90,6 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware', # cache
]
ROOT_URLCONF = 'CalibreWebCompanion.urls'

Binary file not shown.

View File

@ -383,3 +383,25 @@ class BookTagLink(models.Model):
# class Meta:
# managed = False
# db_table = 'feeds'
#
#
# class LastReadPositions(models.Model):
# book = models.IntegerField()
# format = models.TextField()
# user = models.TextField()
# device = models.TextField()
# cfi = models.TextField()
# epoch = models.FloatField()
# pos_frac = models.FloatField()
#
# class Meta:
# managed = False
# db_table = 'last_read_positions'
# class MetadataDirtied(models.Model):
# book = models.IntegerField()
# class Meta:
# managed = False
# db_table = 'metadata_dirtied'

View File

@ -19,7 +19,7 @@
background-color: #515151;
border: 1px #303030;
border-radius: 0.5rem;
padding: .2rem .25rem;
padding: .2rem .25rem ;
margin: 0.1rem 0.1rem .1rem;
}
@ -48,7 +48,6 @@
.tags {
width: 25%;
}
.added {
width: 10%;
}
@ -56,13 +55,12 @@
.published {
width: 10%;
}
</style>
</head>
<body>
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper row green darken-1">
@ -72,9 +70,7 @@
<li class="active"><a href="{{user.get_absolute_url}}"> {{ user.get_username }}</a></li>
<li><a href="{% url 'logout'%}?next={{request.path}}">Logout</a></li>
</ul>
{% load cache %}
{% cache 500 sidebar request.user.username %}
<!--Maybe i'm retarded but this is not caching versions per user-->
<ul class="left">
<li><a href="{% url 'books' %}">Books</a></li>
<li><a class="dropdown-trigger" href={% url 'authors' %} data-target="dropdown-authors">Authors<i
@ -130,7 +126,7 @@
<li><a href="{{pub.get_absolute_url}}">{{pub}} <p class="count">{{pub.num_books}}</p> </a> </li>
{% endfor %}
</ul>
{% endcache %}
{% else %}
<li><a href="{% url 'sign-up'%}?next={{request.path}}">Sign up</a></li>
<li><a href="{% url 'login'%}?next={{request.path}}">Login</a></li>
@ -138,6 +134,7 @@
{% endif %}
</div>
</nav>
</div>
<script>
@ -148,6 +145,7 @@
});
</script>
{% if user.is_authenticated %}
{% block content %} {% endblock %}
{% else %}

View File

@ -6,47 +6,46 @@
<div class="col s12 m7">
<div class="card z-depth-0 horizontal">
<div class="card-image">
<a style="padding-top:15%" href=" {% static "" %}{{download}}"><img src=" {% static "" %}{{imgpath}}"
alt="download" srcset=""></a>
<a style="padding-top:15%" href="{{download}}"><img src=" {% static "" %}{{imgpath}}" alt="download" srcset=""></a>
</div>
<div class="card-stacked">
<div class="card-content">
<h1> {{book.title}}</h1>
<h4> by
{% if book.authors %}
{% for author in book.authors.all %}
<a href="{{author.get_absolute_url}}">{{author.name}}</a>
{%endfor%}
{% else %}
{{book.author_sort}}
{%endif%}
<br>
Published by
{% if book.publishers %}
{% for pub in book.publishers.all %}
<a href="{{pub.get_absolute_url}}">{{pub.name}}</a>
{%endfor%}
{% else %}
Unknown
{%endif%}
<br>
Tags:
{% if book.tags %}
{% for tag in book.tags.all %}
<a href="{{tag.get_absolute_url}}">{{tag.name}}</a>,
{%endfor%}
{% else %}
{%endif%}
<br>
Rating:
{% if book.ratings %}
{% for rating in book.ratings.all %}
<a href="{{rating.get_absolute_url}}">{{rating}}</a>
{%endfor%}
{% else %}
{%endif%}
<br>
<a href="{{book.publisher.get_absolute_url}}">{{book.publisher}}</a>
{% if book.authors %}
{% for author in book.authors.all %}
<a href="{{author.get_absolute_url}}">{{author.name}}</a>
{%endfor%}
{% else %}
{{book.author_sort}}
{%endif%}
<br>
Published by
{% if book.publishers %}
{% for pub in book.publishers.all %}
<a href="{{pub.get_absolute_url}}">{{pub.name}}</a>
{%endfor%}
{% else %}
Unknown
{%endif%}
<br>
Tags:
{% if book.tags %}
{% for tag in book.tags.all %}
<a href="{{tag.get_absolute_url}}">{{tag.name}}</a>,
{%endfor%}
{% else %}
{%endif%}
<br>
Rating:
{% if book.ratings %}
{% for rating in book.ratings.all %}
<a href="{{rating.get_absolute_url}}">{{rating}}</a>
{%endfor%}
{% else %}
{%endif%}
<br>
<a href="{{book.publisher.get_absolute_url}}">{{book.publisher}}</a>
</h4>
</div>
</div>
@ -54,9 +53,9 @@
</div>
<div class="container">
{% autoescape off %}
{{comment}}
{% endautoescape %}
{% autoescape off %}
{{comment}}
{% endautoescape %}
</div>
{% endblock %}

View File

@ -1,6 +1,6 @@
from django.urls import path
from . import views
from django.views.decorators.cache import cache_page
urlpatterns = [

View File

@ -10,7 +10,6 @@ from django.contrib.auth import login
from django.contrib.auth.decorators import login_required
@login_required
def index(request):
return render(request, 'accounts/index.html')