Add logo and rename
This commit is contained in:
@ -16,7 +16,7 @@ import (
|
||||
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/mathieu/project-notes/internal/indexer"
|
||||
"github.com/mathieu/personotes/internal/indexer"
|
||||
)
|
||||
|
||||
// TreeNode représente un nœud dans l'arborescence des fichiers
|
||||
@ -235,6 +235,12 @@ func (h *Handler) handleFileTree(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Si ce n'est pas une requête HTMX, rediriger vers la page principale
|
||||
if r.Header.Get("HX-Request") == "" {
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
tree, err := h.buildFileTree()
|
||||
if err != nil {
|
||||
h.logger.Printf("erreur lors de la construction de l arborescence: %v", err)
|
||||
@ -261,18 +267,26 @@ func (h *Handler) handleHome(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Si ce n'est pas une requête HTMX (ex: accès direct via URL), rediriger vers la page principale
|
||||
if r.Header.Get("HX-Request") == "" {
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
// Générer le contenu Markdown avec la liste de toutes les notes
|
||||
content := h.generateHomeMarkdown()
|
||||
|
||||
// Utiliser le template editor.html pour afficher la page d'accueil
|
||||
data := struct {
|
||||
Filename string
|
||||
Content string
|
||||
IsHome bool
|
||||
Filename string
|
||||
Content string
|
||||
IsHome bool
|
||||
Backlinks []BacklinkInfo
|
||||
}{
|
||||
Filename: "🏠 Accueil - Index",
|
||||
Content: content,
|
||||
IsHome: true,
|
||||
Filename: "🏠 Accueil - Index",
|
||||
Content: content,
|
||||
IsHome: true,
|
||||
Backlinks: nil, // Pas de backlinks pour la page d'accueil
|
||||
}
|
||||
|
||||
err := h.templates.ExecuteTemplate(w, "editor.html", data)
|
||||
@ -577,13 +591,15 @@ func (h *Handler) createAndRenderNote(w http.ResponseWriter, r *http.Request, fi
|
||||
initialContent := "---\n" + string(fmBytes) + "---\n\n# " + newFM.Title + "\n\nCommencez à écrire votre note ici..."
|
||||
|
||||
data := struct {
|
||||
Filename string
|
||||
Content string
|
||||
IsHome bool
|
||||
Filename string
|
||||
Content string
|
||||
IsHome bool
|
||||
Backlinks []BacklinkInfo
|
||||
}{
|
||||
Filename: filename,
|
||||
Content: initialContent,
|
||||
IsHome: false,
|
||||
Filename: filename,
|
||||
Content: initialContent,
|
||||
IsHome: false,
|
||||
Backlinks: nil, // Pas de backlinks pour une nouvelle note
|
||||
}
|
||||
|
||||
err = h.templates.ExecuteTemplate(w, "editor.html", data)
|
||||
@ -599,6 +615,11 @@ func (h *Handler) handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Pas de redirection ici car cet endpoint est utilisé par:
|
||||
// 1. La sidebar de recherche (HTMX)
|
||||
// 2. La modale de recherche Ctrl+K (fetch)
|
||||
// 3. Le link inserter pour créer des backlinks (fetch)
|
||||
|
||||
query := strings.TrimSpace(r.URL.Query().Get("query"))
|
||||
if query == "" {
|
||||
query = strings.TrimSpace(r.URL.Query().Get("tag"))
|
||||
@ -673,6 +694,13 @@ func (h *Handler) handleDeleteNote(w http.ResponseWriter, r *http.Request, filen
|
||||
}
|
||||
|
||||
func (h *Handler) handleGetNote(w http.ResponseWriter, r *http.Request, filename string) {
|
||||
// Si ce n'est pas une requête HTMX (ex: refresh navigateur), rediriger vers la page principale
|
||||
// Cela évite d'afficher un fragment HTML sans CSS lors d'un Ctrl+F5
|
||||
if r.Header.Get("HX-Request") == "" {
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
fullPath := filepath.Join(h.notesDir, filename)
|
||||
content, err := os.ReadFile(fullPath)
|
||||
if err != nil {
|
||||
@ -800,8 +828,12 @@ func (h *Handler) handlePostNote(w http.ResponseWriter, r *http.Request, filenam
|
||||
}
|
||||
}()
|
||||
|
||||
// Repondre a htmx pour vider l'editeur et rafraichir l'arborescence
|
||||
h.renderFileTreeOOB(w)
|
||||
// Pour les notes existantes, ne pas recharger le file-tree (évite de fermer les dossiers ouverts)
|
||||
// Le file-tree sera rechargé uniquement lors de la création de nouveaux fichiers/dossiers
|
||||
if isNewFile {
|
||||
// Nouvelle note : mettre à jour le file-tree pour l'afficher
|
||||
h.renderFileTreeOOB(w)
|
||||
}
|
||||
|
||||
// Répondre avec les statuts de sauvegarde OOB
|
||||
nowStr := time.Now().Format("15:04:05")
|
||||
|
||||
Reference in New Issue
Block a user