generator-folklore 3.0.38 → 3.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/generators/build/index.js +1 -1
- package/lib/generators/eslint/index.js +1 -3
- package/lib/generators/eslint/templates/.eslint.config.js +10 -13
- package/lib/generators/html-project/index.js +5 -2
- package/lib/generators/laravel/templates/laravel/resources/views/layouts/main.blade.php +6 -6
- package/lib/generators/laravel-panneau/index.js +7 -7
- package/lib/generators/laravel-panneau/templates/app/Http/Middleware/Authenticate.php +1 -2
- package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +0 -2
- package/lib/generators/laravel-panneau/templates/{index.js → index.ts} +16 -5
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/{Panneau.jsx → Panneau.tsx} +19 -22
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/{PageSlug.jsx → PageSlug.tsx} +42 -28
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlugLocalized.tsx +42 -0
- package/lib/generators/laravel-project/index.js +8 -4
- package/lib/generators/laravel-project/templates/env +33 -8
- package/lib/generators/laravel-project/templates/laravel/app/Http/Middleware/Authenticate.php +30 -0
- package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +1 -2
- package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +7 -2
- package/lib/generators/laravel-project/templates/laravel/app/Providers/RouteServiceProvider.php +0 -27
- package/lib/generators/laravel-project/templates/laravel/bootstrap/app.php +53 -0
- package/lib/generators/laravel-project/templates/laravel/bootstrap/providers.php +9 -0
- package/lib/generators/laravel-project/templates/laravel/config/app.php +22 -114
- package/lib/generators/laravel-project/templates/laravel/config/auth.php +24 -23
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/base.blade.php +4 -4
- package/lib/generators/laravel-project/templates/laravel/resources/views/meta/opengraph.blade.php +5 -5
- package/lib/generators/lerna-package/index.js +1 -1
- package/lib/generators/lerna-repository/templates/jest.config.js +1 -1
- package/lib/generators/micromag-project/index.js +5 -5
- package/lib/generators/micromag-project/templates/App.tsx +1 -2
- package/lib/generators/micromag-project/templates/MicromagPage.tsx +0 -1
- package/lib/generators/micromag-project/templates/Routes.tsx +0 -1
- package/lib/generators/micromag-project/templates/hooks/useMicromagPreview.ts +0 -1
- package/lib/generators/micromag-project/templates/hooks/useMicromagStory.ts +0 -1
- package/lib/generators/micromag-project/templates/hooks/useMicromagVideo.ts +0 -2
- package/lib/generators/micromag-project/templates/hooks/useStoryTrackingVariables.ts +0 -2
- package/lib/generators/micromag-project/templates/index.html.ejs +1 -1
- package/lib/generators/micromag-project/templates/kiosk/Routes.tsx +0 -1
- package/lib/generators/micromag-project/templates/kiosk/micromags.ts +0 -2
- package/lib/generators/micromag-project/templates/lib/addTrackingCodesToStory.ts +0 -2
- package/lib/generators/micromag-project/templates/micromags.ts +0 -2
- package/lib/generators/micromag-project/templates/partials/Micromag.tsx +0 -2
- package/lib/generators/micromag-project/templates/partials/Thumbnail.tsx +0 -1
- package/lib/generators/micromag-project/templates/types/micromag.d.ts +6 -6
- package/lib/generators/node-project/index.js +2 -2
- package/lib/generators/node-project/templates/index.ts +0 -0
- package/lib/generators/postcss/index.js +45 -0
- package/lib/generators/postcss/templates/config.js +19 -0
- package/lib/generators/prettier/index.js +1 -1
- package/lib/generators/react-app/index.js +11 -11
- package/lib/generators/react-app/templates/_package.json +1 -0
- package/lib/generators/react-app/templates/{index.js → index.ts} +14 -3
- package/lib/generators/react-app/templates/src/components/App.tsx +12 -3
- package/lib/generators/react-app/templates/src/components/buttons/Button.tsx +1 -3
- package/lib/generators/react-app/templates/src/components/menus/Menu.tsx +27 -26
- package/lib/generators/react-app/templates/src/components/partials/PageMeta.tsx +5 -5
- package/lib/generators/react-app/templates/src/contexts/TrackingContext.tsx +45 -0
- package/lib/generators/react-app/templates/src/lib/Tracking.ts +39 -0
- package/lib/generators/react-app/templates/src/lib/utils.ts +6 -0
- package/lib/generators/react-app/templates/types/base.d.ts +19 -14
- package/lib/generators/react-app/templates/types/blocks.d.ts +8 -8
- package/lib/generators/react-app/templates/types/forms.d.ts +12 -12
- package/lib/generators/react-app/templates/types/global.d.ts +17 -12
- package/lib/generators/react-app/templates/types/index.ts +0 -0
- package/lib/generators/react-app/templates/types/metadata.d.ts +6 -6
- package/lib/generators/react-app/templates/types/typings.d.ts +13 -0
- package/lib/generators/rollup/templates/config.js +1 -1
- package/lib/generators/stylelint/index.js +2 -2
- package/lib/generators/typescript/index.js +10 -1
- package/lib/generators/typescript/templates/_tsconfig.json +3 -2
- package/package.json +2 -2
- package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlugLocalized.jsx +0 -43
- package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/PasswordValidationRules.php +0 -18
- package/lib/generators/laravel-project/templates/laravel/app/Providers/TelescopeServiceProvider.php +0 -67
- package/lib/generators/react-app/templates/src/lib/utils.js +0 -14
- package/lib/generators/react-app/templates/types/index.d.ts +0 -4
- /package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/{index.js → index.ts} +0 -0
- /package/lib/generators/{node-project/templates/index.js → laravel-panneau/templates/resources/assets/styles/panneau.css} +0 -0
|
@@ -27,13 +27,11 @@ class EslintGenerator extends _generator.default {
|
|
|
27
27
|
this.addDevDependencies({
|
|
28
28
|
'@babel/eslint-parser': '^7.18.9',
|
|
29
29
|
'@babel/preset-typescript': '^7.26.0',
|
|
30
|
-
'@eslint-react/eslint-plugin': '^
|
|
31
|
-
'eslint-plugin-react': '^7.37.5',
|
|
30
|
+
'@eslint-react/eslint-plugin': '^2.0.0',
|
|
32
31
|
eslint: '^9.36.0',
|
|
33
32
|
'eslint-config-prettier': '^10.1.8',
|
|
34
33
|
'eslint-plugin-formatjs': '^5.4.0',
|
|
35
34
|
'eslint-plugin-import': '^2.32.0',
|
|
36
|
-
'eslint-plugin-jsx-a11y': '^6.10.2',
|
|
37
35
|
'eslint-plugin-prettier': '^5.5.4',
|
|
38
36
|
typescript: '^5.7.3',
|
|
39
37
|
'typescript-eslint': '^8.25.0'
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const eslintReact = require('@eslint-react/eslint-plugin');
|
|
1
|
+
import formatjs from 'eslint-plugin-formatjs';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import babelParser from '@babel/eslint-parser';
|
|
4
|
+
import importPlugin from 'eslint-plugin-import';
|
|
5
|
+
import js from '@eslint/js';
|
|
6
|
+
import tseslint from 'typescript-eslint';
|
|
7
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
8
|
+
import eslintReact from '@eslint-react/eslint-plugin';
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
export default tseslint.config(
|
|
12
11
|
{
|
|
13
12
|
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
|
|
14
13
|
},
|
|
@@ -18,7 +17,7 @@ module.exports = tseslint.config(
|
|
|
18
17
|
{
|
|
19
18
|
settings: {
|
|
20
19
|
react: {
|
|
21
|
-
defaultVersion: '
|
|
20
|
+
defaultVersion: '19',
|
|
22
21
|
},
|
|
23
22
|
},
|
|
24
23
|
languageOptions: {
|
|
@@ -51,8 +50,6 @@ module.exports = tseslint.config(
|
|
|
51
50
|
importPlugin.flatConfigs.typescript,
|
|
52
51
|
importPlugin.flatConfigs.recommended,
|
|
53
52
|
formatjs.configs.recommended,
|
|
54
|
-
reactPlugin.configs.flat.recommended,
|
|
55
|
-
reactPlugin.configs.flat['jsx-runtime'],
|
|
56
53
|
eslintPluginPrettierRecommended,
|
|
57
54
|
{
|
|
58
55
|
rules: {
|
|
@@ -109,6 +109,10 @@ class HTMLProjectGenerator extends _generator.default {
|
|
|
109
109
|
'skip-install': true,
|
|
110
110
|
quiet: true
|
|
111
111
|
});
|
|
112
|
+
this.composeWith('folklore:postcss', {
|
|
113
|
+
quiet: true,
|
|
114
|
+
'skip-install': true
|
|
115
|
+
});
|
|
112
116
|
this.composeWith('folklore:svgo', {
|
|
113
117
|
quiet: true,
|
|
114
118
|
'skip-install': true
|
|
@@ -142,11 +146,10 @@ class HTMLProjectGenerator extends _generator.default {
|
|
|
142
146
|
quiet: true
|
|
143
147
|
});
|
|
144
148
|
}
|
|
145
|
-
console.log(srcPath, jsSrcPath, _path.default.join(jsSrcPath, 'index.js'), _path.default.join(srcPath, 'index.html.ejs'));
|
|
146
149
|
this.log('merging with folklore build');
|
|
147
150
|
this.composeWith('folklore:build', {
|
|
148
151
|
'src-path': srcPath,
|
|
149
|
-
'entry-path': _path.default.join(jsSrcPath, 'index.
|
|
152
|
+
'entry-path': _path.default.join(jsSrcPath, 'index.ts'),
|
|
150
153
|
'html-path': _path.default.join(srcPath, 'index.html.ejs'),
|
|
151
154
|
'build-path': destPath,
|
|
152
155
|
'empty-path': destPath,
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<meta name="language" content="{{ $locale }}">
|
|
12
12
|
|
|
13
13
|
<title>@yield('title')</title>
|
|
14
|
-
<meta name="description" content="@yield('description')"
|
|
14
|
+
<meta name="description" content="@yield('description')">
|
|
15
15
|
|
|
16
16
|
<link rel="shortcut icon" href="{{ asset('favicon.ico') }}" type="image/x-ico">
|
|
17
17
|
<link rel="icon" href="{{ asset('favicon.png') }}" type="image/png">
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
<!-- Open Graph meta -->
|
|
21
21
|
<meta property="og:locale" content="{{ $locale }}_CA">
|
|
22
22
|
@hasSection('thumbnail')
|
|
23
|
-
<meta property="og:image" content="@yield('thumbnail')"
|
|
23
|
+
<meta property="og:image" content="@yield('thumbnail')">
|
|
24
24
|
@endif
|
|
25
|
-
<meta property="og:title" content="@yield('title')"
|
|
26
|
-
<meta property="og:type" content="website"
|
|
27
|
-
<meta property="og:description" content="@yield('description')"
|
|
28
|
-
<meta property="og:url" content="{{ Request::url() }}"
|
|
25
|
+
<meta property="og:title" content="@yield('title')">
|
|
26
|
+
<meta property="og:type" content="website">
|
|
27
|
+
<meta property="og:description" content="@yield('description')">
|
|
28
|
+
<meta property="og:url" content="{{ Request::url() }}">
|
|
29
29
|
@show
|
|
30
30
|
|
|
31
31
|
@section('head:analytics')
|
|
@@ -56,11 +56,11 @@ class LaravelPanneauGenerator extends _generator.default {
|
|
|
56
56
|
},
|
|
57
57
|
packageJSON() {
|
|
58
58
|
this.addDependencies({
|
|
59
|
-
'@panneau/app': '^
|
|
60
|
-
'@panneau/core': '^
|
|
61
|
-
'@panneau/data': '^
|
|
62
|
-
'@panneau/field-text': '^
|
|
63
|
-
'@panneau/field-localized': '^
|
|
59
|
+
'@panneau/app': '^4.0.0',
|
|
60
|
+
'@panneau/core': '^4.0.0',
|
|
61
|
+
'@panneau/data': '^4.0.0',
|
|
62
|
+
'@panneau/field-text': '^4.0.0',
|
|
63
|
+
'@panneau/field-localized': '^4.0.0'
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
66
|
config() {
|
|
@@ -96,8 +96,8 @@ class LaravelPanneauGenerator extends _generator.default {
|
|
|
96
96
|
this.fs.copyTpl(source, destination, {});
|
|
97
97
|
},
|
|
98
98
|
indexJs() {
|
|
99
|
-
const source = this.templatePath('index.
|
|
100
|
-
const destination = this.destinationPath('resources/assets/js/index.
|
|
99
|
+
const source = this.templatePath('index.ts');
|
|
100
|
+
const destination = this.destinationPath('resources/assets/js/index.ts');
|
|
101
101
|
this.fs.copyTpl(source, destination, {});
|
|
102
102
|
},
|
|
103
103
|
files() {
|
|
@@ -15,8 +15,7 @@ class Authenticate extends Middleware
|
|
|
15
15
|
protected function redirectTo($request)
|
|
16
16
|
{
|
|
17
17
|
if (!$request->expectsJson()) {
|
|
18
|
-
$routeWithLocale =
|
|
19
|
-
route('panneau.auth.login') .
|
|
18
|
+
$routeWithLocale = route('login') .
|
|
20
19
|
'?' .
|
|
21
20
|
http_build_query([
|
|
22
21
|
'next' => $request->fullUrl(),
|
|
@@ -45,8 +45,6 @@ class PanneauServiceProvider extends BaseServiceProvider
|
|
|
45
45
|
return config('locale.locales');
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
UploadField::setEndpoint(route('panneau.upload'));
|
|
49
|
-
|
|
50
48
|
PageSlugField::setRoutesResolver(function ($locale) {
|
|
51
49
|
return [
|
|
52
50
|
'page' => url()->routeForReactRouter($locale . '.page', [
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { type ComponentType } from 'react';
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
|
|
4
4
|
import shouldPolyfill from './polyfills/should';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
interface Props {
|
|
7
|
+
isPanneau?: boolean;
|
|
8
|
+
[key: string]: unknown;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
props?: Props;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getAppProps(): Props {
|
|
18
|
+
return window.props || ({} as Props);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function renderApp(Container: ComponentType<Props>, props: Props) {
|
|
11
22
|
const element = document.getElementById('app');
|
|
12
23
|
const container = React.createElement(Container, props);
|
|
13
24
|
const strictMode = React.createElement(React.StrictMode, {}, container);
|
|
@@ -15,7 +26,7 @@ function renderApp(Container, props) {
|
|
|
15
26
|
root.render(strictMode);
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
function loadContainer({ isPanneau = false }) {
|
|
29
|
+
function loadContainer({ isPanneau = false }: Props) {
|
|
19
30
|
return isPanneau
|
|
20
31
|
? import('./components/Panneau').then(({ default: Container }) => Container)
|
|
21
32
|
: import('./components/App').then(({ default: Container }) => Container);
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
+
import '@panneau/app/assets/css/styles.css';
|
|
2
|
+
|
|
1
3
|
import { getCSRFHeaders } from '@folklore/fetch';
|
|
2
4
|
import Panneau from '@panneau/app';
|
|
5
|
+
import { PanneauDefinition } from '@panneau/core';
|
|
3
6
|
import { FIELDS_NAMESPACE } from '@panneau/core/contexts';
|
|
4
|
-
import
|
|
5
|
-
import React, { useState, useEffect } from 'react';
|
|
7
|
+
import { useEffect, useState } from 'react';
|
|
6
8
|
|
|
7
9
|
import * as fieldsComponents from './panneau/fields';
|
|
8
10
|
|
|
9
|
-
import '
|
|
10
|
-
import '@panneau/themes/assets/css/styles.css';
|
|
11
|
-
import '@panneau/themes/assets/css/vendor.css';
|
|
11
|
+
import '../../styles/panneau.css';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
definition:
|
|
15
|
-
baseUrl:
|
|
16
|
-
uploadEndpoint
|
|
17
|
-
user
|
|
18
|
-
statusCode
|
|
19
|
-
}
|
|
13
|
+
export interface PanneauContainerProps {
|
|
14
|
+
definition: PanneauDefinition;
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
uploadEndpoint?: string;
|
|
17
|
+
user?: User | null;
|
|
18
|
+
statusCode?: number | null;
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const PanneauContainer = ({
|
|
22
|
+
definition,
|
|
23
|
+
user = null,
|
|
24
|
+
baseUrl,
|
|
25
|
+
uploadEndpoint = '/panneau/upload',
|
|
26
|
+
statusCode = null,
|
|
27
|
+
}: PanneauContainerProps) => {
|
|
28
28
|
const { routes = {} } = definition;
|
|
29
29
|
const isAuthorized = statusCode !== 401 && statusCode !== 403;
|
|
30
30
|
const [localeLoaded, setLocaleLoaded] = useState(false);
|
|
@@ -62,7 +62,4 @@ const PanneauContainer = ({ definition, user, baseUrl, uploadEndpoint, statusCod
|
|
|
62
62
|
) : null;
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
PanneauContainer.propTypes = propTypes;
|
|
66
|
-
PanneauContainer.defaultProps = defaultProps;
|
|
67
|
-
|
|
68
65
|
export default PanneauContainer;
|
|
@@ -1,45 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
import { generatePath } from '@folklore/routes';
|
|
2
2
|
import { useFormValue } from '@panneau/core/contexts';
|
|
3
3
|
import TextField from '@panneau/field-text';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { generatePath } from '@folklore/routes';
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
fieldLocale: PropTypes.string,
|
|
11
|
-
value: PropTypes.string,
|
|
12
|
-
className: PropTypes.string,
|
|
13
|
-
routes: PropTypes.objectOf(PropTypes.string).isRequired,
|
|
14
|
-
};
|
|
6
|
+
type LocalizedSlug = Record<string, string | null | undefined>;
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
interface PageParent {
|
|
9
|
+
slug?: LocalizedSlug | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface PageFormValue {
|
|
13
|
+
parent?: PageParent | null;
|
|
14
|
+
handle?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface PageSlugRoutes {
|
|
18
|
+
page?: string | null;
|
|
19
|
+
page_with_parent?: string | null;
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
interface PageSlugFieldProps {
|
|
23
|
+
fieldLocale?: string | null;
|
|
24
|
+
value?: string | null;
|
|
25
|
+
className?: string | null;
|
|
26
|
+
routes: PageSlugRoutes;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const PageSlugField = ({
|
|
31
|
+
routes,
|
|
32
|
+
fieldLocale = null,
|
|
33
|
+
className = null,
|
|
34
|
+
value = null,
|
|
35
|
+
...props
|
|
36
|
+
}: PageSlugFieldProps) => {
|
|
37
|
+
const page = useFormValue() as PageFormValue | null;
|
|
24
38
|
const { parent = null, handle = null } = page || {};
|
|
25
|
-
const { slug: parentSlug } = parent || {};
|
|
39
|
+
const { slug: parentSlug = null } = parent || {};
|
|
26
40
|
const { page: pageRoute = null, page_with_parent: pageWithParentRoute = null } = routes || {};
|
|
41
|
+
|
|
27
42
|
let url =
|
|
28
43
|
pageRoute !== null
|
|
29
44
|
? generatePath(pageRoute, {
|
|
30
45
|
page: 'REPLACE',
|
|
31
46
|
})
|
|
32
47
|
: null;
|
|
48
|
+
|
|
33
49
|
if (parent !== null && pageWithParentRoute !== null) {
|
|
50
|
+
const localizedParentSlug =
|
|
51
|
+
fieldLocale !== null && parentSlug !== null ? parentSlug[fieldLocale] || null : null;
|
|
34
52
|
url = generatePath(pageWithParentRoute, {
|
|
35
|
-
parent:
|
|
53
|
+
parent: localizedParentSlug,
|
|
36
54
|
page: 'REPLACE',
|
|
37
55
|
});
|
|
38
56
|
}
|
|
57
|
+
|
|
39
58
|
if (handle === 'home') {
|
|
40
59
|
url = `/${fieldLocale}`;
|
|
41
60
|
}
|
|
42
61
|
|
|
62
|
+
const fieldClassName =
|
|
63
|
+
className !== null ? classNames('flex-nowrap', className) : classNames('flex-nowrap');
|
|
64
|
+
|
|
43
65
|
return (
|
|
44
66
|
<TextField
|
|
45
67
|
prepend={
|
|
@@ -50,19 +72,11 @@ const PageSlugField = ({ routes, fieldLocale, className, value, ...props }) => {
|
|
|
50
72
|
)}`
|
|
51
73
|
: null
|
|
52
74
|
}
|
|
53
|
-
className={
|
|
54
|
-
'flex-nowrap',
|
|
55
|
-
{
|
|
56
|
-
[className]: className !== null,
|
|
57
|
-
},
|
|
58
|
-
])}
|
|
75
|
+
className={fieldClassName}
|
|
59
76
|
value={handle === 'home' ? null : value}
|
|
60
77
|
{...props}
|
|
61
78
|
/>
|
|
62
79
|
);
|
|
63
80
|
};
|
|
64
81
|
|
|
65
|
-
PageSlugField.propTypes = propTypes;
|
|
66
|
-
PageSlugField.defaultProps = defaultProps;
|
|
67
|
-
|
|
68
82
|
export default PageSlugField;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useFormValue } from '@panneau/core/contexts';
|
|
2
|
+
import LocalizedField from '@panneau/field-localized';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import slugify from 'slugify';
|
|
7
|
+
|
|
8
|
+
type LocalizedValue = Record<string, string>;
|
|
9
|
+
|
|
10
|
+
interface PageTitleValue {
|
|
11
|
+
title?: LocalizedValue | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface PageSlugLocalizedFieldProps {
|
|
15
|
+
value?: LocalizedValue | null;
|
|
16
|
+
locales?: string[] | null;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const PageSlugField = ({ value = null, locales = null, ...props }: PageSlugLocalizedFieldProps) => {
|
|
21
|
+
const page = useFormValue() as PageTitleValue | null;
|
|
22
|
+
const { title = null } = page || {};
|
|
23
|
+
const finalValue = useMemo(() => {
|
|
24
|
+
if (locales === null) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return locales.reduce<LocalizedValue | null>(
|
|
28
|
+
(newValue, key) =>
|
|
29
|
+
newValue === null || isEmpty(newValue[key])
|
|
30
|
+
? {
|
|
31
|
+
...newValue,
|
|
32
|
+
[key]: slugify(get(title, key, '')),
|
|
33
|
+
}
|
|
34
|
+
: newValue,
|
|
35
|
+
value,
|
|
36
|
+
);
|
|
37
|
+
}, [locales, value, title]);
|
|
38
|
+
|
|
39
|
+
return <LocalizedField value={finalValue} locales={locales || []} {...props} />;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default PageSlugField;
|
|
@@ -217,6 +217,10 @@ class LaravelProjectGenerator extends _generator.default {
|
|
|
217
217
|
quiet: true,
|
|
218
218
|
'skip-install': true
|
|
219
219
|
});
|
|
220
|
+
this.composeWith('folklore:postcss', {
|
|
221
|
+
quiet: true,
|
|
222
|
+
'skip-install': true
|
|
223
|
+
});
|
|
220
224
|
this.composeWith('folklore:react-app', {
|
|
221
225
|
'project-name': this.options['project-name'],
|
|
222
226
|
path: jsSrcPath,
|
|
@@ -233,7 +237,7 @@ class LaravelProjectGenerator extends _generator.default {
|
|
|
233
237
|
});
|
|
234
238
|
this.composeWith('folklore:build', {
|
|
235
239
|
'src-path': assetsPath,
|
|
236
|
-
'entry-path': _path.default.join(jsSrcPath, 'index.
|
|
240
|
+
'entry-path': _path.default.join(jsSrcPath, 'index.ts'),
|
|
237
241
|
'build-path': publicPath,
|
|
238
242
|
quiet: true,
|
|
239
243
|
'skip-install': true
|
|
@@ -313,7 +317,7 @@ class LaravelProjectGenerator extends _generator.default {
|
|
|
313
317
|
},
|
|
314
318
|
extra: {
|
|
315
319
|
laravel: {
|
|
316
|
-
'dont-discover': ['laravel/telescope'
|
|
320
|
+
'dont-discover': ['laravel/telescope']
|
|
317
321
|
}
|
|
318
322
|
},
|
|
319
323
|
'minimum-stability': 'dev',
|
|
@@ -324,11 +328,11 @@ class LaravelProjectGenerator extends _generator.default {
|
|
|
324
328
|
this.packageJson.merge({
|
|
325
329
|
scripts: {
|
|
326
330
|
clean: 'rm -rf public/static && rm -rf public/precache-*',
|
|
327
|
-
'build:scripts': 'flklr build --load-env ./resources/assets/js/index.
|
|
331
|
+
'build:scripts': 'flklr build --load-env ./resources/assets/js/index.ts',
|
|
328
332
|
'build:views': 'php artisan assets:view',
|
|
329
333
|
build: 'npm run clean && npm run build:scripts && npm run build:views',
|
|
330
334
|
start: 'npm run server',
|
|
331
|
-
server: 'flklr serve --load-env ./resources/assets/js/index.
|
|
335
|
+
server: 'flklr serve --load-env ./resources/assets/js/index.ts'
|
|
332
336
|
}
|
|
333
337
|
});
|
|
334
338
|
},
|
|
@@ -4,7 +4,19 @@ APP_KEY=
|
|
|
4
4
|
APP_DEBUG=true
|
|
5
5
|
APP_URL=<%= url %>
|
|
6
6
|
|
|
7
|
+
APP_LOCALE=en
|
|
8
|
+
APP_FALLBACK_LOCALE=en
|
|
9
|
+
APP_FAKER_LOCALE=en_US
|
|
10
|
+
|
|
11
|
+
APP_MAINTENANCE_DRIVER=file
|
|
12
|
+
# APP_MAINTENANCE_STORE=database
|
|
13
|
+
|
|
14
|
+
# PHP_CLI_SERVER_WORKERS=4
|
|
15
|
+
|
|
16
|
+
BCRYPT_ROUNDS=12
|
|
17
|
+
|
|
7
18
|
LOG_CHANNEL=stack
|
|
19
|
+
LOG_STACK=single
|
|
8
20
|
LOG_DEPRECATIONS_CHANNEL=null
|
|
9
21
|
LOG_LEVEL=debug
|
|
10
22
|
|
|
@@ -15,27 +27,40 @@ DB_DATABASE=<%= db_name %>
|
|
|
15
27
|
DB_USERNAME=<%= db_username %>
|
|
16
28
|
DB_PASSWORD=<%= db_password %>
|
|
17
29
|
|
|
18
|
-
BROADCAST_DRIVER=log
|
|
19
|
-
CACHE_DRIVER=file
|
|
20
|
-
FILESYSTEM_DISK=local
|
|
21
|
-
QUEUE_CONNECTION=sync
|
|
22
30
|
SESSION_DRIVER=file
|
|
23
31
|
SESSION_LIFETIME=120
|
|
32
|
+
SESSION_ENCRYPT=false
|
|
33
|
+
SESSION_PATH=/
|
|
34
|
+
SESSION_DOMAIN=null
|
|
35
|
+
|
|
36
|
+
BROADCAST_CONNECTION=log
|
|
37
|
+
FILESYSTEM_DISK=local
|
|
38
|
+
QUEUE_CONNECTION=database
|
|
39
|
+
|
|
40
|
+
CACHE_STORE=file
|
|
41
|
+
# CACHE_PREFIX=
|
|
24
42
|
|
|
25
43
|
MEMCACHED_HOST=127.0.0.1
|
|
26
44
|
|
|
45
|
+
REDIS_CLIENT=phpredis
|
|
27
46
|
REDIS_HOST=127.0.0.1
|
|
28
47
|
REDIS_PASSWORD=null
|
|
29
48
|
REDIS_PORT=6379
|
|
30
49
|
|
|
31
|
-
MAIL_MAILER=
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
MAIL_MAILER=log
|
|
51
|
+
MAIL_SCHEME=null
|
|
52
|
+
MAIL_HOST=127.0.0.1
|
|
53
|
+
MAIL_PORT=2525
|
|
34
54
|
MAIL_USERNAME=null
|
|
35
55
|
MAIL_PASSWORD=null
|
|
36
|
-
MAIL_ENCRYPTION=null
|
|
37
56
|
MAIL_FROM_ADDRESS="dev@folklore.email"
|
|
38
57
|
MAIL_FROM_NAME="${APP_NAME}"
|
|
39
58
|
|
|
59
|
+
AWS_ACCESS_KEY_ID=
|
|
60
|
+
AWS_SECRET_ACCESS_KEY=
|
|
61
|
+
AWS_DEFAULT_REGION=us-east-1
|
|
62
|
+
AWS_BUCKET=
|
|
63
|
+
AWS_USE_PATH_STYLE_ENDPOINT=false
|
|
64
|
+
|
|
40
65
|
# react-scripts variables
|
|
41
66
|
FLKLR_PROXY=<%= proxy_url %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace App\Http\Middleware;
|
|
4
|
+
|
|
5
|
+
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
|
6
|
+
|
|
7
|
+
class Authenticate extends Middleware
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* Get the path the user should be redirected to when they are not authenticated.
|
|
11
|
+
*
|
|
12
|
+
* @param \Illuminate\Http\Request $request
|
|
13
|
+
* @return string|null
|
|
14
|
+
*/
|
|
15
|
+
protected function redirectTo($request)
|
|
16
|
+
{
|
|
17
|
+
if (!$request->expectsJson() && $request->isPanneau()) {
|
|
18
|
+
return route('panneau.auth.login') .
|
|
19
|
+
'?' .
|
|
20
|
+
http_build_query([
|
|
21
|
+
'next' => $request->fullUrl(),
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return route('login') .
|
|
26
|
+
http_build_query([
|
|
27
|
+
'next' => $request->fullUrl(),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -5,13 +5,12 @@ namespace App\Models;
|
|
|
5
5
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
6
6
|
use Folklore\Models\User as BaseUser;
|
|
7
7
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
8
|
-
use Laravel\Sanctum\HasApiTokens;
|
|
9
8
|
use App\Contracts\Entities\User as UserContract;
|
|
10
9
|
use App\Entities\User as UserResource;
|
|
11
10
|
|
|
12
11
|
class User extends BaseUser
|
|
13
12
|
{
|
|
14
|
-
use
|
|
13
|
+
use HasFactory;
|
|
15
14
|
|
|
16
15
|
public function toEntity(): UserContract
|
|
17
16
|
{
|
package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php
CHANGED
|
@@ -60,9 +60,14 @@ class AppServiceProvider extends ServiceProvider
|
|
|
60
60
|
|
|
61
61
|
protected function registerTelescope()
|
|
62
62
|
{
|
|
63
|
-
if (
|
|
63
|
+
if (
|
|
64
|
+
$this->app->environment('local') &&
|
|
65
|
+
class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)
|
|
66
|
+
) {
|
|
64
67
|
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
|
|
65
|
-
|
|
68
|
+
if (class_exists(TelescopeServiceProvider::class)) {
|
|
69
|
+
$this->app->register(TelescopeServiceProvider::class);
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
73
|
|
package/lib/generators/laravel-project/templates/laravel/app/Providers/RouteServiceProvider.php
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
namespace App\Providers;
|
|
4
4
|
|
|
5
|
-
use Illuminate\Cache\RateLimiting\Limit;
|
|
6
5
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
|
7
|
-
use Illuminate\Http\Request;
|
|
8
|
-
use Illuminate\Support\Facades\RateLimiter;
|
|
9
|
-
use Illuminate\Support\Facades\Route;
|
|
10
6
|
|
|
11
7
|
class RouteServiceProvider extends ServiceProvider
|
|
12
8
|
{
|
|
@@ -26,32 +22,9 @@ class RouteServiceProvider extends ServiceProvider
|
|
|
26
22
|
*/
|
|
27
23
|
public function boot()
|
|
28
24
|
{
|
|
29
|
-
$this->configureRateLimiting();
|
|
30
|
-
|
|
31
25
|
$this->bootPatterns();
|
|
32
26
|
|
|
33
27
|
$this->bootBindings();
|
|
34
|
-
|
|
35
|
-
$this->routes(function () {
|
|
36
|
-
Route::middleware('api')
|
|
37
|
-
->prefix('api')
|
|
38
|
-
->group(base_path('routes/api.php'));
|
|
39
|
-
|
|
40
|
-
Route::middleware('web')
|
|
41
|
-
->group(base_path('routes/web.php'));
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Configure the rate limiters for the application.
|
|
47
|
-
*
|
|
48
|
-
* @return void
|
|
49
|
-
*/
|
|
50
|
-
protected function configureRateLimiting()
|
|
51
|
-
{
|
|
52
|
-
RateLimiter::for('api', function (Request $request) {
|
|
53
|
-
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
|
54
|
-
});
|
|
55
28
|
}
|
|
56
29
|
|
|
57
30
|
protected function bootPatterns()
|