Compare commits
3 Commits
34868bd0a5
...
98e2aa29ba
Author | SHA1 | Date |
---|---|---|
Matthias Portzel | 98e2aa29ba | |
Matthias Portzel | 1defa2b92c | |
Matthias Portzel | 1c2933bef4 |
2
README
|
@ -12,7 +12,7 @@ Running in production requires a WSGI host, which is way beyond the scope of thi
|
||||||
|
|
||||||
Since both production and my local development instance have a large (500+) number of posts, behavior with a small number of posts is untested and undefined. I do know that the system assumes that there is at least one post, and the main page will error if that's not the case. Pull requests (or emailed git patches) to fix this or similar bugs would be accepted.
|
Since both production and my local development instance have a large (500+) number of posts, behavior with a small number of posts is untested and undefined. I do know that the system assumes that there is at least one post, and the main page will error if that's not the case. Pull requests (or emailed git patches) to fix this or similar bugs would be accepted.
|
||||||
|
|
||||||
Disabling pagination is possible by editing ./main/pagination.py.
|
Disabling pagination is possible by editing ./thoughts/pagination.py.
|
||||||
|
|
||||||
After cloning, you should create a `.env` to define environment variables. Read whispermaphone/settings.py.
|
After cloning, you should create a `.env` to define environment variables. Read whispermaphone/settings.py.
|
||||||
You can generate a SECRET_KEY with `python3 -c "import secrets; print(''.join([secrets.choice('abcdefghijklmnopqrstuvwxyz0123456789\!@#$%^&*(-_=+)') for i in range(50)]))"`.
|
You can generate a SECRET_KEY with `python3 -c "import secrets; print(''.join([secrets.choice('abcdefghijklmnopqrstuvwxyz0123456789\!@#$%^&*(-_=+)') for i in range(50)]))"`.
|
||||||
|
|
|
@ -7,7 +7,7 @@ from django.template.loader import render_to_string
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
django.setup()
|
django.setup()
|
||||||
from main.models import Thought
|
from thoughts.models import Thought
|
||||||
|
|
||||||
from jetforce import GeminiServer, JetforceApplication, Response, Status
|
from jetforce import GeminiServer, JetforceApplication, Response, Status
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ app = JetforceApplication()
|
||||||
def index(request):
|
def index(request):
|
||||||
thoughts = Thought.objects.order_by("-posted")
|
thoughts = Thought.objects.order_by("-posted")
|
||||||
|
|
||||||
rendered_text = render_to_string("whispermaphone/index.gmi", {
|
rendered_text = render_to_string("thoughts/index.gmi", {
|
||||||
"thoughts": thoughts,
|
"thoughts": thoughts,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "whispermaphone/page.html" %}
|
{% extends "thoughts/page.html" %}
|
||||||
|
|
||||||
{% block title %}Search{% if query %} "{{ query }}"{% endif %}{% endblock %}
|
{% block title %}Search{% if query %} "{{ query }}"{% endif %}{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,4 @@ from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
class MainConfig(AppConfig):
|
class MainConfig(AppConfig):
|
||||||
name = 'main'
|
name = "thoughts"
|
|
@ -1,6 +1,6 @@
|
||||||
from django.contrib.syndication.views import Feed
|
from django.contrib.syndication.views import Feed
|
||||||
|
|
||||||
from main.models import Thought
|
from thoughts.models import Thought
|
||||||
|
|
||||||
|
|
||||||
class MainFeed(Feed):
|
class MainFeed(Feed):
|
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('main', '0001_initial'),
|
('thoughts', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
|
@ -5,7 +5,7 @@ import uuid
|
||||||
|
|
||||||
|
|
||||||
def add_uuids(apps, schema_editor):
|
def add_uuids(apps, schema_editor):
|
||||||
Thought = apps.get_model("main", "Thought")
|
Thought = apps.get_model("thoughts", "Thought")
|
||||||
for thought in Thought.objects.all():
|
for thought in Thought.objects.all():
|
||||||
thought.uuid = uuid.uuid4()
|
thought.uuid = uuid.uuid4()
|
||||||
thought.save()
|
thought.save()
|
||||||
|
@ -18,7 +18,7 @@ def reverse_add_uuids(apps, schema_editor):
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('main', '0002_auto_20200906_0324'),
|
('thoughts', '0002_auto_20200906_0324'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('main', '0003_thought_uuid'),
|
('thoughts', '0003_thought_uuid'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('main', '0004_thought_media'),
|
('thoughts', '0004_thought_media'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
|
@ -6,7 +6,7 @@ from django.db import migrations, models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('main', '0005_thought_media_alt'),
|
('thoughts', '0005_thought_media_alt'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
|
@ -2,7 +2,7 @@ from haystack import indexes
|
||||||
from .models import Thought
|
from .models import Thought
|
||||||
|
|
||||||
class ThoughtIndex(indexes.SearchIndex, indexes.Indexable):
|
class ThoughtIndex(indexes.SearchIndex, indexes.Indexable):
|
||||||
text = indexes.CharField(document=True, use_template=True, template_name="search/indexes/main/thought_text.txt")
|
text = indexes.CharField(document=True, use_template=True, template_name="search/indexes/thoughts/thought_text.txt")
|
||||||
posted = indexes.DateTimeField(model_attr="posted")
|
posted = indexes.DateTimeField(model_attr="posted")
|
||||||
|
|
||||||
def get_model(self):
|
def get_model(self):
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 340 B After Width: | Height: | Size: 340 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
@ -1,4 +1,4 @@
|
||||||
{% extends "whispermaphone/page.html" %}
|
{% extends "thoughts/page.html" %}
|
||||||
|
|
||||||
{% block title %}About{% endblock %}
|
{% block title %}About{% endblock %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends "whispermaphone/page.html" %}
|
{% extends "thoughts/page.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block title %}Thoughts{% endblock %}
|
{% block title %}Thoughts{% endblock %}
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link rel="alternate" href="/feed" type="application/rss+xml" title="RSS">
|
<link rel="alternate" href="/feed" type="application/rss+xml" title="RSS">
|
||||||
|
|
||||||
<link href="{% static 'main/codehighlight.css' %}" rel="stylesheet">
|
<link href="{% static 'thoughts/codehighlight.css' %}" rel="stylesheet">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<div class="transcript">{{ thought.media_alt|urlize }}</div>
|
<div class="transcript">{{ thought.media_alt|urlize }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif file_type == "mov" or file_type == "mp4" %}
|
{% elif file_type == "mov" or file_type == "mp4" %}
|
||||||
<video src="{{ thought.media.url }}" class="extended-media"></video>
|
<video src="{{ thought.media.url }}" controls class="extended-media"></video>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
|
@ -1,10 +1,10 @@
|
||||||
{% extends "whispermaphone/page.html" %}
|
{% extends "thoughts/page.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block title %}Post{% endblock %}
|
{% block title %}Post{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link href="{% static 'main/login.css' %}" rel="stylesheet">
|
<link href="{% static 'thoughts/login.css' %}" rel="stylesheet">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block navigation %}
|
{% block navigation %}
|
|
@ -6,7 +6,7 @@
|
||||||
<title>{% block title %}{% endblock %}</title>
|
<title>{% block title %}{% endblock %}</title>
|
||||||
|
|
||||||
{% load static %}
|
{% load static %}
|
||||||
<link href="{% static 'main/main.css' %}" rel="stylesheet">
|
<link href="{% static 'thoughts/main.css' %}" rel="stylesheet">
|
||||||
{% block head %}{% endblock %}
|
{% block head %}{% endblock %}
|
||||||
|
|
||||||
<link rel="icon" sizes="192x192" href="{% static 'images/favicon-192x192.png'%}">
|
<link rel="icon" sizes="192x192" href="{% static 'images/favicon-192x192.png'%}">
|
|
@ -1,10 +1,10 @@
|
||||||
{% extends "whispermaphone/page.html" %}
|
{% extends "thoughts/page.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block title %}Post{% endblock %}
|
{% block title %}Post{% endblock %}
|
||||||
|
|
||||||
{% block head %}
|
{% block head %}
|
||||||
<link href="{% static 'main/post.css' %}" rel="stylesheet">
|
<link href="{% static 'thoughts/post.css' %}" rel="stylesheet">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block navigation %}
|
{% block navigation %}
|
|
@ -53,7 +53,7 @@ def index(request):
|
||||||
|
|
||||||
thoughts = requested_page.get_all_entries()
|
thoughts = requested_page.get_all_entries()
|
||||||
|
|
||||||
return render(request, "whispermaphone/index.html", {
|
return render(request, "thoughts/index.html", {
|
||||||
"thoughts": thoughts,
|
"thoughts": thoughts,
|
||||||
"highlighted": highlighted_uuid,
|
"highlighted": highlighted_uuid,
|
||||||
"authenticated": authenticated,
|
"authenticated": authenticated,
|
||||||
|
@ -75,7 +75,7 @@ def login(request):
|
||||||
|
|
||||||
# Returning 401 here causes `links` to always prompt for HTTP basic auth, which is annoying.
|
# Returning 401 here causes `links` to always prompt for HTTP basic auth, which is annoying.
|
||||||
# But the alternative is not following the HTTP spec, so I think this is fine.
|
# But the alternative is not following the HTTP spec, so I think this is fine.
|
||||||
return render(request, "whispermaphone/login.html", status=401)
|
return render(request, "thoughts/login.html", status=401)
|
||||||
|
|
||||||
|
|
||||||
def post(request):
|
def post(request):
|
||||||
|
@ -111,7 +111,7 @@ def post(request):
|
||||||
except:
|
except:
|
||||||
error_line = f"An unknown error occurred processing your request: {errors}"
|
error_line = f"An unknown error occurred processing your request: {errors}"
|
||||||
|
|
||||||
return render(request, "whispermaphone/post.html", {
|
return render(request, "thoughts/post.html", {
|
||||||
"form": thought_form,
|
"form": thought_form,
|
||||||
"form_error": error_line
|
"form_error": error_line
|
||||||
}, status=400)
|
}, status=400)
|
||||||
|
@ -156,13 +156,13 @@ def post(request):
|
||||||
return redirect(editing_thought)
|
return redirect(editing_thought)
|
||||||
return redirect("post")
|
return redirect("post")
|
||||||
|
|
||||||
return render(request, "whispermaphone/post.html", {
|
return render(request, "thoughts/post.html", {
|
||||||
"form": ThoughtForm(instance=editing_thought) if editing_thought else ThoughtForm(),
|
"form": ThoughtForm(instance=editing_thought) if editing_thought else ThoughtForm(),
|
||||||
"editing": not not editing_thought,
|
"editing": not not editing_thought,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def about(request):
|
def about(request):
|
||||||
return render(request, "whispermaphone/about.html", {
|
return render(request, "thoughts/about.html", {
|
||||||
"authenticated": check_authenticated(request)
|
"authenticated": check_authenticated(request)
|
||||||
})
|
})
|
|
@ -45,7 +45,7 @@ INSTALLED_APPS = [
|
||||||
|
|
||||||
"haystack",
|
"haystack",
|
||||||
|
|
||||||
"main",
|
"thoughts",
|
||||||
]
|
]
|
||||||
|
|
||||||
HAYSTACK_SIGNAL_PROCESSOR = "haystack.signals.RealtimeSignalProcessor"
|
HAYSTACK_SIGNAL_PROCESSOR = "haystack.signals.RealtimeSignalProcessor"
|
||||||
|
@ -80,7 +80,7 @@ TEMPLATES = [
|
||||||
"context_processors": [
|
"context_processors": [
|
||||||
"django.template.context_processors.debug",
|
"django.template.context_processors.debug",
|
||||||
"django.template.context_processors.request",
|
"django.template.context_processors.request",
|
||||||
"main.settings_context_processor.add_settings"
|
"thoughts.settings_context_processor.add_settings"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
from main import views
|
from thoughts import views
|
||||||
from main.feed import MainFeed
|
from thoughts.feed import MainFeed
|
||||||
from whispermaphone import settings
|
from whispermaphone import settings
|
||||||
|
|
||||||
from haystack.views import SearchView, search_view_factory
|
from haystack.views import SearchView, search_view_factory
|
||||||
|
|