Change Gemini port to 1973

* I use it behind a reverse proxy. I would be suprised if *this* was the 
only Gemini server someone was running. 1973 is the first prime after 
1965.
* Remove unused important
* Add Secure Cookie option, in-line with Django recommendations
This commit is contained in:
MatthiasSaihttam 2021-10-03 19:42:52 -04:00
parent 987774999c
commit 913e7ad0b5
5 changed files with 13 additions and 19 deletions

View File

@ -47,6 +47,7 @@ if __name__ == "__main__":
host="0.0.0.0",
hostname=("localhost" if settings.DEBUG else settings.ALLOWED_HOSTS[0]),
certfile=config("CERTFILE", default=None),
keyfile=config("KEYFILE", default=None)
keyfile=config("KEYFILE", default=None),
port=1973
)
server.run()

View File

@ -8,6 +8,7 @@ from django import forms
from django.utils.text import normalize_newlines
from django.core.exceptions import ValidationError
class Thought(models.Model):
text = models.CharField(max_length=140)
extended_text = models.TextField(blank=True)
@ -23,6 +24,7 @@ class Thought(models.Model):
else:
return os.path.splitext(self.media.path)[1][1:]
# Honestly I'm so sick of this problem that writing out a comment here to explain why it is necessary is beyond me.
# I'm calling this CharField and not MySpecialLineNormalizingCharField
# because I think this should be the default behavior and I don't understand why it's not.
@ -31,6 +33,7 @@ class CharField(forms.CharField):
# I am assuming that value is always a string and normalize_newlines isn't going to error on any string input
return super().to_python(normalize_newlines(value))
# A dict mapping allowed mime types to file extensions
ALLOWED_MEDIA_TYPES = {
"image/png": "png",
@ -41,6 +44,7 @@ ALLOWED_MEDIA_TYPES = {
"video/quicktime": "mov",
}
class ThoughtForm(forms.ModelForm):
def clean_media(self):
f = self.cleaned_data["media"]

View File

@ -4,7 +4,6 @@ import subprocess
import magic
from django.http import HttpResponse
from django.shortcuts import render
from django.utils import timezone
from django.utils.crypto import constant_time_compare
@ -12,6 +11,7 @@ from django.utils.crypto import constant_time_compare
from whispermaphone import settings
from .models import Thought, ThoughtForm, ALLOWED_MEDIA_TYPES
def check_authenticated(request):
authenticated = False
try:
@ -21,6 +21,7 @@ def check_authenticated(request):
pass
return authenticated
def index(request):
authenticated = check_authenticated(request)

View File

@ -48,6 +48,8 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
CSRF_COOKIE_SECURE = True
ROOT_URLCONF = 'whispermaphone.urls'
TEMPLATES = [

View File

@ -1,18 +1,3 @@
"""whispermaphone URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf.urls.static import static
from django.urls import path
@ -23,6 +8,7 @@ from whispermaphone import settings
urlpatterns = [
path("", views.index, name="index"),
path("about", views.about, name="about"),
path("post", views.post, name="post"),
path("feed", MainFeed())
path("post", views.post_or_edit, name="post"),
path("feed", MainFeed()),
path("edit", views.post_or_edit, name="edit"),
] + (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG else [])