Daniel Bohry vor 1 Monat
Ursprung
Commit
ee93722958

+ 8 - 0
src/main/java/com/lhamacorp/knotes/web/WebController.java

@@ -14,6 +14,14 @@ public class WebController {
         this.service = service;
         this.service = service;
     }
     }
 
 
+    /**
+     * Serve the home page at root path
+     */
+    @GetMapping("/")
+    public String serveHomePage() {
+        return "forward:/home.html";
+    }
+
     /**
     /**
      * Handle note ID paths by serving the index.html file
      * Handle note ID paths by serving the index.html file
      * Matches any alphanumeric ID and forwards to 404 if not found
      * Matches any alphanumeric ID and forwards to 404 if not found

+ 1 - 33
src/main/resources/static/404.html

@@ -14,7 +14,7 @@
 </head>
 </head>
 <body>
 <body>
 <div class="header">
 <div class="header">
-    <div class="title"><img src="logo.png" alt="kNotes logo"/> kNotes</div>
+    <div class="title" onclick="window.location.href='/'" style="cursor: pointer;"><img src="logo.png" alt="kNotes logo"/> kNotes</div>
     <div class="header-right">
     <div class="header-right">
         <div class="theme-switch" id="themeSwitch" onclick="toggleTheme()" title="Toggle dark/light theme"></div>
         <div class="theme-switch" id="themeSwitch" onclick="toggleTheme()" title="Toggle dark/light theme"></div>
         <button class="new-btn" onclick="window.location.href='/'">Home</button>
         <button class="new-btn" onclick="window.location.href='/'">Home</button>
@@ -29,25 +29,6 @@
             The page you're looking for doesn't exist. It might have been moved, deleted,
             The page you're looking for doesn't exist. It might have been moved, deleted,
             or you entered the wrong URL.
             or you entered the wrong URL.
         </p>
         </p>
-        <div class="error-actions">
-            <button class="dialog-btn primary" onclick="window.location.href='/'">
-                Create New Note
-            </button>
-            <button class="dialog-btn secondary" onclick="showIdInput()">
-                Open Existing Note
-            </button>
-        </div>
-    </div>
-</div>
-
-<div id="idInputOverlay" class="id-input-overlay hidden">
-    <div class="id-input-dialog">
-        <h3>Open Note</h3>
-        <input type="text" id="noteIdInput" class="id-input" placeholder="Enter note ID"/>
-        <div class="dialog-buttons">
-            <button class="dialog-btn secondary" onclick="hideIdInput()">Cancel</button>
-            <button class="dialog-btn primary" onclick="loadNoteFromInput()">Open</button>
-        </div>
     </div>
     </div>
 </div>
 </div>
 
 
@@ -104,19 +85,6 @@
         }
         }
     }
     }
 
 
-    function showIdInput() {
-        const idInputOverlay = document.getElementById('idInputOverlay');
-        const noteIdInput = document.getElementById('noteIdInput');
-
-        if (idInputOverlay) {
-            idInputOverlay.classList.remove('hidden');
-        }
-
-        if (noteIdInput) {
-            noteIdInput.focus();
-        }
-    }
-
     function hideIdInput() {
     function hideIdInput() {
         const idInputOverlay = document.getElementById('idInputOverlay');
         const idInputOverlay = document.getElementById('idInputOverlay');
         const noteIdInput = document.getElementById('noteIdInput');
         const noteIdInput = document.getElementById('noteIdInput');

+ 95 - 0
src/main/resources/static/home.html

@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+    <meta name="theme-color" content="#007bff">
+    <meta name="apple-mobile-web-app-capable" content="yes">
+    <meta name="apple-mobile-web-app-status-bar-style" content="default">
+    <meta name="apple-mobile-web-app-title" content="kNotes">
+    <meta name="mobile-web-app-capable" content="yes">
+    <meta name="application-name" content="kNotes">
+    <title>kNotes - Simple Note Taking</title>
+    <link rel="stylesheet" href="style.css">
+</head>
+<body>
+<div class="header">
+    <div class="title" onclick="window.location.href='/'" style="cursor: pointer;"><img src="logo.png"
+                                                                                        alt="kNotes logo"/> kNotes
+    </div>
+    <div class="header-right">
+        <div class="theme-switch" id="themeSwitch" onclick="toggleTheme()" title="Toggle dark/light theme"></div>
+    </div>
+</div>
+
+<div class="content">
+    <div class="error-content">
+        <div class="error-icon">📝</div>
+        <h1 class="error-title">Welcome to kNotes</h1>
+        <div class="error-actions">
+            <button class="dialog-btn primary" onclick="createNewNote()">
+                Create New
+            </button>
+            <button class="dialog-btn secondary" onclick="showIdInput()">
+                Open Existing
+            </button>
+        </div>
+    </div>
+</div>
+
+<div id="idInputOverlay" class="id-input-overlay hidden">
+    <div class="id-input-dialog">
+        <h3>Open Note</h3>
+        <input type="text" id="noteIdInput" class="id-input" placeholder="Enter note ID"/>
+        <div class="dialog-buttons">
+            <button class="dialog-btn secondary" onclick="hideIdInput()">Cancel</button>
+            <button class="dialog-btn primary" onclick="loadNoteFromInput()">Open</button>
+        </div>
+    </div>
+</div>
+
+<script src="script.js"></script>
+<script>
+    function createNewNote() {
+        window.location.href = '/index.html';
+    }
+
+    function hideIdInput() {
+        const idInputOverlay = document.getElementById('idInputOverlay');
+        const noteIdInput = document.getElementById('noteIdInput');
+
+        if (idInputOverlay) {
+            idInputOverlay.classList.add('hidden');
+        }
+
+        if (noteIdInput) {
+            noteIdInput.value = '';
+        }
+    }
+
+    function loadNoteFromInput() {
+        const noteIdInput = document.getElementById('noteIdInput');
+        if (!noteIdInput) return;
+
+        const id = noteIdInput.value.trim();
+        if (id) {
+            hideIdInput();
+            window.location.href = `/${id}`;
+        }
+    }
+
+    document.addEventListener('DOMContentLoaded', function () {
+        initializeTheme();
+
+        const noteIdInput = document.getElementById('noteIdInput');
+        if (noteIdInput) {
+            noteIdInput.addEventListener('keypress', function (e) {
+                if (e.key === 'Enter') {
+                    loadNoteFromInput();
+                }
+            });
+        }
+    });
+</script>
+</body>
+</html>

+ 1 - 1
src/main/resources/static/index.html

@@ -14,7 +14,7 @@
 </head>
 </head>
 <body>
 <body>
 <div class="header">
 <div class="header">
-    <div class="title"><img src="logo.png" alt="kNotes logo"/> kNotes</div>
+    <div class="title" onclick="window.location.href='/'" style="cursor: pointer;"><img src="logo.png" alt="kNotes logo"/> kNotes</div>
     <div class="header-right">
     <div class="header-right">
         <span class="note-id" id="noteIdDisplay" style="display: none;"></span>
         <span class="note-id" id="noteIdDisplay" style="display: none;"></span>
         <div class="theme-switch" id="themeSwitch" onclick="toggleTheme()" title="Toggle dark/light theme"></div>
         <div class="theme-switch" id="themeSwitch" onclick="toggleTheme()" title="Toggle dark/light theme"></div>

+ 8 - 5
src/main/resources/static/script.js

@@ -73,14 +73,17 @@ function init() {
         }
         }
     }
     }
 
 
-    if (idFromUrl) {
-        loadNoteById(idFromUrl);
-    } else {
-        newNote();
+    // Only load/create notes if we're on the note editor page (has noteContent element)
+    const noteContent = document.getElementById('noteContent');
+    if (noteContent) {
+        if (idFromUrl) {
+            loadNoteById(idFromUrl);
+        } else {
+            newNote();
+        }
     }
     }
 
 
     // Set up auto-save on content change
     // Set up auto-save on content change
-    const noteContent = document.getElementById('noteContent');
     if (noteContent) {
     if (noteContent) {
         noteContent.addEventListener('input', handleContentChange);
         noteContent.addEventListener('input', handleContentChange);
     } else {
     } else {