Fix crashes

pull/1/head
Starbeamrainbowlabs 2021-08-09 22:00:27 +01:00
parent c35d7cbe76
commit a634f32a20
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
5 changed files with 107 additions and 1 deletions

View File

@ -30,6 +30,7 @@ async function filter_asset(src) {
// Determine the file type extension
let type = await filetype.fromBuffer(content);
if(typeof type !== "undefined" && type.ext == "xml") type = undefined;
if(typeof type === "undefined") {
// Failed, try to extract from the URL
let match = src.match(/(?<=\.)[a-zA-Z0-9-_]+$/);

1
src/images/post.svg Normal file
View File

@ -0,0 +1 @@
<svg width="135.47mm" height="135.47mm" version="1.1" viewBox="0 0 135.47 135.47" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="#000"><g stroke-linecap="round" stroke-linejoin="round"><path transform="scale(.26458)" d="m220.57 52.99-90.035 90.033v315.99h250.93v-406.02h-160.9z" stroke-width="18.898" style="paint-order:markers stroke fill"/><g stroke-width="5"><path d="m47.536 42.957c13.773 2.65e-4 -2.2793 2.65e-4 11.493 0"/><path d="m47.536 101.83c13.773 2.7e-4 30.234 2.7e-4 44.006 0"/><path d="m47.536 87.114c13.773 2.7e-4 30.234 2.7e-4 44.006 0"/><path d="m47.536 72.395c13.773 2.7e-4 30.234 2.7e-4 44.006 0"/><path d="m47.536 57.676c13.773 2.7e-4 -2.2793 2.7e-4 11.493 0"/></g></g><g transform="matrix(.72963 0 0 .72963 87.925 20.339)"><rect x="-28.372" y="22.462" width="34.069" height="34.069" stroke-linecap="round" stroke-linejoin="round" stroke-width="5" style="paint-order:markers stroke fill"/><path transform="scale(.26458)" d="m19.053 157.53c-13.715-0.17815-33.624 8.4074-48.934 23.535-6.1454-5.7273-15.671-9.6839-22.512-10.004-21.82-1.0194-45.371 6.3951-54.839 42.601l128.76-5e-4 -1.4433-56.101c-0.0088-0.34119-0.68601-0.0267-1.0352-0.0312z" stroke-width="9.4488"/><circle cx="-18.695" cy="31.576" r="3.416" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" style="paint-order:markers stroke fill"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

103
src/images/post_edit.svg Normal file
View File

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="135.46666mm"
height="135.46666mm"
viewBox="0 0 135.46666 135.46666"
version="1.1"
id="svg5"
inkscape:version="1.1 (1:1.1+202105261518+ce6663b3b7)"
sodipodi:docname="post_edit.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
units="mm"
inkscape:zoom="1.1709775"
inkscape:cx="262.60112"
inkscape:cy="304.01951"
inkscape:window-width="1831"
inkscape:window-height="1047"
inkscape:window-x="89"
inkscape:window-y="33"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
showguides="true"
inkscape:guide-bbox="true">
<sodipodi:guide
position="93.995546,76.83242"
orientation="1,0"
id="guide4134" />
</sodipodi:namedview>
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="rect846"
style="fill:none;fill-opacity:0.554024;stroke:#000000;stroke-width:18.89763804;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
d="M 220.56836 52.990234 L 130.5332 143.02344 L 130.5332 459.00977 L 381.4668 459.00977 L 381.4668 52.990234 L 220.56836 52.990234 z "
transform="scale(0.26458333)" />
<path
style="fill:none;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 47.535618,42.957261 c 13.772554,2.65e-4 -2.279285,2.65e-4 11.492741,0"
id="path1460"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 47.535618,101.83312 c 13.772554,2.7e-4 30.234244,2.7e-4 44.00627,0"
id="path1578"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 47.535618,87.11415 c 13.772554,2.7e-4 30.234244,2.7e-4 44.00627,0"
id="path1580"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 47.535618,72.395185 c 13.772554,2.7e-4 30.234244,2.7e-4 44.00627,0"
id="path1598"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 47.535618,57.676219 c 13.772554,2.7e-4 -2.279285,2.7e-4 11.492741,0"
id="path1600"
sodipodi:nodetypes="cc" />
<g
id="g3995"
transform="matrix(0.72962981,0,0,0.72962981,87.924529,20.339042)">
<rect
style="fill:none;fill-opacity:0.554024;stroke:#000000;stroke-width:4.99999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1624"
width="34.068798"
height="34.068798"
x="-28.37191"
y="22.461601" />
<path
id="path1659"
style="fill:none;stroke:#000000;stroke-width:9.44882;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 19.052734,157.52539 c -13.7148354,-0.17815 -33.624479,8.40738 -48.933593,23.53516 -6.145398,-5.72729 -15.670552,-9.6839 -22.512408,-10.00356 -21.819678,-1.01942 -45.371223,6.3951 -54.839153,42.60121 l 128.763655,-5e-4 -1.443344,-56.10106 c -0.0088,-0.34119 -0.686012,-0.0267 -1.035157,-0.0312 z"
transform="scale(0.26458333)"
sodipodi:nodetypes="ccsccscc" />
<circle
style="fill:none;fill-opacity:0.554024;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
id="path3910"
cx="-18.694792"
cy="31.576357"
r="3.4159789" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -63,6 +63,7 @@ module.exports = async function() {
if(temp_image !== null)
item.media_image = temp_image[1];
}
item.media_image_notfound = item.media_image == `./images/post.svg`;
console.log(`MEDIA IMAGE`, item.media_image);
return item;

View File

@ -4,7 +4,7 @@
{% for post in pagination.items %}
<article class="post">
<h2><a href="{{ post.link }}">{{ post.title | striphtml }}</a></h2>
<div class="post-image" style="background: url({% asset post.media_image %});"></div>
<div class="post-image {% if post.media_image_notfound %}invert-when-dark{% endif %}" style="background: url({% asset post.media_image %}); {% if post.media_image_notfound %}background-size: contain !important;{% endif %}"></div>
<div class="post-extract">
{{ post.description | striphtml }}…
<div><a href="{{ post.link }}">Read more</a></div>