from django.contrib.sitemaps.views import sitemap
from django.urls import path
from django.views.generic import RedirectView

from apps.ads.views import ad_click
from apps.contact import views as contact
from apps.editorial.views import public as editorial
from apps.engagement import views as engagement

from . import views
from .sitemaps import SITEMAPS

app_name = "public"

# Les adresses reprennent celles du site Laravel pour préserver les liens et le référencement.
urlpatterns = [
    path("", editorial.home, name="home"),
    path("articles", editorial.article_list, name="articles"),
    path("articles/", RedirectView.as_view(pattern_name="public:articles")),
    path("search", editorial.search, name="search"),
    path("categorie/<slug:slug>", editorial.category, name="category"),
    path("tag/<slug:slug>", editorial.tag, name="tag"),
    path("article/<int:pk>/next", editorial.article_next, name="article-next"),
    path("article/<slug:slug>", editorial.article_detail, name="article"),
    path("annonces", editorial.annonce_list, name="annonces"),
    path("annonce/<slug:slug>", editorial.annonce_detail, name="annonce"),
    path("apercu/<str:token>/", editorial.preview, name="preview"),

    path("articles/<int:pk>/comments", engagement.comment_create, name="comment-create"),
    path("articles/<int:pk>/react", engagement.reaction_toggle, name="react"),
    path("comments/<int:pk>/vote", engagement.comment_vote, name="comment-vote"),

    path("contact", contact.contact, name="contact"),
    path("newsletter/subscribe", contact.subscribe, name="subscribe"),
    path("services", views.services, name="services"),
    path("pub/<int:pk>/clic", ad_click, name="ad-click"),

    path("a-propos", views.page, {"slug": "a-propos"}, name="about"),
    path("mentions-legales", views.page, {"slug": "mentions-legales"}, name="legal"),
    path("confidentialite", views.page, {"slug": "confidentialite"}, name="privacy"),
    path("cgu", views.page, {"slug": "cgu"}, name="terms"),
    path("page/<slug:slug>", views.page, name="page"),

    path("sitemap.xml", sitemap, {"sitemaps": SITEMAPS}, name="sitemap"),
    path("robots.txt", views.robots, name="robots"),
]
