2025.10.13-06:49:54

This commit is contained in:
2025-10-13 06:49:54 +02:00
parent 90252f1d07
commit a2b7ff45f8
5 changed files with 25 additions and 26 deletions

View File

@@ -76,8 +76,8 @@ django_apps= [
third_party_apps = [ third_party_apps = [
'allauth', 'allauth',
'allauth.account', 'allauth.account',
'allauth.socialaccount', 'allauth.socialaccount',
'allauth.socialaccount.providers.oauth2', # required for github 'allauth.socialaccount.providers.oauth2', # required for github
'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.openid', 'allauth.socialaccount.providers.openid',

View File

@@ -20,7 +20,7 @@ from django.conf import settings
urlpatterns = [ urlpatterns = [
path('',include("tinywiki.urls")), path('',include("tinywiki.urls")),
path("user/",include("user.urls")), path("user/",include("user.urls")),
path('admin/', admin.site.urls), path("admin/", admin.site.urls),
path('accounts/',include('allauth.urls')), path('accounts/',include('allauth.urls')),
] ]

8
poetry.lock generated
View File

@@ -422,13 +422,13 @@ bcrypt = ["bcrypt"]
[[package]] [[package]]
name = "django-allauth" name = "django-allauth"
version = "65.11.2" version = "65.12.0"
description = "Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication." description = "Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication."
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "django_allauth-65.11.2.tar.gz", hash = "sha256:7b7e771d3384d0e247d0d6aef31b0cb589f92305b7e975e70056a513525906e7"}, {file = "django_allauth-65.12.0.tar.gz", hash = "sha256:a76ec55935354a1455753601a0a814a4ded368242e8969323480a2810b349183"},
] ]
[package.dependencies] [package.dependencies]
@@ -436,7 +436,7 @@ asgiref = ">=3.8.1"
Django = ">=4.2.16" Django = ">=4.2.16"
oauthlib = {version = ">=3.3.0,<4", optional = true, markers = "extra == \"socialaccount\""} oauthlib = {version = ">=3.3.0,<4", optional = true, markers = "extra == \"socialaccount\""}
pyjwt = {version = ">=2.0,<3", extras = ["crypto"], optional = true, markers = "extra == \"socialaccount\""} pyjwt = {version = ">=2.0,<3", extras = ["crypto"], optional = true, markers = "extra == \"socialaccount\""}
python3-openid = {version = ">=3.0.8,<4", optional = true, markers = "extra == \"steam\""} python3-openid = {version = ">=3.0.8,<4", optional = true, markers = "extra == \"openid\" or extra == \"steam\""}
requests = {version = ">=2.0.0,<3", optional = true, markers = "extra == \"socialaccount\""} requests = {version = ">=2.0.0,<3", optional = true, markers = "extra == \"socialaccount\""}
[package.extras] [package.extras]
@@ -1084,4 +1084,4 @@ testing = ["coverage[toml]", "zope.event", "zope.testing"]
[metadata] [metadata]
lock-version = "2.1" lock-version = "2.1"
python-versions = ">=3.12,<3.14" python-versions = ">=3.12,<3.14"
content-hash = "cdc572d2076797697db50f74bfecc2a67620b6a7bcc8eb3a799e816848c0c261" content-hash = "98e621f617ddd42f730009c747e8e771e95e2a5260bcca3409e6f0edbcef6b17"

View File

