mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 14:43:24 +00:00
Compare commits
6 Commits
216c404b16
...
56b52adac0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56b52adac0 | ||
|
|
a5ddc9eb55 | ||
|
|
309cf2c9d2 | ||
|
|
97ba56b1e7 | ||
|
|
d56bd1ef80 | ||
|
|
8b176e3d0e |
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
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=my-links-pwd
|
||||
DB_DATABASE=my-links
|
||||
DB_USER=root
|
||||
DB_PASSWORD=root
|
||||
DB_DATABASE=app
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
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:
|
||||
@docker compose down
|
||||
@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({
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of ace commands to register from packages. The application commands
|
||||
| will be scanned automatically from the "./commands" directory.
|
||||
|
|
||||
*/
|
||||
|--------------------------------------------------------------------------
|
||||
| Commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of ace commands to register from packages. The application commands
|
||||
| will be scanned automatically from the "./commands" directory.
|
||||
|
|
||||
*/
|
||||
commands: [
|
||||
() => import('@adonisjs/core/commands'),
|
||||
() => import('@adonisjs/lucid/commands'),
|
||||
() => import('@izzyjs/route/commands'),
|
||||
() => import('@tuyau/core/commands'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Service providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of service providers to import and register when booting the
|
||||
| application
|
||||
|
|
||||
*/
|
||||
|--------------------------------------------------------------------------
|
||||
| Service providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of service providers to import and register when booting the
|
||||
| application
|
||||
|
|
||||
*/
|
||||
providers: [
|
||||
() => import('@adonisjs/core/providers/app_provider'),
|
||||
() => import('@adonisjs/core/providers/hash_provider'),
|
||||
@@ -45,27 +46,32 @@ export default defineConfig({
|
||||
() => import('@adonisjs/ally/ally_provider'),
|
||||
() => import('@izzyjs/route/izzy_provider'),
|
||||
() => import('#providers/route_provider'),
|
||||
() => import('@tuyau/core/tuyau_provider'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Preloads
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of modules to import before starting the application.
|
||||
|
|
||||
*/
|
||||
preloads: [() => import('#start/routes'), () => import('#start/kernel')],
|
||||
|--------------------------------------------------------------------------
|
||||
| Preloads
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of modules to import before starting the application.
|
||||
|
|
||||
*/
|
||||
preloads: [
|
||||
() => import('#start/routes'),
|
||||
() => import('#start/kernel'),
|
||||
() => import('#start/view'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Tests
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of test suites to organize tests by their type. Feel free to remove
|
||||
| and add additional suites.
|
||||
|
|
||||
*/
|
||||
|--------------------------------------------------------------------------
|
||||
| Tests
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| List of test suites to organize tests by their type. Feel free to remove
|
||||
| and add additional suites.
|
||||
|
|
||||
*/
|
||||
tests: {
|
||||
suites: [
|
||||
{
|
||||
@@ -83,14 +89,14 @@ export default defineConfig({
|
||||
},
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Metafiles
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| A collection of files you want to copy to the build folder when creating
|
||||
| the production build.
|
||||
|
|
||||
*/
|
||||
|--------------------------------------------------------------------------
|
||||
| Metafiles
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| A collection of files you want to copy to the build folder when creating
|
||||
| the production build.
|
||||
|
|
||||
*/
|
||||
metaFiles: [
|
||||
{
|
||||
pattern: 'resources/views/**/*.edge',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 User from '#user/models/user';
|
||||
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 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
|
||||
.group(() => {
|
||||
router.get('/dashboard', [CollectionsController, 'index']).as('dashboard');
|
||||
router
|
||||
.get('/dashboard', [ShowCollectionsController, 'render'])
|
||||
.as('dashboard');
|
||||
|
||||
router
|
||||
.group(() => {
|
||||
// Create
|
||||
router
|
||||
.get('/create', [CollectionsController, 'showCreatePage'])
|
||||
.get('/create', [CreateCollectionController, 'render'])
|
||||
.as('collection.create-form');
|
||||
router
|
||||
.post('/', [CollectionsController, 'store'])
|
||||
.post('/', [CreateCollectionController, 'execute'])
|
||||
.as('collection.create');
|
||||
|
||||
// Update
|
||||
router
|
||||
.get('/edit', [CollectionsController, 'showEditPage'])
|
||||
.get('/edit', [UpdateCollectionController, 'render'])
|
||||
.as('collection.edit-form');
|
||||
router
|
||||
.put('/:id', [CollectionsController, 'update'])
|
||||
.put('/:id', [UpdateCollectionController, 'execute'])
|
||||
.as('collection.edit');
|
||||
|
||||
// Delete
|
||||
router
|
||||
.get('/delete', [CollectionsController, 'showDeletePage'])
|
||||
.get('/delete', [DeleteCollectionController, 'render'])
|
||||
.as('collection.delete-form');
|
||||
router
|
||||
.delete('/:id', [CollectionsController, 'delete'])
|
||||
.delete('/:id', [DeleteCollectionController, 'execute'])
|
||||
.as('collection.delete');
|
||||
})
|
||||
.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 { createLinkValidator } from '#links/validators/create_link_validator';
|
||||
import { deleteLinkValidator } from '#links/validators/delete_link_validator';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import env from '#start/env';
|
||||
import app from '@adonisjs/core/services/app';
|
||||
import { Secret } from '@adonisjs/core/helpers';
|
||||
import { defineConfig } from '@adonisjs/core/http';
|
||||
import app from '@adonisjs/core/services/app';
|
||||
|
||||
/**
|
||||
* 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
|
||||
* from anywhere inside your application.
|
||||
*/
|
||||
useAsyncLocalStorage: false,
|
||||
useAsyncLocalStorage: true,
|
||||
|
||||
/**
|
||||
* Manage cookies configuration. The settings for the session id cookie are
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
const PROJECT_NAME = 'MyLinks';
|
||||
const PROJECT_DESCRIPTION =
|
||||
'Another bookmark manager that lets you manage and share your favorite links in an intuitive interface';
|
||||
const PROJECT_URL = 'https://www.mylinks.app';
|
||||
const APP_COLOR = '#f0eef6';
|
||||
export const PRIMARY_COLOR = '#3f88c5';
|
||||
|
||||
export default {
|
||||
name: PROJECT_NAME,
|
||||
description: PROJECT_DESCRIPTION,
|
||||
url: PROJECT_URL,
|
||||
color: APP_COLOR,
|
||||
};
|
||||
export const PROJECT_NAME = 'MyLinks';
|
||||
export const PROJECT_DESCRIPTION =
|
||||
'Another bookmark manager that lets you manage and share your favorite links in an intuitive interface';
|
||||
export const PROJECT_URL = 'https://www.mylinks.app';
|
||||
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/fr';
|
||||
import { createRoot, hydrateRoot } from 'react-dom/client';
|
||||
import DefaultLayout from '~/layouts/default_layout';
|
||||
import '../i18n/index';
|
||||
|
||||
const appName = import.meta.env.VITE_APP_NAME || 'MyLinks';
|
||||
@@ -13,11 +14,17 @@ createInertiaApp({
|
||||
|
||||
title: (title) => `${appName}${title && ` - ${title}`}`,
|
||||
|
||||
resolve: (name) => {
|
||||
return resolvePageComponent(
|
||||
resolve: async (name) => {
|
||||
const currentPage: any = await resolvePageComponent(
|
||||
`../pages/${name}.tsx`,
|
||||
import.meta.glob('../pages/**/*.tsx')
|
||||
);
|
||||
|
||||
currentPage.default.layout =
|
||||
currentPage.default.layout ||
|
||||
((p: any) => <DefaultLayout children={p} />);
|
||||
|
||||
return currentPage;
|
||||
},
|
||||
|
||||
setup({ el, App, props }) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createInertiaApp } from '@inertiajs/react';
|
||||
import ReactDOMServer from 'react-dom/server';
|
||||
import DefaultLayout from '~/layouts/default_layout';
|
||||
|
||||
export default function render(page: any) {
|
||||
return createInertiaApp({
|
||||
@@ -7,7 +8,11 @@ export default function render(page: any) {
|
||||
render: ReactDOMServer.renderToString,
|
||||
resolve: (name) => {
|
||||
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} />,
|
||||
});
|
||||
|
||||
@@ -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 { LS_LANG_KEY } from '~/constants';
|
||||
|
||||
export function MantineLanguageSwitcher() {
|
||||
export function LocaleSwitcher() {
|
||||
const { i18n } = useTranslation();
|
||||
const newLanguage = i18n.language === 'en' ? 'fr' : 'en';
|
||||
return (
|
||||
@@ -2,7 +2,7 @@ import { ActionIcon, useMantineColorScheme } from '@mantine/core';
|
||||
import { TbMoonStars, TbSun } from 'react-icons/tb';
|
||||
import { makeRequest } from '~/lib/request';
|
||||
|
||||
export function MantineThemeSwitcher() {
|
||||
export function ThemeSwitcher() {
|
||||
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
|
||||
const handleThemeChange = () => {
|
||||
toggleColorScheme();
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Avatar, Group, Menu, Text, UnstyledButton } from '@mantine/core';
|
||||
import { forwardRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { TbChevronRight } from 'react-icons/tb';
|
||||
import useUser from '~/hooks/use_user';
|
||||
import { useAuth } from '~/hooks/use_auth';
|
||||
|
||||
interface UserButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
||||
image: string;
|
||||
@@ -45,9 +45,9 @@ const UserButton = forwardRef<HTMLButtonElement, UserButtonProps>(
|
||||
)
|
||||
);
|
||||
|
||||
export function MantineUserCard() {
|
||||
export function UserCard() {
|
||||
const { t } = useTranslation('common');
|
||||
const { user, isAuthenticated } = useUser();
|
||||
const { user, isAuthenticated } = useAuth();
|
||||
return (
|
||||
isAuthenticated && (
|
||||
<Menu withArrow>
|
||||
|
||||
@@ -17,11 +17,11 @@ import { AiOutlineFolderAdd } from 'react-icons/ai';
|
||||
import { IoIosSearch } from 'react-icons/io';
|
||||
import { IoAdd, IoShieldHalfSharp } from 'react-icons/io5';
|
||||
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 { SearchSpotlight } from '~/components/search/search';
|
||||
import { useAuth } from '~/hooks/use_auth';
|
||||
import useShortcut from '~/hooks/use_shortcut';
|
||||
import useUser from '~/hooks/use_user';
|
||||
import { appendCollectionId } from '~/lib/navigation';
|
||||
import { useActiveCollection } from '~/stores/collection_store';
|
||||
import { useGlobalHotkeysStore } from '~/stores/global_hotkeys_store';
|
||||
@@ -32,7 +32,7 @@ interface DashboardNavbarProps {
|
||||
}
|
||||
export function DashboardNavbar({ isOpen, toggle }: DashboardNavbarProps) {
|
||||
const { t } = useTranslation('common');
|
||||
const { isAuthenticated, user } = useUser();
|
||||
const { isAuthenticated, user } = useAuth();
|
||||
|
||||
const { activeCollection } = useActiveCollection();
|
||||
const { globalHotkeysEnabled, setGlobalHotkeysEnabled } =
|
||||
@@ -84,7 +84,7 @@ export function DashboardNavbar({ isOpen, toggle }: DashboardNavbarProps) {
|
||||
<Burger opened={isOpen} onClick={toggle} size="sm" />
|
||||
<Text>Navigation</Text>
|
||||
</Group>
|
||||
<MantineUserCard />
|
||||
<UserCard />
|
||||
<Divider mt="xs" mb="md" />
|
||||
{isAuthenticated && user.isAdmin && (
|
||||
<NavLink
|
||||
|
||||
@@ -4,8 +4,8 @@ import { route } from '@izzyjs/route/client';
|
||||
import { Anchor, Group, Text } from '@mantine/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ExternalLink from '~/components/common/external_link';
|
||||
import { MantineLanguageSwitcher } from '~/components/common/language_switcher';
|
||||
import { MantineThemeSwitcher } from '~/components/common/theme_switcher';
|
||||
import { LocaleSwitcher } from '~/components/common/locale_switcher';
|
||||
import { ThemeSwitcher } from '~/components/common/theme_switcher';
|
||||
import packageJson from '../../../package.json';
|
||||
import classes from './footer.module.css';
|
||||
|
||||
@@ -46,8 +46,8 @@ export function MantineFooter() {
|
||||
</Group>
|
||||
|
||||
<Group gap="sm" mt={4} mb={4}>
|
||||
<MantineThemeSwitcher />
|
||||
<MantineLanguageSwitcher />
|
||||
<ThemeSwitcher />
|
||||
<LocaleSwitcher />
|
||||
</Group>
|
||||
|
||||
<Group gap="xs" justify="flex-end" wrap="nowrap">
|
||||
|
||||
@@ -15,9 +15,9 @@ import {
|
||||
import { useDisclosure } from '@mantine/hooks';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ExternalLink from '~/components/common/external_link';
|
||||
import { MantineLanguageSwitcher } from '~/components/common/language_switcher';
|
||||
import { MantineThemeSwitcher } from '~/components/common/theme_switcher';
|
||||
import useUser from '~/hooks/use_user';
|
||||
import { LocaleSwitcher } from '~/components/common/locale_switcher';
|
||||
import { ThemeSwitcher } from '~/components/common/theme_switcher';
|
||||
import useUser from '~/hooks/use_auth';
|
||||
import classes from './mobile.module.css';
|
||||
|
||||
export default function Navbar() {
|
||||
@@ -47,8 +47,8 @@ export default function Navbar() {
|
||||
</Group>
|
||||
|
||||
<Group gap="xs">
|
||||
<MantineThemeSwitcher />
|
||||
<MantineLanguageSwitcher />
|
||||
<ThemeSwitcher />
|
||||
<LocaleSwitcher />
|
||||
{!isAuthenticated ? (
|
||||
<Button
|
||||
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 { ColorSchemeScript, MantineProvider } from '@mantine/core';
|
||||
import { api } from '#adonis/api';
|
||||
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/spotlight/styles.css';
|
||||
import { createTuyau } from '@tuyau/client';
|
||||
import { TuyauProvider } from '@tuyau/inertia/react';
|
||||
import dayjs from 'dayjs';
|
||||
import { ReactNode, useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@@ -10,9 +20,66 @@ import '../styles/index.css';
|
||||
const TRANSITION_IN_CLASS = '__transition_fadeIn';
|
||||
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();
|
||||
dayjs.locale(i18n.language);
|
||||
const { props } = usePage<PageProps & { appBaseUrl: string }>();
|
||||
|
||||
const tuyauClient = createTuyau({
|
||||
api,
|
||||
baseUrl: props.appBaseUrl,
|
||||
});
|
||||
|
||||
const findAppElement = () => document.getElementById('app');
|
||||
|
||||
@@ -50,9 +117,9 @@ export default function BaseLayout({ children }: { children: ReactNode }) {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<TuyauProvider client={tuyauClient}>
|
||||
<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 BaseLayout from '~/layouts/_base_layout';
|
||||
import { BaseLayout } from '~/layouts/_base_layout';
|
||||
|
||||
const LayoutWrapper = ({ children }: PropsWithChildren) => (
|
||||
<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 { FormEvent, PropsWithChildren } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { MantineFooter } from '~/components/footer/footer';
|
||||
import i18n from '~/i18n';
|
||||
import BaseLayout from '~/layouts/_base_layout';
|
||||
import { BaseLayout } from '~/layouts/_base_layout';
|
||||
import { appendCollectionId } from '~/lib/navigation';
|
||||
|
||||
export interface FormLayoutProps extends PropsWithChildren {
|
||||
@@ -40,7 +39,7 @@ function FormLayout({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}}
|
||||
pt={80}
|
||||
pt={rem(40)}
|
||||
>
|
||||
<main
|
||||
style={{
|
||||
@@ -87,7 +86,6 @@ function FormLayout({
|
||||
{textSubmitButton}
|
||||
</Button>
|
||||
</Group>
|
||||
<MantineFooter />
|
||||
</form>
|
||||
</main>
|
||||
</Container>
|
||||
|
||||
@@ -34,3 +34,11 @@ export const generateShareUrl = (
|
||||
if (typeof window === 'undefined') return 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 {
|
||||
UsersTable,
|
||||
UsersTableProps,
|
||||
} 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} />;
|
||||
}
|
||||
|
||||
AdminDashboardPage.layout = (page: ReactNode) => (
|
||||
<ContentLayout children={page} />
|
||||
);
|
||||
export default AdminDashboardPage;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
font-family:
|
||||
Greycliff CF,
|
||||
var(--mantine-font-family);
|
||||
font-weight: 900;
|
||||
margin-bottom: var(--mantine-spacing-md);
|
||||
text-align: center;
|
||||
|
||||
@@ -18,6 +17,7 @@
|
||||
}
|
||||
|
||||
.description {
|
||||
color: var(--mantine-color-dimmed);
|
||||
text-align: center;
|
||||
|
||||
@media (max-width: $mantine-breakpoint-sm) {
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { Container, Text, Title } from '@mantine/core';
|
||||
import { ReactNode } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { FeatureList } from '~/components/home/feature_list';
|
||||
import classes from './home.module.css';
|
||||
import { ContentLayout } from '~/layouts/content_layout';
|
||||
|
||||
function HomePage() {
|
||||
export default function HomePage() {
|
||||
const { t } = useTranslation('about');
|
||||
return (
|
||||
<Container className={classes.wrapper}>
|
||||
@@ -21,6 +19,3 @@ function HomePage() {
|
||||
</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 { ContentLayout } from '~/layouts/content_layout';
|
||||
|
||||
function PrivacyPage() {
|
||||
export default function PrivacyPage() {
|
||||
const { t } = useTranslation('privacy');
|
||||
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 { ReactNode, useEffect } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { LinkList } from '~/components/dashboard/link/list/link_list';
|
||||
import { ContentLayout } from '~/layouts/content_layout';
|
||||
import { useCollectionsSetter } from '~/stores/collection_store';
|
||||
import type { CollectionWithLinks, PublicUser } from '~/types/app';
|
||||
|
||||
@@ -10,7 +9,7 @@ interface SharedPageProps {
|
||||
collection: CollectionWithLinks & { author: PublicUser };
|
||||
}
|
||||
|
||||
function SharedPage({ collection }: SharedPageProps) {
|
||||
export default function SharedPage({ collection }: SharedPageProps) {
|
||||
const { t } = useTranslation('common');
|
||||
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 { route } from '@izzyjs/route/client';
|
||||
import { ReactNode } from 'react';
|
||||
import { Trans, useTranslation } from 'react-i18next';
|
||||
import { ContentLayout } from '~/layouts/content_layout';
|
||||
|
||||
function TermsPage() {
|
||||
export default function TermsPage() {
|
||||
const { t } = useTranslation('terms');
|
||||
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);
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
min-height: 100svh;
|
||||
width: 100%;
|
||||
background-color: light-dark(var(--ml-bg-light), var(--ml-bg-dark));
|
||||
/* Fix nprogress position */
|
||||
#nprogress {
|
||||
position: relative;
|
||||
z-index: 9999999;
|
||||
}
|
||||
|
||||
#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 {
|
||||
|
||||
15
package.json
15
package.json
@@ -14,12 +14,15 @@
|
||||
"check": "pnpm run lint && pnpm run typecheck",
|
||||
"prepare": "husky",
|
||||
"release": "release-it",
|
||||
"generate-icons": "pwa-assets-generator"
|
||||
"generate-icons": "pwa-assets-generator",
|
||||
"tuyau": "node ace tuyau:generate"
|
||||
},
|
||||
"imports": {
|
||||
"#admin/*": "./app/admin/*.js",
|
||||
"#adonis/api": "./.adonisjs/api.ts",
|
||||
"#auth/*": "./app/auth/*.js",
|
||||
"#collections/*": "./app/collections/*.js",
|
||||
"#config/*": "./config/*.js",
|
||||
"#core/*": "./app/core/*.js",
|
||||
"#favicons/*": "./app/favicons/*.js",
|
||||
"#home/*": "./app/home/*.js",
|
||||
@@ -31,8 +34,8 @@
|
||||
"#providers/*": "./providers/*.js",
|
||||
"#database/*": "./database/*.js",
|
||||
"#tests/*": "./tests/*.js",
|
||||
"#start/*": "./start/*.js",
|
||||
"#config/*": "./config/*.js"
|
||||
"#shared/*": "./shared/*.js",
|
||||
"#start/*": "./start/*.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@adonisjs/assembler": "^7.8.2",
|
||||
@@ -44,6 +47,7 @@
|
||||
"@japa/plugin-adonisjs": "^4.0.0",
|
||||
"@japa/runner": "^4.3.0",
|
||||
"@swc/core": "^1.13.3",
|
||||
"@tuyau/utils": "^0.0.9",
|
||||
"@types/luxon": "^3.7.1",
|
||||
"@types/node": "^24.2.0",
|
||||
"@types/react": "^19.1.9",
|
||||
@@ -76,12 +80,17 @@
|
||||
"@adonisjs/static": "^1.1.1",
|
||||
"@adonisjs/vite": "^4.0.0",
|
||||
"@inertiajs/react": "^2.0.17",
|
||||
"@izzyjs/route": "^1.2.0",
|
||||
"@mantine/core": "^8.2.3",
|
||||
"@mantine/hooks": "^8.2.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",
|
||||
"@vitejs/plugin-react-oxc": "^0.3.0",
|
||||
"bentocache": "^1.5.0",
|
||||
"clsx": "^2.1.1",
|
||||
"dayjs": "^1.11.13",
|
||||
"edge.js": "^6.3.0",
|
||||
"i18next": "^25.3.2",
|
||||
|
||||
125
pnpm-lock.yaml
generated
125
pnpm-lock.yaml
generated
@@ -44,6 +44,9 @@ importers:
|
||||
'@inertiajs/react':
|
||||
specifier: ^2.0.17
|
||||
version: 2.0.17(react@19.1.1)
|
||||
'@izzyjs/route':
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.0(@adonisjs/core@6.19.0(@adonisjs/assembler@7.8.2(typescript@5.9.2))(@vinejs/vine@3.0.1)(edge.js@6.3.0))(edge.js@6.3.0)
|
||||
'@mantine/core':
|
||||
specifier: ^8.2.3
|
||||
version: 8.2.3(@mantine/hooks@8.2.3(react@19.1.1))(@types/react@19.1.9)(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||
@@ -53,6 +56,15 @@ importers:
|
||||
'@mantine/spotlight':
|
||||
specifier: ^8.2.3
|
||||
version: 8.2.3(@mantine/core@8.2.3(@mantine/hooks@8.2.3(react@19.1.1))(@types/react@19.1.9)(react-dom@19.1.1(react@19.1.1))(react@19.1.1))(@mantine/hooks@8.2.3(react@19.1.1))(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
|
||||
'@tuyau/client':
|
||||
specifier: ^0.2.10
|
||||
version: 0.2.10
|
||||
'@tuyau/core':
|
||||
specifier: ^0.4.2
|
||||
version: 0.4.2(@adonisjs/core@6.19.0(@adonisjs/assembler@7.8.2(typescript@5.9.2))(@vinejs/vine@3.0.1)(edge.js@6.3.0))
|
||||
'@tuyau/inertia':
|
||||
specifier: ^0.0.15
|
||||
version: 0.0.15(@inertiajs/react@2.0.17(react@19.1.1))(@tuyau/client@0.2.10)(react@19.1.1)
|
||||
'@vinejs/vine':
|
||||
specifier: ^3.0.1
|
||||
version: 3.0.1
|
||||
@@ -62,6 +74,9 @@ importers:
|
||||
bentocache:
|
||||
specifier: ^1.5.0
|
||||
version: 1.5.0(knex@3.1.0(pg@8.16.3))
|
||||
clsx:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
dayjs:
|
||||
specifier: ^1.11.13
|
||||
version: 1.11.13
|
||||
@@ -135,6 +150,9 @@ importers:
|
||||
'@swc/core':
|
||||
specifier: ^1.13.3
|
||||
version: 1.13.3
|
||||
'@tuyau/utils':
|
||||
specifier: ^0.0.9
|
||||
version: 0.0.9
|
||||
'@types/luxon':
|
||||
specifier: ^3.7.1
|
||||
version: 3.7.1
|
||||
@@ -1336,6 +1354,21 @@ packages:
|
||||
'@types/node':
|
||||
optional: true
|
||||
|
||||
'@isaacs/balanced-match@4.0.1':
|
||||
resolution: {integrity: sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
'@isaacs/brace-expansion@5.0.0':
|
||||
resolution: {integrity: sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
'@izzyjs/route@1.2.0':
|
||||
resolution: {integrity: sha512-GOc2tf4xNrFMZK3SGK7XSweUfxNskJX6vrdhx9M8mDOgkRONnpuIzaVM/N7AgRjCft8f97d5t2oOXyk5Sq92hA==}
|
||||
engines: {node: '>=20.6.0'}
|
||||
peerDependencies:
|
||||
'@adonisjs/core': ^6.2.0
|
||||
edge.js: ^6.0.2
|
||||
|
||||
'@japa/assert@4.1.1':
|
||||
resolution: {integrity: sha512-Hhv8A/gkd1b4Xa2Jti4XJ3FsP/pJ8ZXAWwvgYVKZQNcl79lqIHsMjMrL3e475pbf8lybB++FvXi4ruoz2SsiBA==}
|
||||
engines: {node: '>=18.16.0'}
|
||||
@@ -1850,6 +1883,9 @@ packages:
|
||||
'@ts-morph/common@0.24.0':
|
||||
resolution: {integrity: sha512-c1xMmNHWpNselmpIqursHeOHHBTIsJLbB+NuovbTTRCNiTLEr/U9dbJ8qy0jd/O2x5pc3seWuOUN5R2IoOTp8A==}
|
||||
|
||||
'@ts-morph/common@0.27.0':
|
||||
resolution: {integrity: sha512-Wf29UqxWDpc+i61k3oIOzcUfQt79PIT9y/MWfAGlrkjg6lBC1hwDECLXPVJAhWjiGbfBCxZd65F/LIZF3+jeJQ==}
|
||||
|
||||
'@tsconfig/node10@1.0.11':
|
||||
resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==}
|
||||
|
||||
@@ -1862,9 +1898,39 @@ packages:
|
||||
'@tsconfig/node16@1.0.4':
|
||||
resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==}
|
||||
|
||||
'@tuyau/client@0.2.10':
|
||||
resolution: {integrity: sha512-sVp4JX9uvvV3BSPgZNogJWYp0oleqi2Zy0gyBLFjFz6KWtTVPqNKBA74n0UsnaeZB8y3xxXkYSeWf19z+7yhmg==}
|
||||
|
||||
'@tuyau/core@0.4.2':
|
||||
resolution: {integrity: sha512-thobRIBW+fQGt9gXQ9zdvhVUyZE5qLZorBeDqxJ2SF07igZAqm0+fyvMTQbOH/vIcpwK2ob9ev3bBhqW4E2hWw==}
|
||||
engines: {node: '>=20.6.0'}
|
||||
peerDependencies:
|
||||
'@adonisjs/core': ^6.2.0
|
||||
|
||||
'@tuyau/inertia@0.0.15':
|
||||
resolution: {integrity: sha512-1pJCqeGOUPYvdR1FuvyvpGci0n69QJmeKAy7bJx+rtg8cxGnGCh+fa0vYp/o2LJ8CEOUBT7bDZya9GzLx82Mwg==}
|
||||
peerDependencies:
|
||||
'@inertiajs/react': ^1.0.0 || ^2.0.0
|
||||
'@inertiajs/vue3': ^1.0.0 || ^2.0.0
|
||||
'@tuyau/client': 0.2.10
|
||||
react: ^18.0.0 || ^19.0.0
|
||||
vue: ^3.0.0
|
||||
peerDependenciesMeta:
|
||||
'@inertiajs/react':
|
||||
optional: true
|
||||
'@inertiajs/vue3':
|
||||
optional: true
|
||||
react:
|
||||
optional: true
|
||||
vue:
|
||||
optional: true
|
||||
|
||||
'@tuyau/utils@0.0.7':
|
||||
resolution: {integrity: sha512-Y1JgQoshbcxEwmajeWpJibBmoBlGuEq38ICKmWQ5dS+ESqY0J0757rWcHAQgiB74J1vf/DxHkt8veBRSKTAjJQ==}
|
||||
|
||||
'@tuyau/utils@0.0.9':
|
||||
resolution: {integrity: sha512-Uirv4CH7d7US5atdKda3mPmg2K0PsYQx2Gab7Xe/PSGdlq/fp4Ia1IWYKRL2Lfx36QAzEuHqrk4WmDxmw1sTVw==}
|
||||
|
||||
'@tybys/wasm-util@0.10.0':
|
||||
resolution: {integrity: sha512-VyyPYFlOMNylG45GoAe0xDoLwWuowvf92F9kySqzYh8vmYm7D2u4iUJKa1tOUpS70Ku13ASrOkS4ScXFsTaCNQ==}
|
||||
|
||||
@@ -3771,6 +3837,10 @@ packages:
|
||||
resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
minimatch@10.0.3:
|
||||
resolution: {integrity: sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==}
|
||||
engines: {node: 20 || >=22}
|
||||
|
||||
minimatch@3.1.2:
|
||||
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
|
||||
|
||||
@@ -3876,6 +3946,9 @@ packages:
|
||||
resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
object-to-formdata@4.5.1:
|
||||
resolution: {integrity: sha512-QiM9D0NiU5jV6J6tjE1g7b4Z2tcUnKs1OPUi4iMb2zH+7jwlcUrASghgkFk9GtzqNNq8rTQJtT8AzjBAvLoNMw==}
|
||||
|
||||
object.assign@4.1.7:
|
||||
resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@@ -4892,6 +4965,9 @@ packages:
|
||||
ts-morph@23.0.0:
|
||||
resolution: {integrity: sha512-FcvFx7a9E8TUe6T3ShihXJLiJOiqyafzFKUO4aqIHDUCIvADdGNShcbc2W5PMr3LerXRv7mafvFZ9lRENxJmug==}
|
||||
|
||||
ts-morph@26.0.0:
|
||||
resolution: {integrity: sha512-ztMO++owQnz8c/gIENcM9XfCEzgoGphTv+nKpYNM1bgsdOVC/jRZuEBf6N+mLLDNg68Kl+GgUZfOySaRiG1/Ug==}
|
||||
|
||||
ts-node-maintained@10.9.6:
|
||||
resolution: {integrity: sha512-m/1ZCksNnIofWjmY5/K+6y8oia05Y/5+vMWTvuFzrr6UGRV7ImrLMyYAB06cHlwBW5/NuYeZoh44mAOGNRNxZA==}
|
||||
hasBin: true
|
||||
@@ -6655,6 +6731,17 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@types/node': 24.2.0
|
||||
|
||||
'@isaacs/balanced-match@4.0.1': {}
|
||||
|
||||
'@isaacs/brace-expansion@5.0.0':
|
||||
dependencies:
|
||||
'@isaacs/balanced-match': 4.0.1
|
||||
|
||||
'@izzyjs/route@1.2.0(@adonisjs/core@6.19.0(@adonisjs/assembler@7.8.2(typescript@5.9.2))(@vinejs/vine@3.0.1)(edge.js@6.3.0))(edge.js@6.3.0)':
|
||||
dependencies:
|
||||
'@adonisjs/core': 6.19.0(@adonisjs/assembler@7.8.2(typescript@5.9.2))(@vinejs/vine@3.0.1)(edge.js@6.3.0)
|
||||
edge.js: 6.3.0
|
||||
|
||||
'@japa/assert@4.1.1(@japa/runner@4.3.0)':
|
||||
dependencies:
|
||||
'@japa/runner': 4.3.0
|
||||
@@ -7177,6 +7264,12 @@ snapshots:
|
||||
mkdirp: 3.0.1
|
||||
path-browserify: 1.0.1
|
||||
|
||||
'@ts-morph/common@0.27.0':
|
||||
dependencies:
|
||||
fast-glob: 3.3.3
|
||||
minimatch: 10.0.3
|
||||
path-browserify: 1.0.1
|
||||
|
||||
'@tsconfig/node10@1.0.11': {}
|
||||
|
||||
'@tsconfig/node12@1.0.11': {}
|
||||
@@ -7185,8 +7278,29 @@ snapshots:
|
||||
|
||||
'@tsconfig/node16@1.0.4': {}
|
||||
|
||||
'@tuyau/client@0.2.10':
|
||||
dependencies:
|
||||
'@tuyau/utils': 0.0.9
|
||||
ky: 1.8.2
|
||||
object-to-formdata: 4.5.1
|
||||
|
||||
'@tuyau/core@0.4.2(@adonisjs/core@6.19.0(@adonisjs/assembler@7.8.2(typescript@5.9.2))(@vinejs/vine@3.0.1)(edge.js@6.3.0))':
|
||||
dependencies:
|
||||
'@adonisjs/core': 6.19.0(@adonisjs/assembler@7.8.2(typescript@5.9.2))(@vinejs/vine@3.0.1)(edge.js@6.3.0)
|
||||
'@tuyau/utils': 0.0.9
|
||||
ts-morph: 26.0.0
|
||||
|
||||
'@tuyau/inertia@0.0.15(@inertiajs/react@2.0.17(react@19.1.1))(@tuyau/client@0.2.10)(react@19.1.1)':
|
||||
dependencies:
|
||||
'@tuyau/client': 0.2.10
|
||||
optionalDependencies:
|
||||
'@inertiajs/react': 2.0.17(react@19.1.1)
|
||||
react: 19.1.1
|
||||
|
||||
'@tuyau/utils@0.0.7': {}
|
||||
|
||||
'@tuyau/utils@0.0.9': {}
|
||||
|
||||
'@tybys/wasm-util@0.10.0':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
@@ -9068,6 +9182,10 @@ snapshots:
|
||||
|
||||
min-indent@1.0.1: {}
|
||||
|
||||
minimatch@10.0.3:
|
||||
dependencies:
|
||||
'@isaacs/brace-expansion': 5.0.0
|
||||
|
||||
minimatch@3.1.2:
|
||||
dependencies:
|
||||
brace-expansion: 1.1.12
|
||||
@@ -9152,6 +9270,8 @@ snapshots:
|
||||
|
||||
object-keys@1.1.1: {}
|
||||
|
||||
object-to-formdata@4.5.1: {}
|
||||
|
||||
object.assign@4.1.7:
|
||||
dependencies:
|
||||
call-bind: 1.0.8
|
||||
@@ -10243,6 +10363,11 @@ snapshots:
|
||||
'@ts-morph/common': 0.24.0
|
||||
code-block-writer: 13.0.3
|
||||
|
||||
ts-morph@26.0.0:
|
||||
dependencies:
|
||||
'@ts-morph/common': 0.27.0
|
||||
code-block-writer: 13.0.3
|
||||
|
||||
ts-node-maintained@10.9.6(@swc/core@1.13.3)(@types/node@24.2.0)(typescript@5.9.2):
|
||||
dependencies:
|
||||
'@cspotcode/source-map-support': 0.8.1
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
href='/favicon.png'
|
||||
type='image/png'
|
||||
/>
|
||||
<link
|
||||
rel='manifest'
|
||||
href='/assets/manifest.webmanifest'
|
||||
/>
|
||||
<link
|
||||
rel='apple-touch-icon'
|
||||
href='/favicon.png'
|
||||
@@ -30,6 +26,11 @@
|
||||
href='/favicon.png'
|
||||
/>
|
||||
<title inertia>MyLinks</title>
|
||||
@if(nodeEnv === 'production')
|
||||
<link
|
||||
rel='manifest'
|
||||
href='/assets/manifest.webmanifest'
|
||||
/>
|
||||
<script defer>
|
||||
if('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
@@ -37,6 +38,7 @@
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@endif
|
||||
|
||||
@routes()
|
||||
@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,4 +1,8 @@
|
||||
import project from '#config/project';
|
||||
import {
|
||||
PRIMARY_COLOR,
|
||||
PROJECT_DESCRIPTION,
|
||||
PROJECT_NAME,
|
||||
} from '#config/project';
|
||||
import { getDirname } from '@adonisjs/core/helpers';
|
||||
import inertia from '@adonisjs/inertia/client';
|
||||
import adonisjs from '@adonisjs/vite/client';
|
||||
@@ -16,11 +20,11 @@ export default defineConfig({
|
||||
enabled: true,
|
||||
},
|
||||
manifest: {
|
||||
name: project.name,
|
||||
short_name: project.name,
|
||||
description: project.description,
|
||||
theme_color: project.color,
|
||||
background_color: project.color,
|
||||
name: PROJECT_NAME,
|
||||
short_name: PROJECT_NAME,
|
||||
description: PROJECT_DESCRIPTION,
|
||||
theme_color: PRIMARY_COLOR,
|
||||
background_color: PRIMARY_COLOR,
|
||||
scope: '/',
|
||||
display: 'standalone',
|
||||
orientation: 'portrait',
|
||||
|
||||
Reference in New Issue
Block a user