Skip to content

Commit

Permalink
Update github repo package
Browse files Browse the repository at this point in the history
  • Loading branch information
underpostnet committed Dec 12, 2024
1 parent 2d8f9a3 commit e2b9681
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const DefaultConf = {
ssr: {
Default: {
head: ['Seo', 'Pwa', 'Css', 'DefaultScripts', 'Production'],
body: ['CacheControl', 'DefaultSplashScreen'],
body: ['CacheControl', 'DefaultSplashScreen', '404', '500'],
mailer: {
userVerifyEmail: 'DefaultVerifyEmail',
userRecoverEmail: 'DefaultRecoverEmail',
Expand Down
3 changes: 3 additions & 0 deletions src/client/components/core/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,9 @@ const Modal = {
backMenuButtonEvent();
}
s(`.btn-close-modal-menu`).click();
if (window.location.pathname !== (getProxyPath() === '/' ? getProxyPath() : `${getProxyPath()}/`))
setPath(getProxyPath());
setDocTitle({ ...options.RouterInstance, route: '' });
};
EventsUI.onClick(`.btn-icon-menu-back`, backMenuButtonEvent);
EventsUI.onClick(`.btn-icon-menu-mode`, () => {
Expand Down
4 changes: 3 additions & 1 deletion src/client/components/core/VanillaJs.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ const isDevInstance = () => location.origin.match('localhost') && location.port;
const getDataFromInputFile = async (file) => Array.from(new Uint8Array(await file.arrayBuffer()));

const getLang = () =>
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
.slice(0, 2)
.toLowerCase();

export {
s,
Expand Down
1 change: 1 addition & 0 deletions src/client/components/default/MenuDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const MenuDefault = {
return '';
},
mode: 'slide-menu',
RouterInstance,
heightTopBar,
heightBottomBar,
htmlMainBody: options?.htmlMainBody ? options.htmlMainBody : undefined,
Expand Down
73 changes: 73 additions & 0 deletions src/client/ssr/body/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const s = (el) => document.querySelector(el);

const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);

const getLang = () =>
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
.slice(0, 2)
.toLowerCase();

const main = () => {
const Translate = {
Data: {
['page-not-found']: {
en: 'Page not found',
es: 'Página no encontrada',
},
['page-broken']: {
es: 'Algo salio mal',
en: 'Something went wrong',
},
['back']: {
en: 'Back to <br> homepage',
es: 'Volver a <br> la pagina principal',
},
},
Render: function (id) {
return this.Data[id][getLang()] ? this.Data[id][getLang()] : this.Data[id]['en'];
},
};
const icon = html`
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 24 24">
<path
fill="currentColor"
d="M15.097 5.904A6.5 6.5 0 0 0 4 10.504l.001 1h-2v-1a8.5 8.5 0 1 1 15.176 5.258l5.344 5.345l-1.414 1.414l-5.344-5.345A8.48 8.48 0 0 1 10.5 19h-1v-2h1a6.5 6.5 0 0 0 4.596-11.096M1.672 13.257L4.5 16.086l2.829-2.829l1.414 1.415L5.915 17.5l2.828 2.828l-1.414 1.415L4.5 18.914l-2.828 2.829l-1.414-1.415L3.086 17.5L.258 14.672z"
/>
</svg>
`;
append(
'body',
html` <style>
body {
font-family: arial;
font-size: 20px;
background-color: #d8d8d8;
color: #333;
}
a {
color: black;
}
</style>
<div class="abs center" style="top: 45%">
${icon}
<br />
<br />
<span class="bold">404</span>
<br />
<br />${Translate.Render('page-not-found')} <br />
<br />
<a href="${location.origin}">${Translate.Render('back')}</a>
</div>`,
);
};

SrrComponent = () => html`<script>
{
const s = ${s};
const append = ${append};
const getLang = ${getLang};
const main = ${main};
window.onload = main;
}
</script>`;
72 changes: 72 additions & 0 deletions src/client/ssr/body/500.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const s = (el) => document.querySelector(el);

const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);

const getLang = () =>
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
.slice(0, 2)
.toLowerCase();

const main = () => {
const Translate = {
Data: {
['page-not-found']: {
en: 'Page not found',
es: 'Página no encontrada',
},
['page-broken']: {
es: 'Algo salio mal',
en: 'Something went wrong',
},
['back']: {
en: 'Back to <br> homepage',
es: 'Volver a <br> la pagina principal',
},
},
Render: function (id) {
return this.Data[id][getLang()] ? this.Data[id][getLang()] : this.Data[id]['en'];
},
};
const icon = html`<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 20 20">
<path
fill="currentColor"
d="M6 2a2 2 0 0 0-2 2v5.207a5.5 5.5 0 0 1 1-.185V4a1 1 0 0 1 1-1h4v3.5A1.5 1.5 0 0 0 11.5 8H15v8a1 1 0 0 1-1 1h-3.6a5.5 5.5 0 0 1-.657 1H14a2 2 0 0 0 2-2V7.414a1.5 1.5 0 0 0-.44-1.06l-3.914-3.915A1.5 1.5 0 0 0 10.586 2zm8.793 5H11.5a.5.5 0 0 1-.5-.5V3.207zM10 14.5a4.5 4.5 0 1 1-9 0a4.5 4.5 0 0 1 9 0M5.5 12a.5.5 0 0 0-.5.5v2a.5.5 0 0 0 1 0v-2a.5.5 0 0 0-.5-.5m0 5.125a.625.625 0 1 0 0-1.25a.625.625 0 0 0 0 1.25"
/>
</svg>`;

append(
'body',
html` <style>
body {
font-family: arial;
font-size: 20px;
background-color: #d8d8d8;
color: #333;
}
a {
color: black;
}
</style>
<div class="abs center" style="top: 45%">
${icon}
<br />
<br />
<span class="bold">500</span>
<br />
<br />${Translate.Render('page-broken')} <br />
<br />
<a href="${location.origin}">${Translate.Render('back')}</a>
</div>`,
);
};

SrrComponent = () => html`<script>
{
const s = ${s};
const append = ${append};
const getLang = ${getLang};
const main = ${main};
window.onload = main;
}
</script>`;
4 changes: 3 additions & 1 deletion src/client/ssr/offline/NoNetworkConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const s = (el) => document.querySelector(el);
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);

const getLang = () =>
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
.slice(0, 2)
.toLowerCase();

const main = () => {
const Translate = {
Expand Down
4 changes: 3 additions & 1 deletion src/client/ssr/pages/Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ const s = (el) => document.querySelector(el);
const append = (el, html) => s(el).insertAdjacentHTML('beforeend', html);

const getLang = () =>
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang).slice(0, 2);
(localStorage.getItem('lang') || navigator.language || navigator.userLanguage || s('html').lang)
.slice(0, 2)
.toLowerCase();

const main = () => {
const Translate = {
Expand Down

0 comments on commit e2b9681

Please sign in to comment.