diff --git a/apps/custom_djangocms_blog_feed/__init__.py b/apps/custom_djangocms_blog_feed/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/apps/custom_djangocms_blog_feed/apps.py b/apps/custom_djangocms_blog_feed/apps.py new file mode 100644 index 000000000..d9280a921 --- /dev/null +++ b/apps/custom_djangocms_blog_feed/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig +from django.utils.translation import gettext_lazy as _ + +class djangoCMSBlogFeedAppConfig(AppConfig): + name = 'apps.custom_djangocms_blog_feed' diff --git a/apps/custom_djangocms_blog_feed/feeds.py b/apps/custom_djangocms_blog_feed/feeds.py new file mode 100644 index 000000000..a1d008ece --- /dev/null +++ b/apps/custom_djangocms_blog_feed/feeds.py @@ -0,0 +1,26 @@ +from aldryn_apphooks_config.utils import get_app_instance +from django.utils.feedgenerator import Rss201rev2Feed + +from djangocms_blog.feeds import LatestEntriesFeed as DjangoCMSBlogLatestEntriesFeed +from djangocms_blog.settings import get_setting +from djangocms_blog.cms_appconfig import BlogConfig + +# XXX: This file is loaded, but it does NOT override the feed +# XXX: Logging via logger fails anywhere; via print fails inside any method +class LatestEntriesFeed(DjangoCMSBlogLatestEntriesFeed): + feed_type = Rss201rev2Feed + feed_items_number = get_setting("FEED_LATEST_ITEMS") + + def __call__(self, request, *args, **kwargs): + namespace = get_setting("AUTO_NAMESPACE") + + self.request = request + self.namespace = get_setting("AUTO_NAMESPACE") + self.config = BlogConfig.objects.get(namespace=namespace) + + return super().__call__(request, *args, **kwargs) + + def items(self): + items = super().items() + + return items diff --git a/apps/custom_djangocms_blog_feed/urls.py b/apps/custom_djangocms_blog_feed/urls.py new file mode 100644 index 000000000..e2a846661 --- /dev/null +++ b/apps/custom_djangocms_blog_feed/urls.py @@ -0,0 +1,17 @@ +from django.urls import path + +from .feeds import LatestEntriesFeed + +# from apps.custom_example.views import CustomExampleView + +app_name = 'custom_djangocms_blog_feed' +urlpatterns = [ + # To render styled Blog feed + # XXX: Does NOT load page + # XXX: Does NOT style the feed + # XXX: Does NOT customize the feed + # FAQ: See errors at `/blog/feed/`, items at `/blog/feed/fb` + # FAQ: See Blog app feed root at `/news/feed/`, items at `/news/feed/fb` + path('feed/', LatestEntriesFeed(), name='feed'), + # path('feed/', CustomExampleView, name='feed'), +] diff --git a/taccsite_cms/custom_app_settings.example.py b/taccsite_cms/custom_app_settings.example.py index 3ac04c50d..257edd8e5 100644 --- a/taccsite_cms/custom_app_settings.example.py +++ b/taccsite_cms/custom_app_settings.example.py @@ -1,3 +1,3 @@ -CUSTOM_APPS = ['apps.custom_example'] +CUSTOM_APPS = ['apps.custom_example', 'apps.custom_djangocms_blog_feed'] CUSTOM_MIDDLEWARE = [] STATICFILES_DIRS = () diff --git a/taccsite_cms/urls_custom.example.py b/taccsite_cms/urls_custom.example.py index d7b3795e4..3d8b0d08a 100644 --- a/taccsite_cms/urls_custom.example.py +++ b/taccsite_cms/urls_custom.example.py @@ -1,5 +1,5 @@ -from django.urls import path, include +from django.urls import re_path, include custom_urls = [ - path('custom_test/', include('apps.custom_example.urls', namespace='custom_test')), + re_path(r'^custom_test/', include('apps.custom_example.urls', namespace='custom_test')), ]