📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
CDN Server
Smaug67393211c4039df0
diff --git a/cdn/go.mod b/cdn/go.modnew file mode 100644index 00000000..a58a4533--- /dev/null+++ b/cdn/go.mod@@ -0,0 +1,9 @@+module github.com/Smaug6739/Alexandrie++go 1.22.4++require (+ github.com/felixge/httpsnoop v1.0.3 // indirect+ github.com/gorilla/handlers v1.5.2 // indirect+ github.com/gorilla/mux v1.8.1 // indirect+)diff --git a/cdn/go.sum b/cdn/go.sumnew file mode 100644index 00000000..a9361ce5--- /dev/null+++ b/cdn/go.sum@@ -0,0 +1,6 @@+github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=+github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=+github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=+github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=+github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=+github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=diff --git a/cdn/main.go b/cdn/main.gonew file mode 100644index 00000000..7dd3d7ec--- /dev/null+++ b/cdn/main.go@@ -0,0 +1,52 @@+package main++import (+ "fmt"+ "log"+ "net/http"+ "strings"++ "github.com/gorilla/handlers"+ "github.com/gorilla/mux"+)++func main() {+ port := ":3002"++ r := mux.NewRouter()++ fileHandler := http.FileServer(http.Dir("../uploads"))+ r.PathPrefix("/").Handler(http.StripPrefix("/", neuter(fileHandler)))++ // Middlewares pour la sécurité+ r.Use(handlers.CompressHandler)+ r.Use(handlers.CORS())+ r.Use(securityHeadersMiddleware)++ fmt.Println("Server is running on port", port)+ log.Fatal(http.ListenAndServe(port, r))+}++func securityHeadersMiddleware(next http.Handler) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ //w.Header().Set("Content-Security-Policy", "default-src 'self'")+ w.Header().Set("X-Content-Type-Options", "nosniff")+ w.Header().Set("X-Frame-Options", "DENY")+ w.Header().Set("Strict-Transport-Security", "max-age=63072000; includeSubDomains")+ // If url starts with /other or /backups, add 'Content-Disposition', `attachment; filename` header+ if strings.HasPrefix(r.URL.Path, "/other") || strings.HasPrefix(r.URL.Path, "/backups") {+ w.Header().Set("Content-Disposition", "attachment; filename")+ }+ next.ServeHTTP(w, r)+ })+}+func neuter(next http.Handler) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if strings.HasSuffix(r.URL.Path, "/") {+ http.NotFound(w, r)+ return+ }++ next.ServeHTTP(w, r)+ })+}diff --git a/frontend/.env.development b/frontend/.env.developmentindex 3f3c70c6..55cc6a27 100644--- a/frontend/.env.development+++ b/frontend/.env.development@@ -1 +1,2 @@-VITE_BASE_API="http://192.168.0.25:3001"\ No newline at end of file+VITE_BASE_API="http://192.168.0.25:3001"+VITE_BASE_CDN="http://192.168.0.25:3001"\ No newline at end of filediff --git a/frontend/.env.production b/frontend/.env.productionindex a0628664..a11ac8ed 100644--- a/frontend/.env.production+++ b/frontend/.env.production@@ -1 +1,2 @@-VITE_BASE_API="https://api.alexandrie-hub.fr"\ No newline at end of file+VITE_BASE_API="https://api.alexandrie-hub.fr"+VITE_BASE_CDN="https://cdn.alexandrie-hub.fr"\ No newline at end of filediff --git a/frontend/components/Icon.vue b/frontend/components/Icon.vueindex 2fd4eaa4..36e07581 100644--- a/frontend/components/Icon.vue+++ b/frontend/components/Icon.vue@@ -1,39 +1,37 @@<template>- <i v-html="icon" class="icon" :style="{ fill: props.fill || 'var(--red)' }"- :class="{ fill: props.fill, big: props.big }"></i>+ <i v-html="icon" class="icon" :style="{ fill: props.fill || 'var(--red)' }" :class="{ fill: props.fill, big: props.big }"></i></template><script setup lang="ts">import type { IconName } from '~/composables/icons';-const props = defineProps<{ name: IconName | string, fill?: string, big?: true }>();+const props = defineProps<{ name: IconName | string; fill?: string; big?: true }>();const icon = useIcon(props.name as IconName) || props.name;-</script><style scoped lang="scss">.icon {- display: flex;- align-items: center;+ display: flex;+ align-items: center;- &:deep(svg) {- width: 20px;- max-height: 22px;- margin-right: 5px;+ &:deep(svg) {+ width: 20px;+ max-height: 22px;+ margin-right: 5px;- path {- fill: inherit; // Utilise la couleur de l'élément parent }- }- }+ path {+ fill: inherit; // Utilise la couleur de l'élément parent }+ }+ }}-.fill:deep(svg)>path {- fill: inherit !important; // Utilise la couleur de l'élément parent }+.fill:deep(svg) > path {+ fill: inherit !important; // Utilise la couleur de l'élément parent }}.big {- &:deep(svg) {- width: 30px;- max-height: 30px;- }+ &:deep(svg) {+ width: 25px;+ max-height: 25px;+ }}-</style>\ No newline at end of file+</style>diff --git a/frontend/components/Sidebar/Collapse.vue b/frontend/components/Sidebar/Collapse.vuedeleted file mode 100644index 7cb8c18a..00000000--- a/frontend/components/Sidebar/Collapse.vue+++ /dev/null@@ -1,32 +0,0 @@-<template>- <div class="collapse-header item">- <svg @click="toggleShow" :class="{ 'rotated': !show }" xmlns="http://www.w3.org/2000/svg" height="24"- viewBox="0 -960 960 960" width="24">- <path d="M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z" />- </svg>- <slot name="header"></slot>- </div>- <div v-if="show" class="collapse-body">- <slot name="body"></slot>- </div>-</template>--<script setup lang="ts">-const show = ref(true);-const toggleShow = () => show.value = !show.value;-</script>--<style lang="scss" scoped>-.collapse-header {- display: flex;- align-items: center;-- svg {- fill: var(--font-color);-- &.rotated {- transform: rotate(-90deg);- }- }-}-</style>\ No newline at end of filediff --git a/frontend/components/Sidebar/Search.vue b/frontend/components/Sidebar/Search.vueindex 06394440..81c9b2aa 100644--- a/frontend/components/Sidebar/Search.vue+++ b/frontend/components/Sidebar/Search.vue@@ -1,34 +1,18 @@<template>- <div v-if="showSearchModal" class="modal-mask">- <div class="modal-container" ref="searchContainer">- <span class="search-input">- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"- stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"- class="mr-2 h-4 w-4 shrink-0 opacity-50">- <circle cx="11" cy="11" r="8"></circle>- <path d="m21 21-4.3-4.3"></path>- </svg>- <input type="text" v-model="filter" placeholder="Search document" ref="searchInput" />- <button @click="close" style="background: none;">- <Icon name="close" />- </button>- </span>- <span class="title">Documents</span>- <NuxtLink v-if="docs.length" v-for="doc of docs" class="item" :to="`/dashboard/docs/${doc.id}`" @click="close">- <i class="icon">- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"- stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mr-2 h-4 w-4">- <path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"></path>- <polyline points="14 2 14 8 20 8"></polyline>- </svg>- </i>- <span>{{ doc.name }}</span>- </NuxtLink>- <p v-else class="no-result">- No result found.- </p>- </div>- </div>+ <div v-if="showSearchModal" class="modal-mask">+ <div class="modal-container" ref="searchContainer">+ <span class="search-input">+ <Icon name="search" />+ <input type="text" v-model="filter" placeholder="Search document" ref="searchInput" />+ <button @click="close" style="background: none">+ <Icon name="close" :big="true" />+ </button>+ </span>+ <span class="title">Documents</span>+ <NuxtLink v-if="docs.length" v-for="doc of docs" class="item" :to="`/dashboard/docs/${doc.id}`" @click="close"> <Icon name="draft" :big="true" fill="var(--font-color)" /> {{ doc.name }} </NuxtLink>+ <p v-else class="no-result">No result found.</p>+ </div>+ </div></template><script setup lang="ts">@@ -42,109 +26,108 @@ const showSearchModal = ref<boolean>(false);const docs = computed(() => documents.value.slice(0, 5));const close = () => {- showSearchModal.value = false;- filter.value = '';+ showSearchModal.value = false;+ filter.value = '';};const searchContainer = ref<HTMLElement | null>(null);const searchInput = ref<HTMLInputElement | null>(null);const handleTab = (event: KeyboardEvent) => {- event.preventDefault();- if (!searchContainer.value) return;- const focusableItems = Array.from(searchContainer.value.querySelectorAll('a'));- const currentIndex = focusableItems.findIndex(item => item === document.activeElement);- let nextIndex;- if (event.shiftKey) {- nextIndex = (currentIndex - 1 + focusableItems.length) % focusableItems.length;- } else {- nextIndex = (currentIndex + 1) % focusableItems.length;- }- focusableItems[nextIndex]?.focus();-}+ event.preventDefault();+ if (!searchContainer.value) return;+ const focusableItems = Array.from(searchContainer.value.querySelectorAll('a'));+ const currentIndex = focusableItems.findIndex(item => item === document.activeElement);+ let nextIndex;+ if (event.shiftKey) {+ nextIndex = (currentIndex - 1 + focusableItems.length) % focusableItems.length;+ } else {+ nextIndex = (currentIndex + 1) % focusableItems.length;+ }+ focusableItems[nextIndex]?.focus();+};onMounted(() => document.addEventListener('keydown', handleSearchShortCut));onBeforeUnmount(() => document.removeEventListener('keydown', handleSearchShortCut));const handleSearchShortCut = (e: KeyboardEvent) => {- if (e.ctrlKey && e.key === 'q') {- if (!showSearchModal.value) {- showSearchModal.value = true;- nextTick(() => searchInput.value?.focus());- } else close();- }- if (showSearchModal.value) {- if (e.key === 'Escape') close();- if (e.key === 'Tab') handleTab(e);- }+ if (e.ctrlKey && e.key === 'q') {+ if (!showSearchModal.value) {+ showSearchModal.value = true;+ nextTick(() => searchInput.value?.focus());+ } else close();+ }+ if (showSearchModal.value) {+ if (e.key === 'Escape') close();+ if (e.key === 'Tab') handleTab(e);+ }};</script><style lang="scss" scoped>.modal-container {- width: 600px;- margin: auto;- padding: 20px;- background-color: var(--bg-color);- border-radius: 10px;- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);- transition: all 0.3s ease;+ width: 600px;+ margin: auto;+ padding: 20px;+ background-color: var(--bg-color);+ border-radius: 10px;+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.33);+ transition: all 0.3s ease;}.search-input {- display: flex;- align-items: center;--- input {- background-color: var(--bg-color);- border: none;- outline: none;- width: 100%;- }-- svg {- fill: var(--bg-contrast);- }+ display: flex;+ align-items: center;++ input {+ background-color: var(--bg-color);+ border: none;+ outline: none;+ width: 100%;+ }++ svg {+ fill: var(--bg-contrast);+ }}.title {- font-weight: 500;- font-size: 0.75rem;- color: #737373;- padding: 10px 0;+ font-weight: 500;+ font-size: 0.75rem;+ color: #737373;+ padding: 10px 0;}.item {- display: flex;- justify-content: flex-start;- align-items: center;- margin: 2.5px 0;- padding: 10px 0;- border-radius: 5px;- color: var(--font-color);- cursor: pointer;-- &.router-link-active {- background: var(--bg-contrast-2);- }-- &:focus {- outline: 2px solid var(--font-color);- }-- .icon {- display: flex;- align-items: center;-- &:deep(svg) {- width: 35px;- margin-right: 5px;- }- }+ display: flex;+ justify-content: flex-start;+ align-items: center;+ margin: 2.5px 0;+ padding: 10px 0;+ border-radius: 5px;+ color: var(--font-color);+ cursor: pointer;++ &:hover {+ background: var(--bg-contrast-2);+ }++ &:focus {+ outline: 2px solid var(--font-color);+ }++ .icon {+ display: flex;+ align-items: center;++ &:deep(svg) {+ width: 35px;+ margin-right: 5px;+ }+ }}.no-result {- text-align: center;- font-weight: 500;- font-size: 0.85rem;+ text-align: center;+ font-weight: 500;+ font-size: 0.85rem;}</style>diff --git a/frontend/components/Sidebar/Sidebar.vue b/frontend/components/Sidebar/Sidebar.vueindex 534e3966..4b1629d9 100644--- a/frontend/components/Sidebar/Sidebar.vue+++ b/frontend/components/Sidebar/Sidebar.vue@@ -1,7 +1,7 @@<template><div :class="{ 'modal-mask': isMobile() && isOpened }"></div><Resizable>- <div class="sidebar-content">+ <div class="sidebar"><section class="header"><span class="name"><IconApp />@@ -9,12 +9,12 @@</span><IconClose class="btn" /></section>- <input type="text" placeholder="Search or Ctrl + q" class="search" v-model="filter" />+ <input type="text" placeholder="Search or ctrl + q" class="search" v-model="filter" /><div class="user" v-if="usrStr.user"><img :src="useAvatar(usrStr.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" /><div>- <div class="username">{{ usrStr.user.username }}</div>+ <div>{{ usrStr.user.username }}</div><div class="email">{{ usrStr.user.email }}</div></div></div>@@ -47,14 +47,16 @@ const handleSearchShortCut = (e: KeyboardEvent) => {const items = computed((): Item[] => {const navigation: Item[] = navigationItems.map(item => ({ id: item.id, parent_id: '', title: item.title, route: item.route, icon: item.icon, type: 'navigation', data: item }));- const categories: Item[] = categoriesStore.categories.map((category: Category) => ({- id: category.id,- parent_id: category.parent_id || '',- title: category.name,- route: category.parent_id ? `/dashboard/categories/${category.id}` : '',- icon: category.icon,- data: category,- }));+ const categories: Item[] = categoriesStore.categories+ .map((category: Category) => ({+ id: category.id,+ parent_id: category.parent_id || '',+ title: category.name,+ route: category.parent_id ? `/dashboard/categories/${category.id}` : '',+ icon: category.icon,+ data: category,+ }))+ .filter(c => c.data.name.toLowerCase().includes(filter.value.toLowerCase()));const documents: Item[] = documentsStore.documents.map(document => ({id: document.id,@@ -88,7 +90,7 @@ onBeforeUnmount(() => {</script><style scoped lang="scss">-.sidebar-content {+.sidebar {margin: 0 0 0 10px;}@@ -129,9 +131,9 @@ onBeforeUnmount(() => {.user {display: flex;align-items: center;- margin-top: 4px;+ margin: 4px 0 0 5px;div {- font-size: 0.8rem;+ font-size: 0.85rem;margin-left: 5px;.email {font-size: 0.7rem;diff --git a/frontend/composables/icons.ts b/frontend/composables/icons.tsindex ebb5080d..3d383d73 100644--- a/frontend/composables/icons.ts+++ b/frontend/composables/icons.ts@@ -7,6 +7,7 @@ const icons = {security: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m438-338 226-226-57-57-169 169-84-84-57 57 141 141Zm42 258q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z"/></svg>`,close: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>`,profil: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z"/></svg>`,+ search: `<svg xmlns="http://www.w3.org/2000/svg"height="24" viewBox="0 0 24 24" fill="none"stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"class="mr-2 h-4 w-4 shrink-0 opacity-50"><circle cx="11" cy="11" r="8"></circle><path d="m21 21-4.3-4.3"></path></svg>`,draft: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path style="fill:var(--turquoise)" d="M240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"/></svg>`,folder: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path style="fill:var(--yellow);" d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640H447l-80-80H160v480l96-320h684L837-217q-8 26-29.5 41.5T760-160H160Zm84-80h516l72-240H316l-72 240Zm0 0 72-240-72 240Zm-84-400v-80 80Z"/></svg>`,diff --git a/uploads/index.html b/uploads/index.htmlnew file mode 100644index 00000000..3e8c0dc8--- /dev/null+++ b/uploads/index.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<html lang="en">++<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>CDN: Alexandrie</title>+ <link rel="stylesheet" href="styles.css">+</head>++<body>++ <div class="container">+ <h1>CDN: Alexandrie</h1>+ <p>Nothing to see here. Go back to the <a href="https://alexandrie-hub.fr">Alexandrie home page</a>.</p>+ </div>++</body>++</html>\ No newline at end of filediff --git a/uploads/styles.css b/uploads/styles.cssnew file mode 100644index 00000000..4ac35552--- /dev/null+++ b/uploads/styles.css@@ -0,0 +1,37 @@+body {+ font-family: Arial, sans-serif;+ background-color: #f4f4f4;+ margin: 0;+ padding: 0;+ display: flex;+ justify-content: center;+ align-items: center;+ height: 100vh;+ color: #333;+}++.container {+ background-color: #fff;+ padding: 20px;+ border-radius: 8px;+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);+ text-align: center;+}++h1 {+ margin-top: 0;+ color: #007bff;+}++p {+ font-size: 1.2em;+}++a {+ color: #007bff;+ text-decoration: none;+}++a:hover {+ text-decoration: underline;+}