This commit is contained in:
Adrian Amaglio 2023-08-01 17:26:50 +02:00
parent d207efd6dc
commit f6be728c19
6 changed files with 2940 additions and 25 deletions

View File

@ -1,18 +1,16 @@
FROM node:20-alpine
# Workdir
RUN mkdir /usr/local/app
RUN chown 33:33 /usr/local/app
WORKDIR /usr/local/app
ADD entrypoint.sh /usr/local/bin
RUN mkdir /usr/lib/json-server
#RUN chown 33:33 /usr/lib/json-server
WORKDIR /usr/lib/json-server
# Install modules
RUN npm install -g json-server
USER 33
ADD entrypoint.sh /usr/local/bin
#USER 33
# Cant kill with ctrl+c
#ENTRYPOINT ["/usr/local/bin/json-server", "db.json"]
ENTRYPOINT ["entrypoint.sh"]
CMD ["json-server", "-H", "0.0.0.0", "db.json"]
CMD ["json-server", "-H", "0.0.0.0", "/usr/lib/json-server/db.json"]

View File

@ -1,3 +1,9 @@
#!/bin/sh
if [ ! -f db.json ] ; then
touch db.json
fi
if [ ! -s db.json ] ; then
echo '{"projects": [ {"id": 1, "data": {"assets": [], "styles": [], "pages": []} } ]}' > db.json
fi
"$@"

View File

@ -1,3 +1,9 @@
.red {
color: #f24b4b;
}
.gjs-block {
width: auto;
height: auto;
min-height: auto;
}

2875
db.json Normal file

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit f8b66a1d7e28b6c156cb7d6c61d2951872e9675f
Subproject commit 8893dbe2e79972e5c34806e71075d2e94a4a9e3e

View File

@ -7,27 +7,57 @@ if (projectID == '' || isNaN(projectID)) {
} else {
const projectEndpoint = `/projects/${projectID}`;
var editor = grapesjs.init({
container : '#gjs',
components: '<div class="red">Le chargement du projet est en cours. Si ce message ne disparait pas, le chargement a sans doutes échoué…</div>',
container : '#gjs',
//plugins: ['grapesjs-preset-webpage', 'customBlocks', 'customTypes'],
//components: '<div class="red">Le chargement du projet est en cours. Si ce message ne disparait pas, le chargement a sans doutes échoué…</div>',
i18n: {
locale: 'fr', // default locale
detectLocale: false, // by default, the editor will detect the language
//localeFallback: 'en', // default fallback
messages: {fr},
},
storageManager: {
type: 'remote',
stepsBeforeSave: 1,
autosave: true,
options: {
remote: {
urlLoad: projectEndpoint,
urlStore: projectEndpoint,
fetchOptions: opts => (opts.method === 'POST' ? { method: 'PATCH' } : {}),
onStore: data => ({ id: projectID, data }),
onLoad: result => result.data,
}
storageManager: {
type: 'remote',
stepsBeforeSave: 1,
autosave: true,
options: {
remote: {
urlLoad: projectEndpoint,
urlStore: projectEndpoint,
fetchOptions: opts => (opts.method === 'POST' ? { method: 'PATCH' } : {}),
onStore: data => ({ id: projectID, data }),
onLoad: result => result.data,
}
}
});
},
//blockManager: {
// appendTo: '#blocks',
// blocks: [
// {
// id: 'section', // id is mandatory
// label: '<b>Section</b>', // You can use HTML/SVG inside labels
// attributes: { class:'gjs-block-section' },
// content: `<section>
// <h1>Ho ! Mais cest un titre !</h1>
// <div>Il faut regarder avec le cœur. Lessentiel est invisible pour les yeux. Cest du petit prince ;)</div>
// </section>`,
// }, {
// id: 'text',
// label: 'Text',
// content: '<div data-gjs-type="text">Voici un bloc de texte tout seul :o</div>',
// }, {
// id: 'image',
// label: 'Image',
// // Select the component once it's dropped
// select: true,
// // You can pass components as a JSON instead of a simple HTML string,
// // in this case we also use a defined component type `image`
// content: { type: 'image' },
// // This triggers `active` event on dropped components and the `image`
// // reacts by opening the AssetManager
// activate: true,
// }
// ]
//},
});
}