Skip to content

Commit

Permalink
Add source parameter to RSS and Atom feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Nov 11, 2024
1 parent 3b7b5c5 commit f007e35
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
7 changes: 5 additions & 2 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<meta name="tna.app.build-version" content="{{ app_config.BUILD_VERSION }}">
<meta name="tna.settings.theme" content="{{ theme }}">
<meta name="tna.page.route" content="{{ request.url_rule }}">
{% if request.args.get('source') %}
<meta name="tna.source" content="{{ request.args.get('source') }}">
{% endif %}
{% endblock %}

{% block stylesheets %}
Expand All @@ -52,9 +55,9 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans:[email protected]&family=Roboto+Mono:[email protected]&display=swap" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='font-awesome.css', v=app_config.BUILD_VERSION) }}" media="screen,print">
<link rel="stylesheet" href="{{ url_for('static', filename='ie.css', v=app_config.BUILD_VERSION) }}" media="all and (-ms-high-contrast: none), (-ms-high-contrast: active)">
{%- if feature.LOGO_ADORNMENTS_CSS %}
{% if feature.LOGO_ADORNMENTS_CSS %}
<link rel="stylesheet" href="{{ feature.LOGO_ADORNMENTS_CSS }}?date={{ now_iso_8601_no_time() }}" media="screen">
{%- endif %}
{% endif %}
{% endblock %}

{% block cookies %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/blog/atom_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<logo>{{ blog_post.teaser_image.jpeg.full_url }}</logo>
<icon>{{ blog_post.teaser_image.jpeg.full_url }}</icon>
{% endif %} #}
<id>{{ url_for('wagtail.page_permalink', page_id=blog_post.id, _external=True, _scheme='https') }}</id>
<id>{{ url_for('wagtail.page_permalink', page_id=blog_post.id, source='atom', _external=True, _scheme='https') }}</id>
<summary>{{ blog_post.teaser_text }}</summary>
{% if blog_post.authors %}
{% for author in blog_post.authors %}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/blog/rss_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<![CDATA[ {{ blog_post.teaser_text }} ]]>
</description>
<link>{{ blog_post.full_url }}</link>
<guid isPermaLink="true">{{ url_for('wagtail.page_permalink', page_id=blog_post.id, _external=True, _scheme='https') }}</guid>
<guid isPermaLink="true">{{ url_for('wagtail.page_permalink', page_id=blog_post.id, source='rss', _external=True, _scheme='https') }}</guid>
{% if blog_post.authors %}
<dc:creator>
<![CDATA[ {% for author in blog_post.authors -%}
Expand Down
26 changes: 13 additions & 13 deletions app/templates/macros/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
<meta name="twitter:card" content="summary">
{% if title %}
<meta property="og:title" content="{{ title }}">
{% endif %}
{%- endif %}
{% if page_data.meta and page_data.meta.twitter_og_title %}
<meta name="twitter:title" content="{{ page_data.meta.twitter_og_title }}">
{% endif %}
{%- endif %}

{% if description %}
<meta name="description" content="{{ description }}">
<meta property="og:description" content="{{ description }}">
{% endif %}
{%- endif %}
{% if page_data.meta and page_data.meta.twitter_og_description %}
<meta name="twitter:description" content="{{ page_data.meta.twitter_og_description }}">
{% endif %}
{%- endif %}

{% if url %}
<meta property="og:url" content="{{ url }}">
{% endif %}
{%- endif %}

{%- set og_image = None %}
{% if page_data.meta and page_data.meta.facebook_og_image %}
Expand All @@ -45,14 +45,14 @@
'height': page_data.meta.teaser_image.jpeg.height,
'type': 'image/jpeg'
} %}
{% endif %}
{%- endif %}

{% if og_image %}
<meta property="og:image" content="{{ og_image.src }}">
<meta property="og:image:width" content="{{ og_image.width }}">
<meta property="og:image:height" content="{{ og_image.height }}">
<meta property="og:image:type" content="{{ og_image.type }}">
{% endif %}
{%- endif %}

{%- set og_image_twitter = None %}
{% if page_data.meta and page_data.meta.twitter_og_image %}
Expand All @@ -65,26 +65,26 @@
{% set og_image_twitter = {
'src': page_data.meta.teaser_image.jpeg.full_url
} %}
{% endif %}
{%- endif %}
{% if og_image_twitter %}
<meta name="twitter:image" content="{{ og_image_twitter.src }}">
{% endif %}
{%- endif %}

{% if page_data.id %}
<meta name="tna.page.wagtail.id" content="{{ page_data.id }}">
{% endif %}
{%- endif %}

{% if page_data.title %}
<meta name="tna.page.title" content="{{ page_data.title }}">
{% endif %}
{%- endif %}

{% if page_data.meta and page_data.meta.type %}
<meta name="tna.page.wagtail.type" content="{{ page_data.meta.type }}">
<meta name="page_type" content="{{ page_data.meta.type.split('.')[1] }}">
{% endif %}
{%- endif %}

{% if page_data.tags and page_data.tags | length %}
<meta name="tna.page.tags" content="{{ page_data.tags | join('; ') }}">
<meta name="taxonom_tags" content="{{ page_data.tags | join('; ') }}">
{% endif %}
{%- endif %}
{% endmacro %}
1 change: 1 addition & 0 deletions app/wagtail/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def page_permalink(page_id):
url_for(
"wagtail.page",
path=page_data["meta"]["url"].strip("/"),
**request.args.to_dict(),
),
code=302,
)
Expand Down

0 comments on commit f007e35

Please sign in to comment.