cleanups
This commit is contained in:
@ -40,7 +40,6 @@
|
||||
toProps: args => {
|
||||
if (args.length > 0) {
|
||||
var dir = args.find(arg => arg.startsWith('dir='))?.split('=')[1].replaceAll("\"","") ?? '';
|
||||
console.log(dir);
|
||||
return { dir: dir };
|
||||
}
|
||||
|
||||
@ -64,7 +63,7 @@
|
||||
}));
|
||||
},
|
||||
preview: ({ dir }) => {
|
||||
return h('div', {"className": "row", "style": { border: "1px solid #868686", borderRadius: "8px", padding: "10px" }},
|
||||
return h('div', {"className": "row", "style": { border: "1px solid #868686", borderRadius: "8px", padding: "10px", marginBottom: "5px" }},
|
||||
h('b', {"style": { marginRight: "5px" }}, "Gallerie-Ordner:"),
|
||||
h('code', {}, dir));
|
||||
},
|
||||
@ -77,7 +76,6 @@
|
||||
toProps: args => {
|
||||
if (args.length > 0) {
|
||||
var src = args.find(arg => arg.startsWith('src='))?.split('=')[1].replaceAll("\"","") ?? '';
|
||||
console.log(src);
|
||||
return { src };
|
||||
}
|
||||
|
||||
@ -86,7 +84,7 @@
|
||||
toArgs: ({ src }) => {
|
||||
return [`src=\"${src}\"`];
|
||||
},
|
||||
/* control: ({ src, onChange, controlProps: { field, collection, entry } }) => {
|
||||
/*control: ({ src, onChange, controlProps: { field, collection, entry } }) => {
|
||||
const controlID = useUUID();
|
||||
const handleOnChange = (newSrc) => {
|
||||
onChange(newSrc);
|
||||
@ -133,6 +131,78 @@
|
||||
h('code', {}, src));
|
||||
},
|
||||
});
|
||||
CMS.registerShortcode('download', {
|
||||
label: 'Download-Karte',
|
||||
openTag: '{{< ',
|
||||
closeTag: ' >}}',
|
||||
separator: ' ',
|
||||
toProps: args => {
|
||||
if (args.length > 0) {
|
||||
var title = "";
|
||||
var link = "";
|
||||
var linkIndex = args.findIndex(arg => arg.startsWith('link="'));
|
||||
var titleIndex = args.findIndex(arg => arg.startsWith('title="'));
|
||||
if (titleIndex + 1 < linkIndex) {
|
||||
title += args.find(arg => arg.startsWith('title='))?.split('=')[1].replaceAll("\"","") ?? '';
|
||||
for (let i = titleIndex + 1; i < linkIndex; i++) {
|
||||
title += " " + args[i].replaceAll("\"","") ;
|
||||
}
|
||||
} else {
|
||||
title = args.find(arg => arg.startsWith('title='))?.split('=')[1].replaceAll("\"","") ?? ''
|
||||
}
|
||||
if (linkIndex + 1 < args.length) {
|
||||
link += args.find(arg => arg.startsWith('link='))?.split('=')[1].replaceAll("\"","") ?? '';
|
||||
for (let i = linkIndex + 1; i < args.length; i++) {
|
||||
link += " " + args[i].replaceAll("\"","");
|
||||
}
|
||||
} else {
|
||||
link = args.find(arg => arg.startsWith('link='))?.split('=')[1].replaceAll("\"","") ?? ''
|
||||
}
|
||||
title.trim();
|
||||
link.trim();
|
||||
return { title: title, link: link };
|
||||
}
|
||||
|
||||
return { title: '', link: '' };
|
||||
},
|
||||
toArgs: ({ title, link }) => {
|
||||
return [`title=\"${title}\"`, `link=\"${link}\"`];
|
||||
},
|
||||
control: ({ title, link, onChange }) => {
|
||||
return h('div', {"className": "row", "style": { border: "1px solid #868686", borderRadius: "8px", padding: "10px" }},
|
||||
h('b', {"style": {width: "30%", fontFamily: "sans-serif", margin: "10px"}}, "Download-Karte:"),
|
||||
h('input', {
|
||||
key: 'control-input',
|
||||
value: title,
|
||||
"style": {
|
||||
border: "1px solid #ced4da", borderRadius: "8px", padding: "10px", width: "35%", marginLeft: "5px", marginRight: "5px"
|
||||
},
|
||||
onChange: event => {
|
||||
onChange({ title: event.target.value, link: link });
|
||||
},
|
||||
}),
|
||||
h('input', {
|
||||
key: 'control-input',
|
||||
value: link,
|
||||
"style": {
|
||||
border: "1px solid #ced4da", borderRadius: "8px", padding: "10px", width: "35%", marginLeft: "5px", marginRight: "5px"
|
||||
},
|
||||
onChange: event => {
|
||||
onChange({ title: title, link: event.target.value });
|
||||
},
|
||||
})
|
||||
);
|
||||
},
|
||||
preview: ({ title, link }) => {
|
||||
return h('div', {"className": "container mb-0"},
|
||||
h('div', {"className": "card border-primary rounded-0 hover-shadow mb-5"},
|
||||
h('div', {"className": "card-body mb-0"},
|
||||
h('h4', {"className": "card-title"},
|
||||
h('a', {"className": "text-decoration-none", "href": link}, title),
|
||||
),
|
||||
h('a', {"className": "mb-0 btn btn-primary btn-sm text-decoration-none", "href": link}, "Download")
|
||||
)))},
|
||||
});
|
||||
CMS.registerShortcode('card', {
|
||||
label: 'Link-Karte',
|
||||
openTag: '{{< ',
|
||||
@ -142,7 +212,6 @@
|
||||
if (args.length > 0) {
|
||||
var title = "";
|
||||
var link = "";
|
||||
console.log(args);
|
||||
var linkIndex = args.findIndex(arg => arg.startsWith('link="'));
|
||||
var titleIndex = args.findIndex(arg => arg.startsWith('title="'));
|
||||
if (titleIndex + 1 < linkIndex) {
|
||||
@ -322,7 +391,7 @@
|
||||
<script>
|
||||
var ChronikPreview = ({widgetFor, widgetsFor, entry, document, window }) => {
|
||||
const divStyle = {
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.png"),url("/media/backgrounds/page-title.png")',
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.webp"),url("/media/backgrounds/page-title.webp")',
|
||||
};
|
||||
return h('div', {"id": "sc-root"},
|
||||
h('section', {"className": "page-title-section overlay", "style": divStyle},
|
||||
@ -418,7 +487,7 @@
|
||||
<script>
|
||||
var PostPreviewContent = ({widgetFor, entry}) => {
|
||||
const divStyle = {
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.png"),url("/media/backgrounds/page-title.png")',
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.webp"),url("/media/backgrounds/page-title.webp")',
|
||||
};
|
||||
return h('div', {},
|
||||
h('section', {"className": "page-title-section overlay", "style": divStyle},
|
||||
@ -448,22 +517,16 @@
|
||||
);
|
||||
};
|
||||
|
||||
CMS.registerPreviewTemplate("impressum", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("datenschutz", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("schuelerrat-geschaeftsordnung", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("schuelervertretung-index", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("elternvertretung-index", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("jia-index", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("bibo", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("abiturienten", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("cantorfora", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("contact-index", PostPreviewContent);
|
||||
CMS.registerPreviewTemplate("pages", PostPreviewContent);
|
||||
|
||||
</script>
|
||||
<script>
|
||||
var AnmeldungPreviewContent = ({widgetsFor, widgetFor, entry}) => {
|
||||
const divStyle = {
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.png"),url("/media/backgrounds/page-title.png")',
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.webp"),url("/media/backgrounds/page-title.webp")',
|
||||
};
|
||||
return h('div', {},
|
||||
h('section', {"className": "page-title-section overlay", "style": divStyle},
|
||||
@ -513,7 +576,7 @@
|
||||
<script>
|
||||
var EventPreview = ({widgetsFor, entry}) => {
|
||||
const divStyle = {
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.png"),url("/media/backgrounds/page-title.png")',
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.webp"),url("/media/backgrounds/page-title.webp")',
|
||||
};
|
||||
return h('div', {},
|
||||
h('section', {"className": "page-title-section overlay", "style": divStyle},
|
||||
@ -541,11 +604,10 @@
|
||||
h('div', {"className": "col-12 "},
|
||||
h('ul', {"className": "list-unstyled"},
|
||||
widgetsFor('events').map(function(event, index) {
|
||||
console.log(event.data.date);
|
||||
return h('li', {"className": "d-md-table mb-4 w-100 border-bottom hover-shadow"},
|
||||
h('div', {"className": "d-md-table-cell text-center p-4 bg-primary text-white mb-4 mb-md-0 termin-tc"},
|
||||
h('span', {"className": "h2 d-block"}, new Intl.DateTimeFormat('de-De', { day: 'numeric'}).format(new Date(event.data.date))),
|
||||
new Intl.DateTimeFormat('de-De', { month: 'short', year: 'numeric' }).format(new Date(event.data.date))
|
||||
h('div', {"className": "d-md-table-cell text-center p-4 bg-primary text-white mb-4 mb-md-0 termin-tc"}, event.data.date != null && event.data.date != "" ?
|
||||
h('span', {"className": "h2 d-block"}, new Intl.DateTimeFormat('de-De', { day: 'numeric'}).format(new Date(event.data.date))) : "",
|
||||
event.data.date != null && event.data.date != "" ? Intl.DateTimeFormat('de-De', { month: 'short', year: 'numeric' }).format(new Date(event.data.date)) : ""
|
||||
),
|
||||
h('div', {"className": "d-md-table-cell px-4 vertical-alighn-middle mb-4 mb-md-0"},
|
||||
h('p', {"className": "h4 mb-3 d-block"}, event.data.title),
|
||||
@ -571,7 +633,7 @@
|
||||
<script>
|
||||
var PagePreview = ({widgetFor, entry}) => {
|
||||
const divStyle = {
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.png"),url("/media/backgrounds/page-title.png")',
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.webp"),url("/media/backgrounds/page-title.webp")',
|
||||
};
|
||||
return h('div', {},
|
||||
h('section', {"className": "page-title-section overlay", "style": divStyle},
|
||||
@ -625,7 +687,7 @@
|
||||
}, [image]);
|
||||
|
||||
const divStyle = {
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.png"),url("/media/backgrounds/page-title.png")',
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.webp"),url("/media/backgrounds/page-title.webp")',
|
||||
};
|
||||
return h('div', {},
|
||||
h('section', {"className": "page-title-section overlay", "style": divStyle},
|
||||
@ -658,8 +720,81 @@
|
||||
)
|
||||
);
|
||||
};
|
||||
CMS.registerPreviewTemplate("about-index", PagePreviewImage);
|
||||
CMS.registerPreviewTemplate("blog", PagePreviewImage);
|
||||
</script>
|
||||
<script>
|
||||
var AboutPreview = ({ widgetFor, widgetsFor, getAsset, entry}) => {
|
||||
const [imageUrl, setImageUrl] = useState('');
|
||||
const image = useMemo(() => entry.data.image, [entry.data.image]);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
|
||||
const loadImage = async () => {
|
||||
const imageAsset = await getAsset(image);
|
||||
if (alive) {
|
||||
setImageUrl(imageAsset.toString());
|
||||
}
|
||||
};
|
||||
|
||||
loadImage();
|
||||
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [image]);
|
||||
|
||||
const divStyle = {
|
||||
backgroundImage: 'url("/media/backgrounds/page-title.webp"),url("/media/backgrounds/page-title.webp")',
|
||||
};
|
||||
return h('div', {},
|
||||
h('section', {"className": "page-title-section overlay", "style": divStyle},
|
||||
h('div', {"className": "row"},
|
||||
h('div', {"className": "container"},
|
||||
h('div', {"className": "col-md-8"},
|
||||
h('ul', {"className": "list-inline custom-breadcrumb"},
|
||||
h('li', {"className": "list-inline-item h2"},
|
||||
h('a', {"className": "text-primary font-secondary", href: ""}, "Startseite")
|
||||
),
|
||||
h('li', {"className": "list-inline-item h2"},
|
||||
h("i", {"className": "fa-solid fa-angle-right text-white"})
|
||||
),
|
||||
h('li', {"className": "list-inline-item text-white h2 font-secondary"}, entry.data.title
|
||||
)
|
||||
),
|
||||
h('p', {"className": "text-lighten"}, entry.data.description
|
||||
))
|
||||
)
|
||||
)
|
||||
),
|
||||
h('section', {"className": "section-sm"},
|
||||
h('div', {"className": "container"},
|
||||
h('div', {"className": "row"},
|
||||
h('div', {"className": "col-12 mb-4"},
|
||||
h('img', {"className": "img-fluid w-100 mb-4", src: imageUrl}),
|
||||
widgetFor('body'))
|
||||
)
|
||||
)
|
||||
),
|
||||
entry.data.stats.enable ? h(
|
||||
'section',
|
||||
{"className": "section-sm bg-primary"},
|
||||
h('div', {"className": "container"},
|
||||
h('div', {"className": "row"},
|
||||
widgetsFor('stats').data.zahlen.map(element => {
|
||||
return h('div', {"className": "col-md-3 col-sm-6 mb-4 mb-md-0"},
|
||||
h('div', {"className": "text-center"},
|
||||
h('h2', {"className": "count text-white"}, element.count),
|
||||
h('h5', {"className": "text-white"}, element.name)
|
||||
)
|
||||
);
|
||||
})
|
||||
)
|
||||
)
|
||||
) : null
|
||||
);
|
||||
};
|
||||
CMS.registerPreviewTemplate("about-index", AboutPreview);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user