Skip to content

Commit

Permalink
Merge pull request #177 from AaronC81/social-redirects
Browse files Browse the repository at this point in the history
Add redirects for Slack, newsletter, and Discord
  • Loading branch information
AaronC81 authored Sep 27, 2021
2 parents 72eeca3 + 8511b20 commit afa8685
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/creating_modifying_complex_pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ Page redirects are implemented by setting the `redirect` variable. Note that if
{% set redirect="/coc.html" %}
```

Some pages in the site, such as `newsletter.html`, are provided as redirects which we can print on posters or other media. These aren't linked to within the site itself, so we must tell the freezer about them. If you add a page like this, you should also add its relative link to the list in the `get_redirect_page_routes` function of `freeze.py`.



[jinjadocs]: https://jinja.palletsprojects.com/en/3.0.x/templates/ "Template designer documentation - Jinja Documentation (3.0.x)"
Expand Down
18 changes: 18 additions & 0 deletions hacksoc_org/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ def get_server_page_routes() -> Generator[str, None, None]:
# see `get_static_routes`


@freezer.register_generator
def get_redirect_page_routes() -> Generator[str, None, None]:
"""Yields URL routes for pages which exist solely to redirect. We use these similarly to a URL
shortener, providing nicer URLs to print or distribute.
This generator wouldn't be necessary if we used these links from our About pages, but that
would add an unnecessary redirect in the middle when coming from those pages.
Yields:
Generator[str, None, None]: URL routes
"""
yield from [
"/newsletter.html",
"/slack.html",
"/discord.html"
]


def freeze():
"""this seemingly useless method is used to provide a stable API if the freeze provider changes
in the future
Expand Down
3 changes: 3 additions & 0 deletions templates/content/discord.html.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% extends "base.html.jinja2" %}

{% set redirect="https://discord.com/invite/cb3XweNhYs" %}
3 changes: 3 additions & 0 deletions templates/content/newsletter.html.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% extends "base.html.jinja2" %}

{% set redirect=mailing_list_signup %}
3 changes: 3 additions & 0 deletions templates/content/slack.html.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% extends "base.html.jinja2" %}

{% set redirect="https://hacksoc-york.slack.com/signup" %}

0 comments on commit afa8685

Please sign in to comment.