gcg-website/static/admin/index.html

206 lines
6.3 KiB
HTML
Raw Permalink Normal View History

2023-01-10 22:23:04 +01:00
<!DOCTYPE html>
2020-07-11 13:45:14 +02:00
<html>
2023-01-10 22:23:04 +01:00
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
2023-05-29 16:22:34 +02:00
<link
rel="stylesheet"
href="https://assets.cantorgymnasium.de/fonts/mdi/v7/css/materialdesignicons.min.css"
/>
<link
rel="stylesheet"
2024-01-06 10:53:56 +01:00
href="https://unpkg.com/@staticcms/app@^4.0.0/dist/main.css"
2023-05-29 16:22:34 +02:00
/>
2023-01-10 22:23:04 +01:00
<title>Static CMS</title>
</head>
<body>
2024-01-06 10:53:56 +01:00
<script src="https://unpkg.com/@staticcms/app@^4.0.0/dist/static-cms-app.js"></script>
<script type="module">
2023-05-11 06:44:30 +02:00
import config from "./config/index.js";
// imports
import {
AboutPreview,
BlogPreview,
ContestPreview,
PagePreview,
EventPreview,
AnmeldungPreview,
HeaderPreview,
ChronikPreview,
KontaktPreview,
AnmeldeformularPreview,
ChronikIndexPreview,
AuthorPreview,
FormsPreview,
CantorpreisPreview,
ProjektwochePreview,
AbiturientenPreview,
PreviewStyles,
} from "./previews/page-previews/index.js";
import {
BooleanPreview,
DraftPreview,
CountPreview,
BodyPreview,
DatePreview,
} from "./previews/field-previews/index.js";
import {
GalleryShortcode,
ImageShortcode,
DownloadShortcode,
CardShortcode,
YoutubeShortcode,
AudioShortcode,
SliderShortcode,
} from "./shortcodes/index.js";
import { StatusPage, WikiLink } from "./links/index.js";
import Icons from "./icons.js";
// cms initialization
2023-05-29 16:22:34 +02:00
CMS.init({ config });
2023-02-11 20:15:36 +01:00
// preview templates
2023-01-14 17:31:54 +01:00
CMS.registerPreviewTemplate("about-index", AboutPreview);
CMS.registerPreviewTemplate("blog", BlogPreview);
CMS.registerPreviewTemplate("wettbewerbe", ContestPreview);
2023-05-29 16:22:34 +02:00
CMS.registerPreviewTemplate("kontakt", KontaktPreview);
CMS.registerPreviewTemplate("termine", EventPreview);
CMS.registerPreviewTemplate("anmeldung-index", AnmeldungPreview);
2023-05-11 06:44:30 +02:00
CMS.registerPreviewTemplate("chronikjahre", ChronikPreview);
CMS.registerPreviewTemplate("anmeldeformular", AnmeldeformularPreview);
CMS.registerPreviewTemplate("schulchronik-index", ChronikIndexPreview);
CMS.registerPreviewTemplate("author", AuthorPreview);
CMS.registerPreviewTemplate("forms", FormsPreview);
CMS.registerPreviewTemplate("cantorpreis", CantorpreisPreview);
CMS.registerPreviewTemplate("begabte", ContestPreview);
["projektwoche", "superhaufen", "ganztagsangebote-index"].forEach((page) =>
CMS.registerPreviewTemplate(page, ProjektwochePreview)
);
["abiturienten", "cantorfora"].forEach((page) =>
CMS.registerPreviewTemplate(page, AbiturientenPreview)
);
[
"blog-index",
"cantorpreis-index",
"forms-index",
"wettbewerbe-index",
"begabte-index",
"abiturienten-index",
"projektwoche-index",
"author-index",
].forEach((page) => CMS.registerPreviewTemplate(page, HeaderPreview));
[
"abiturienten",
"cantorfora-index",
"pages",
"anmeldeformular",
"schulchronik-index",
"chronikseiten",
].forEach((page) => CMS.registerPreviewTemplate(page, PagePreview));
PreviewStyles.forEach((url) => {
CMS.registerPreviewStyle(url);
2023-02-11 20:15:36 +01:00
});
//shortcodes
CMS.registerShortcode("gallery", GalleryShortcode);
CMS.registerShortcode("image", ImageShortcode);
CMS.registerShortcode("download", DownloadShortcode);
CMS.registerShortcode("card", CardShortcode);
CMS.registerShortcode("youtube", YoutubeShortcode);
CMS.registerShortcode("audio", AudioShortcode);
CMS.registerShortcode("slider", SliderShortcode);
// links
CMS.registerAdditionalLink(StatusPage);
CMS.registerAdditionalLink(WikiLink);
// icons
Icons.forEach((i) => CMS.registerIcon(i.name, i.icon));
// field previews
CMS.registerFieldPreview("author", "active", BooleanPreview);
CMS.registerFieldPreview("author", "simplified", BooleanPreview);
CMS.registerFieldPreview("blog", "date", DatePreview);
2023-05-11 06:44:30 +02:00
CMS.registerFieldPreview("chronikjahre", "topics", CountPreview);
["projektwoche", "superhaufen"].forEach((collection) =>
CMS.registerFieldPreview(collection, "tiles", CountPreview)
);
[
"forms",
"blog",
"cantorpreis",
"pages",
"wettbewerbe",
"begabte",
"projektwoche",
2023-05-11 06:44:30 +02:00
"chronikjahre",
"abiturienten",
"superhaufen",
"cantorfora",
"chronikseiten",
].forEach((collection) =>
2023-04-20 07:51:28 +02:00
CMS.registerFieldPreview(collection, "draft", DraftPreview)
);
2023-05-29 16:22:34 +02:00
[
"blog",
"author",
"chronikseiten",
"pages",
"cantorpreis",
"begabte",
].forEach((collection) =>
CMS.registerFieldPreview(collection, "body", BodyPreview)
);
[
"cantorpreis-index",
"wettbewerbe-index",
"abiturienten-index",
"pages",
"projektwoche",
"cantorfora",
"blog-index",
"about-index",
"anmeldung-index",
2023-05-29 16:22:34 +02:00
"kontakt",
"termine",
"forms-index",
"ganztagsangebote-index",
"begabte-index",
"projektwoche-index",
].forEach((collection) =>
CMS.registerFieldPreview(collection, "description", BodyPreview)
);
["chronikseiten", "blog"].forEach((collection) =>
CMS.registerFieldPreview(collection, "title", BodyPreview)
);
2023-05-29 16:22:34 +02:00
// access control
CMS.registerEventListener({
name: "login",
2023-09-30 16:32:22 +02:00
handler: ({ author: { login, name } }) => {
2023-05-29 16:22:34 +02:00
const adminUsers = [
2023-05-29 16:52:55 +02:00
"Tramus00",
2023-05-29 16:22:34 +02:00
"denyskon",
"gfelke",
2023-09-30 16:40:41 +02:00
"lberthold",
2023-05-29 16:22:34 +02:00
"cschapitz",
"bgorsler",
"tmesse",
2024-04-03 18:46:00 +02:00
"spflug",
"fberner"
2023-05-29 16:22:34 +02:00
];
2023-09-30 16:34:21 +02:00
if (login && !adminUsers.includes(login)) {
2023-05-29 16:22:34 +02:00
alert(
2023-09-30 16:34:21 +02:00
"Sie sind nicht berechtigt, diese Seite aufzurufen. Sie werden nun zur Startseite weitergeleitet."
2023-05-29 16:22:34 +02:00
);
location.href = "/";
2023-09-30 16:37:01 +02:00
} else {
2023-09-30 16:37:16 +02:00
console.log("Willkommen im Admin-Bereich!")
2023-05-29 16:22:34 +02:00
}
},
});
2023-01-30 19:54:31 +01:00
</script>
2023-01-10 22:23:04 +01:00
</body>
2020-07-11 13:45:14 +02:00
</html>