Commit 97fdc4aa authored by shadMod's avatar shadMod 💬

added dynamic news in Home Page

parent da85d408
Pipeline #355 passed with stage
in 0 seconds
...@@ -75,14 +75,20 @@ def prepare_blueprint(app): ...@@ -75,14 +75,20 @@ def prepare_blueprint(app):
""" """
Prepare a blueprint with all the pages Prepare a blueprint with all the pages
""" """
bp = flask.Blueprint("pages", __name__) bp = flask.Blueprint("pages", __name__)
data_path = os.path.expanduser(os.path.abspath("data")) data_path = os.path.expanduser(os.path.abspath("data"))
path = os.path.join(data_path, "downloads.toml")
distros = toml.load(path)['distros'] def list_news():
distros.pop('desktop') news_path = os.path.join(data_path, "news", "2023")
distros.pop('live-server') _list_news = [x.replace('.md', '') for x in os.listdir(news_path)[:4]]
return _list_news
def list_distro():
path = os.path.join(data_path, "downloads.toml")
distros = toml.load(path)['distros']
distros.pop('desktop')
distros.pop('live-server')
return distros
# Dynamically generate all the pages # Dynamically generate all the pages
for url, tmpl in get_pages_list(app).items(): for url, tmpl in get_pages_list(app).items():
...@@ -93,7 +99,8 @@ def prepare_blueprint(app): ...@@ -93,7 +99,8 @@ def prepare_blueprint(app):
def _(_tmpl=tmpl): def _(_tmpl=tmpl):
return flask.render_template( return flask.render_template(
_tmpl, _tmpl,
distros=distros news=list_news(),
distros=list_distro()
) )
return bp return bp
{# Source code of the Ubuntu-it website {# Source code of the Ubuntu-it website
# Copyright (C) 2015 Pietro Albini <pietroalbini@ubuntu.com> # Copyright (C) 2015 Pietro Albini <pietroalbini@ubuntu.com>
# Copyright (C) 2021 Alessandro Viprati <vipri.alessandro@gmail.com> # Copyright (C) 2021 Alessandro Viprati <vipri.alessandro@gmail.com>
# Copyright (C) 2023 shadMod # Copyright (C) 2023 shadMod <mattia.a@shadmod.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published # it under the terms of the GNU Affero General Public License as published
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# GNU Affero General Public License for more details. # GNU Affero General Public License for more details.
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
#} #}
{% extends "layout.html" %} {% extends "layout.html" %}
...@@ -107,21 +107,13 @@ Home page ...@@ -107,21 +107,13 @@ Home page
Ultime novità Ultime novità
</h2> </h2>
<ul class="item-list"> <ul class="item-list">
{% for news in news %}
<li> <li>
<a href="{{ url_for('pages.derivate_index') }}"> <a href="{{ url_for('news.detail', year='2023', filename=news) }}">
Newsletter Italiana #Ubuntu - 2023.030 Newsletter Italiana #Ubuntu - 2023.{{ news }}
</a>
</li>
<li>
<a href="{{ url_for('pages.derivate_index') }}">
Newsletter Italiana #Ubuntu - 2023.029
</a>
</li>
<li>
<a href="{{ url_for('pages.derivate_index') }}">
Newsletter Italiana #Ubuntu - 2023.028
</a> </a>
</li> </li>
{% endfor %}
</ul> </ul>
</div> </div>
</div> </div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment