Compare commits
3 commits
94482f1696
...
1b3a2dec72
Author | SHA1 | Date | |
---|---|---|---|
1b3a2dec72 | |||
310fd5ed7a | |||
e98db55a16 |
5 changed files with 70 additions and 11 deletions
|
@ -5,6 +5,7 @@ from django.db import models
|
||||||
from modelcluster.fields import ParentalKey, ParentalManyToManyField
|
from modelcluster.fields import ParentalKey, ParentalManyToManyField
|
||||||
from modelcluster.contrib.taggit import ClusterTaggableManager
|
from modelcluster.contrib.taggit import ClusterTaggableManager
|
||||||
from taggit.models import TaggedItemBase
|
from taggit.models import TaggedItemBase
|
||||||
|
from wagtail.api import APIField
|
||||||
|
|
||||||
from wagtail.models import Page, Orderable
|
from wagtail.models import Page, Orderable
|
||||||
from wagtail.fields import RichTextField, StreamField
|
from wagtail.fields import RichTextField, StreamField
|
||||||
|
@ -74,6 +75,13 @@ class BlogPage(SeoMixin, Page):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# Export fields over the API
|
||||||
|
api_fields = [
|
||||||
|
APIField('gallery_images'),
|
||||||
|
APIField('body'),
|
||||||
|
APIField('intro'),
|
||||||
|
APIField('tags'),
|
||||||
|
]
|
||||||
search_fields = Page.search_fields + [
|
search_fields = Page.search_fields + [
|
||||||
index.SearchField('intro'),
|
index.SearchField('intro'),
|
||||||
index.SearchField('body'),
|
index.SearchField('body'),
|
||||||
|
@ -122,6 +130,9 @@ class BlogPageGalleryImage(Orderable):
|
||||||
FieldPanel('image'),
|
FieldPanel('image'),
|
||||||
FieldPanel('caption'),
|
FieldPanel('caption'),
|
||||||
]
|
]
|
||||||
|
api_fields = [
|
||||||
|
APIField('image'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@register_snippet
|
@register_snippet
|
||||||
|
|
15
iamkonstantin_web/api.py
Normal file
15
iamkonstantin_web/api.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from wagtail.api.v2.views import PagesAPIViewSet
|
||||||
|
from wagtail.api.v2.router import WagtailAPIRouter
|
||||||
|
from wagtail.images.api.v2.views import ImagesAPIViewSet
|
||||||
|
from wagtail.documents.api.v2.views import DocumentsAPIViewSet
|
||||||
|
|
||||||
|
# Create the router. "wagtailapi" is the URL namespace
|
||||||
|
api_router = WagtailAPIRouter('wagtailapi')
|
||||||
|
|
||||||
|
# Add the three endpoints using the "register_endpoint" method.
|
||||||
|
# The first parameter is the name of the endpoint (such as pages, images). This
|
||||||
|
# is used in the URL of the endpoint
|
||||||
|
# The second parameter is the endpoint class that handles the requests
|
||||||
|
api_router.register_endpoint('pages', PagesAPIViewSet)
|
||||||
|
api_router.register_endpoint('images', ImagesAPIViewSet)
|
||||||
|
api_router.register_endpoint('documents', DocumentsAPIViewSet)
|
|
@ -35,6 +35,7 @@ INSTALLED_APPS = [
|
||||||
"wagtail.contrib.settings",
|
"wagtail.contrib.settings",
|
||||||
"wagtail.contrib.forms",
|
"wagtail.contrib.forms",
|
||||||
"wagtail.contrib.redirects",
|
"wagtail.contrib.redirects",
|
||||||
|
"wagtail.contrib.simple_translation",
|
||||||
"wagtail.embeds",
|
"wagtail.embeds",
|
||||||
"wagtail.sites",
|
"wagtail.sites",
|
||||||
"wagtail.users",
|
"wagtail.users",
|
||||||
|
@ -43,6 +44,9 @@ INSTALLED_APPS = [
|
||||||
"wagtail.images",
|
"wagtail.images",
|
||||||
"wagtail.search",
|
"wagtail.search",
|
||||||
"wagtail.admin",
|
"wagtail.admin",
|
||||||
|
"wagtail.locales",
|
||||||
|
"wagtail.api.v2",
|
||||||
|
"rest_framework",
|
||||||
"wagtail",
|
"wagtail",
|
||||||
"modelcluster",
|
"modelcluster",
|
||||||
"taggit",
|
"taggit",
|
||||||
|
@ -68,6 +72,7 @@ MIDDLEWARE = [
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"django.middleware.security.SecurityMiddleware",
|
||||||
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
"wagtail.contrib.redirects.middleware.RedirectMiddleware",
|
||||||
"blog.middleware.BlogRedirectMiddleware",
|
"blog.middleware.BlogRedirectMiddleware",
|
||||||
|
"django.middleware.locale.LocaleMiddleware",
|
||||||
"django_browser_reload.middleware.BrowserReloadMiddleware"
|
"django_browser_reload.middleware.BrowserReloadMiddleware"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -128,7 +133,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/5.0/topics/i18n/
|
# https://docs.djangoproject.com/en/5.0/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = "en-us"
|
LANGUAGE_CODE = "en"
|
||||||
|
|
||||||
TIME_ZONE = "UTC"
|
TIME_ZONE = "UTC"
|
||||||
|
|
||||||
|
@ -136,6 +141,18 @@ USE_I18N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
WAGTAIL_I18N_ENABLED = True
|
||||||
|
|
||||||
|
USE_L10N = True # allows dates to be shown in the user's locale
|
||||||
|
|
||||||
|
WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
|
||||||
|
('en', "English"),
|
||||||
|
('fr', "French"),
|
||||||
|
('es', "Spanish"),
|
||||||
|
('nl', "Dutch"),
|
||||||
|
]
|
||||||
|
|
||||||
|
WAGTAILSIMPLETRANSLATION_SYNC_PAGE_TREE = True
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
# https://docs.djangoproject.com/en/5.0/howto/static-files/
|
||||||
|
@ -186,6 +203,9 @@ WAGTAILSEARCH_BACKENDS = {
|
||||||
# Base URL to use when referring to full URLs within the Wagtail admin backend -
|
# Base URL to use when referring to full URLs within the Wagtail admin backend -
|
||||||
# e.g. in notification emails. Don't include '/admin' or a trailing slash
|
# e.g. in notification emails. Don't include '/admin' or a trailing slash
|
||||||
WAGTAILADMIN_BASE_URL = "https://iamkonstantin.eu"
|
WAGTAILADMIN_BASE_URL = "https://iamkonstantin.eu"
|
||||||
|
WAGTAILAPI_BASE_URL = "https://iamkonstantin.eu"
|
||||||
|
|
||||||
|
WAGTAILAPI_SEARCH_ENABLED = True
|
||||||
|
|
||||||
WAGTAIL_CODE_BLOCK_LANGUAGES = (
|
WAGTAIL_CODE_BLOCK_LANGUAGES = (
|
||||||
('bash', 'Bash/Shell'),
|
('bash', 'Bash/Shell'),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.conf.urls.i18n import i18n_patterns
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
|
@ -8,6 +9,7 @@ from wagtail import urls as wagtail_urls
|
||||||
from wagtail.documents import urls as wagtaildocs_urls
|
from wagtail.documents import urls as wagtaildocs_urls
|
||||||
|
|
||||||
from blog.feeds import RssBlogFeed
|
from blog.feeds import RssBlogFeed
|
||||||
|
from iamkonstantin_web.api import api_router
|
||||||
from newsletter import views as newsletter_views
|
from newsletter import views as newsletter_views
|
||||||
from search import views as search_views
|
from search import views as search_views
|
||||||
from wagtail.contrib.sitemaps.views import sitemap
|
from wagtail.contrib.sitemaps.views import sitemap
|
||||||
|
@ -25,6 +27,17 @@ urlpatterns = [
|
||||||
path('newsletter/thanks', newsletter_views.thanks, name='thanks')
|
path('newsletter/thanks', newsletter_views.thanks, name='thanks')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
urlpatterns += [
|
||||||
|
path('api/v2/', api_router.urls),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Translatable URLs
|
||||||
|
# These will be available under a language code prefix. For example /en/search/
|
||||||
|
urlpatterns += i18n_patterns(
|
||||||
|
path("", include(wagtail_urls)),
|
||||||
|
prefix_default_language=False,
|
||||||
|
)
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
|
@ -34,12 +47,12 @@ if settings.DEBUG:
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
urlpatterns += path("__reload__/", include("django_browser_reload.urls")),
|
urlpatterns += path("__reload__/", include("django_browser_reload.urls")),
|
||||||
|
|
||||||
urlpatterns = urlpatterns + [
|
# urlpatterns = urlpatterns + [
|
||||||
# For anything not caught by a more specific rule above, hand over to
|
# # For anything not caught by a more specific rule above, hand over to
|
||||||
# Wagtail's page serving mechanism. This should be the last pattern in
|
# # Wagtail's page serving mechanism. This should be the last pattern in
|
||||||
# the list:
|
# # the list:
|
||||||
path("", include(wagtail_urls)),
|
# path("", include(wagtail_urls)),
|
||||||
# Alternatively, if you want Wagtail pages to be served from a subpath
|
# # Alternatively, if you want Wagtail pages to be served from a subpath
|
||||||
# of your site, rather than the site root:
|
# # of your site, rather than the site root:
|
||||||
# path("pages/", include(wagtail_urls)),
|
# # path("pages/", include(wagtail_urls)),
|
||||||
]
|
# ]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Django>=4.2,<5.2
|
Django>=4.2,<5.2
|
||||||
wagtail>=6.3,<6.4
|
wagtail>=6.3.1,<6.4
|
||||||
whitenoise>=6.6,<7.0
|
whitenoise>=6.6,<7.0
|
||||||
wagtailcodeblock>=1.29.0.2,<2.0
|
wagtailcodeblock>=1.29.0.2,<2.0
|
||||||
django-tailwind>=3.6.0
|
django-tailwind>=3.6.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue