Commit avant changement d'agent vers devstral

This commit is contained in:
2025-11-13 17:00:47 +01:00
parent a09b73e4f1
commit cc1d6880a7
25 changed files with 2903 additions and 89 deletions

View File

@ -58,6 +58,53 @@ func (h *Handler) getDailyNoteAbsolutePath(date time.Time) string {
return filepath.Join(h.notesDir, relativePath)
}
// translateWeekday traduit un jour de la semaine
func (h *Handler) translateWeekday(r *http.Request, weekday time.Weekday) string {
dayKeys := map[time.Weekday]string{
time.Monday: "calendar.monday",
time.Tuesday: "calendar.tuesday",
time.Wednesday: "calendar.wednesday",
time.Thursday: "calendar.thursday",
time.Friday: "calendar.friday",
time.Saturday: "calendar.saturday",
time.Sunday: "calendar.sunday",
}
return h.t(r, dayKeys[weekday])
}
// translateWeekdayShort traduit un jour de la semaine (version courte)
func (h *Handler) translateWeekdayShort(r *http.Request, weekday time.Weekday) string {
dayKeys := map[time.Weekday]string{
time.Monday: "calendar.mon",
time.Tuesday: "calendar.tue",
time.Wednesday: "calendar.wed",
time.Thursday: "calendar.thu",
time.Friday: "calendar.fri",
time.Saturday: "calendar.sat",
time.Sunday: "calendar.sun",
}
return h.t(r, dayKeys[weekday])
}
// translateMonth traduit un nom de mois
func (h *Handler) translateMonth(r *http.Request, month time.Month) string {
monthKeys := map[time.Month]string{
time.January: "calendar.january",
time.February: "calendar.february",
time.March: "calendar.march",
time.April: "calendar.april",
time.May: "calendar.may",
time.June: "calendar.june",
time.July: "calendar.july",
time.August: "calendar.august",
time.September: "calendar.september",
time.October: "calendar.october",
time.November: "calendar.november",
time.December: "calendar.december",
}
return h.t(r, monthKeys[month])
}
// dailyNoteExists vérifie si une daily note existe pour une date donnée
func (h *Handler) dailyNoteExists(date time.Time) bool {
absPath := h.getDailyNoteAbsolutePath(date)
@ -66,7 +113,7 @@ func (h *Handler) dailyNoteExists(date time.Time) bool {
}
// createDailyNote crée une daily note avec un template par défaut
func (h *Handler) createDailyNote(date time.Time) error {
func (h *Handler) createDailyNote(r *http.Request, date time.Time) error {
absPath := h.getDailyNoteAbsolutePath(date)
// Créer les dossiers parents si nécessaire
@ -84,35 +131,9 @@ func (h *Handler) createDailyNote(date time.Time) error {
dateStr := date.Format("02-01-2006")
dateTimeStr := date.Format("02-01-2006:15:04")
// Noms des jours en français
dayNames := map[time.Weekday]string{
time.Monday: "Lundi",
time.Tuesday: "Mardi",
time.Wednesday: "Mercredi",
time.Thursday: "Jeudi",
time.Friday: "Vendredi",
time.Saturday: "Samedi",
time.Sunday: "Dimanche",
}
// Noms des mois en français
monthNames := map[time.Month]string{
time.January: "janvier",
time.February: "février",
time.March: "mars",
time.April: "avril",
time.May: "mai",
time.June: "juin",
time.July: "juillet",
time.August: "août",
time.September: "septembre",
time.October: "octobre",
time.November: "novembre",
time.December: "décembre",
}
dayName := dayNames[date.Weekday()]
monthName := monthNames[date.Month()]
// Traduire le nom du jour et du mois
dayName := h.translateWeekday(r, date.Weekday())
monthName := h.translateMonth(r, date.Month())
// Template de la daily note
template := fmt.Sprintf(`---
@ -159,7 +180,7 @@ func (h *Handler) handleDailyToday(w http.ResponseWriter, r *http.Request) {
// Créer la note si elle n'existe pas
if !h.dailyNoteExists(today) {
if err := h.createDailyNote(today); err != nil {
if err := h.createDailyNote(r, today); err != nil {
h.logger.Printf("Erreur création daily note: %v", err)
http.Error(w, "Erreur lors de la création de la note", http.StatusInternalServerError)
return
@ -190,7 +211,7 @@ func (h *Handler) handleDailyDate(w http.ResponseWriter, r *http.Request, dateSt
// Créer la note si elle n'existe pas
if !h.dailyNoteExists(date) {
if err := h.createDailyNote(date); err != nil {
if err := h.createDailyNote(r, date); err != nil {
h.logger.Printf("Erreur création daily note: %v", err)
http.Error(w, "Erreur lors de la création de la note", http.StatusInternalServerError)
return
@ -232,7 +253,7 @@ func (h *Handler) handleDailyCalendar(w http.ResponseWriter, r *http.Request, ye
}
// Créer les données du calendrier
calendarData := h.buildCalendarData(year, time.Month(month))
calendarData := h.buildCalendarData(r, year, time.Month(month))
// Rendre le template
w.Header().Set("Content-Type", "text/html; charset=utf-8")
@ -243,7 +264,7 @@ func (h *Handler) handleDailyCalendar(w http.ResponseWriter, r *http.Request, ye
}
// buildCalendarData construit les données du calendrier pour un mois donné
func (h *Handler) buildCalendarData(year int, month time.Month) *CalendarData {
func (h *Handler) buildCalendarData(r *http.Request, year int, month time.Month) *CalendarData {
// Premier jour du mois
firstDay := time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
@ -253,26 +274,10 @@ func (h *Handler) buildCalendarData(year int, month time.Month) *CalendarData {
// Date d'aujourd'hui
today := time.Now()
// Noms des mois en français
monthNames := map[time.Month]string{
time.January: "Janvier",
time.February: "Février",
time.March: "Mars",
time.April: "Avril",
time.May: "Mai",
time.June: "Juin",
time.July: "Juillet",
time.August: "Août",
time.September: "Septembre",
time.October: "Octobre",
time.November: "Novembre",
time.December: "Décembre",
}
data := &CalendarData{
Year: year,
Month: month,
MonthName: monthNames[month],
MonthName: h.translateMonth(r, month),
Weeks: make([][7]CalendarDay, 0),
}
@ -373,22 +378,12 @@ func (h *Handler) handleDailyRecent(w http.ResponseWriter, r *http.Request) {
date := today.AddDate(0, 0, -i)
if h.dailyNoteExists(date) {
dayNames := map[time.Weekday]string{
time.Monday: "Lun",
time.Tuesday: "Mar",
time.Wednesday: "Mer",
time.Thursday: "Jeu",
time.Friday: "Ven",
time.Saturday: "Sam",
time.Sunday: "Dim",
}
info := &DailyNoteInfo{
Date: date,
Path: h.getDailyNotePath(date),
Exists: true,
Title: date.Format("02/01/2006"),
DayOfWeek: dayNames[date.Weekday()],
DayOfWeek: h.translateWeekdayShort(r, date.Weekday()),
DayOfMonth: date.Day(),
}
recentNotes = append(recentNotes, info)