Skip to content

Commit

Permalink
Move ipv6 day logic into function for tera compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Sep 16, 2024
1 parent 7b443f3 commit e921db7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion repologyapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from repologyapp.config import config
from repologyapp.globals import repometadata
from repologyapp.template_filters import css_for_versionclass, extract_netloc, maintainer_to_links, maintainers_to_group_mailto
from repologyapp.template_functions import endpoint_like, url_for, url_for_self, url_for_static
from repologyapp.template_functions import endpoint_like, needs_ipv6_notice, url_for, url_for_self, url_for_static
from repologyapp.template_tests import for_page, has_flag, has_flag_at, is_fallback_maintainer
from repologyapp.views import registry as view_registry

Expand Down Expand Up @@ -63,6 +63,7 @@
app.jinja_env.globals['url_for'] = url_for
app.jinja_env.globals['url_for_self'] = url_for_self
app.jinja_env.globals['url_for_static'] = url_for_static
app.jinja_env.globals['needs_ipv6_notice'] = needs_ipv6_notice

# templates: custom global data
app.jinja_env.globals['REPOLOGY_HOME'] = config['REPOLOGY_HOME']
Expand Down
6 changes: 6 additions & 0 deletions repologyapp/template_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with repology. If not, see <http://www.gnu.org/licenses/>.

import datetime
from typing import Any

import flask
Expand Down Expand Up @@ -62,3 +63,8 @@ def endpoint_like(*variants: str) -> bool:
return True

return False


def needs_ipv6_notice(*variants: str) -> bool:
now = datetime.datetime.now()
return now.month == 6 and now.day == 6 and ':' not in flask.request.environ.REMOTE_ADDR and flask.request.endpoint != 'index'
2 changes: 1 addition & 1 deletion repologyapp/templates/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</head>
<body>

{% if now().month == 6 and now().day == 6 and ':' not in request.environ.REMOTE_ADDR and request.endpoint != 'index' %}
{% if needs_ipv6_notice() %}
<div class="site-alert-outer">
<div class="container site-alert-inner">
<img src="{{ url_for_static(file="ipv6.v1.svg") }}" alt="IPv6 logo" height="64">
Expand Down

0 comments on commit e921db7

Please sign in to comment.