mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
Compare commits
7 Commits
3.1.3
...
56b52adac0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56b52adac0 | ||
|
|
a5ddc9eb55 | ||
|
|
309cf2c9d2 | ||
|
|
97ba56b1e7 | ||
|
|
d56bd1ef80 | ||
|
|
8b176e3d0e | ||
|
|
216c404b16 |
476
.adonisjs/api.ts
Normal file
476
.adonisjs/api.ts
Normal file
@@ -0,0 +1,476 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
/* eslint-disable */
|
||||||
|
// --------------------------------------------------
|
||||||
|
// This file is auto-generated by Tuyau. Do not edit manually !
|
||||||
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
import type { MakeTuyauRequest, MakeTuyauResponse } from '@tuyau/utils/types';
|
||||||
|
import type { InferInput } from '@vinejs/vine/types';
|
||||||
|
|
||||||
|
type AdminGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/admin/controllers/admin_controller.ts').default['index'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type AuthCallbackGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/auth/controllers/auth_controller.ts').default['callbackAuth'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type AuthLogoutGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/auth/controllers/auth_controller.ts').default['logout'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type DashboardGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/collections/controllers/show_collections_controller.ts').default['render'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type CollectionsCreateGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/collections/controllers/create_collection_controller.ts').default['render'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type CollectionsPost = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/collections/validators/create_collection_validator.ts'))['createCollectionValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/collections/controllers/create_collection_controller.ts').default['execute'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type CollectionsEditGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/collections/controllers/update_collection_controller.ts').default['render'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type CollectionsIdPut = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/collections/validators/update_collection_validator.ts'))['updateCollectionValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/collections/controllers/update_collection_controller.ts').default['execute'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type CollectionsDeleteGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/collections/controllers/delete_collection_controller.ts').default['render'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type CollectionsIdDelete = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/collections/validators/delete_collection_validator.ts'))['deleteCollectionValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/collections/controllers/delete_collection_controller.ts').default['execute'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type FaviconGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/favicons/controllers/favicons_controller.ts').default['index'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type LinksCreateGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/links/controllers/links_controller.ts').default['showCreatePage'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type LinksPost = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/links/validators/create_link_validator.ts'))['createLinkValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/links/controllers/links_controller.ts').default['store'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type LinksEditGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/links/controllers/links_controller.ts').default['showEditPage'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type LinksIdPut = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/links/validators/update_link_validator.ts'))['updateLinkValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/links/controllers/links_controller.ts').default['update'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type LinksIdFavoritePut = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/links/validators/update_favorite_link_validator.ts'))['updateLinkFavoriteStatusValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/links/controllers/links_controller.ts').default['toggleFavorite'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type LinksDeleteGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/links/controllers/links_controller.ts').default['showDeletePage'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type LinksIdDelete = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/links/validators/delete_link_validator.ts'))['deleteLinkValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/links/controllers/links_controller.ts').default['delete'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type SearchGetHead = {
|
||||||
|
request: unknown;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/search/controllers/search_controller.ts').default['search'],
|
||||||
|
false
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type SharedIdGetHead = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/shared_collections/validators/shared_collection.ts'))['getSharedCollectionValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/shared_collections/controllers/shared_collections_controller.ts').default['index'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
type UserThemePost = {
|
||||||
|
request: MakeTuyauRequest<
|
||||||
|
InferInput<
|
||||||
|
(typeof import('../app/user/validators/update_theme_validator.ts'))['updateThemeValidator']
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
response: MakeTuyauResponse<
|
||||||
|
import('../app/user/controllers/theme_controller.ts').default['index'],
|
||||||
|
true
|
||||||
|
>;
|
||||||
|
};
|
||||||
|
export interface ApiDefinition {
|
||||||
|
admin: {
|
||||||
|
$url: {};
|
||||||
|
$get: AdminGetHead;
|
||||||
|
$head: AdminGetHead;
|
||||||
|
};
|
||||||
|
auth: {
|
||||||
|
callback: {
|
||||||
|
$url: {};
|
||||||
|
$get: AuthCallbackGetHead;
|
||||||
|
$head: AuthCallbackGetHead;
|
||||||
|
};
|
||||||
|
logout: {
|
||||||
|
$url: {};
|
||||||
|
$get: AuthLogoutGetHead;
|
||||||
|
$head: AuthLogoutGetHead;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
dashboard: {
|
||||||
|
$url: {};
|
||||||
|
$get: DashboardGetHead;
|
||||||
|
$head: DashboardGetHead;
|
||||||
|
};
|
||||||
|
collections: {
|
||||||
|
create: {
|
||||||
|
$url: {};
|
||||||
|
$get: CollectionsCreateGetHead;
|
||||||
|
$head: CollectionsCreateGetHead;
|
||||||
|
};
|
||||||
|
$url: {};
|
||||||
|
$post: CollectionsPost;
|
||||||
|
edit: {
|
||||||
|
$url: {};
|
||||||
|
$get: CollectionsEditGetHead;
|
||||||
|
$head: CollectionsEditGetHead;
|
||||||
|
};
|
||||||
|
':id': {
|
||||||
|
$url: {};
|
||||||
|
$put: CollectionsIdPut;
|
||||||
|
$delete: CollectionsIdDelete;
|
||||||
|
};
|
||||||
|
delete: {
|
||||||
|
$url: {};
|
||||||
|
$get: CollectionsDeleteGetHead;
|
||||||
|
$head: CollectionsDeleteGetHead;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
favicon: {
|
||||||
|
$url: {};
|
||||||
|
$get: FaviconGetHead;
|
||||||
|
$head: FaviconGetHead;
|
||||||
|
};
|
||||||
|
links: {
|
||||||
|
create: {
|
||||||
|
$url: {};
|
||||||
|
$get: LinksCreateGetHead;
|
||||||
|
$head: LinksCreateGetHead;
|
||||||
|
};
|
||||||
|
$url: {};
|
||||||
|
$post: LinksPost;
|
||||||
|
edit: {
|
||||||
|
$url: {};
|
||||||
|
$get: LinksEditGetHead;
|
||||||
|
$head: LinksEditGetHead;
|
||||||
|
};
|
||||||
|
':id': {
|
||||||
|
$url: {};
|
||||||
|
$put: LinksIdPut;
|
||||||
|
favorite: {
|
||||||
|
$url: {};
|
||||||
|
$put: LinksIdFavoritePut;
|
||||||
|
};
|
||||||
|
$delete: LinksIdDelete;
|
||||||
|
};
|
||||||
|
delete: {
|
||||||
|
$url: {};
|
||||||
|
$get: LinksDeleteGetHead;
|
||||||
|
$head: LinksDeleteGetHead;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
search: {
|
||||||
|
$url: {};
|
||||||
|
$get: SearchGetHead;
|
||||||
|
$head: SearchGetHead;
|
||||||
|
};
|
||||||
|
shared: {
|
||||||
|
':id': {
|
||||||
|
$url: {};
|
||||||
|
$get: SharedIdGetHead;
|
||||||
|
$head: SharedIdGetHead;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
user: {
|
||||||
|
theme: {
|
||||||
|
$url: {};
|
||||||
|
$post: UserThemePost;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const routes = [
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'admin.dashboard',
|
||||||
|
path: '/admin',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as AdminGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'auth',
|
||||||
|
path: '/auth/google',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as unknown,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'auth.callback',
|
||||||
|
path: '/auth/callback',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as AuthCallbackGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'auth.logout',
|
||||||
|
path: '/auth/logout',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as AuthLogoutGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'dashboard',
|
||||||
|
path: '/dashboard',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as DashboardGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'collection.create-form',
|
||||||
|
path: '/collections/create',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as CollectionsCreateGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'collection.create',
|
||||||
|
path: '/collections',
|
||||||
|
method: ['POST'],
|
||||||
|
types: {} as CollectionsPost,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'collection.edit-form',
|
||||||
|
path: '/collections/edit',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as CollectionsEditGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: ['id'],
|
||||||
|
name: 'collection.edit',
|
||||||
|
path: '/collections/:id',
|
||||||
|
method: ['PUT'],
|
||||||
|
types: {} as CollectionsIdPut,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'collection.delete-form',
|
||||||
|
path: '/collections/delete',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as CollectionsDeleteGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: ['id'],
|
||||||
|
name: 'collection.delete',
|
||||||
|
path: '/collections/:id',
|
||||||
|
method: ['DELETE'],
|
||||||
|
types: {} as CollectionsIdDelete,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'favicon',
|
||||||
|
path: '/favicon',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as FaviconGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'home',
|
||||||
|
path: '/',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as unknown,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'terms',
|
||||||
|
path: '/terms',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as unknown,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'privacy',
|
||||||
|
path: '/privacy',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as unknown,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'link.create-form',
|
||||||
|
path: '/links/create',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as LinksCreateGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'link.create',
|
||||||
|
path: '/links',
|
||||||
|
method: ['POST'],
|
||||||
|
types: {} as LinksPost,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'link.edit-form',
|
||||||
|
path: '/links/edit',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as LinksEditGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: ['id'],
|
||||||
|
name: 'link.edit',
|
||||||
|
path: '/links/:id',
|
||||||
|
method: ['PUT'],
|
||||||
|
types: {} as LinksIdPut,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: ['id'],
|
||||||
|
name: 'link.toggle-favorite',
|
||||||
|
path: '/links/:id/favorite',
|
||||||
|
method: ['PUT'],
|
||||||
|
types: {} as LinksIdFavoritePut,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'link.delete-form',
|
||||||
|
path: '/links/delete',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as LinksDeleteGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: ['id'],
|
||||||
|
name: 'link.delete',
|
||||||
|
path: '/links/:id',
|
||||||
|
method: ['DELETE'],
|
||||||
|
types: {} as LinksIdDelete,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'search',
|
||||||
|
path: '/search',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as SearchGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: ['id'],
|
||||||
|
name: 'shared',
|
||||||
|
path: '/shared/:id',
|
||||||
|
method: ['GET', 'HEAD'],
|
||||||
|
types: {} as SharedIdGetHead,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
params: [],
|
||||||
|
name: 'user.theme',
|
||||||
|
path: '/user/theme',
|
||||||
|
method: ['POST'],
|
||||||
|
types: {} as UserThemePost,
|
||||||
|
},
|
||||||
|
] as const;
|
||||||
|
export const api = {
|
||||||
|
routes,
|
||||||
|
definition: {} as ApiDefinition,
|
||||||
|
};
|
||||||
|
declare module '@tuyau/inertia/types' {
|
||||||
|
type InertiaApi = typeof api;
|
||||||
|
export interface Api extends InertiaApi {}
|
||||||
|
}
|
||||||
3
.adonisjs/index.ts
Normal file
3
.adonisjs/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
/// <reference path="../adonisrc.ts" />
|
||||||
|
|
||||||
|
export * from './api.js';
|
||||||
@@ -8,9 +8,9 @@ NODE_ENV=development
|
|||||||
SESSION_DRIVER=cookie
|
SESSION_DRIVER=cookie
|
||||||
DB_HOST=127.0.0.1
|
DB_HOST=127.0.0.1
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
DB_USER=postgres
|
DB_USER=root
|
||||||
DB_PASSWORD=my-links-pwd
|
DB_PASSWORD=root
|
||||||
DB_DATABASE=my-links
|
DB_DATABASE=app
|
||||||
GOOGLE_CLIENT_ID=
|
GOOGLE_CLIENT_ID=
|
||||||
GOOGLE_CLIENT_SECRET=
|
GOOGLE_CLIENT_SECRET=
|
||||||
GOOGLE_CLIENT_CALLBACK_URL=http://localhost:3333/auth/callback
|
GOOGLE_CLIENT_CALLBACK_URL=http://localhost:3333/auth/callback
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -1,3 +1,7 @@
|
|||||||
|
tuyau:
|
||||||
|
@node ace tuyau:generate
|
||||||
|
@pnpm run format
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
@docker compose down
|
@docker compose down
|
||||||
@docker compose -f dev.compose.yml pull
|
@docker compose -f dev.compose.yml pull
|
||||||
|
|||||||
86
adonisrc.ts
86
adonisrc.ts
@@ -2,29 +2,30 @@ import { defineConfig } from '@adonisjs/core/app';
|
|||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Commands
|
| Commands
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| List of ace commands to register from packages. The application commands
|
| List of ace commands to register from packages. The application commands
|
||||||
| will be scanned automatically from the "./commands" directory.
|
| will be scanned automatically from the "./commands" directory.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
commands: [
|
commands: [
|
||||||
() => import('@adonisjs/core/commands'),
|
() => import('@adonisjs/core/commands'),
|
||||||
() => import('@adonisjs/lucid/commands'),
|
() => import('@adonisjs/lucid/commands'),
|
||||||
() => import('@izzyjs/route/commands'),
|
() => import('@izzyjs/route/commands'),
|
||||||
|
() => import('@tuyau/core/commands'),
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Service providers
|
| Service providers
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| List of service providers to import and register when booting the
|
| List of service providers to import and register when booting the
|
||||||
| application
|
| application
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
providers: [
|
providers: [
|
||||||
() => import('@adonisjs/core/providers/app_provider'),
|
() => import('@adonisjs/core/providers/app_provider'),
|
||||||
() => import('@adonisjs/core/providers/hash_provider'),
|
() => import('@adonisjs/core/providers/hash_provider'),
|
||||||
@@ -45,27 +46,32 @@ export default defineConfig({
|
|||||||
() => import('@adonisjs/ally/ally_provider'),
|
() => import('@adonisjs/ally/ally_provider'),
|
||||||
() => import('@izzyjs/route/izzy_provider'),
|
() => import('@izzyjs/route/izzy_provider'),
|
||||||
() => import('#providers/route_provider'),
|
() => import('#providers/route_provider'),
|
||||||
|
() => import('@tuyau/core/tuyau_provider'),
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Preloads
|
| Preloads
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| List of modules to import before starting the application.
|
| List of modules to import before starting the application.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
preloads: [() => import('#start/routes'), () => import('#start/kernel')],
|
preloads: [
|
||||||
|
() => import('#start/routes'),
|
||||||
|
() => import('#start/kernel'),
|
||||||
|
() => import('#start/view'),
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Tests
|
| Tests
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| List of test suites to organize tests by their type. Feel free to remove
|
| List of test suites to organize tests by their type. Feel free to remove
|
||||||
| and add additional suites.
|
| and add additional suites.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
tests: {
|
tests: {
|
||||||
suites: [
|
suites: [
|
||||||
{
|
{
|
||||||
@@ -83,14 +89,14 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Metafiles
|
| Metafiles
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| A collection of files you want to copy to the build folder when creating
|
| A collection of files you want to copy to the build folder when creating
|
||||||
| the production build.
|
| the production build.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
metaFiles: [
|
metaFiles: [
|
||||||
{
|
{
|
||||||
pattern: 'resources/views/**/*.edge',
|
pattern: 'resources/views/**/*.edge',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import AuthController from '#auth/controllers/auth_controller';
|
import AuthController from '#auth/controllers/auth_controller';
|
||||||
import CollectionsController from '#collections/controllers/collections_controller';
|
import CollectionsController from '#collections/controllers/show_collections_controller';
|
||||||
import LinksController from '#links/controllers/links_controller';
|
import LinksController from '#links/controllers/links_controller';
|
||||||
import User from '#user/models/user';
|
import User from '#user/models/user';
|
||||||
import { inject } from '@adonisjs/core';
|
import { inject } from '@adonisjs/core';
|
||||||
|
|||||||
32
app/collections/controllers/base_collection_controller.ts
Normal file
32
app/collections/controllers/base_collection_controller.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import Collection from '#collections/models/collection';
|
||||||
|
import { HttpContext } from '@adonisjs/core/http';
|
||||||
|
import vine from '@vinejs/vine';
|
||||||
|
|
||||||
|
export default class BaseCollectionController {
|
||||||
|
protected collectionIdValidator = vine.compile(
|
||||||
|
vine.object({
|
||||||
|
collectionId: vine.number().positive().optional(),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
async validateCollectionId(collectionIdRequired: boolean = true) {
|
||||||
|
const ctx = HttpContext.getOrFail();
|
||||||
|
const { collectionId } = await ctx.request.validateUsing(
|
||||||
|
this.collectionIdValidator
|
||||||
|
);
|
||||||
|
if (!collectionId && collectionIdRequired) {
|
||||||
|
console.log('redirecting to dashboard');
|
||||||
|
ctx.response.redirectToNamedRoute('dashboard');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
console.log('collectionId', collectionId);
|
||||||
|
return collectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
redirectToCollectionId(collectionId: Collection['id']) {
|
||||||
|
const ctx = HttpContext.getOrFail();
|
||||||
|
return ctx.response.redirectToNamedRoute('dashboard', {
|
||||||
|
qs: { collectionId },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
import Collection from '#collections/models/collection';
|
|
||||||
import { createCollectionValidator } from '#collections/validators/create_collection_validator';
|
|
||||||
import { deleteCollectionValidator } from '#collections/validators/delete_collection_validator';
|
|
||||||
import { updateCollectionValidator } from '#collections/validators/update_collection_validator';
|
|
||||||
import User from '#user/models/user';
|
|
||||||
import type { HttpContext } from '@adonisjs/core/http';
|
|
||||||
import db from '@adonisjs/lucid/services/db';
|
|
||||||
|
|
||||||
export default class CollectionsController {
|
|
||||||
// Dashboard
|
|
||||||
async index({ auth, inertia, request, response }: HttpContext) {
|
|
||||||
const collections = await this.getCollectionsByAuthorId(auth.user!.id);
|
|
||||||
if (collections.length === 0) {
|
|
||||||
return response.redirectToNamedRoute('collection.create-form');
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeCollectionId = Number(request.qs()?.collectionId ?? '');
|
|
||||||
const activeCollection = collections.find(
|
|
||||||
(c) => c.id === activeCollectionId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!activeCollection && !!activeCollectionId) {
|
|
||||||
return response.redirectToNamedRoute('dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Create DTOs
|
|
||||||
return inertia.render('dashboard', {
|
|
||||||
collections: collections.map((collection) => collection.serialize()),
|
|
||||||
activeCollection:
|
|
||||||
activeCollection?.serialize() || collections[0].serialize(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create collection form
|
|
||||||
async showCreatePage({ inertia, auth }: HttpContext) {
|
|
||||||
const collections = await this.getCollectionsByAuthorId(auth.user!.id);
|
|
||||||
return inertia.render('collections/create', {
|
|
||||||
disableHomeLink: collections.length === 0,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method called when creating a collection
|
|
||||||
async store({ request, response, auth }: HttpContext) {
|
|
||||||
const payload = await request.validateUsing(createCollectionValidator);
|
|
||||||
const collection = await Collection.create({
|
|
||||||
...payload,
|
|
||||||
authorId: auth.user?.id!,
|
|
||||||
});
|
|
||||||
return this.redirectToCollectionId(response, collection.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async showEditPage({ auth, request, inertia, response }: HttpContext) {
|
|
||||||
const collectionId = request.qs()?.collectionId;
|
|
||||||
if (!collectionId) {
|
|
||||||
return response.redirectToNamedRoute('dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
const collection = await this.getCollectionById(
|
|
||||||
collectionId,
|
|
||||||
auth.user!.id
|
|
||||||
);
|
|
||||||
return inertia.render('collections/edit', {
|
|
||||||
collection,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async update({ request, auth, response }: HttpContext) {
|
|
||||||
const { params, ...payload } = await request.validateUsing(
|
|
||||||
updateCollectionValidator
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cant use validator (vinejs) custom rule 'cause its too generic,
|
|
||||||
// because we have to find a collection by identifier and
|
|
||||||
// check whether the current user is the author.
|
|
||||||
// https://vinejs.dev/docs/extend/custom_rules
|
|
||||||
await this.getCollectionById(params.id, auth.user!.id);
|
|
||||||
|
|
||||||
await Collection.updateOrCreate(
|
|
||||||
{
|
|
||||||
id: params.id,
|
|
||||||
},
|
|
||||||
payload
|
|
||||||
);
|
|
||||||
return this.redirectToCollectionId(response, params.id);
|
|
||||||
}
|
|
||||||
|
|
||||||
async showDeletePage({ auth, request, inertia, response }: HttpContext) {
|
|
||||||
const collectionId = request.qs()?.collectionId;
|
|
||||||
if (!collectionId) {
|
|
||||||
return response.redirectToNamedRoute('dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
const collection = await this.getCollectionById(
|
|
||||||
collectionId,
|
|
||||||
auth.user!.id
|
|
||||||
);
|
|
||||||
return inertia.render('collections/delete', {
|
|
||||||
collection,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async delete({ request, auth, response }: HttpContext) {
|
|
||||||
const { params } = await request.validateUsing(deleteCollectionValidator);
|
|
||||||
const collection = await this.getCollectionById(params.id, auth.user!.id);
|
|
||||||
await collection.delete();
|
|
||||||
return response.redirectToNamedRoute('dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
async getTotalCollectionsCount() {
|
|
||||||
const totalCount = await db.from('collections').count('* as total');
|
|
||||||
return Number(totalCount[0].total);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get collection by id.
|
|
||||||
*
|
|
||||||
* /!\ Only return private collection (create by the current user)
|
|
||||||
*/
|
|
||||||
async getCollectionById(id: Collection['id'], userId: User['id']) {
|
|
||||||
return await Collection.query()
|
|
||||||
.where('id', id)
|
|
||||||
.andWhere('author_id', userId)
|
|
||||||
.firstOrFail();
|
|
||||||
}
|
|
||||||
|
|
||||||
async getCollectionsByAuthorId(authorId: User['id']) {
|
|
||||||
return await Collection.query()
|
|
||||||
.where('author_id', authorId)
|
|
||||||
.orderBy('created_at')
|
|
||||||
.preload('links');
|
|
||||||
}
|
|
||||||
|
|
||||||
redirectToCollectionId(
|
|
||||||
response: HttpContext['response'],
|
|
||||||
collectionId: Collection['id']
|
|
||||||
) {
|
|
||||||
return response.redirectToNamedRoute('dashboard', {
|
|
||||||
qs: { collectionId },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
25
app/collections/controllers/create_collection_controller.ts
Normal file
25
app/collections/controllers/create_collection_controller.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import BaseCollectionController from '#collections/controllers/base_collection_controller';
|
||||||
|
import { CollectionService } from '#collections/services/collection_service';
|
||||||
|
import { createCollectionValidator } from '#collections/validators/create_collection_validator';
|
||||||
|
import { inject } from '@adonisjs/core';
|
||||||
|
import { type HttpContext } from '@adonisjs/core/http';
|
||||||
|
|
||||||
|
@inject()
|
||||||
|
export default class CreateCollectionController extends BaseCollectionController {
|
||||||
|
constructor(private collectionService: CollectionService) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
async render({ inertia }: HttpContext) {
|
||||||
|
const collections = await this.collectionService.getCollectionsByAuthorId();
|
||||||
|
return inertia.render('collections/create', {
|
||||||
|
disableHomeLink: collections.length === 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute({ request }: HttpContext) {
|
||||||
|
const payload = await request.validateUsing(createCollectionValidator);
|
||||||
|
const collection = await this.collectionService.createCollection(payload);
|
||||||
|
return this.redirectToCollectionId(collection.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/collections/controllers/delete_collection_controller.ts
Normal file
29
app/collections/controllers/delete_collection_controller.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import BaseCollectionController from '#collections/controllers/base_collection_controller';
|
||||||
|
import { CollectionService } from '#collections/services/collection_service';
|
||||||
|
import { deleteCollectionValidator } from '#collections/validators/delete_collection_validator';
|
||||||
|
import { inject } from '@adonisjs/core';
|
||||||
|
import { HttpContext } from '@adonisjs/core/http';
|
||||||
|
|
||||||
|
@inject()
|
||||||
|
export default class DeleteCollectionController extends BaseCollectionController {
|
||||||
|
constructor(private collectionService: CollectionService) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
async render({ inertia }: HttpContext) {
|
||||||
|
const collectionId = await this.validateCollectionId();
|
||||||
|
if (!collectionId) return;
|
||||||
|
|
||||||
|
const collection =
|
||||||
|
await this.collectionService.getCollectionById(collectionId);
|
||||||
|
return inertia.render('collections/delete', {
|
||||||
|
collection,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute({ request, response }: HttpContext) {
|
||||||
|
const { params } = await request.validateUsing(deleteCollectionValidator);
|
||||||
|
await this.collectionService.deleteCollection(params.id);
|
||||||
|
return response.redirectToNamedRoute('dashboard');
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/collections/controllers/show_collections_controller.ts
Normal file
34
app/collections/controllers/show_collections_controller.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import BaseCollectionController from '#collections/controllers/base_collection_controller';
|
||||||
|
import { CollectionService } from '#collections/services/collection_service';
|
||||||
|
import { inject } from '@adonisjs/core';
|
||||||
|
import type { HttpContext } from '@adonisjs/core/http';
|
||||||
|
|
||||||
|
@inject()
|
||||||
|
export default class ShowCollectionsController extends BaseCollectionController {
|
||||||
|
constructor(private collectionService: CollectionService) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dashboard
|
||||||
|
async render({ inertia, response }: HttpContext) {
|
||||||
|
const activeCollectionId = await this.validateCollectionId(false);
|
||||||
|
const collections = await this.collectionService.getCollectionsByAuthorId();
|
||||||
|
if (collections.length === 0) {
|
||||||
|
return response.redirectToNamedRoute('collection.create-form');
|
||||||
|
}
|
||||||
|
|
||||||
|
const activeCollection = collections.find(
|
||||||
|
(c) => c.id === activeCollectionId
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!activeCollection && !!activeCollectionId) {
|
||||||
|
return response.redirectToNamedRoute('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
return inertia.render('dashboard', {
|
||||||
|
collections: collections.map((collection) => collection.serialize()),
|
||||||
|
activeCollection:
|
||||||
|
activeCollection?.serialize() || collections[0].serialize(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/collections/controllers/update_collection_controller.ts
Normal file
33
app/collections/controllers/update_collection_controller.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import BaseCollectionController from '#collections/controllers/base_collection_controller';
|
||||||
|
import { CollectionService } from '#collections/services/collection_service';
|
||||||
|
import { updateCollectionValidator } from '#collections/validators/update_collection_validator';
|
||||||
|
import { inject } from '@adonisjs/core';
|
||||||
|
import { HttpContext } from '@adonisjs/core/http';
|
||||||
|
|
||||||
|
@inject()
|
||||||
|
export default class UpdateCollectionController extends BaseCollectionController {
|
||||||
|
constructor(private collectionService: CollectionService) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
async render({ inertia }: HttpContext) {
|
||||||
|
const collectionId = await this.validateCollectionId();
|
||||||
|
if (!collectionId) return;
|
||||||
|
|
||||||
|
const collection =
|
||||||
|
await this.collectionService.getCollectionById(collectionId);
|
||||||
|
return inertia.render('collections/update', {
|
||||||
|
collection: collection.serialize(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute({ request }: HttpContext) {
|
||||||
|
const {
|
||||||
|
params: { id: collectionId },
|
||||||
|
...payload
|
||||||
|
} = await request.validateUsing(updateCollectionValidator);
|
||||||
|
|
||||||
|
await this.collectionService.updateCollection(collectionId, payload);
|
||||||
|
return this.redirectToCollectionId(collectionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +1,45 @@
|
|||||||
import { middleware } from '#start/kernel';
|
import { middleware } from '#start/kernel';
|
||||||
import router from '@adonisjs/core/services/router';
|
import router from '@adonisjs/core/services/router';
|
||||||
const CollectionsController = () =>
|
|
||||||
import('#collections/controllers/collections_controller');
|
const ShowCollectionsController = () =>
|
||||||
|
import('#collections/controllers/show_collections_controller');
|
||||||
|
const CreateCollectionController = () =>
|
||||||
|
import('#collections/controllers/create_collection_controller');
|
||||||
|
const UpdateCollectionController = () =>
|
||||||
|
import('#collections/controllers/update_collection_controller');
|
||||||
|
const DeleteCollectionController = () =>
|
||||||
|
import('#collections/controllers/delete_collection_controller');
|
||||||
|
|
||||||
router
|
router
|
||||||
.group(() => {
|
.group(() => {
|
||||||
router.get('/dashboard', [CollectionsController, 'index']).as('dashboard');
|
router
|
||||||
|
.get('/dashboard', [ShowCollectionsController, 'render'])
|
||||||
|
.as('dashboard');
|
||||||
|
|
||||||
router
|
router
|
||||||
.group(() => {
|
.group(() => {
|
||||||
|
// Create
|
||||||
router
|
router
|
||||||
.get('/create', [CollectionsController, 'showCreatePage'])
|
.get('/create', [CreateCollectionController, 'render'])
|
||||||
.as('collection.create-form');
|
.as('collection.create-form');
|
||||||
router
|
router
|
||||||
.post('/', [CollectionsController, 'store'])
|
.post('/', [CreateCollectionController, 'execute'])
|
||||||
.as('collection.create');
|
.as('collection.create');
|
||||||
|
|
||||||
|
// Update
|
||||||
router
|
router
|
||||||
.get('/edit', [CollectionsController, 'showEditPage'])
|
.get('/edit', [UpdateCollectionController, 'render'])
|
||||||
.as('collection.edit-form');
|
.as('collection.edit-form');
|
||||||
router
|
router
|
||||||
.put('/:id', [CollectionsController, 'update'])
|
.put('/:id', [UpdateCollectionController, 'execute'])
|
||||||
.as('collection.edit');
|
.as('collection.edit');
|
||||||
|
|
||||||
|
// Delete
|
||||||
router
|
router
|
||||||
.get('/delete', [CollectionsController, 'showDeletePage'])
|
.get('/delete', [DeleteCollectionController, 'render'])
|
||||||
.as('collection.delete-form');
|
.as('collection.delete-form');
|
||||||
router
|
router
|
||||||
.delete('/:id', [CollectionsController, 'delete'])
|
.delete('/:id', [DeleteCollectionController, 'execute'])
|
||||||
.as('collection.delete');
|
.as('collection.delete');
|
||||||
})
|
})
|
||||||
.prefix('/collections');
|
.prefix('/collections');
|
||||||
|
|||||||
70
app/collections/services/collection_service.ts
Normal file
70
app/collections/services/collection_service.ts
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import { Visibility } from '#collections/enums/visibility';
|
||||||
|
import Collection from '#collections/models/collection';
|
||||||
|
import { HttpContext } from '@adonisjs/core/http';
|
||||||
|
import db from '@adonisjs/lucid/services/db';
|
||||||
|
|
||||||
|
type CreateCollectionPayload = {
|
||||||
|
name: string;
|
||||||
|
description: string | null;
|
||||||
|
visibility: Visibility;
|
||||||
|
};
|
||||||
|
|
||||||
|
type UpdateCollectionPayload = CreateCollectionPayload;
|
||||||
|
|
||||||
|
export class CollectionService {
|
||||||
|
async getCollectionById(id: Collection['id']) {
|
||||||
|
const context = this.getAuthContext();
|
||||||
|
return await Collection.query()
|
||||||
|
.where('id', id)
|
||||||
|
.andWhere('author_id', context.auth.user!.id)
|
||||||
|
.firstOrFail();
|
||||||
|
}
|
||||||
|
|
||||||
|
async getCollectionsByAuthorId() {
|
||||||
|
const context = this.getAuthContext();
|
||||||
|
return await Collection.query()
|
||||||
|
.where('author_id', context.auth.user!.id)
|
||||||
|
.orderBy('created_at')
|
||||||
|
.preload('links');
|
||||||
|
}
|
||||||
|
|
||||||
|
async getTotalCollectionsCount() {
|
||||||
|
const totalCount = await db.from('collections').count('* as total');
|
||||||
|
return Number(totalCount[0].total);
|
||||||
|
}
|
||||||
|
|
||||||
|
createCollection(payload: CreateCollectionPayload) {
|
||||||
|
const context = this.getAuthContext();
|
||||||
|
return Collection.create({
|
||||||
|
...payload,
|
||||||
|
authorId: context.auth.user!.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateCollection(
|
||||||
|
id: Collection['id'],
|
||||||
|
payload: UpdateCollectionPayload
|
||||||
|
) {
|
||||||
|
const context = this.getAuthContext();
|
||||||
|
return await Collection.query()
|
||||||
|
.where('id', id)
|
||||||
|
.andWhere('author_id', context.auth.user!.id)
|
||||||
|
.update(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteCollection(id: Collection['id']) {
|
||||||
|
const context = this.getAuthContext();
|
||||||
|
return Collection.query()
|
||||||
|
.where('id', id)
|
||||||
|
.andWhere('author_id', context.auth.user!.id)
|
||||||
|
.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
getAuthContext() {
|
||||||
|
const context = HttpContext.getOrFail();
|
||||||
|
if (!context.auth.user || !context.auth.user.id) {
|
||||||
|
throw new Error('User not authenticated');
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import CollectionsController from '#collections/controllers/collections_controller';
|
import CollectionsController from '#collections/controllers/show_collections_controller';
|
||||||
import Link from '#links/models/link';
|
import Link from '#links/models/link';
|
||||||
import { createLinkValidator } from '#links/validators/create_link_validator';
|
import { createLinkValidator } from '#links/validators/create_link_validator';
|
||||||
import { deleteLinkValidator } from '#links/validators/delete_link_validator';
|
import { deleteLinkValidator } from '#links/validators/delete_link_validator';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import env from '#start/env';
|
import env from '#start/env';
|
||||||
import app from '@adonisjs/core/services/app';
|
|
||||||
import { Secret } from '@adonisjs/core/helpers';
|
import { Secret } from '@adonisjs/core/helpers';
|
||||||
import { defineConfig } from '@adonisjs/core/http';
|
import { defineConfig } from '@adonisjs/core/http';
|
||||||
|
import app from '@adonisjs/core/services/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The app key is used for encrypting cookies, generating signed URLs,
|
* The app key is used for encrypting cookies, generating signed URLs,
|
||||||
@@ -23,7 +23,7 @@ export const http = defineConfig({
|
|||||||
* Enabling async local storage will let you access HTTP context
|
* Enabling async local storage will let you access HTTP context
|
||||||
* from anywhere inside your application.
|
* from anywhere inside your application.
|
||||||
*/
|
*/
|
||||||
useAsyncLocalStorage: false,
|
useAsyncLocalStorage: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage cookies configuration. The settings for the session id cookie are
|
* Manage cookies configuration. The settings for the session id cookie are
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
const PROJECT_NAME = 'MyLinks';
|
export const PRIMARY_COLOR = '#3f88c5';
|
||||||
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 {
|
export const PROJECT_NAME = 'MyLinks';
|
||||||
name: PROJECT_NAME,
|
export const PROJECT_DESCRIPTION =
|
||||||
description: PROJECT_DESCRIPTION,
|
'Another bookmark manager that lets you manage and share your favorite links in an intuitive interface';
|
||||||
url: PROJECT_URL,
|
export const PROJECT_URL = 'https://www.mylinks.app';
|
||||||
color: APP_COLOR,
|
export const PROJECT_REPO_GITHUB_URL = 'https://github.com/my-links/my-links';
|
||||||
};
|
export const PROJECT_EXTENSION_URL =
|
||||||
|
'https://chromewebstore.google.com/detail/mylinks/agkmlplihacolkakgeccnbhphnepphma';
|
||||||
|
|
||||||
|
export const AUTHOR_NAME = 'Sonny';
|
||||||
|
export const AUTHOR_GITHUB_URL = 'https://github.com/Sonny93';
|
||||||
|
export const AUTHOR_WEBSITE_URL = 'https://www.sonny.dev/?utm_source=mylinks';
|
||||||
|
|||||||
7
config/tuyau.ts
Normal file
7
config/tuyau.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { defineConfig } from '@tuyau/core';
|
||||||
|
|
||||||
|
const tuyauConfig = defineConfig({
|
||||||
|
codegen: {},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default tuyauConfig;
|
||||||
@@ -4,6 +4,7 @@ import { isSSREnableForPage } from 'config-ssr';
|
|||||||
import 'dayjs/locale/en';
|
import 'dayjs/locale/en';
|
||||||
import 'dayjs/locale/fr';
|
import 'dayjs/locale/fr';
|
||||||
import { createRoot, hydrateRoot } from 'react-dom/client';
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
||||||
|
import DefaultLayout from '~/layouts/default_layout';
|
||||||
import '../i18n/index';
|
import '../i18n/index';
|
||||||
|
|
||||||
const appName = import.meta.env.VITE_APP_NAME || 'MyLinks';
|
const appName = import.meta.env.VITE_APP_NAME || 'MyLinks';
|
||||||
@@ -13,11 +14,17 @@ createInertiaApp({
|
|||||||
|
|
||||||
title: (title) => `${appName}${title && ` - ${title}`}`,
|
title: (title) => `${appName}${title && ` - ${title}`}`,
|
||||||
|
|
||||||
resolve: (name) => {
|
resolve: async (name) => {
|
||||||
return resolvePageComponent(
|
const currentPage: any = await resolvePageComponent(
|
||||||
`../pages/${name}.tsx`,
|
`../pages/${name}.tsx`,
|
||||||
import.meta.glob('../pages/**/*.tsx')
|
import.meta.glob('../pages/**/*.tsx')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
currentPage.default.layout =
|
||||||
|
currentPage.default.layout ||
|
||||||
|
((p: any) => <DefaultLayout children={p} />);
|
||||||
|
|
||||||
|
return currentPage;
|
||||||
},
|
},
|
||||||
|
|
||||||
setup({ el, App, props }) {
|
setup({ el, App, props }) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { createInertiaApp } from '@inertiajs/react';
|
import { createInertiaApp } from '@inertiajs/react';
|
||||||
import ReactDOMServer from 'react-dom/server';
|
import ReactDOMServer from 'react-dom/server';
|
||||||
|
import DefaultLayout from '~/layouts/default_layout';
|
||||||
|
|
||||||
export default function render(page: any) {
|
export default function render(page: any) {
|
||||||
return createInertiaApp({
|
return createInertiaApp({
|
||||||
@@ -7,7 +8,11 @@ export default function render(page: any) {
|
|||||||
render: ReactDOMServer.renderToString,
|
render: ReactDOMServer.renderToString,
|
||||||
resolve: (name) => {
|
resolve: (name) => {
|
||||||
const pages = import.meta.glob('../pages/**/*.tsx', { eager: true });
|
const pages = import.meta.glob('../pages/**/*.tsx', { eager: true });
|
||||||
return pages[`../pages/${name}.tsx`];
|
let pageComponent: any = pages[`../pages/${name}.tsx`];
|
||||||
|
pageComponent.default.layout =
|
||||||
|
pageComponent?.default?.layout ||
|
||||||
|
((pageChildren: any) => <DefaultLayout children={pageChildren} />);
|
||||||
|
return pageComponent;
|
||||||
},
|
},
|
||||||
setup: ({ App, props }) => <App {...props} />,
|
setup: ({ App, props }) => <App {...props} />,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
.navbarWrapper {
|
||||||
|
z-index: 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
height: rem(60);
|
||||||
|
background-color: color-mix(
|
||||||
|
in srgb,
|
||||||
|
var(--mantine-color-body) 50%,
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
padding-inline: var(--mantine-spacing-lg);
|
||||||
|
transition: transform 400ms ease;
|
||||||
|
backdrop-filter: blur(16px);
|
||||||
|
overflow: hidden;
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar__content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
height: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
margin-inline: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar__content > div:last-child {
|
||||||
|
flex: 1;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
108
inertia/components/common/floating_navbar/floating_navbar.tsx
Normal file
108
inertia/components/common/floating_navbar/floating_navbar.tsx
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
import {
|
||||||
|
PROJECT_EXTENSION_URL,
|
||||||
|
PROJECT_NAME,
|
||||||
|
PROJECT_REPO_GITHUB_URL,
|
||||||
|
} from '#config/project';
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Burger,
|
||||||
|
Button,
|
||||||
|
Drawer,
|
||||||
|
Flex,
|
||||||
|
Group,
|
||||||
|
Image,
|
||||||
|
rem,
|
||||||
|
useMantineTheme,
|
||||||
|
} from '@mantine/core';
|
||||||
|
import { useDisclosure, useMediaQuery } from '@mantine/hooks';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import { UserDropdown } from '~/components/common/floating_navbar/user_dropdown';
|
||||||
|
import { ExternalLinkUnstyled } from '~/components/common/links/external_link_unstyled';
|
||||||
|
import { InternalLink } from '~/components/common/links/internal_link';
|
||||||
|
import { useAuth } from '~/hooks/use_auth';
|
||||||
|
import classes from './floating_navbar.module.css';
|
||||||
|
|
||||||
|
interface FloatingNavbarProps {
|
||||||
|
width: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FloatingNavbar({ width }: FloatingNavbarProps) {
|
||||||
|
const auth = useAuth();
|
||||||
|
const theme = useMantineTheme();
|
||||||
|
const [opened, handler] = useDisclosure(false);
|
||||||
|
const isMobile = useMediaQuery(`(max-width: ${theme.breakpoints.sm})`, false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (opened && !isMobile) {
|
||||||
|
handler.close();
|
||||||
|
}
|
||||||
|
}, [isMobile]);
|
||||||
|
|
||||||
|
const links = (
|
||||||
|
<>
|
||||||
|
<InternalLink route="dashboard" style={{ fontSize: rem(16) }}>
|
||||||
|
Dashboard
|
||||||
|
</InternalLink>
|
||||||
|
<ExternalLinkUnstyled
|
||||||
|
href={PROJECT_REPO_GITHUB_URL}
|
||||||
|
style={{ fontSize: rem(16) }}
|
||||||
|
>
|
||||||
|
Github
|
||||||
|
</ExternalLinkUnstyled>
|
||||||
|
<ExternalLinkUnstyled
|
||||||
|
href={PROJECT_EXTENSION_URL}
|
||||||
|
style={{ fontSize: rem(16) }}
|
||||||
|
>
|
||||||
|
Extension
|
||||||
|
</ExternalLinkUnstyled>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Box className={classes.navbar}>
|
||||||
|
<Group className={classes.navbar__content} style={{ width }}>
|
||||||
|
<Group>
|
||||||
|
<InternalLink style={{ fontSize: rem(24) }} route="home">
|
||||||
|
<Image
|
||||||
|
src="/logo.png"
|
||||||
|
h={35}
|
||||||
|
alt="MyLinks's logo"
|
||||||
|
referrerPolicy="no-referrer"
|
||||||
|
/>
|
||||||
|
</InternalLink>
|
||||||
|
</Group>
|
||||||
|
<Group>
|
||||||
|
{!isMobile && <Group>{links}</Group>}
|
||||||
|
{isMobile && <Burger opened={opened} onClick={handler.toggle} />}
|
||||||
|
{auth.isAuthenticated && <UserDropdown />}
|
||||||
|
{!auth.isAuthenticated && (
|
||||||
|
<Button
|
||||||
|
variant="default"
|
||||||
|
component={ExternalLinkUnstyled}
|
||||||
|
newTab={false}
|
||||||
|
href="/auth/google"
|
||||||
|
>
|
||||||
|
Log in
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
|
||||||
|
{/* Mobile drawer */}
|
||||||
|
<Drawer
|
||||||
|
opened={opened}
|
||||||
|
onClose={handler.close}
|
||||||
|
padding="md"
|
||||||
|
title={PROJECT_NAME}
|
||||||
|
zIndex={999999}
|
||||||
|
onClick={handler.close}
|
||||||
|
>
|
||||||
|
<Flex direction="column" gap="md">
|
||||||
|
{links}
|
||||||
|
</Flex>
|
||||||
|
</Drawer>
|
||||||
|
</Box>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
.user {
|
||||||
|
color: light-dark(var(--mantine-color-black), var(--mantine-color-dark-0));
|
||||||
|
padding: var(--mantine-spacing-xs) var(--mantine-spacing-sm) !important;
|
||||||
|
border-radius: var(--mantine-radius-sm);
|
||||||
|
transition: background-color 100ms ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: light-dark(
|
||||||
|
var(--mantine-color-white),
|
||||||
|
var(--mantine-color-dark-8)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.userActive {
|
||||||
|
background-color: light-dark(
|
||||||
|
var(--mantine-color-white),
|
||||||
|
var(--mantine-color-dark-8)
|
||||||
|
);
|
||||||
|
}
|
||||||
73
inertia/components/common/floating_navbar/user_dropdown.tsx
Normal file
73
inertia/components/common/floating_navbar/user_dropdown.tsx
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import { Avatar, Group, Menu, Text, UnstyledButton } from '@mantine/core';
|
||||||
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
|
import cx from 'clsx';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { TbChevronDown, TbLogout, TbUser } from 'react-icons/tb';
|
||||||
|
import { InternalLink } from '~/components/common/links/internal_link';
|
||||||
|
import { InternalLinkUnstyled } from '~/components/common/links/internal_link_unstyled';
|
||||||
|
import { useAuth } from '~/hooks/use_auth';
|
||||||
|
import classes from './user_dropdown.module.css';
|
||||||
|
|
||||||
|
export function UserDropdown() {
|
||||||
|
const auth = useAuth();
|
||||||
|
const [userMenuOpened, { open: openUserMenu, close: closeUserMenu }] =
|
||||||
|
useDisclosure(false);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<Menu
|
||||||
|
width={260}
|
||||||
|
position="bottom-end"
|
||||||
|
transitionProps={{ transition: 'pop-top-right' }}
|
||||||
|
onClose={closeUserMenu}
|
||||||
|
onOpen={openUserMenu}
|
||||||
|
withinPortal
|
||||||
|
>
|
||||||
|
<Menu.Target>
|
||||||
|
<UnstyledButton
|
||||||
|
className={cx(classes.user, { [classes.userActive]: userMenuOpened })}
|
||||||
|
>
|
||||||
|
<Group gap={7}>
|
||||||
|
<Avatar
|
||||||
|
src={auth.user?.avatarUrl}
|
||||||
|
alt={auth.user?.fullname}
|
||||||
|
radius="xl"
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
<Text fw={500} size="sm" lh={1} mr={3}>
|
||||||
|
{auth.user?.fullname}
|
||||||
|
</Text>
|
||||||
|
<TbChevronDown size={12} />
|
||||||
|
</Group>
|
||||||
|
</UnstyledButton>
|
||||||
|
</Menu.Target>
|
||||||
|
<Menu.Dropdown>
|
||||||
|
<Menu.Label>{t('common:user')}</Menu.Label>
|
||||||
|
<Menu.Item
|
||||||
|
leftSection={<TbUser size={16} />}
|
||||||
|
component={InternalLinkUnstyled}
|
||||||
|
href={`/user/${auth.user?.fullname}`}
|
||||||
|
color="inherit"
|
||||||
|
>
|
||||||
|
{t('common:profile')}
|
||||||
|
</Menu.Item>
|
||||||
|
|
||||||
|
{auth.user?.isAdmin && (
|
||||||
|
<>
|
||||||
|
<Menu.Label>{t('common:admin')}</Menu.Label>
|
||||||
|
<InternalLink href="/admin">{t('common:admin')}</InternalLink>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Menu.Label>{t('common:settings')}</Menu.Label>
|
||||||
|
<Menu.Item
|
||||||
|
leftSection={<TbLogout size={16} />}
|
||||||
|
component={InternalLinkUnstyled}
|
||||||
|
href="/auth/logout"
|
||||||
|
color="inherit"
|
||||||
|
>
|
||||||
|
{t('common:logout')}
|
||||||
|
</Menu.Item>
|
||||||
|
</Menu.Dropdown>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
}
|
||||||
23
inertia/components/common/footer/footer.module.css
Normal file
23
inertia/components/common/footer/footer.module.css
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
.footer {
|
||||||
|
background-color: color-mix(
|
||||||
|
in srgb,
|
||||||
|
var(--mantine-color-body) 50%,
|
||||||
|
transparent
|
||||||
|
);
|
||||||
|
padding: var(--mantine-spacing-sm) var(--mantine-spacing-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer__content {
|
||||||
|
max-width: 100%;
|
||||||
|
gap: var(--mantine-spacing-xs);
|
||||||
|
margin-inline: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer__content p {
|
||||||
|
font-size: var(--mantine-font-size-sm) !important;
|
||||||
|
color: var(--mantine-color-dimmed) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer__content a {
|
||||||
|
font-size: var(--mantine-font-size-sm) !important;
|
||||||
|
}
|
||||||
33
inertia/components/common/footer/footer.tsx
Normal file
33
inertia/components/common/footer/footer.tsx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { AUTHOR_GITHUB_URL, AUTHOR_NAME } from '#config/project';
|
||||||
|
import PATHS from '#core/constants/paths';
|
||||||
|
import { Anchor, Group, Text } from '@mantine/core';
|
||||||
|
import ExternalLink from '~/components/common/external_link';
|
||||||
|
import { ExternalLinkStyled } from '~/components/common/links/external_link_styled';
|
||||||
|
import { LocaleSwitcher } from '~/components/common/locale_switcher';
|
||||||
|
import { ThemeSwitcher } from '~/components/common/theme_switcher';
|
||||||
|
import packageJson from '../../../../package.json';
|
||||||
|
import classes from './footer.module.css';
|
||||||
|
|
||||||
|
export const Footer = () => (
|
||||||
|
<Group className={classes.footer}>
|
||||||
|
<Group className={classes.footer__content}>
|
||||||
|
<Text>
|
||||||
|
Made with ❤️ by{' '}
|
||||||
|
<ExternalLinkStyled href={AUTHOR_GITHUB_URL}>
|
||||||
|
{AUTHOR_NAME}
|
||||||
|
</ExternalLinkStyled>
|
||||||
|
</Text>
|
||||||
|
•
|
||||||
|
<Text>
|
||||||
|
<Anchor size="sm" component={ExternalLink} href={PATHS.REPO_GITHUB}>
|
||||||
|
{packageJson.version}
|
||||||
|
</Anchor>
|
||||||
|
</Text>
|
||||||
|
•
|
||||||
|
<Group gap="sm" mt={4} mb={4}>
|
||||||
|
<ThemeSwitcher />
|
||||||
|
<LocaleSwitcher />
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
28
inertia/components/common/links/external_link_styled.tsx
Normal file
28
inertia/components/common/links/external_link_styled.tsx
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { Anchor } from '@mantine/core';
|
||||||
|
import { AnchorHTMLAttributes, CSSProperties, ReactNode } from 'react';
|
||||||
|
|
||||||
|
interface ExternalLinkStyledProps
|
||||||
|
extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
||||||
|
children: ReactNode;
|
||||||
|
style?: CSSProperties;
|
||||||
|
title?: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ExternalLinkStyled = ({
|
||||||
|
children,
|
||||||
|
title,
|
||||||
|
href,
|
||||||
|
...props
|
||||||
|
}: ExternalLinkStyledProps) => (
|
||||||
|
<Anchor<'a'>
|
||||||
|
component="a"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
title={title}
|
||||||
|
href={href}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Anchor>
|
||||||
|
);
|
||||||
26
inertia/components/common/links/external_link_unstyled.tsx
Normal file
26
inertia/components/common/links/external_link_unstyled.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { Anchor, CSSProperties } from '@mantine/core';
|
||||||
|
import { AnchorHTMLAttributes, ReactNode } from 'react';
|
||||||
|
|
||||||
|
interface ExternalLinkUnstyledProps
|
||||||
|
extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
||||||
|
children: ReactNode;
|
||||||
|
style?: CSSProperties;
|
||||||
|
title?: string;
|
||||||
|
className?: string;
|
||||||
|
newTab?: boolean;
|
||||||
|
}
|
||||||
|
export const ExternalLinkUnstyled = ({
|
||||||
|
children,
|
||||||
|
newTab = true,
|
||||||
|
...props
|
||||||
|
}: ExternalLinkUnstyledProps) => (
|
||||||
|
<Anchor
|
||||||
|
component="a"
|
||||||
|
target={newTab ? '_blank' : undefined}
|
||||||
|
rel="noreferrer"
|
||||||
|
{...props}
|
||||||
|
style={{ ...props.style, textDecoration: 'none' }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Anchor>
|
||||||
|
);
|
||||||
50
inertia/components/common/links/internal_link.tsx
Normal file
50
inertia/components/common/links/internal_link.tsx
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { ApiRouteName } from '#shared/types/index';
|
||||||
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { Anchor } from '@mantine/core';
|
||||||
|
import { useTuyau } from '@tuyau/inertia/react';
|
||||||
|
import { CSSProperties } from 'react';
|
||||||
|
|
||||||
|
interface InternalLinkProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
onClick?: (event: React.MouseEvent<any>) => void;
|
||||||
|
route?: ApiRouteName;
|
||||||
|
href?: string;
|
||||||
|
forceRefresh?: boolean;
|
||||||
|
style?: CSSProperties;
|
||||||
|
className?: string;
|
||||||
|
params?: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const InternalLink = ({
|
||||||
|
children,
|
||||||
|
onClick,
|
||||||
|
route,
|
||||||
|
href,
|
||||||
|
forceRefresh,
|
||||||
|
style,
|
||||||
|
className,
|
||||||
|
params,
|
||||||
|
}: InternalLinkProps) => {
|
||||||
|
const tuyau = useTuyau();
|
||||||
|
|
||||||
|
if ((!route && !href) || !tuyau) {
|
||||||
|
throw new Error('InternalLink: route, href or tuyau is missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = route ? tuyau.$route(route, params).path : href;
|
||||||
|
if (!url) {
|
||||||
|
throw new Error('InternalLink: url not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Anchor<'a' | typeof Link>
|
||||||
|
component={forceRefresh ? 'a' : Link}
|
||||||
|
href={url}
|
||||||
|
style={style}
|
||||||
|
onClick={onClick}
|
||||||
|
className={className}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Anchor>
|
||||||
|
);
|
||||||
|
};
|
||||||
61
inertia/components/common/links/internal_link_unstyled.tsx
Normal file
61
inertia/components/common/links/internal_link_unstyled.tsx
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import { ApiRouteName } from '#shared/types/index';
|
||||||
|
import { Link } from '@inertiajs/react';
|
||||||
|
import { useTuyau } from '@tuyau/inertia/react';
|
||||||
|
import { CSSProperties } from 'react';
|
||||||
|
|
||||||
|
interface InternalLinkProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
onClick?: (event: React.MouseEvent<any>) => void;
|
||||||
|
route?: ApiRouteName;
|
||||||
|
href?: string;
|
||||||
|
forceRefresh?: boolean;
|
||||||
|
style?: CSSProperties;
|
||||||
|
className?: string;
|
||||||
|
params?: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const InternalLinkUnstyled = ({
|
||||||
|
children,
|
||||||
|
onClick,
|
||||||
|
route,
|
||||||
|
href,
|
||||||
|
forceRefresh,
|
||||||
|
style,
|
||||||
|
className,
|
||||||
|
params,
|
||||||
|
}: InternalLinkProps) => {
|
||||||
|
const tuyau = useTuyau();
|
||||||
|
|
||||||
|
if ((!route && !href) || !tuyau) {
|
||||||
|
throw new Error('InternalLink: route, href or tuyau is missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = route ? tuyau.$route(route, params).path : href;
|
||||||
|
if (!url) {
|
||||||
|
throw new Error('InternalLink: url not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forceRefresh) {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
href={url}
|
||||||
|
style={{ ...style, textDecoration: 'none' }}
|
||||||
|
onClick={onClick}
|
||||||
|
className={className}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
href={url}
|
||||||
|
style={{ ...style, textDecoration: 'none' }}
|
||||||
|
onClick={onClick}
|
||||||
|
className={className}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -2,7 +2,7 @@ import { ActionIcon, Image } from '@mantine/core';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { LS_LANG_KEY } from '~/constants';
|
import { LS_LANG_KEY } from '~/constants';
|
||||||
|
|
||||||
export function MantineLanguageSwitcher() {
|
export function LocaleSwitcher() {
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const newLanguage = i18n.language === 'en' ? 'fr' : 'en';
|
const newLanguage = i18n.language === 'en' ? 'fr' : 'en';
|
||||||
return (
|
return (
|
||||||
@@ -2,7 +2,7 @@ import { ActionIcon, useMantineColorScheme } from '@mantine/core';
|
|||||||
import { TbMoonStars, TbSun } from 'react-icons/tb';
|
import { TbMoonStars, TbSun } from 'react-icons/tb';
|
||||||
import { makeRequest } from '~/lib/request';
|
import { makeRequest } from '~/lib/request';
|
||||||
|
|
||||||
export function MantineThemeSwitcher() {
|
export function ThemeSwitcher() {
|
||||||
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
|
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
|
||||||
const handleThemeChange = () => {
|
const handleThemeChange = () => {
|
||||||
toggleColorScheme();
|
toggleColorScheme();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Avatar, Group, Menu, Text, UnstyledButton } from '@mantine/core';
|
|||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { TbChevronRight } from 'react-icons/tb';
|
import { TbChevronRight } from 'react-icons/tb';
|
||||||
import useUser from '~/hooks/use_user';
|
import { useAuth } from '~/hooks/use_auth';
|
||||||
|
|
||||||
interface UserButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
interface UserButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
||||||
image: string;
|
image: string;
|
||||||
@@ -45,9 +45,9 @@ const UserButton = forwardRef<HTMLButtonElement, UserButtonProps>(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
export function MantineUserCard() {
|
export function UserCard() {
|
||||||
const { t } = useTranslation('common');
|
const { t } = useTranslation('common');
|
||||||
const { user, isAuthenticated } = useUser();
|
const { user, isAuthenticated } = useAuth();
|
||||||
return (
|
return (
|
||||||
isAuthenticated && (
|
isAuthenticated && (
|
||||||
<Menu withArrow>
|
<Menu withArrow>
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ import { AiOutlineFolderAdd } from 'react-icons/ai';
|
|||||||
import { IoIosSearch } from 'react-icons/io';
|
import { IoIosSearch } from 'react-icons/io';
|
||||||
import { IoAdd, IoShieldHalfSharp } from 'react-icons/io5';
|
import { IoAdd, IoShieldHalfSharp } from 'react-icons/io5';
|
||||||
import { PiGearLight } from 'react-icons/pi';
|
import { PiGearLight } from 'react-icons/pi';
|
||||||
import { MantineUserCard } from '~/components/common/user_card';
|
import { UserCard } from '~/components/common/user_card';
|
||||||
import { FavoriteList } from '~/components/dashboard/favorite/favorite_list';
|
import { FavoriteList } from '~/components/dashboard/favorite/favorite_list';
|
||||||
import { SearchSpotlight } from '~/components/search/search';
|
import { SearchSpotlight } from '~/components/search/search';
|
||||||
|
import { useAuth } from '~/hooks/use_auth';
|
||||||
import useShortcut from '~/hooks/use_shortcut';
|
import useShortcut from '~/hooks/use_shortcut';
|
||||||
import useUser from '~/hooks/use_user';
|
|
||||||
import { appendCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
import { useActiveCollection } from '~/stores/collection_store';
|
import { useActiveCollection } from '~/stores/collection_store';
|
||||||
import { useGlobalHotkeysStore } from '~/stores/global_hotkeys_store';
|
import { useGlobalHotkeysStore } from '~/stores/global_hotkeys_store';
|
||||||
@@ -32,7 +32,7 @@ interface DashboardNavbarProps {
|
|||||||
}
|
}
|
||||||
export function DashboardNavbar({ isOpen, toggle }: DashboardNavbarProps) {
|
export function DashboardNavbar({ isOpen, toggle }: DashboardNavbarProps) {
|
||||||
const { t } = useTranslation('common');
|
const { t } = useTranslation('common');
|
||||||
const { isAuthenticated, user } = useUser();
|
const { isAuthenticated, user } = useAuth();
|
||||||
|
|
||||||
const { activeCollection } = useActiveCollection();
|
const { activeCollection } = useActiveCollection();
|
||||||
const { globalHotkeysEnabled, setGlobalHotkeysEnabled } =
|
const { globalHotkeysEnabled, setGlobalHotkeysEnabled } =
|
||||||
@@ -84,7 +84,7 @@ export function DashboardNavbar({ isOpen, toggle }: DashboardNavbarProps) {
|
|||||||
<Burger opened={isOpen} onClick={toggle} size="sm" />
|
<Burger opened={isOpen} onClick={toggle} size="sm" />
|
||||||
<Text>Navigation</Text>
|
<Text>Navigation</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<MantineUserCard />
|
<UserCard />
|
||||||
<Divider mt="xs" mb="md" />
|
<Divider mt="xs" mb="md" />
|
||||||
{isAuthenticated && user.isAdmin && (
|
{isAuthenticated && user.isAdmin && (
|
||||||
<NavLink
|
<NavLink
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { route } from '@izzyjs/route/client';
|
|||||||
import { Anchor, Group, Text } from '@mantine/core';
|
import { Anchor, Group, Text } from '@mantine/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import ExternalLink from '~/components/common/external_link';
|
import ExternalLink from '~/components/common/external_link';
|
||||||
import { MantineLanguageSwitcher } from '~/components/common/language_switcher';
|
import { LocaleSwitcher } from '~/components/common/locale_switcher';
|
||||||
import { MantineThemeSwitcher } from '~/components/common/theme_switcher';
|
import { ThemeSwitcher } from '~/components/common/theme_switcher';
|
||||||
import packageJson from '../../../package.json';
|
import packageJson from '../../../package.json';
|
||||||
import classes from './footer.module.css';
|
import classes from './footer.module.css';
|
||||||
|
|
||||||
@@ -46,8 +46,8 @@ export function MantineFooter() {
|
|||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group gap="sm" mt={4} mb={4}>
|
<Group gap="sm" mt={4} mb={4}>
|
||||||
<MantineThemeSwitcher />
|
<ThemeSwitcher />
|
||||||
<MantineLanguageSwitcher />
|
<LocaleSwitcher />
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group gap="xs" justify="flex-end" wrap="nowrap">
|
<Group gap="xs" justify="flex-end" wrap="nowrap">
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ import {
|
|||||||
import { useDisclosure } from '@mantine/hooks';
|
import { useDisclosure } from '@mantine/hooks';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import ExternalLink from '~/components/common/external_link';
|
import ExternalLink from '~/components/common/external_link';
|
||||||
import { MantineLanguageSwitcher } from '~/components/common/language_switcher';
|
import { LocaleSwitcher } from '~/components/common/locale_switcher';
|
||||||
import { MantineThemeSwitcher } from '~/components/common/theme_switcher';
|
import { ThemeSwitcher } from '~/components/common/theme_switcher';
|
||||||
import useUser from '~/hooks/use_user';
|
import useUser from '~/hooks/use_auth';
|
||||||
import classes from './mobile.module.css';
|
import classes from './mobile.module.css';
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
@@ -47,8 +47,8 @@ export default function Navbar() {
|
|||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
<MantineThemeSwitcher />
|
<ThemeSwitcher />
|
||||||
<MantineLanguageSwitcher />
|
<LocaleSwitcher />
|
||||||
{!isAuthenticated ? (
|
{!isAuthenticated ? (
|
||||||
<Button
|
<Button
|
||||||
component="a"
|
component="a"
|
||||||
|
|||||||
25
inertia/hooks/use_auth.tsx
Normal file
25
inertia/hooks/use_auth.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { usePage } from '@inertiajs/react';
|
||||||
|
import type { Auth, InertiaPage } from '~/types/inertia';
|
||||||
|
|
||||||
|
export const useAuth = () => usePage<InertiaPage>().props.auth;
|
||||||
|
|
||||||
|
export const withAuth = <T extends object>(
|
||||||
|
Component: React.ComponentType<T & { auth: Auth }>
|
||||||
|
): React.ComponentType<Omit<T, 'auth'>> => {
|
||||||
|
return (props: Omit<T, 'auth'>) => {
|
||||||
|
const auth = useAuth();
|
||||||
|
return <Component {...(props as T)} auth={auth} />;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const withAuthRequired = <T extends object>(
|
||||||
|
Component: React.ComponentType<T & { auth: Auth }>
|
||||||
|
): React.ComponentType<Omit<T, 'auth'>> => {
|
||||||
|
return (props: Omit<T, 'auth'>) => {
|
||||||
|
const auth = useAuth();
|
||||||
|
if (!auth.isAuthenticated) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return <Component {...(props as T)} auth={auth} />;
|
||||||
|
};
|
||||||
|
};
|
||||||
48
inertia/hooks/use_route.tsx
Normal file
48
inertia/hooks/use_route.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { ApiRouteName } from '#shared/types/index';
|
||||||
|
import { useTuyau } from '@tuyau/inertia/react';
|
||||||
|
import { buildUrl } from '~/lib/navigation';
|
||||||
|
|
||||||
|
interface TuyauRoute {
|
||||||
|
route: ApiRouteName;
|
||||||
|
params?: Record<string, string>; // TODO: add type
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NonTuyauRoute {
|
||||||
|
href: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type UseRouteProps = TuyauRoute | NonTuyauRoute;
|
||||||
|
|
||||||
|
type TuyauReturn = {
|
||||||
|
url: string;
|
||||||
|
method: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type NonTuyauReturn = {
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type UseRouteReturn<T extends UseRouteProps> = T extends TuyauRoute
|
||||||
|
? TuyauReturn
|
||||||
|
: NonTuyauReturn;
|
||||||
|
|
||||||
|
export const useRoute = <T extends UseRouteProps>(
|
||||||
|
props: T
|
||||||
|
): UseRouteReturn<T> => {
|
||||||
|
const tuyau = useTuyau();
|
||||||
|
if ('href' in props) {
|
||||||
|
return {
|
||||||
|
url: props.href,
|
||||||
|
} as UseRouteReturn<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const route = tuyau?.$route(props.route, props.params);
|
||||||
|
if (!route) {
|
||||||
|
throw new Error(`Route ${props.route} not found`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: buildUrl(route.path, props.params ?? {}),
|
||||||
|
method: route.method,
|
||||||
|
} as UseRouteReturn<T>;
|
||||||
|
};
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import { usePage } from '@inertiajs/react';
|
|
||||||
import type { InertiaPage } from '~/types/inertia';
|
|
||||||
|
|
||||||
const useUser = () => usePage<InertiaPage>().props.auth;
|
|
||||||
export default useUser;
|
|
||||||
@@ -1,7 +1,17 @@
|
|||||||
import { router } from '@inertiajs/react';
|
import { api } from '#adonis/api';
|
||||||
import { ColorSchemeScript, MantineProvider } from '@mantine/core';
|
import { PRIMARY_COLOR } from '#config/project';
|
||||||
|
import { PageProps } from '@adonisjs/inertia/types';
|
||||||
|
import { router, usePage } from '@inertiajs/react';
|
||||||
|
import {
|
||||||
|
ColorSchemeScript,
|
||||||
|
createTheme,
|
||||||
|
MantineProvider,
|
||||||
|
rem,
|
||||||
|
} from '@mantine/core';
|
||||||
import '@mantine/core/styles.css';
|
import '@mantine/core/styles.css';
|
||||||
import '@mantine/spotlight/styles.css';
|
import '@mantine/spotlight/styles.css';
|
||||||
|
import { createTuyau } from '@tuyau/client';
|
||||||
|
import { TuyauProvider } from '@tuyau/inertia/react';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { ReactNode, useEffect } from 'react';
|
import { ReactNode, useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@@ -10,9 +20,66 @@ import '../styles/index.css';
|
|||||||
const TRANSITION_IN_CLASS = '__transition_fadeIn';
|
const TRANSITION_IN_CLASS = '__transition_fadeIn';
|
||||||
const TRANSITION_OUT_CLASS = '__transition_fadeOut';
|
const TRANSITION_OUT_CLASS = '__transition_fadeOut';
|
||||||
|
|
||||||
export default function BaseLayout({ children }: { children: ReactNode }) {
|
const customTheme = createTheme({
|
||||||
|
colors: {
|
||||||
|
blue: [
|
||||||
|
'#e7f5ff',
|
||||||
|
'#d0ebff',
|
||||||
|
'#a5d8ff',
|
||||||
|
'#74c0fc',
|
||||||
|
'#4dabf7',
|
||||||
|
PRIMARY_COLOR,
|
||||||
|
'#228be6',
|
||||||
|
'#1c7ed6',
|
||||||
|
'#1971c2',
|
||||||
|
'#1864ab',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
primaryColor: 'blue',
|
||||||
|
fontFamily: 'Poppins, sans-serif',
|
||||||
|
respectReducedMotion: true,
|
||||||
|
components: {
|
||||||
|
Button: {
|
||||||
|
styles: {
|
||||||
|
root: {
|
||||||
|
fontWeight: '400',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Badge: {
|
||||||
|
styles: {
|
||||||
|
root: {
|
||||||
|
fontWeight: '500',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
headings: {
|
||||||
|
fontWeight: '400',
|
||||||
|
|
||||||
|
sizes: {
|
||||||
|
h1: {
|
||||||
|
fontSize: rem(36),
|
||||||
|
lineHeight: '1.4',
|
||||||
|
},
|
||||||
|
h2: { fontSize: rem(30), lineHeight: '1.2' },
|
||||||
|
h3: { fontSize: rem(24), lineHeight: '1.2' },
|
||||||
|
h4: { fontSize: rem(20), lineHeight: '1.2' },
|
||||||
|
h5: { fontSize: rem(16), lineHeight: '1.2' },
|
||||||
|
h6: { fontSize: rem(12), lineHeight: '1.2' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export function BaseLayout({ children }: { children: ReactNode }) {
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
dayjs.locale(i18n.language);
|
dayjs.locale(i18n.language);
|
||||||
|
const { props } = usePage<PageProps & { appBaseUrl: string }>();
|
||||||
|
|
||||||
|
const tuyauClient = createTuyau({
|
||||||
|
api,
|
||||||
|
baseUrl: props.appBaseUrl,
|
||||||
|
});
|
||||||
|
|
||||||
const findAppElement = () => document.getElementById('app');
|
const findAppElement = () => document.getElementById('app');
|
||||||
|
|
||||||
@@ -50,9 +117,9 @@ export default function BaseLayout({ children }: { children: ReactNode }) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<TuyauProvider client={tuyauClient}>
|
||||||
<ColorSchemeScript />
|
<ColorSchemeScript />
|
||||||
<MantineProvider>{children}</MantineProvider>
|
<MantineProvider theme={customTheme}>{children}</MantineProvider>
|
||||||
</>
|
</TuyauProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import { Container } from '@mantine/core';
|
|
||||||
import { PropsWithChildren } from 'react';
|
|
||||||
import { MantineFooter } from '~/components/footer/footer';
|
|
||||||
import Navbar from '~/components/navbar/navbar';
|
|
||||||
import BaseLayout from '~/layouts/_base_layout';
|
|
||||||
|
|
||||||
const ContentLayout = ({ children }: PropsWithChildren) => (
|
|
||||||
<Container
|
|
||||||
style={{
|
|
||||||
minHeight: '100%',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Navbar />
|
|
||||||
<main
|
|
||||||
style={{
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</main>
|
|
||||||
<MantineFooter />
|
|
||||||
</Container>
|
|
||||||
);
|
|
||||||
|
|
||||||
const LayoutWrapper = ({ children }: PropsWithChildren) => (
|
|
||||||
<BaseLayout>
|
|
||||||
<ContentLayout>{children}</ContentLayout>
|
|
||||||
</BaseLayout>
|
|
||||||
);
|
|
||||||
|
|
||||||
export { LayoutWrapper as ContentLayout };
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { PropsWithChildren } from 'react';
|
import { PropsWithChildren } from 'react';
|
||||||
import BaseLayout from '~/layouts/_base_layout';
|
import { BaseLayout } from '~/layouts/_base_layout';
|
||||||
|
|
||||||
const LayoutWrapper = ({ children }: PropsWithChildren) => (
|
const LayoutWrapper = ({ children }: PropsWithChildren) => (
|
||||||
<BaseLayout>{children}</BaseLayout>
|
<BaseLayout>{children}</BaseLayout>
|
||||||
|
|||||||
44
inertia/layouts/default_layout.tsx
Normal file
44
inertia/layouts/default_layout.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import { Box, rem } from '@mantine/core';
|
||||||
|
import { PropsWithChildren } from 'react';
|
||||||
|
import { FloatingNavbar } from '~/components/common/floating_navbar/floating_navbar';
|
||||||
|
import { Footer } from '~/components/common/footer/footer';
|
||||||
|
import { BaseLayout } from './_base_layout';
|
||||||
|
|
||||||
|
const DefaultLayout = ({ children }: PropsWithChildren) => (
|
||||||
|
<BaseLayout>
|
||||||
|
<Layout>{children}</Layout>
|
||||||
|
</BaseLayout>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default DefaultLayout;
|
||||||
|
|
||||||
|
const LAYOUT_WIDTH = '1500px';
|
||||||
|
const Layout = ({ children }: PropsWithChildren) => (
|
||||||
|
<>
|
||||||
|
{/* Top navbar */}
|
||||||
|
<FloatingNavbar width={LAYOUT_WIDTH} />
|
||||||
|
|
||||||
|
{/* Page content */}
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
paddingInline: 'var(--mantine-spacing-lg)',
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
style={{
|
||||||
|
height: '100%',
|
||||||
|
maxWidth: '100%',
|
||||||
|
width: LAYOUT_WIDTH,
|
||||||
|
marginInline: 'auto',
|
||||||
|
marginBlock: rem(60),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Footer */}
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
);
|
||||||
@@ -3,9 +3,8 @@ import { route } from '@izzyjs/route/client';
|
|||||||
import { Anchor, Button, Container, Group, rem, Title } from '@mantine/core';
|
import { Anchor, Button, Container, Group, rem, Title } from '@mantine/core';
|
||||||
import { FormEvent, PropsWithChildren } from 'react';
|
import { FormEvent, PropsWithChildren } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { MantineFooter } from '~/components/footer/footer';
|
|
||||||
import i18n from '~/i18n';
|
import i18n from '~/i18n';
|
||||||
import BaseLayout from '~/layouts/_base_layout';
|
import { BaseLayout } from '~/layouts/_base_layout';
|
||||||
import { appendCollectionId } from '~/lib/navigation';
|
import { appendCollectionId } from '~/lib/navigation';
|
||||||
|
|
||||||
export interface FormLayoutProps extends PropsWithChildren {
|
export interface FormLayoutProps extends PropsWithChildren {
|
||||||
@@ -40,7 +39,7 @@ function FormLayout({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
}}
|
}}
|
||||||
pt={80}
|
pt={rem(40)}
|
||||||
>
|
>
|
||||||
<main
|
<main
|
||||||
style={{
|
style={{
|
||||||
@@ -87,7 +86,6 @@ function FormLayout({
|
|||||||
{textSubmitButton}
|
{textSubmitButton}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
<MantineFooter />
|
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
@@ -34,3 +34,11 @@ export const generateShareUrl = (
|
|||||||
if (typeof window === 'undefined') return pathname;
|
if (typeof window === 'undefined') return pathname;
|
||||||
return `${window.location.origin}${pathname}`;
|
return `${window.location.origin}${pathname}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const buildUrl = (url: string, params: Record<string, string>) => {
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
Object.entries(params).forEach(([key, value]) => {
|
||||||
|
urlObj.searchParams.set(key, value);
|
||||||
|
});
|
||||||
|
return urlObj.toString();
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
import {
|
import {
|
||||||
UsersTable,
|
UsersTable,
|
||||||
UsersTableProps,
|
UsersTableProps,
|
||||||
} from '~/components/admin/users/users_table';
|
} from '~/components/admin/users/users_table';
|
||||||
import { ContentLayout } from '~/layouts/content_layout';
|
|
||||||
|
|
||||||
function AdminDashboardPage(props: UsersTableProps) {
|
export default function AdminDashboardPage(props: UsersTableProps) {
|
||||||
return <UsersTable {...props} />;
|
return <UsersTable {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminDashboardPage.layout = (page: ReactNode) => (
|
|
||||||
<ContentLayout children={page} />
|
|
||||||
);
|
|
||||||
export default AdminDashboardPage;
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
font-family:
|
font-family:
|
||||||
Greycliff CF,
|
Greycliff CF,
|
||||||
var(--mantine-font-family);
|
var(--mantine-font-family);
|
||||||
font-weight: 900;
|
|
||||||
margin-bottom: var(--mantine-spacing-md);
|
margin-bottom: var(--mantine-spacing-md);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
@@ -18,6 +17,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
|
color: var(--mantine-color-dimmed);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
@media (max-width: $mantine-breakpoint-sm) {
|
@media (max-width: $mantine-breakpoint-sm) {
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import { Container, Text, Title } from '@mantine/core';
|
import { Container, Text, Title } from '@mantine/core';
|
||||||
import { ReactNode } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { FeatureList } from '~/components/home/feature_list';
|
import { FeatureList } from '~/components/home/feature_list';
|
||||||
import classes from './home.module.css';
|
import classes from './home.module.css';
|
||||||
import { ContentLayout } from '~/layouts/content_layout';
|
|
||||||
|
|
||||||
function HomePage() {
|
export default function HomePage() {
|
||||||
const { t } = useTranslation('about');
|
const { t } = useTranslation('about');
|
||||||
return (
|
return (
|
||||||
<Container className={classes.wrapper}>
|
<Container className={classes.wrapper}>
|
||||||
@@ -21,6 +19,3 @@ function HomePage() {
|
|||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
HomePage.layout = (page: ReactNode) => <ContentLayout children={page} />;
|
|
||||||
export default HomePage;
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { ContentLayout } from '~/layouts/content_layout';
|
|
||||||
|
|
||||||
function PrivacyPage() {
|
export default function PrivacyPage() {
|
||||||
const { t } = useTranslation('privacy');
|
const { t } = useTranslation('privacy');
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -43,6 +41,3 @@ function PrivacyPage() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivacyPage.layout = (page: ReactNode) => <ContentLayout children={page} />;
|
|
||||||
export default PrivacyPage;
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import { Flex, Text } from '@mantine/core';
|
import { Flex, Text } from '@mantine/core';
|
||||||
import { ReactNode, useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { LinkList } from '~/components/dashboard/link/list/link_list';
|
import { LinkList } from '~/components/dashboard/link/list/link_list';
|
||||||
import { ContentLayout } from '~/layouts/content_layout';
|
|
||||||
import { useCollectionsSetter } from '~/stores/collection_store';
|
import { useCollectionsSetter } from '~/stores/collection_store';
|
||||||
import type { CollectionWithLinks, PublicUser } from '~/types/app';
|
import type { CollectionWithLinks, PublicUser } from '~/types/app';
|
||||||
|
|
||||||
@@ -10,7 +9,7 @@ interface SharedPageProps {
|
|||||||
collection: CollectionWithLinks & { author: PublicUser };
|
collection: CollectionWithLinks & { author: PublicUser };
|
||||||
}
|
}
|
||||||
|
|
||||||
function SharedPage({ collection }: SharedPageProps) {
|
export default function SharedPage({ collection }: SharedPageProps) {
|
||||||
const { t } = useTranslation('common');
|
const { t } = useTranslation('common');
|
||||||
const { setActiveCollection } = useCollectionsSetter();
|
const { setActiveCollection } = useCollectionsSetter();
|
||||||
|
|
||||||
@@ -43,6 +42,3 @@ function SharedPage({ collection }: SharedPageProps) {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPage.layout = (page: ReactNode) => <ContentLayout>{page}</ContentLayout>;
|
|
||||||
export default SharedPage;
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import { Link } from '@inertiajs/react';
|
import { Link } from '@inertiajs/react';
|
||||||
import { route } from '@izzyjs/route/client';
|
import { route } from '@izzyjs/route/client';
|
||||||
import { ReactNode } from 'react';
|
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
import { ContentLayout } from '~/layouts/content_layout';
|
|
||||||
|
|
||||||
function TermsPage() {
|
export default function TermsPage() {
|
||||||
const { t } = useTranslation('terms');
|
const { t } = useTranslation('terms');
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -52,6 +50,3 @@ function TermsPage() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
TermsPage.layout = (page: ReactNode) => <ContentLayout children={page} />;
|
|
||||||
export default TermsPage;
|
|
||||||
|
|||||||
@@ -3,11 +3,26 @@
|
|||||||
--ml-bg-dark: rgb(34, 40, 49);
|
--ml-bg-dark: rgb(34, 40, 49);
|
||||||
}
|
}
|
||||||
|
|
||||||
html,
|
/* Fix nprogress position */
|
||||||
body {
|
#nprogress {
|
||||||
min-height: 100svh;
|
position: relative;
|
||||||
width: 100%;
|
z-index: 9999999;
|
||||||
background-color: light-dark(var(--ml-bg-light), var(--ml-bg-dark));
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For light mode */
|
||||||
|
:root[data-mantine-color-scheme='light'] {
|
||||||
|
--mantine-color-body: var(--ml-bg-light) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For dark mode */
|
||||||
|
:root[data-mantine-color-scheme='dark'] {
|
||||||
|
--mantine-color-body: var(--ml-bg-dark) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.__transition_fadeIn {
|
.__transition_fadeIn {
|
||||||
|
|||||||
41
package.json
41
package.json
@@ -14,12 +14,15 @@
|
|||||||
"check": "pnpm run lint && pnpm run typecheck",
|
"check": "pnpm run lint && pnpm run typecheck",
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"release": "release-it",
|
"release": "release-it",
|
||||||
"generate-icons": "pwa-assets-generator"
|
"generate-icons": "pwa-assets-generator",
|
||||||
|
"tuyau": "node ace tuyau:generate"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
"#admin/*": "./app/admin/*.js",
|
"#admin/*": "./app/admin/*.js",
|
||||||
|
"#adonis/api": "./.adonisjs/api.ts",
|
||||||
"#auth/*": "./app/auth/*.js",
|
"#auth/*": "./app/auth/*.js",
|
||||||
"#collections/*": "./app/collections/*.js",
|
"#collections/*": "./app/collections/*.js",
|
||||||
|
"#config/*": "./config/*.js",
|
||||||
"#core/*": "./app/core/*.js",
|
"#core/*": "./app/core/*.js",
|
||||||
"#favicons/*": "./app/favicons/*.js",
|
"#favicons/*": "./app/favicons/*.js",
|
||||||
"#home/*": "./app/home/*.js",
|
"#home/*": "./app/home/*.js",
|
||||||
@@ -31,12 +34,12 @@
|
|||||||
"#providers/*": "./providers/*.js",
|
"#providers/*": "./providers/*.js",
|
||||||
"#database/*": "./database/*.js",
|
"#database/*": "./database/*.js",
|
||||||
"#tests/*": "./tests/*.js",
|
"#tests/*": "./tests/*.js",
|
||||||
"#start/*": "./start/*.js",
|
"#shared/*": "./shared/*.js",
|
||||||
"#config/*": "./config/*.js"
|
"#start/*": "./start/*.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@adonisjs/assembler": "^7.8.2",
|
"@adonisjs/assembler": "^7.8.2",
|
||||||
"@adonisjs/eslint-config": "2.1.0",
|
"@adonisjs/eslint-config": "2.1.1",
|
||||||
"@adonisjs/prettier-config": "^1.4.5",
|
"@adonisjs/prettier-config": "^1.4.5",
|
||||||
"@adonisjs/tsconfig": "^1.4.1",
|
"@adonisjs/tsconfig": "^1.4.1",
|
||||||
"@faker-js/faker": "^9.9.0",
|
"@faker-js/faker": "^9.9.0",
|
||||||
@@ -44,26 +47,26 @@
|
|||||||
"@japa/plugin-adonisjs": "^4.0.0",
|
"@japa/plugin-adonisjs": "^4.0.0",
|
||||||
"@japa/runner": "^4.3.0",
|
"@japa/runner": "^4.3.0",
|
||||||
"@swc/core": "^1.13.3",
|
"@swc/core": "^1.13.3",
|
||||||
|
"@tuyau/utils": "^0.0.9",
|
||||||
"@types/luxon": "^3.7.1",
|
"@types/luxon": "^3.7.1",
|
||||||
"@types/node": "^22.14.0",
|
"@types/node": "^24.2.0",
|
||||||
"@types/react": "^19.1.9",
|
"@types/react": "^19.1.9",
|
||||||
"@types/react-dom": "^19.1.7",
|
"@types/react-dom": "^19.1.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
||||||
"@vite-pwa/assets-generator": "^1.0.0",
|
"@vite-pwa/assets-generator": "^1.0.0",
|
||||||
"@vitejs/plugin-react": "^4.7.0",
|
|
||||||
"eslint": "^9.32.0",
|
"eslint": "^9.32.0",
|
||||||
"hot-hook": "^0.4.0",
|
"hot-hook": "^0.4.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^15.5.0",
|
"lint-staged": "^16.1.4",
|
||||||
"pino-pretty": "^13.1.1",
|
"pino-pretty": "^13.1.1",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
"postcss-preset-mantine": "^1.18.0",
|
"postcss-preset-mantine": "^1.18.0",
|
||||||
"postcss-simple-vars": "^7.0.1",
|
"postcss-simple-vars": "^7.0.1",
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.6.2",
|
||||||
"release-it": "^18.1.2",
|
"release-it": "^19.0.4",
|
||||||
"ts-node-maintained": "^10.9.6",
|
"ts-node-maintained": "^10.9.6",
|
||||||
"typescript": "~5.9.2",
|
"typescript": "~5.9.2",
|
||||||
"vite": "^6.2.5"
|
"vite": "^7.0.6"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@adonisjs/ally": "^5.1.0",
|
"@adonisjs/ally": "^5.1.0",
|
||||||
@@ -78,21 +81,26 @@
|
|||||||
"@adonisjs/vite": "^4.0.0",
|
"@adonisjs/vite": "^4.0.0",
|
||||||
"@inertiajs/react": "^2.0.17",
|
"@inertiajs/react": "^2.0.17",
|
||||||
"@izzyjs/route": "^1.2.0",
|
"@izzyjs/route": "^1.2.0",
|
||||||
"@mantine/core": "^7.17.3",
|
"@mantine/core": "^8.2.3",
|
||||||
"@mantine/hooks": "^7.17.3",
|
"@mantine/hooks": "^8.2.3",
|
||||||
"@mantine/spotlight": "^7.17.3",
|
"@mantine/spotlight": "^8.2.3",
|
||||||
|
"@tuyau/client": "^0.2.10",
|
||||||
|
"@tuyau/core": "^0.4.2",
|
||||||
|
"@tuyau/inertia": "^0.0.15",
|
||||||
"@vinejs/vine": "^3.0.1",
|
"@vinejs/vine": "^3.0.1",
|
||||||
|
"@vitejs/plugin-react-oxc": "^0.3.0",
|
||||||
"bentocache": "^1.5.0",
|
"bentocache": "^1.5.0",
|
||||||
|
"clsx": "^2.1.1",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"edge.js": "^6.3.0",
|
"edge.js": "^6.3.0",
|
||||||
"i18next": "^24.2.3",
|
"i18next": "^25.3.2",
|
||||||
"knex": "^3.1.0",
|
"knex": "^3.1.0",
|
||||||
"luxon": "^3.7.1",
|
"luxon": "^3.7.1",
|
||||||
"node-html-parser": "^7.0.1",
|
"node-html-parser": "^7.0.1",
|
||||||
"pg": "^8.16.3",
|
"pg": "^8.16.3",
|
||||||
"react": "^19.1.1",
|
"react": "^19.1.1",
|
||||||
"react-dom": "^19.1.1",
|
"react-dom": "^19.1.1",
|
||||||
"react-hotkeys-hook": "^4.6.1",
|
"react-hotkeys-hook": "^5.1.0",
|
||||||
"react-i18next": "^15.6.1",
|
"react-i18next": "^15.6.1",
|
||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.5.0",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
@@ -120,5 +128,10 @@
|
|||||||
},
|
},
|
||||||
"volta": {
|
"volta": {
|
||||||
"node": "24.1.0"
|
"node": "24.1.0"
|
||||||
|
},
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {
|
||||||
|
"vite": "npm:rolldown-vite@latest"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5159
pnpm-lock.yaml
generated
5159
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -17,10 +17,6 @@
|
|||||||
href='/favicon.png'
|
href='/favicon.png'
|
||||||
type='image/png'
|
type='image/png'
|
||||||
/>
|
/>
|
||||||
<link
|
|
||||||
rel='manifest'
|
|
||||||
href='/assets/manifest.webmanifest'
|
|
||||||
/>
|
|
||||||
<link
|
<link
|
||||||
rel='apple-touch-icon'
|
rel='apple-touch-icon'
|
||||||
href='/favicon.png'
|
href='/favicon.png'
|
||||||
@@ -30,6 +26,11 @@
|
|||||||
href='/favicon.png'
|
href='/favicon.png'
|
||||||
/>
|
/>
|
||||||
<title inertia>MyLinks</title>
|
<title inertia>MyLinks</title>
|
||||||
|
@if(nodeEnv === 'production')
|
||||||
|
<link
|
||||||
|
rel='manifest'
|
||||||
|
href='/assets/manifest.webmanifest'
|
||||||
|
/>
|
||||||
<script defer>
|
<script defer>
|
||||||
if('serviceWorker' in navigator) {
|
if('serviceWorker' in navigator) {
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@endif
|
||||||
|
|
||||||
@routes()
|
@routes()
|
||||||
@inertiaHead()
|
@inertiaHead()
|
||||||
|
|||||||
3
shared/types/index.ts
Normal file
3
shared/types/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { api } from '#adonis/api';
|
||||||
|
|
||||||
|
export type ApiRouteName = (typeof api.routes)[number]['name'];
|
||||||
7
start/view.ts
Normal file
7
start/view.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import env from '#start/env';
|
||||||
|
import edge from 'edge.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define a global property
|
||||||
|
*/
|
||||||
|
edge.global('nodeEnv', env.get('NODE_ENV'));
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
import project from '#config/project';
|
import {
|
||||||
|
PRIMARY_COLOR,
|
||||||
|
PROJECT_DESCRIPTION,
|
||||||
|
PROJECT_NAME,
|
||||||
|
} from '#config/project';
|
||||||
import { getDirname } from '@adonisjs/core/helpers';
|
import { getDirname } from '@adonisjs/core/helpers';
|
||||||
import inertia from '@adonisjs/inertia/client';
|
import inertia from '@adonisjs/inertia/client';
|
||||||
import adonisjs from '@adonisjs/vite/client';
|
import adonisjs from '@adonisjs/vite/client';
|
||||||
import react from '@vitejs/plugin-react';
|
import react from '@vitejs/plugin-react-oxc';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import { VitePWA } from 'vite-plugin-pwa';
|
import { VitePWA } from 'vite-plugin-pwa';
|
||||||
|
|
||||||
@@ -16,11 +20,11 @@ export default defineConfig({
|
|||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
manifest: {
|
manifest: {
|
||||||
name: project.name,
|
name: PROJECT_NAME,
|
||||||
short_name: project.name,
|
short_name: PROJECT_NAME,
|
||||||
description: project.description,
|
description: PROJECT_DESCRIPTION,
|
||||||
theme_color: project.color,
|
theme_color: PRIMARY_COLOR,
|
||||||
background_color: project.color,
|
background_color: PRIMARY_COLOR,
|
||||||
scope: '/',
|
scope: '/',
|
||||||
display: 'standalone',
|
display: 'standalone',
|
||||||
orientation: 'portrait',
|
orientation: 'portrait',
|
||||||
|
|||||||
Reference in New Issue
Block a user