From 22a800e5e66ec81b681a41a62a481a36635fbacd Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 14 Apr 2025 23:39:42 +0200 Subject: [PATCH] wip --- app/auth/__pycache__/routes.cpython-313.pyc | Bin 4564 -> 4588 bytes app/auth/routes.py | 6 +- app/routes.py | 6 +- app/static/css/main.css | 175 ++++++++++++++++++++ app/static/js/utils.js | 56 +++++++ app/templates/base.html | 62 +------ app/templates/index.html | 77 +++------ 7 files changed, 271 insertions(+), 111 deletions(-) create mode 100644 app/static/css/main.css create mode 100644 app/static/js/utils.js diff --git a/app/auth/__pycache__/routes.cpython-313.pyc b/app/auth/__pycache__/routes.cpython-313.pyc index 6f6f9cd63e9b7df09a640c2262bec79f12e64b3c..81b8c716a923708866d835f4749363b4ad8051da 100644 GIT binary patch delta 110 zcmcbj{6?AgGcPX}0}$M)|C^q=k@pstE4xo-Qc+@2WfgC3N~Ug7etvdwMrux4m5zIA zUTRTdjzV!seoQa1z@ NZb-OoKEuPo3IMRXC!_!X delta 86 zcmaE(d_|e}GcPX}0}${R{Z04X$a{-Rm!&8_zod#kHziXyEk7qEwMZ8%AR1g*T#}lr j0OBa5WEQ0+m*f{!Zr0)6$jB~!Ls034g#P9yJRGb50+$`q diff --git a/app/auth/routes.py b/app/auth/routes.py index 8d833bf..bf591d1 100644 --- a/app/auth/routes.py +++ b/app/auth/routes.py @@ -45,9 +45,9 @@ def signup(): # Create root category for the user root_category = Category( - name='root', - icon='mdi-folder-root', - description='System root directory', + name='Library', + icon='mdi-bookshelf', + description='General storage for documents and categories', user_id=user.id, is_root=True ) diff --git a/app/routes.py b/app/routes.py index 7dc1670..c5ea0cc 100644 --- a/app/routes.py +++ b/app/routes.py @@ -131,9 +131,9 @@ def save_document(): if not root_category: # Create a root category if it doesn't exist root_category = Category( - name='root', - icon='mdi-folder-root', - description='System root directory', + name='Library', + icon='mdi-bookshelf', + description='General storage for documents and categories', user_id=current_user.id, is_root=True ) diff --git a/app/static/css/main.css b/app/static/css/main.css new file mode 100644 index 0000000..1f4b273 --- /dev/null +++ b/app/static/css/main.css @@ -0,0 +1,175 @@ +/* Animation for expanding/collapsing */ +.animate-slide-down { + animation: slideDown 0.3s ease-out forwards; +} + +.animate-slide-up { + animation: slideUp 0.3s ease-out forwards; +} + +@keyframes slideDown { + from { + opacity: 0; + transform: translateY(-10px); + max-height: 0; + } + to { + opacity: 1; + transform: translateY(0); + max-height: 1000px; + } +} + +@keyframes slideUp { + from { + opacity: 1; + transform: translateY(0); + max-height: 1000px; + } + to { + opacity: 0; + transform: translateY(-10px); + max-height: 0; + } +} + +/* Active view styling */ +.active-view { + background-color: rgba(76, 175, 80, 0.2); /* Primary color with opacity */ + color: #4CAF50; /* Primary color */ +} + +/* Fix for sidebar tree view */ +.sidebar-hidden .sidebar { + transform: translateX(-100%); +} + +.sidebar-hidden main { + margin-left: 0; +} + +/* Category tree styling */ +#category-tree { + margin-left: 0; +} + +.category-item > div { + padding: 4px 0; + border-radius: 4px; +} + +.document-item { + position: relative; +} + +.document-item a { + border-radius: 4px; + display: block; +} + +.category-item .actions, +.document-item .actions { + right: 0; + top: 50%; + transform: translateY(-50%); + background-color: #282a36; + padding: 0 4px; + border-radius: 4px; + z-index: 10; +} + +/* Drag and drop styles */ +.drop-target { + background-color: rgba(80, 250, 123, 0.15); + border-radius: 4px; + outline: 1px dashed #50fa7b; +} + +.dragging { + opacity: 0.5; +} + +/* GitHub-style admonitions/alerts */ +.markdown-body .admonition { + padding: 1rem; + border-left: 4px solid; + margin: 1em 0; + border-radius: 6px; + background-color: rgba(175, 184, 193, 0.2); +} + +.markdown-body .admonition-title { + font-weight: 600; + margin-top: 0; +} + +/* Regular blockquotes */ +.markdown-body blockquote { + padding: 0.5rem 1rem; + color: #8b949e; + border-left: 0.25em solid #30363d; + margin: 1em 0; + background-color: rgba(55, 65, 81, 0.1); +} + +.markdown-body blockquote > :first-child { + margin-top: 0; +} + +.markdown-body blockquote > :last-child { + margin-bottom: 0; +} + +.markdown-body .admonition-note { + border-color: #2b6eff; + background-color: rgba(43, 110, 255, 0.1); +} + +.markdown-body .admonition-note .admonition-title { + color: #2b6eff; +} + +.markdown-body .admonition-tip { + border-color: #3fb950; + background-color: rgba(63, 185, 80, 0.1); +} + +.markdown-body .admonition-tip .admonition-title { + color: #3fb950; +} + +.markdown-body .admonition-important { + border-color: #a371f7; + background-color: rgba(163, 113, 247, 0.1); +} + +.markdown-body .admonition-important .admonition-title { + color: #a371f7; +} + +.markdown-body .admonition-warning { + border-color: #d29922; + background-color: rgba(210, 153, 34, 0.1); +} + +.markdown-body .admonition-warning .admonition-title { + color: #d29922; +} + +.markdown-body .admonition-caution { + border-color: #f85149; + background-color: rgba(248, 81, 73, 0.1); +} + +.markdown-body .admonition-caution .admonition-title { + color: #f85149; +} + +.markdown-body .admonition-danger { + border-color: #cf222e; + background-color: rgba(207, 34, 46, 0.1); +} + +.markdown-body .admonition-danger .admonition-title { + color: #cf222e; +} \ No newline at end of file diff --git a/app/static/js/utils.js b/app/static/js/utils.js new file mode 100644 index 0000000..bf6644d --- /dev/null +++ b/app/static/js/utils.js @@ -0,0 +1,56 @@ +/** + * Utility functions for Vim Docs application + */ + +// Debounce function to limit how often a function can run +function debounce(func, wait) { + let timeout; + return function() { + const context = this; + const args = arguments; + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(context, args), wait); + }; +} + +// Helper function to show notifications +function showNotification(message, type = 'success') { + const notification = document.createElement('div'); + const icon = type === 'success' ? 'mdi-check-circle' : 'mdi-alert-circle'; + const bgColor = type === 'success' ? 'bg-primary/90' : 'bg-red-500/90'; + + notification.className = `fixed bottom-4 right-4 ${bgColor} text-white px-4 py-2 rounded-md shadow-lg transform translate-y-0 opacity-100 transition-all duration-300 flex items-center`; + notification.innerHTML = `${message}`; + + document.body.appendChild(notification); + + setTimeout(() => { + notification.classList.add('translate-y-16', 'opacity-0'); + setTimeout(() => notification.remove(), 300); + }, 3000); +} + +// Helper function to get CSRF token from meta tag +function getCsrfToken() { + return document.querySelector('meta[name="csrf-token"]').getAttribute('content'); +} + +// Toggle element visibility +function toggleVisibility(element, show) { + if (show) { + element.classList.remove('hidden'); + } else { + element.classList.add('hidden'); + } +} + +// Load preference from localStorage with default value +function getPreference(key, defaultValue) { + const value = localStorage.getItem(key); + return value !== null ? value : defaultValue; +} + +// Save preference to localStorage +function savePreference(key, value) { + localStorage.setItem(key, value); +} diff --git a/app/templates/base.html b/app/templates/base.html index 115bfff..3de4985 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -9,6 +9,9 @@ + + + + {% block extra_css %}{% endblock %} @@ -317,7 +270,7 @@ // Add document button - consistent across all views const newDocButton = document.createElement('button'); newDocButton.className = 'p-1 text-gray-500 hover:text-primary rounded transition-colors'; - newDocButton.title = 'Add Document'; + newDocButton.title = 'Add document'; newDocButton.innerHTML = ''; newDocButton.addEventListener('click', function(e) { e.preventDefault(); @@ -329,7 +282,7 @@ // Add subcategory button - consistent across all views const newSubfolderButton = document.createElement('button'); newSubfolderButton.className = 'p-1 text-gray-500 hover:text-primary rounded transition-colors'; - newSubfolderButton.title = 'Add Sub-category'; + newSubfolderButton.title = 'Add subcategory'; newSubfolderButton.innerHTML = ''; newSubfolderButton.addEventListener('click', function(e) { e.preventDefault(); @@ -341,7 +294,7 @@ // Edit category button - consistent across all views const editButton = document.createElement('button'); editButton.className = 'p-1 text-gray-500 hover:text-primary rounded transition-colors'; - editButton.title = 'Edit Category'; + editButton.title = 'Rename category'; editButton.innerHTML = ''; editButton.addEventListener('click', function(e) { e.preventDefault(); @@ -634,6 +587,7 @@ {% endif %} + {% block extra_js %}{% endblock %} \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index e5d53b7..6293754 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -123,8 +123,21 @@
{% if categories %} {% for category in categories %} -
- + @@ -620,46 +636,5 @@ }); - + {% endblock %} \ No newline at end of file