11 Commits
3.0.2 ... 3.1.0

Author SHA1 Message Date
Sonny
fb0345bf68 chore: release v3.1.0 2025-01-03 02:01:22 +01:00
Sonny
e28d5ebea8 feat: add asset caching (sw) 2025-01-03 02:00:37 +01:00
Sonny
e2494e8cf0 chore: update deps 2025-01-02 19:59:10 +01:00
Thomas Bonnet
0d87a3f4bc Edit repository GitHub link to "my-links" 2024-12-24 00:26:16 +01:00
Sonny
c46cc1a8fb fix: footer link behaviour 2024-11-15 23:53:17 +01:00
Sonny
2f820bb877 feat: save user theme preference 2024-11-15 23:16:47 +01:00
Sonny
01298661a5 chore: release v3.0.3 2024-11-15 18:56:41 +01:00
Sonny
2de2556a20 fix: navbar & footer broken links 2024-11-15 18:53:28 +01:00
Sonny
6005374340 feat: remove SSR for dasboard page 2024-11-15 18:42:42 +01:00
Sonny
eac0c135d6 fix: dashboard header wrap when collection's name too large 2024-11-15 18:41:10 +01:00
Sonny
aef2db6071 fix: remove forgotten character 2024-11-15 18:17:38 +01:00
34 changed files with 4028 additions and 1827 deletions

View File

