Add backlink
This commit is contained in:
176
static/sidebar-resize.js
Normal file
176
static/sidebar-resize.js
Normal file
@ -0,0 +1,176 @@
|
||||
/**
|
||||
* Sidebar Resizable
|
||||
* Allows users to resize the sidebar by dragging the right edge
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const STORAGE_KEY = 'sidebar-width';
|
||||
const DEFAULT_WIDTH = 300;
|
||||
const MIN_WIDTH = 200;
|
||||
const MAX_WIDTH = 600;
|
||||
|
||||
let sidebar = null;
|
||||
let resizeHandle = null;
|
||||
let isResizing = false;
|
||||
let startX = 0;
|
||||
let startWidth = 0;
|
||||
|
||||
/**
|
||||
* Initialize sidebar resize functionality
|
||||
*/
|
||||
function init() {
|
||||
sidebar = document.querySelector('#sidebar');
|
||||
if (!sidebar) {
|
||||
console.warn('Sidebar not found');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Sidebar resize initialized');
|
||||
|
||||
// Create resize handle
|
||||
createResizeHandle();
|
||||
|
||||
// Restore saved width
|
||||
restoreSidebarWidth();
|
||||
|
||||
// Add event listeners
|
||||
setupEventListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the resize handle element
|
||||
*/
|
||||
function createResizeHandle() {
|
||||
resizeHandle = document.createElement('div');
|
||||
resizeHandle.className = 'sidebar-resize-handle';
|
||||
resizeHandle.title = 'Drag to resize sidebar / Glisser pour redimensionner';
|
||||
|
||||
sidebar.appendChild(resizeHandle);
|
||||
console.log('Resize handle created and appended');
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup event listeners for resizing
|
||||
*/
|
||||
function setupEventListeners() {
|
||||
resizeHandle.addEventListener('mousedown', startResize);
|
||||
document.addEventListener('mousemove', handleResize);
|
||||
document.addEventListener('mouseup', stopResize);
|
||||
|
||||
// Prevent text selection while resizing
|
||||
resizeHandle.addEventListener('selectstart', (e) => e.preventDefault());
|
||||
}
|
||||
|
||||
/**
|
||||
* Start resizing
|
||||
*/
|
||||
function startResize(e) {
|
||||
isResizing = true;
|
||||
startX = e.clientX;
|
||||
startWidth = sidebar.offsetWidth;
|
||||
|
||||
resizeHandle.classList.add('resizing');
|
||||
document.body.style.cursor = 'col-resize';
|
||||
document.body.style.userSelect = 'none';
|
||||
|
||||
console.log('Started resizing from:', startX, 'width:', startWidth);
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle resize dragging
|
||||
*/
|
||||
function handleResize(e) {
|
||||
if (!isResizing) return;
|
||||
|
||||
const delta = e.clientX - startX;
|
||||
const newWidth = Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, startWidth + delta));
|
||||
|
||||
applySidebarWidth(newWidth);
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop resizing
|
||||
*/
|
||||
function stopResize(e) {
|
||||
if (!isResizing) return;
|
||||
|
||||
isResizing = false;
|
||||
resizeHandle.classList.remove('resizing');
|
||||
document.body.style.cursor = '';
|
||||
document.body.style.userSelect = '';
|
||||
|
||||
console.log('Stopped resizing at width:', sidebar.offsetWidth);
|
||||
|
||||
// Save the new width
|
||||
saveSidebarWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save sidebar width to localStorage
|
||||
*/
|
||||
function saveSidebarWidth() {
|
||||
const width = sidebar.offsetWidth;
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, width.toString());
|
||||
} catch (e) {
|
||||
console.warn('Failed to save sidebar width:', e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore sidebar width from localStorage
|
||||
*/
|
||||
function restoreSidebarWidth() {
|
||||
try {
|
||||
const savedWidth = localStorage.getItem(STORAGE_KEY);
|
||||
if (savedWidth) {
|
||||
const width = parseInt(savedWidth, 10);
|
||||
if (width >= MIN_WIDTH && width <= MAX_WIDTH) {
|
||||
applySidebarWidth(width);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('Failed to restore sidebar width:', e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply sidebar width to both sidebar and main content
|
||||
*/
|
||||
function applySidebarWidth(width) {
|
||||
sidebar.style.width = `${width}px`;
|
||||
|
||||
// Update main content margin
|
||||
const main = document.querySelector('main');
|
||||
if (main) {
|
||||
main.style.marginLeft = `${width}px`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset sidebar to default width
|
||||
*/
|
||||
function resetSidebarWidth() {
|
||||
applySidebarWidth(DEFAULT_WIDTH);
|
||||
saveSidebarWidth();
|
||||
}
|
||||
|
||||
// Initialize on DOM ready
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
// DOM already loaded
|
||||
init();
|
||||
}
|
||||
|
||||
// Expose reset function globally for debugging
|
||||
window.resetSidebarWidth = resetSidebarWidth;
|
||||
})();
|
||||
435
static/theme.css
435
static/theme.css
@ -132,6 +132,8 @@ aside {
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
width: 300px;
|
||||
min-width: 200px;
|
||||
max-width: 600px;
|
||||
transform: translateX(0);
|
||||
transition: transform 0.25s ease;
|
||||
z-index: 10;
|
||||
@ -144,6 +146,51 @@ aside {
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
/* Resize handle for sidebar */
|
||||
.sidebar-resize-handle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: -6px; /* Overlap for easier grab */
|
||||
bottom: 0;
|
||||
width: 16px; /* Even wider for Firefox */
|
||||
cursor: col-resize;
|
||||
background: rgba(66, 165, 245, 0.05);
|
||||
border-left: 2px solid transparent;
|
||||
border-right: 2px solid transparent;
|
||||
transition: all 0.2s ease;
|
||||
z-index: 11;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sidebar-resize-handle:hover {
|
||||
background: rgba(66, 165, 245, 0.15);
|
||||
border-left-color: var(--accent-primary);
|
||||
border-right-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.sidebar-resize-handle.resizing {
|
||||
background: rgba(66, 165, 245, 0.25);
|
||||
border-left: 3px solid var(--accent-primary);
|
||||
border-right: 3px solid var(--accent-primary);
|
||||
}
|
||||
|
||||
/* Visual indicator - always visible */
|
||||
.sidebar-resize-handle::before {
|
||||
content: '⋮';
|
||||
font-size: 18px;
|
||||
color: var(--accent-primary);
|
||||
opacity: 0.5;
|
||||
transition: all 0.2s ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.sidebar-resize-handle:hover::before {
|
||||
opacity: 1;
|
||||
text-shadow: 0 0 4px var(--accent-primary);
|
||||
}
|
||||
|
||||
aside::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
@ -1483,7 +1530,9 @@ body, html {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: -280px;
|
||||
width: 280px;
|
||||
width: 280px !important; /* Force width on mobile, ignore resize */
|
||||
min-width: 280px;
|
||||
max-width: 280px;
|
||||
height: 100vh;
|
||||
z-index: 1000;
|
||||
transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
@ -1493,6 +1542,11 @@ body, html {
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
/* Hide resize handle on mobile */
|
||||
.sidebar-resize-handle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
aside.sidebar-visible {
|
||||
left: 0;
|
||||
}
|
||||
@ -2923,3 +2977,382 @@ body, html {
|
||||
max-height: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Link Inserter Modal Styles
|
||||
========================================================================== */
|
||||
|
||||
.link-inserter-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 10000;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-top: 15vh;
|
||||
opacity: 0;
|
||||
transition: opacity 200ms ease;
|
||||
}
|
||||
|
||||
.link-inserter-modal.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.link-inserter-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
backdrop-filter: blur(3px);
|
||||
}
|
||||
|
||||
.link-inserter-container {
|
||||
position: relative;
|
||||
width: 90%;
|
||||
max-width: 560px;
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-lg), var(--shadow-glow);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 60vh;
|
||||
transform: translateY(-20px);
|
||||
transition: transform 200ms ease;
|
||||
}
|
||||
|
||||
.link-inserter-modal.active .link-inserter-container {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.link-inserter-header {
|
||||
padding: var(--spacing-md);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.link-inserter-input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.link-inserter-icon {
|
||||
color: var(--accent-primary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.link-inserter-input {
|
||||
flex: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-primary);
|
||||
font-size: 15px;
|
||||
outline: none;
|
||||
padding: var(--spacing-sm) 0;
|
||||
}
|
||||
|
||||
.link-inserter-input::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.link-inserter-kbd {
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 2px 6px;
|
||||
font-size: 11px;
|
||||
font-family: monospace;
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Body */
|
||||
.link-inserter-body {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.link-inserter-results {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: var(--spacing-sm);
|
||||
}
|
||||
|
||||
/* Results Header */
|
||||
.link-inserter-results-header {
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.link-inserter-results-count {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Result Item */
|
||||
.link-inserter-result-item {
|
||||
display: flex;
|
||||
gap: var(--spacing-sm);
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
margin: var(--spacing-xs) 0;
|
||||
border-radius: var(--radius-md);
|
||||
cursor: pointer;
|
||||
transition: all var(--transition-fast);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.link-inserter-result-item:hover {
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.link-inserter-result-item.selected {
|
||||
background: linear-gradient(135deg, rgba(130, 170, 255, 0.15), rgba(199, 146, 234, 0.15));
|
||||
border-color: var(--accent-primary);
|
||||
}
|
||||
|
||||
.link-inserter-result-icon {
|
||||
font-size: 1.2rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.link-inserter-result-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.link-inserter-result-title {
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: 3px;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.link-inserter-result-title mark {
|
||||
background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
|
||||
color: white;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.link-inserter-result-path {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.link-inserter-result-tags {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.tag-pill-small {
|
||||
background: var(--bg-tertiary);
|
||||
color: var(--accent-primary);
|
||||
border: 1px solid var(--border-primary);
|
||||
padding: 1px 6px;
|
||||
border-radius: 10px;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Help */
|
||||
.link-inserter-help {
|
||||
padding: var(--spacing-xl);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.link-inserter-help-text {
|
||||
font-size: 0.95rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Loading */
|
||||
.link-inserter-loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--spacing-xl);
|
||||
gap: var(--spacing-md);
|
||||
}
|
||||
|
||||
.link-inserter-spinner {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 3px solid var(--bg-tertiary);
|
||||
border-top-color: var(--accent-primary);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
.link-inserter-loading p {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* No Results */
|
||||
.link-inserter-no-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--spacing-xl);
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.link-inserter-no-results-icon {
|
||||
font-size: 2.5rem;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.link-inserter-no-results p {
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Error */
|
||||
.link-inserter-error {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--spacing-xl);
|
||||
gap: var(--spacing-sm);
|
||||
}
|
||||
|
||||
.link-inserter-error-icon {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.link-inserter-error p {
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
.link-inserter-footer {
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
border-top: 1px solid var(--border-primary);
|
||||
background: var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.link-inserter-footer-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-sm);
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.link-inserter-footer-hint kbd {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 2px 5px;
|
||||
font-family: monospace;
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
BACKLINKS SECTION
|
||||
============================================ */
|
||||
|
||||
/* Preview wrapper to contain both preview and backlinks */
|
||||
.preview-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-md);
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Backlinks section styling */
|
||||
.backlinks-section {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--border-primary);
|
||||
border-radius: var(--radius-md);
|
||||
padding: var(--spacing-md);
|
||||
margin-top: var(--spacing-md);
|
||||
}
|
||||
|
||||
.backlinks-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
margin: 0 0 var(--spacing-sm) 0;
|
||||
padding-bottom: var(--spacing-sm);
|
||||
border-bottom: 1px solid var(--border-primary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.backlinks-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-xs);
|
||||
}
|
||||
|
||||
.backlink-item {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.backlink-link {
|
||||
display: block;
|
||||
padding: var(--spacing-sm) var(--spacing-md);
|
||||
background: var(--bg-tertiary);
|
||||
border: 1px solid var(--border-secondary);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
transition: all var(--transition-fast);
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.backlink-link:hover {
|
||||
background: var(--bg-primary);
|
||||
border-color: var(--accent-primary);
|
||||
color: var(--accent-primary);
|
||||
transform: translateX(4px);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.backlink-link:active {
|
||||
transform: translateX(2px);
|
||||
}
|
||||
|
||||
/* Mobile Adaptation */
|
||||
@media screen and (max-width: 768px) {
|
||||
.link-inserter-container {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
border-radius: 0;
|
||||
max-height: 100vh;
|
||||
}
|
||||
|
||||
.link-inserter-input {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.link-inserter-results {
|
||||
max-height: calc(100vh - 200px);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user