@@ -10,7 +10,7 @@ dependencies = [
"django-extensions (>=4.1,<5.0)", "django-extensions (>=4.1,<5.0)",
"django-widget-tweaks (>=1.5.0,<2.0.0)", "django-widget-tweaks (>=1.5.0,<2.0.0)",
"django-environ (>=0.12.0,<0.13.0)", "django-environ (>=0.12.0,<0.13.0)",
"django-allauth[socialaccount,steam] (>=65.11.2,<66.0.0)", "django-allauth[oauth2,openid,saml2,socialaccount,steam] (>=65.12.0,<66.0.0)",
"django-browser-reload (>=1.19.0,<2.0.0)", "django-browser-reload (>=1.19.0,<2.0.0)",
"pillow (>=11.3.0,<12.0.0)", "pillow (>=11.3.0,<12.0.0)",
"bbcode (>=1.1.0,<2.0.0)", "bbcode (>=1.1.0,<2.0.0)",

View File

@@ -1,4 +1,3 @@
from curses.ascii import isalpha
from django.shortcuts import render from django.shortcuts import render
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.urls import reverse from django.urls import reverse
@@ -6,7 +5,7 @@ from django.urls import reverse
from django_project.settings import STATIC_URL from django_project.settings import STATIC_URL
from tinywiki import settings from tinywiki import settings
from .base import View from .base import View
from django.http import HttpRequest,HttpResponse from django.http import HttpRequest, HttpResponse
from django.db.models.functions import Lower from django.db.models.functions import Lower
import string import string
from ..models import Page from ..models import Page
@@ -17,15 +16,15 @@ from django.utils.translation import ngettext, gettext as _
class HomeView(View): class HomeView(View):
template_name = "tinywiki/home/home.html" template_name = "tinywiki/home/home.html"
def get(self,request): def get(self,request):
try: try:
page = Page.objects.get(slug='tw-home') page = Page.objects.get(slug='tw-home')
if (not Page.status == WikiPageStatus.PUBLISHED if (not Page.status == WikiPageStatus.PUBLISHED
and not request.user.is_staff and not request.user.is_staff
and not request.user.has_perm('page.view-all')): and not request.user.has_perm('page.view-all')):
page = None page = None
except Page.DoesNotExist: except Page.DoesNotExist:
page = None page = None
if self.user_can_create_system_pages: if self.user_can_create_system_pages:
@@ -35,7 +34,7 @@ class HomeView(View):
create_tw_home = f"<a href={reverse("tinywiki:page",kwargs={'slug':'tw-home'})}>{_('create a new page with the slug <i>tw-home</i>')}</a>" create_tw_home = f"<a href={reverse("tinywiki:page",kwargs={'slug':'tw-home'})}>{_('create a new page with the slug <i>tw-home</i>')}</a>"
else: else:
create_tw_home = "create a new page with the slug <i>tw-home</i>" create_tw_home = "create a new page with the slug <i>tw-home</i>"
if settings.USE_BOOTSTRAP: if settings.USE_BOOTSTRAP:
markdown_guide = f"<a class=\"icon-link icon-link-hover\" href={reverse('tinywiki:page',kwargs={'slug':'tw-markdown'})}>{_('Guide for markdown used by TinyWiki')}<svg class=\"bi\"><use xlink:href=\"{settings.settings.STATIC_URL + 'tinywiki/icons/bootstrap-icons.svg' }#journal\"></use></svg></a>" markdown_guide = f"<a class=\"icon-link icon-link-hover\" href={reverse('tinywiki:page',kwargs={'slug':'tw-markdown'})}>{_('Guide for markdown used by TinyWiki')}<svg class=\"bi\"><use xlink:href=\"{settings.settings.STATIC_URL + 'tinywiki/icons/bootstrap-icons.svg' }#journal\"></use></svg></a>"
bbcode_guide = f"<a class=\"icon-link icon-link-hover\" href={reverse('tinywiki:page',kwargs={'slug':'tw-bbcode'})}>{_('Guide for BBCode used by TinyWiki')}<svg class=\"bi\"><use xlink:href=\"{settings.settings.STATIC_URL + 'tinywiki/icons/bootstrap-icons.svg' }#journal\"></use></svg></a>" bbcode_guide = f"<a class=\"icon-link icon-link-hover\" href={reverse('tinywiki:page',kwargs={'slug':'tw-bbcode'})}>{_('Guide for BBCode used by TinyWiki')}<svg class=\"bi\"><use xlink:href=\"{settings.settings.STATIC_URL + 'tinywiki/icons/bootstrap-icons.svg' }#journal\"></use></svg></a>"
@@ -53,26 +52,26 @@ class HomeView(View):
class TocView(View): class TocView(View):
template_name = "tinywiki/home/wiki-content.html" template_name = "tinywiki/home/wiki-content.html"
bs_template_name = "tinywiki/home/bs-wiki-content.html" bs_template_name = "tinywiki/home/bs-wiki-content.html"
@classmethod @classmethod
def get_template_name(cls): def get_template_name(cls):
if settings.USE_BOOTSTRAP: if settings.USE_BOOTSTRAP:
return cls.bs_template_name return cls.bs_template_name
return cls.template_name return cls.template_name
def get(self,request): def get(self,request):
def mkdict(page:Page): def mkdict(page:Page):
return {'slug':page.slug,'title':page.title, 'is_system':page.slug.startswith('tw-')} return {'slug':page.slug,'title':page.title, 'is_system':page.slug.startswith('tw-')}
user = self.request.user user = self.request.user
if (user.is_staff or user.has_perm('page.read_all')): if (user.is_staff or user.has_perm('page.read_all')):
pages = Page.objects.all() pages = Page.objects.all()
else: else:
pages = Page.objects.filter(status_data=WikiPageStatus.PUBLISHED.value) pages = Page.objects.filter(status_data=WikiPageStatus.PUBLISHED.value)
toc_mapping = {} toc_mapping = {}
for page in pages: for page in pages:
first_char = page.title.lstrip()[0].upper() first_char = page.title.lstrip()[0].upper()
if first_char.isdigit(): if first_char.isdigit():
@@ -90,8 +89,8 @@ class TocView(View):
toc_mapping[first_char] = [mkdict(page)] toc_mapping[first_char] = [mkdict(page)]
else: else:
toc_mapping[first_char].append(mkdict(page)) toc_mapping[first_char].append(mkdict(page))
toc = [] toc = []
for key in sorted(toc_mapping.keys()): for key in sorted(toc_mapping.keys()):
toc_entries = toc_mapping[key] toc_entries = toc_mapping[key]
count = len(toc_mapping[key]) count = len(toc_mapping[key])
@@ -101,19 +100,19 @@ class TocView(View):
pages_1 = [] pages_1 = []
else: else:
pages_1 = toc_entries[split:] pages_1 = toc_entries[split:]
if (key.startswith('0') or key == '#'): if (key.startswith('0') or key == '#'):
toc_section = key toc_section = key
else: else:
toc_section = f"{key}..." toc_section = f"{key}..."
toc_section = ngettext("{toc_section} ({n} page)","{toc_section} ({n} pages)", count).format( toc_section = ngettext("{toc_section} ({n} page)","{toc_section} ({n} pages)", count).format(
toc_section=toc_section, toc_section=toc_section,
n=count, n=count,
) )
toc.append((toc_section,pages_0,pages_1)) toc.append((toc_section,pages_0,pages_1))
return render(request, return render(request,
self.get_template_name(), self.get_template_name(),
self.get_context_data(toc=toc,subtitle=_("Table of Contents"))) self.get_context_data(toc=toc,subtitle=_("Table of Contents")))