@@ -11,6 +11,7 @@
</div>
## Table of Contents
- [Main Features](#main-features)
- [Getting Started](#getting-started)
- [Setup](#setup)
@@ -24,7 +25,7 @@
- [Contributing](#contributing)
- [License](#license)
## Main Features
## Main Features
- **Organize bookmarks with collections**: Keep your links tidy and easily accessible by grouping them into customizable collections.
- **Intuitive link management**: Add, edit, and manage your bookmarks effortlessly with a user-friendly interface.
@@ -124,6 +125,7 @@ ssh-copy-id -i ./id_rsa.pub user@host
> Source: https://github.com/appleboy/ssh-action#setting-up-a-ssh-key
## Contributing
We welcome contributions! Please visit our Trello board for project management and roadmap details. You can contribute by:
- Creating issues for bugs, features, or discussions.
@@ -133,4 +135,4 @@ For detailed contribution guidelines, refer to the CONTRIBUTING.md file.
## License
This project is licensed under the [GPLv3 License](./LICENCE).
This project is licensed under the [GPLv3 License](./LICENCE).

View File

@@ -1,6 +1,6 @@
const PATHS = {
AUTHOR: 'https://www.sonny.dev/?utm_source=mylinks',
REPO_GITHUB: 'https://github.com/Sonny93/my-links',
REPO_GITHUB: 'https://github.com/my-links/my-links',
EXTENSION:
'https://chromewebstore.google.com/detail/mylinks/agkmlplihacolkakgeccnbhphnepphma',
} as const;

View File

@@ -0,0 +1,18 @@
import { HttpContext } from '@adonisjs/core/http';
const HEADER_NAME = 'Service-Worker-Allowed';
export default class ServiceWorkerScopeExtender {
async handle(
{ request, response, logger }: HttpContext,
next: () => Promise<void>
) {
if (request.url().startsWith('/assets/sw.js')) {
response.header(HEADER_NAME, '/');
logger.debug(
`Header ${HEADER_NAME} for ${request.url()} set to ${response.getHeader(HEADER_NAME)}`
);
}
await next();
}
}

View File

@@ -1,2 +1,3 @@
export const PREFER_DARK_THEME = 'prefer_dark_theme';
export const DARK_THEME_DEFAULT_VALUE = true;
export const KEY_USER_THEME = 'user_theme';
export const THEMES = ['dark', 'light'] as const;
export const DEFAULT_USER_THEME = THEMES.at(0);

View File

@@ -1,12 +1,11 @@
import { PREFER_DARK_THEME } from '#user/constants/theme';
import { KEY_USER_THEME } from '#user/constants/theme';
import { updateThemeValidator } from '#user/validators/update_theme_validator';
import type { HttpContext } from '@adonisjs/core/http';
export default class ThemeController {
async index({ request, session, response }: HttpContext) {
const { preferDarkTheme } =
await request.validateUsing(updateThemeValidator);
session.put(PREFER_DARK_THEME, preferDarkTheme);
const { theme } = await request.validateUsing(updateThemeValidator);
session.put(KEY_USER_THEME, theme);
return response.ok({ message: 'ok' });
}
}

View File

@@ -1,7 +1,8 @@
import { THEMES } from '#user/constants/theme';
import vine from '@vinejs/vine';
export const updateThemeValidator = vine.compile(
vine.object({
preferDarkTheme: vine.boolean(),
theme: vine.enum(THEMES),
})
);

View File

@@ -1,7 +1,6 @@
import {
PREFER_DARK_THEME,
DARK_THEME_DEFAULT_VALUE,
} from '#user/constants/theme';
import { isSSREnableForPage } from '#config/ssr';
import { DEFAULT_USER_THEME, KEY_USER_THEME } from '#user/constants/theme';
import logger from '@adonisjs/core/services/logger';
import { defineConfig } from '@adonisjs/inertia';
export default defineConfig({
@@ -15,8 +14,9 @@ export default defineConfig({
*/
sharedData: {
errors: (ctx) => ctx.session?.flashMessages.get('errors'),
preferDarkTheme: (ctx) =>
ctx.session?.get(PREFER_DARK_THEME, DARK_THEME_DEFAULT_VALUE),
user: (ctx) => ({
theme: ctx.session?.get(KEY_USER_THEME, DEFAULT_USER_THEME),
}),
auth: async (ctx) => {
await ctx.auth?.check();
return {
@@ -32,5 +32,10 @@ export default defineConfig({
ssr: {
enabled: true,
entrypoint: 'inertia/app/ssr.tsx',
pages: (_, page) => {
const ssrEnabled = isSSREnableForPage(page);
logger.debug(`Page "${page}" SSR enabled: ${ssrEnabled}`);
return ssrEnabled;
},
},
});

12
config/project.ts Normal file
View File

@@ -0,0 +1,12 @@
const PROJECT_NAME = 'MyLinks';
const PROJECT_DESCRIPTION =
'Another bookmark manager that lets you manage and share your favorite links in an intuitive interface';
const PROJECT_URL = 'https://www.mylinks.app';
const APP_COLOR = '#f0eef6';
export default {
name: PROJECT_NAME,
description: PROJECT_DESCRIPTION,
url: PROJECT_URL,
color: APP_COLOR,
};

2
config/ssr.ts Normal file
View File

@@ -0,0 +1,2 @@
export const CSR_ROUTES = ['dashboard'];
export const isSSREnableForPage = (page: string) => !CSR_ROUTES.includes(page);

View File

Before

Width:  |  Height:  |  Size: 957 B

After

Width:  |  Height:  |  Size: 957 B

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@@ -1,8 +1,9 @@
import { resolvePageComponent } from '@adonisjs/inertia/helpers';
import { createInertiaApp } from '@inertiajs/react';
import { isSSREnableForPage } from 'config-ssr';
import 'dayjs/locale/en';
import 'dayjs/locale/fr';
import { hydrateRoot } from 'react-dom/client';
import { createRoot, hydrateRoot } from 'react-dom/client';
import '../i18n/index';
const appName = import.meta.env.VITE_APP_NAME || 'MyLinks';
@@ -20,6 +21,13 @@ createInertiaApp({
},
setup({ el, App, props }) {
hydrateRoot(el, <App {...props} />);
const componentName = props.initialPage.component;
const isSSREnabled = isSSREnableForPage(componentName);
console.debug(`Page "${componentName}" SSR enabled: ${isSSREnabled}`);
if (isSSREnabled) {
hydrateRoot(el, <App {...props} />);
} else {
createRoot(el).render(<App {...props} />);
}
},
});

View File

@@ -1,13 +1,22 @@
import { ActionIcon, useMantineColorScheme } from '@mantine/core';
import { TbMoonStars, TbSun } from 'react-icons/tb';
import { makeRequest } from '~/lib/request';
export function MantineThemeSwitcher() {
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
const handleThemeChange = () => {
toggleColorScheme();
makeRequest({
url: '/user/theme',
method: 'POST',
body: { theme: colorScheme === 'dark' ? 'light' : 'dark' },
});
};
return (
<ActionIcon
variant="light"
aria-label="Toggle color scheme"
onClick={() => toggleColorScheme()}
onClick={handleThemeChange}
size="lg"
>
{colorScheme === 'dark' ? <TbSun /> : <TbMoonStars />}

View File

@@ -40,12 +40,8 @@ export default function CollectionItem({
{collection.name}
</Text>
{showLinks && (
<Text
style={{ whiteSpace: 'nowrap' }}
c="var(--mantine-color-gray-5)"
ml={4}
>
{linksCount}0
<Text style={{ whiteSpace: 'nowrap' }} c="dimmed" ml="sm">
{linksCount}
</Text>
)}
</Link>

View File

@@ -35,7 +35,7 @@ export function DashboardHeader({ navbar, aside }: DashboardHeaderProps) {
const { activeCollection } = useActiveCollection();
return (
<AppShell.Header style={{ display: 'flex', alignItems: 'center' }}>
<Group justify="space-between" px="md" flex={1}>
<Group justify="space-between" px="md" flex={1} wrap="nowrap">
<Group h="100%" wrap="nowrap">
<Burger
opened={navbar.opened}
@@ -57,7 +57,7 @@ export function DashboardHeader({ navbar, aside }: DashboardHeaderProps) {
)}
</Box>
</Group>
<Group>
<Group wrap="nowrap">
<ShareCollection />
<Menu withinPortal shadow="md" width={225}>

View File

@@ -13,15 +13,16 @@ export function MantineFooter() {
const { t } = useTranslation('common');
const links = [
{ link: route('privacy').url, label: t('privacy') },
{ link: route('terms').url, label: t('terms') },
{ link: PATHS.EXTENSION, label: 'Extension' },
{ link: route('privacy').path, label: t('privacy'), external: false },
{ link: route('terms').path, label: t('terms'), external: false },
{ link: PATHS.EXTENSION, label: 'Extension', external: true },
];
const items = links.map((link) => (
<Anchor
c="dimmed"
component={Link}
// @ts-expect-error
component={link.external ? ExternalLink : Link}
key={link.label}
href={link.link}
size="sm"

View File

@@ -17,7 +17,6 @@ import { useTranslation } from 'react-i18next';
import ExternalLink from '~/components/common/external_link';
import { MantineLanguageSwitcher } from '~/components/common/language_switcher';
import { MantineThemeSwitcher } from '~/components/common/theme_switcher';
import { MantineUserCard } from '~/components/common/user_card';
import useUser from '~/hooks/use_user';
import classes from './mobile.module.css';
@@ -31,7 +30,9 @@ export default function Navbar() {
<Box pb={40}>
<header className={classes.header}>
<Group justify="space-between" h="100%">
<Image src="/logo-light.png" h={35} alt="MyLinks's logo" />
<Link href="/">
<Image src="/logo.png" h={35} alt="MyLinks's logo" />
</Link>
<Group h="100%" gap={0} visibleFrom="sm">
<Link href="/" className={classes.link}>
@@ -102,11 +103,13 @@ export default function Navbar() {
<Group justify="center" grow pb="xl" px="md">
{!isAuthenticated ? (
<Button component="a" href={route('auth').path}>
<Button component="a" href={route('auth').path} w={110}>
{t('login')}
</Button>
) : (
<MantineUserCard />
<Button component={Link} href={route('dashboard').path} w={110}>
Dashboard
</Button>
)}
</Group>
</ScrollArea>

View File

@@ -6,8 +6,9 @@
"jsx": "react-jsx",
"resolveJsonModule": true,
"paths": {
"~/*": ["./*"]
"~/*": ["./*"],
"config-ssr": ["../config/ssr"]
}
},
"include": ["./**/*.ts", "./**/*.tsx"]
"include": ["./**/*.ts", "./**/*.tsx", "../config/ssr.ts"]
}

View File

@@ -1,18 +1,19 @@
{
"name": "my-links",
"version": "3.0.2",
"version": "3.1.0",
"type": "module",
"license": "GPL-3.0-only",
"scripts": {
"start": "node bin/server.js",
"build": "node ace build",
"dev": "node ace serve --watch",
"dev": "node ace serve --hmr",
"test": "node ace test",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"format": "prettier --write --parser typescript '**/*.{ts,tsx}'",
"typecheck": "tsc --noEmit",
"prepare": "husky",
"release": "release-it"
"release": "release-it",
"generate-icons": "pwa-assets-generator"
},
"imports": {
"#admin/*": "./app/admin/*.js",
@@ -37,63 +38,65 @@
"@adonisjs/eslint-config": "2.0.0-beta.6",
"@adonisjs/prettier-config": "^1.4.0",
"@adonisjs/tsconfig": "^1.4.0",
"@faker-js/faker": "^9.2.0",
"@japa/assert": "^3.0.0",
"@faker-js/faker": "^9.3.0",
"@japa/assert": "^4.0.0",
"@japa/plugin-adonisjs": "^3.0.1",
"@japa/runner": "^3.1.4",
"@swc/core": "^1.9.1",
"@swc/core": "^1.10.4",
"@types/luxon": "^3.4.2",
"@types/node": "^20.14.10",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@vitejs/plugin-react": "^4.3.3",
"eslint": "^9.14.0",
"hot-hook": "^0.3.1",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"pino-pretty": "^12.1.0",
"postcss": "^8.4.47",
"@types/node": "^22.10.4",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"@vite-pwa/assets-generator": "^0.2.6",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.17.0",
"hot-hook": "^0.4.0",
"husky": "^9.1.7",
"lint-staged": "^15.3.0",
"pino-pretty": "^13.0.0",
"postcss": "^8.4.49",
"postcss-preset-mantine": "^1.17.0",
"postcss-simple-vars": "^7.0.1",
"prettier": "^3.3.3",
"release-it": "^17.10.0",
"prettier": "^3.4.2",
"release-it": "^17.11.0",
"ts-node-maintained": "^10.9.4",
"typescript": "~5.6.3",
"vite": "^5.4.10"
"typescript": "~5.7.2",
"vite": "^6.0.6"
},
"dependencies": {
"@adonisjs/ally": "^5.0.2",
"@adonisjs/auth": "^9.2.4",
"@adonisjs/core": "^6.14.1",
"@adonisjs/auth": "^9.3.0",
"@adonisjs/core": "^6.17.0",
"@adonisjs/cors": "^2.2.1",
"@adonisjs/inertia": "^1.2.3",
"@adonisjs/lucid": "^21.3.0",
"@adonisjs/inertia": "^2.1.2",
"@adonisjs/lucid": "^21.6.0",
"@adonisjs/session": "^7.5.0",
"@adonisjs/shield": "^8.1.1",
"@adonisjs/static": "^1.1.1",
"@adonisjs/vite": "^3.0.0",
"@inertiajs/react": "^1.2.0",
"@adonisjs/vite": "^4.0.0",
"@inertiajs/react": "^2.0.0",
"@izzyjs/route": "^1.2.0",
"@mantine/core": "^7.13.5",
"@mantine/hooks": "^7.13.5",
"@mantine/spotlight": "^7.13.5",
"@vinejs/vine": "^2.1.0",
"@mantine/core": "^7.15.2",
"@mantine/hooks": "^7.15.2",
"@mantine/spotlight": "^7.15.2",
"@vinejs/vine": "^3.0.0",
"bentocache": "^1.0.0-beta.9",
"dayjs": "^1.11.13",
"edge.js": "^6.2.0",
"i18next": "^23.16.5",
"i18next": "^24.2.0",
"knex": "^3.1.0",
"luxon": "^3.5.0",
"node-html-parser": "^6.1.13",
"node-html-parser": "^7.0.1",
"pg": "^8.13.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-hotkeys-hook": "^4.6.1",
"react-i18next": "^15.1.1",
"react-icons": "^5.3.0",
"react-i18next": "^15.4.0",
"react-icons": "^5.4.0",
"reflect-metadata": "^0.2.2",
"zustand": "^5.0.1"
"vite-plugin-pwa": "^0.21.1",
"zustand": "^5.0.2"
},
"hotHook": {
"boundaries": [

5482
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

View File

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -1,21 +0,0 @@
{
"name": "MyLinks",
"short_name": "MyLinks",
"description": "MyLinks is a free and open source software, that lets you manage your favorite links in an intuitive interface",
"launch_handler": {
"client_mode": ["focus-existing", "auto"]
},
"icons": [
{
"src": "/favicon.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
}
],
"theme_color": "#f0eef6",
"background_color": "#f0eef6",
"start_url": "/",
"display": "standalone",
"orientation": "portrait"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
public/pwa-192x192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
public/pwa-512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
public/pwa-64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

12
pwa-assets.config.ts Normal file
View File

@@ -0,0 +1,12 @@
import {
defineConfig,
minimal2023Preset as preset,
} from '@vite-pwa/assets-generator/config';
export default defineConfig({
headLinkOptions: {
preset: '2023',
},
preset,
images: ['public/favicon.png'],
});

View File

@@ -19,7 +19,7 @@
/>
<link
rel='manifest'
href='/manifest.json'
href='/assets/manifest.webmanifest'
/>
<link
rel='apple-touch-icon'
@@ -30,6 +30,13 @@
href='/favicon.png'
/>
<title inertia>MyLinks</title>
<script defer>
if('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/assets/sw.js', { scope: '/' })
})
}
</script>
@routes()
@inertiaHead()

View File

@@ -24,6 +24,7 @@ server.errorHandler(() => import('#core/exceptions/handler'));
*/
server.use([
() => import('#core/middlewares/container_bindings_middleware'),
() => import('#core/middlewares/service_worker_scope_extender'),
() => import('@adonisjs/static/static_middleware'),
() => import('#core/middlewares/log_request'),
() => import('@adonisjs/cors/cors_middleware'),

View File

@@ -1,8 +1,12 @@
{
"extends": "@adonisjs/tsconfig/tsconfig.app.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "./build"
},
"exclude": ["./inertia/**/*", "node_modules", "build"]
}
"extends": "@adonisjs/tsconfig/tsconfig.app.json",
"compilerOptions": {
"rootDir": "./",
"outDir": "./build"
},
"exclude": [
"./inertia/**/*",
"node_modules",
"build"
]
}

View File

@@ -1,11 +1,103 @@
import { defineConfig } from 'vite';
import project from '#config/project';
import { getDirname } from '@adonisjs/core/helpers';
import inertia from '@adonisjs/inertia/client';
import react from '@vitejs/plugin-react';
import adonisjs from '@adonisjs/vite/client';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
export default defineConfig({
plugins: [
VitePWA({
registerType: 'autoUpdate',
injectRegister: false,
strategies: 'generateSW',
devOptions: {
enabled: true,
},
manifest: {
name: project.name,
short_name: project.name,
description: project.description,
theme_color: project.color,
background_color: project.color,
scope: '/',
display: 'standalone',
orientation: 'portrait',
icons: [
{
src: '/pwa-64x64.png',
sizes: '64x64',
type: 'image/png',
},
{
src: '/pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any',
},
{
src: '/maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable',
},
],
launch_handler: {
client_mode: ['focus-existing', 'auto'],
},
},
workbox: {
clientsClaim: true,
skipWaiting: true,
globPatterns: ['**/*.{js,css,html,png,svg,ico,json,woff2}'],
globIgnores: ['sw*.js', '**/manifest.webmanifest*'],
// undefined is required for solving the following error :
// Uncaught (in promise) non-precached-url: non-precached-url :: [{"url":"/index.html"}]
// Source : https://github.com/vite-pwa/nuxt/issues/53#issuecomment-1615266204
navigateFallback: undefined,
runtimeCaching: [
{
urlPattern: /\.(?:js|css|woff2|woff|ttf|eot|otf)$/,
handler: 'CacheFirst',
options: {
cacheName: 'static-assets-cache',
expiration: {
maxEntries: 50,
maxAgeSeconds: 60 * 60 * 24 * 30,
},
},
},
{
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp|ico)$/,
handler: 'CacheFirst',
options: {
cacheName: 'images-cache',
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60 * 24 * 30,
},
},
},
{
urlPattern: /\/.*$/,
handler: 'NetworkFirst',
options: {
cacheName: 'html-cache',
expiration: {
maxEntries: 20,
maxAgeSeconds: 60 * 60 * 24 * 7,
},
},
},
],
},
}),
inertia({ ssr: { enabled: true, entrypoint: 'inertia/app/ssr.tsx' } }),
react(),
adonisjs({
@@ -14,13 +106,10 @@ export default defineConfig({
}),
],
/**
* Define aliases for importing modules from
* your frontend code
*/
resolve: {
alias: {
'~/': `${getDirname(import.meta.url)}/inertia/`,
'config-ssr': `${getDirname(import.meta.url)}/config/ssr.ts`,
},
},
});