Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-perso committed Jul 22, 2023
0 parents commit e33b3a0
Show file tree
Hide file tree
Showing 31 changed files with 1,736 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Taille maximale d'un fichier, affiché sur l'accueil du site
FILE_MAX_SIZE=1 GB

# URL de l'API, ne peut pas être une IP locale (localhost, 127.0.0.1, 192.168.x.x, etc.)
API_BASE_URL=https://stend-api.example.com
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
.vercel
.env
node_modules
build
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
pnpm-lock.yaml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Johan le stickman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Stend | Client WEB

Stend est un projet visant à être l'une des meilleures solutions pour configurer son propre service de partage de fichiers. Il a été conçu pour être aussi complet que la plupart des services propriétaires, mais avec une facilité d'installation et de configuration incomparable aux autres projets open-source.

Ce repo GitHub contient le code source du client WEB de Stend, permettant de télécharger ou d'envoyer des fichiers sur une instance de Stend.

![Accueil](https://stend-docs.johanstick.me/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fdemo_homepage.90c32aac.png&w=1920&q=75)
![Téléchargement](https://stend-docs.johanstick.me/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fdemo_downloadPage.5b317e36.png&w=1920&q=75)

Pour plus d'informations sur ce client, vous pouvez lire [la page de la documentation dédiée](https://stend-docs.johanstick.me/web-docs/selfhost).

### Licence

MIT © [Johan](https://johanstick.me)
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "stend-web",
"private": true,
"version": "1.0.5",
"rocVersion": "1.1.0",
"scripts": {
"dev": "node roc.js dev",
"build": "node roc.js build",
"start": "node roc.js start"
},
"dependencies": {
"boxen": "5.1.2",
"chalk": "4.1.2",
"chokidar": "3.5.3",
"daisyui": "3.0.2",
"dotenv": "10.0.0",
"express": "^4.18.2",
"html-minifier": "^4.0.0",
"localtunnel": "^2.0.2",
"open": "8.4.2",
"ora": "5.4.1",
"postcss": "^8.4.24",
"sqwish": "^0.2.2",
"tailwindcss": "3.3.2",
"tailwindcss-hero-patterns": "^0.1.2",
"terser": "^5.19.0",
"ws": "^8.13.0"
}
}
35 changes: 35 additions & 0 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="fr" class="bg-gris-100 dark:bg-base-200 heropattern-topography-indigo-500 dark:heropattern-topography-violet-800">
<head>
<!-- Propriétés importantes -->
<title>Stend</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="favicon.png">

<!-- Meta tag -->
<meta property="og:title" content="Stend">
<meta property="og:description" content="Stend vous permet d'envoyer des fichiers via un simple lien d'accès qui expire lorsque vous l'aurez décidé.">
<meta name="title" content="Stend">
<meta name="description" content="Stend vous permet d'envoyer des fichiers via un simple lien d'accès qui expire lorsque vous l'aurez décidé.">
</head>
<body class="absolute inset-0"> <!--Comment j'ai pas connu cette méthode pour remplacer le "h-screen" avant ??? -->
<!-- Conteneur principal -->
<div id="topContainer" class="h-full xs:px-2 sm:px-4 md:px-10 lg:px-20">
<div class="grid items-center h-full text-center bg-gris-100 shadowMainContainer xs:rounded-xl dark:bg-base-200 justify-items-center">
<div class="px-6 py-1">
<h1 class="leading-9 text-base-200 dark:text-gris-100 font-semibold text-3xl sm:text-4xl">Oups...</h1>
<p class="leading-3 select-none">&nbsp;</p><p class="leading-7 text-gris-400 dark:text-gris-300 text-md sm:text-lg">On dirait bien que cette page n'existe pas. Assure-toi qu'il n'y ait aucune faute dans l'URL.</p>
<p class="leading-5 select-none">&nbsp;</p><button onclick="location.href = '/'" class="bg-blue-700 dark:bg-blue-500 text-white text-center w-full sm:w-2/3 font-semibold p-2 rounded-lg">Aller à l'accueil</button>
</div>
</div>
</div>

<!-- Footer -->
<div class="invisible xs:visible">
<div class="absolute bottom-0 right-0 text-sm text-gray-700 bg-gris-100 rounded-tl-lg dark:text-gris-100 dark:bg-base-200">
<a class="hover:underline" href="https://github.com/johan-perso/stend-web"><p class="px-2 py-1">Repo GitHub</p></a>
</div>
</div>
</body>
</html>
35 changes: 35 additions & 0 deletions public/_routing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"/section/optionsBeforeSend.html": {
"options": {
"disableLiveReload": true,
"disableTailwind": true,
"showFile": "public/section/optionsBeforeSend.html"
}
},
"/section/sending.html": {
"options": {
"disableLiveReload": true,
"disableTailwind": true,
"showFile": "public/section/sending.html"
}
},
"/section/sent.html": {
"options": {
"disableLiveReload": true,
"disableTailwind": true,
"showFile": "public/section/sent.html"
}
},
"/d.html": {
"options": {
"showFile": "public/download.html"
}
},
"/version": {
"options": {
"showFile": "public/version.html",
"disableTailwind": true,
"disableLiveReload": true
}
}
}
62 changes: 62 additions & 0 deletions public/download.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!doctype html>
<html lang="fr" class="bg-gris-100 dark:bg-base-200 heropattern-topography-indigo-500 dark:heropattern-topography-violet-800">
<head apibaseurl="{{ process.env.API_BASE_URL }}">
<!-- Propriétés importantes -->
<title>Stend</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="initial-scale=1, viewport-fit=cover, width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

<!-- Icones, PWA -->
<link rel="icon" type="image/png" href="favicon.png">
<link rel="apple-touch-icon" href="icon_maskable.png">
<link rel="apple-touch-startup-image" href="icon_maskable.png">
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#16161E">
<script src="importSW.js"></script>

<!-- Fonctionnement -->
<script src="scriptDownloadPage.js" defer></script>
<link rel="preconnect" href="{{ process.env.API_BASE_URL }}">

<!-- Meta tag -->
<meta property="og:title" content="Stend">
<meta property="og:description" content="Stend vous permet d'envoyer des fichiers via un simple lien d'accès qui expire lorsque vous l'aurez décidé.">
<meta name="title" content="Stend">
<meta name="description" content="Stend vous permet d'envoyer des fichiers via un simple lien d'accès qui expire lorsque vous l'aurez décidé.">
</head>
<body class="absolute inset-0"> <!--Comment j'ai pas connu cette méthode pour remplacer le "h-screen" avant ??? -->
<!-- Conteneur principal -->
<div id="topContainer" class="h-full xs:px-2 sm:px-4 md:px-10 lg:px-20">
<div class="grid items-center h-full text-center bg-gris-100 shadowMainContainer xs:rounded-xl dark:bg-base-200 justify-items-center">
<!-- Conteneur -->
<div id="container" class="hidden px-6 py-1">
<!-- Textes -->
<h1 id="download_title" class="xs:leading-9 text-base-200 dark:text-gris-100 font-semibold text-xl xs:text-2xl sm:text-3xl md:text-4xl">Télécharger les fichiers</h1>
<p id="download_subtitle" class="mt-2 leading-7 text-gris-400 dark:text-gris-300 text-md sm:text-lg">Ces fichiers ont été partagés avec Stend. Vous pouvez les télécharger individuellement, ou tout télécharger.</p>

<!-- Fichiers -->
<div id="files" class="mt-2 overflow-y-auto" style="max-height: 45vh;"></div>

<!-- Télécharger -->
<button id="download_button" onclick="downloadAll(this)" class="hidden mt-6 bg-blue-700 dark:bg-blue-500 text-white text-center w-full sm:w-2/3 font-semibold p-2 rounded-lg">Tout télécharger</button>
</div>

<!-- Chargement -->
<div id="loading" class="grid justify-items-center items-center">
<svg aria-hidden="true" class="w-10 h-10 md:w-16 md:h-16 mx-auto text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
<p id="loadingText" class="mt-4 text-center text-gray-600 dark:text-gris-100 font-medium">Chargement...</p>
<noscript><p id="loadingText_noJS" class="mt-4 text-center text-red-500 dark:text-red-400 font-medium">Vous devez activer JavaScript pour utiliser ce site.</p></noscript>
</div>
</div>
</div>

<!-- Footer -->
<div class="invisible xs:visible">
<div class="absolute bottom-0 right-0 text-sm text-gray-700 bg-gris-100 rounded-tl-lg dark:text-gris-100 dark:bg-base-200">
<a class="hover:underline" href="https://github.com/johan-perso/stend-web"><p class="px-2 py-1">Repo GitHub</p></a>
</div>
</div>
</body>
</html>
35 changes: 35 additions & 0 deletions public/expiredFile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="fr" class="bg-gris-100 dark:bg-base-200 heropattern-topography-indigo-500 dark:heropattern-topography-violet-800">
<head>
<!-- Propriétés importantes -->
<title>Stend</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="favicon.png">

<!-- Meta tag -->
<meta property="og:title" content="Stend">
<meta property="og:description" content="Stend vous permet d'envoyer des fichiers via un simple lien d'accès qui expire lorsque vous l'aurez décidé.">
<meta name="title" content="Stend">
<meta name="description" content="Stend vous permet d'envoyer des fichiers via un simple lien d'accès qui expire lorsque vous l'aurez décidé.">
</head>
<body class="absolute inset-0"> <!--Comment j'ai pas connu cette méthode pour remplacer le "h-screen" avant ??? -->
<!-- Conteneur principal -->
<div id="topContainer" class="h-full xs:px-2 sm:px-4 md:px-10 lg:px-20">
<div class="grid items-center h-full text-center bg-gris-100 shadowMainContainer xs:rounded-xl dark:bg-base-200 justify-items-center">
<div class="px-6 py-1">
<h1 class="leading-9 text-base-200 dark:text-gris-100 font-semibold text-3xl sm:text-4xl">Oups...</h1>
<p class="leading-3 select-none">&nbsp;</p><p class="leading-7 text-gris-400 dark:text-gris-300 text-md sm:text-lg">On dirait bien que ce transfert n'existe pas. Il se peut qu'il soit expiré. Vous pouvez aussi vérifier l'URL pour vous assurer qu'il n'y a aucune faute.</p>
<p class="leading-5 select-none">&nbsp;</p><button onclick="location.href = '/'" class="bg-blue-700 dark:bg-blue-500 text-white text-center w-full sm:w-2/3 font-semibold p-2 rounded-lg">Aller à l'accueil</button>
</div>
</div>
</div>

<!-- Footer -->
<div class="invisible xs:visible">
<div class="absolute bottom-0 right-0 text-sm text-gray-700 bg-gris-100 rounded-tl-lg dark:text-gris-100 dark:bg-base-200">
<a class="hover:underline" href="https://github.com/johan-perso/stend-web"><p class="px-2 py-1">Repo GitHub</p></a>
</div>
</div>
</body>
</html>
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/fonts/inter-v12-latin-500.woff2
Binary file not shown.
Binary file added public/fonts/inter-v12-latin-600.woff2
Binary file not shown.
Binary file added public/fonts/inter-v12-latin-700.woff2
Binary file not shown.
Binary file added public/fonts/inter-v12-latin-regular.woff2
Binary file not shown.
Binary file added public/fonts/poppins-v20-latin-700.woff2
Binary file not shown.
Binary file added public/fonts/poppins-v20-latin-regular.woff2
Binary file not shown.
Binary file added public/icon_maskable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions public/importSW.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Quand la page a fini de charger
window.addEventListener('load', () => {
// Si les services worker sont compatible
if('serviceWorker' in navigator){
// Importer le service worker
navigator.serviceWorker.register('sw.js').then(() => {
// Quand le service worker nous envoie au message
navigator.serviceWorker.addEventListener('message', async event => {
// Si le message est que le cache a été mis à jour
if(event.data === 'updateCacheDone'){
// Dire que la mise à jour s'est effectué
console.log('Mise à jour du cache effectué !')

// Mettre la version dans le localStorage
localStorage.setItem('version', (await fetch('version').then(res => res.text()).catch(() => { return '0.0.0' })))
}
})

// Mettre le site dans le cache
updateCache()

// Si ça n'a pas marché, afficher l'erreur dans la console
}).catch(err => {
console.log(err)
})
}
})

// Vérifier le cache du site
async function updateCache(){
// Récupérer la version du site
var version = await fetch('version').then(res => res.text()).catch(() => { return '0.0.0' })
if(version == '0.0.0') return console.warn('Impossible de récupérer la version du site, sûrement en mode hors connexion.')

// Vérifier si la version du site est différente de la version du cache
if(version != localStorage.getItem('version')){
// Log
console.log('Mise à jour du cache...')

// Envoyer au message au service worker pour lui dire de mettre à jour le cache
navigator.serviceWorker.ready.then(registration => {
registration.active.postMessage("updateCache")
})
}

// Log
console.log('Version du site : ' + version)
}
Loading

0 comments on commit e33b3a0

Please sign in to comment.