Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Maják
Commits
6f0af6dd
Commit
6f0af6dd
authored
2 years ago
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
finished rss feed
parent
93af939f
Branches
Branches containing commit
No related tags found
2 merge requests
!690
Release
,
!689
Add RSS feed to main website
Pipeline
#10942
passed
2 years ago
Stage: build
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
main/feeds.py
+38
-23
38 additions, 23 deletions
main/feeds.py
main/models.py
+8
-1
8 additions, 1 deletion
main/models.py
main/templates/main/feed_item_description.html
+2
-0
2 additions, 0 deletions
main/templates/main/feed_item_description.html
main/urls.py
+0
-7
0 additions, 7 deletions
main/urls.py
with
48 additions
and
31 deletions
main/feeds.py
+
38
−
23
View file @
6f0af6dd
from
datetime
import
datetime
from
django.contrib.syndication.views
import
Feed
from
django.
shortcuts
import
render
from
django.
template.loader
import
render
_to_string
from
django.urls
import
reverse
from
main.models
import
MainArticlesPage
,
MainArticlePage
from
.models
import
MainArticlesPage
,
MainArticlePage
class
LatestArticlesFeed
(
Feed
):
def
get_object
(
self
:
LatestArticlesFeed
,
self
,
request
,
title
:
str
id
:
int
)
->
MainArticlesPage
:
return
MainArticlesPage
.
objects
.
get
(
title
=
title
)
return
MainArticlesPage
.
objects
.
get
(
id
=
id
)
def
title
(
self
:
LatestArticlesFeed
,
self
,
obj
:
MainArticlesPage
)
->
str
:
return
obj
.
title
def
link
(
self
:
LatestArticlesFeed
,
self
,
obj
:
MainArticlesPage
)
->
str
:
return
obj
.
get_full_url
()
def
description
(
self
:
LatestArticlesFeed
,
self
,
obj
:
MainArticlesPage
)
->
str
:
return
obj
.
perex
def
items
(
self
:
LatestArticlesFeed
,
self
,
obj
:
MainArticlesPage
)
->
list
:
return
obj
.
get_children
().
type
(
MainArticlePage
)[:
32
]
return
MainArticlePage
.
objects
.
live
().
child_of
(
obj
)[:
32
]
def
item_title
(
self
:
LatestArticlesFeed
,
obj
:
MainArticlePage
self
,
item
:
MainArticlePage
)
->
str
:
return
obj
.
title
return
item
.
title
def
item_description
(
self
:
LatestArticlesFeed
,
self
,
item
:
MainArticlePage
):
return
render
(
None
,
)
->
str
:
return
render_to_string
(
"
main/feed_item_description.html
"
,
{
"
item
"
:
item
},
)
def
item_pubdate
(
self
:
LatestArticlesFeed
,
self
,
item
:
MainArticlePage
):
)
->
datetime
:
return
item
.
first_published_at
def
item_updateddate
(
self
:
LatestArticlesFeed
,
self
,
item
:
MainArticlePage
):
)
->
datetime
:
return
item
.
last_published_at
def
item_author_name
(
self
,
item
:
MainArticlePage
)
->
str
:
if
item
.
author
:
return
item
.
author
if
item
.
author_page
.
title
:
return
item_author_page
.
title
return
""
def
item_categories
(
self
:
LatestArticlesFeed
,
self
,
item
:
MainArticlePage
)
->
list
:
return
item
.
tags
.
all
()
def
item_link
(
self
:
LatestArticlesFeed
,
self
,
item
:
MainArticlePage
)
->
str
:
return
item
.
get_full_url
()
This diff is collapsed.
Click to expand it.
main/models.py
+
8
−
1
View file @
6f0af6dd
...
...
@@ -4,7 +4,7 @@ from dateutil.relativedelta import relativedelta
from
django.conf
import
settings
from
django.core.paginator
import
Paginator
from
django.db
import
models
from
django.http
import
HttpResponseRedirect
,
JsonResponse
from
django.http
import
HttpResponseRedirect
,
HttpResponse
,
JsonResponse
from
django.shortcuts
import
render
from
django.utils
import
timezone
from
modelcluster.contrib.taggit
import
ClusterTaggableManager
...
...
@@ -301,6 +301,13 @@ class MainHomePage(
return
HttpResponseRedirect
(
self
.
url
)
return
HttpResponseRedirect
(
self
.
url
)
@route
(
r
"
^feeds/atom/$
"
)
def
view_feed
(
self
,
request
):
# Avoid circular import
from
.feeds
import
LatestArticlesFeed
# noqa
return
LatestArticlesFeed
()(
request
,
self
.
articles_page
.
id
)
def
_first_subpage_of_type
(
self
,
page_type
)
->
Page
or
None
:
try
:
return
self
.
get_descendants
().
type
(
page_type
).
live
().
specific
()[
0
]
...
...
This diff is collapsed.
Click to expand it.
main/templates/main/feed_item_description.html
+
2
−
0
View file @
6f0af6dd
{% load wagtailcore_tags %}
{% for block in item.content %}
{% include_block block %}
{% endfor %}
This diff is collapsed.
Click to expand it.
main/urls.py
deleted
100644 → 0
+
0
−
7
View file @
93af939f
from
django.urls
import
path
from
main.feeds
import
LatestArticlesFeed
urlpatterns
=
[
path
(
'
feed
'
,
LatestArticlesFeed
()),
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment