{#
# Source code of the Ubuntu-it website
# Copyright (C) 2023 shadMod <m.allegro@shadmod.com>
#
# 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
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; witout even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# 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/>.
#}

{% extends "news/index.html" %}

{% block content %}
<div class="page bg-transparent shadow-none">
	<div class="row bg-transparent pt-3">

		<div class="col-10 px-3">
			{% for news in news %}
			<div class="row my-20 shadow-square">
				<div class="col">
					<div class="w-100 d-inline-block align-i-center">
						<small class="btn-news float-end">
							<strong>
								{{ news.category }}
							</strong>
						</small>
						<img src="{{ url_for('static', filename='images/news/' + news.category.lower() + '.png') }}"
							 class="float-start me-20">
						<h3 class="w-100">
							<a href="{{ url_for('news.detail', year=news.year, category=news.category.lower(), filename=news.nr_file) }}"
							   class="arrow-hover text-dark underline-10">
								{% if news.category == 'newsletter' %}
								Newsletter Italiana #Ubuntu -
								{% endif %}
								{{ news.title|truncate(50) }}
							</a>
						</h3>
						<small>
							Inviato da
							<a href="mailto:{{ news.mail|safe }}">
								{{ news.author|safe }}
							</a>
							il {{ news.birth_time }}
						</small>
					</div>

					{% if news.category == 'newsletter' %}
					<p>
						È disponibile la newsletter N° {{ news.nr_news }} della comunità di ubuntu-it. In questo
						numero:
					</p>
					{% endif %}

					{{ news.html|safe }}

					{% if news.category == 'newsletter' %}
					<p>
						Puoi
						<a href="http://wiki.ubuntu-it.org/NewsletterItaliana/{{ news.title }}">
							leggere direttamente la newsletter
						</a>
						oppure
						<a href="https://wiki.ubuntu-it.org/NewsletterItaliana/Archivio/Pdf{{ news.year }}?action=AttachFile&do=view&target=Newsletter+Ubuntu-it+{{ news.nr_file }}.{{ news.year }}.pdf">
							scaricarla in formato pdf</a>.
						<br/>
						Se hai perso i numeri precedenti, puoi trovarli nell'
						<a href="https://wiki.ubuntu-it.org/NewsletterItaliana/Archivio">
							archivio</a>!
					</p>
					<div class="mb-3">
						<small>
							Per ricevere la newsletter ogni settimana nella tua casella di posta elettronica,
							iscriviti alla lista
							<a href="http://liste.ubuntu-it.org/cgi-bin/mailman/listinfo/newsletter-italiana">
								newsletter-italiana</a>.
						</small>
					</div>
					{% endif %}

					<div class="w-100 text-end">
						<a href="{{ url_for('news.detail', year=news.year, category=news.category.lower(), filename=news.nr_file) }}">
							<small class="me-10">
								Leggi tutto
							</small>
						</a>
					</div>
				</div>
			</div>
			{% else %}
			<div class="row my-20 shadow-square">
				<div class="col">
					<h3>
						Nessuna news disponibile
					</h3>
					<p>
						Vai al nostro
						<a href="https://wiki.ubuntu-it.org/NewsletterItaliana/Archivio">
							archivio
						</a>!
						O torna alla
						<a href="{{ url_for('news.list') }}">
							lista delle news
						</a>.
					</p>
					<small>
						Per ricevere la newsletter ogni settimana nella tua casella di posta elettronica,
						iscriviti alla lista
						<a href="http://liste.ubuntu-it.org/cgi-bin/mailman/listinfo/newsletter-italiana">
							newsletter-italiana
						</a>.
					</small>
				</div>
			</div>
			{% endfor %}
		</div>

		<div class="col-2 my-20 bg-white">
			<ul class="item-list">
				{% for value in list_years %}
				{% with val_split = value.split() %}
				<li class="ms-0">
					<a href="?month={{ val_split[0] }}&year={{ val_split[1] }}">
						{{ value }}
					</a>
				</li>
				{% endwith %}
				{% endfor %}
			</ul>
		</div>

	</div>
</div>
{% endblock %}
