Skip to content

Commit 6e5a105

Browse files
build version 2.0.0-alpha.16
1 parent df37aaf commit 6e5a105

File tree

21 files changed

+118
-78
lines changed

21 files changed

+118
-78
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0-alpha.15
1+
2.0.0-alpha.16

automad/dist/admin/main.bundle.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/admin/main.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/blocks/main.bundle.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/blocks/main.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/inpage/main.bundle.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/inpage/main.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/mail/main.bundle.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/mail/main.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/prism/main.bundle.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/dist/prism/main.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

automad/src/server/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
* @license MIT license - https://automad.org/license
5757
*/
5858
class App {
59-
const VERSION = '2.0.0-alpha.15';
59+
const VERSION = '2.0.0-alpha.16';
6060

6161
/**
6262
* Required PHP version.

automad/src/server/Blocks/Section.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,16 @@ public static function render(array $block, Automad $Automad): string {
131131
}
132132
}
133133

134-
$attr = Attr::render($block['tunes'], $classes, $styles);
134+
$attr = Attr::render($block['tunes']);
135+
$classes = Attr::renderClasses($classes);
136+
$styles = Attr::renderStyles($styles);
135137

136138
return <<< HTML
137-
<am-section $attr>
138-
$html
139-
</am-section>
139+
<section $attr>
140+
<am-section $classes $styles>
141+
$html
142+
</am-section>
143+
</section>
140144
HTML;
141145
}
142146
}

automad/src/server/Blocks/Utils/Attr.php

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,42 @@ public static function render(array $tunes, array $classes = array(), ?array $st
6868
return join(' ', array_filter(array($id, self::classAttr($tunes, $classes), self::styleAttr($tunes, $styles))));
6969
}
7070

71+
/**
72+
* Render a class attribute.
73+
*
74+
* @param array $classes
75+
* @return string
76+
*/
77+
public static function renderClasses(array $classes): string {
78+
if (empty($classes)) {
79+
return '';
80+
}
81+
82+
return 'class="' . join(' ', $classes) . '"';
83+
}
84+
85+
/**
86+
* Render a style attribute.
87+
*
88+
* @param array<non-empty-literal-string, string> $styles
89+
* @return string
90+
*/
91+
public static function renderStyles(array $styles): string {
92+
if (empty($styles)) {
93+
return '';
94+
}
95+
96+
$rules = array();
97+
98+
foreach ($styles as $key => $value) {
99+
$value = preg_replace('/[<>]/', '', $value);
100+
$key = strtolower(preg_replace('/([A-Z])/', '-$1', $key));
101+
$rules[] = "$key: $value;";
102+
}
103+
104+
return 'style="' . join(' ', $rules) . '"';
105+
}
106+
71107
/**
72108
* Reset the array on unique IDs.
73109
*/
@@ -89,7 +125,7 @@ private static function classAttr(array $tunes, array $custom = array()): string
89125
$classes[] = preg_replace('/[<>]/', '', $tunes['className']);
90126
}
91127

92-
return 'class="' . join(' ', $classes) . '"';
128+
return self::renderClasses($classes);
93129
}
94130

95131
/**
@@ -122,19 +158,7 @@ private static function getPaddingStylesFromTunes(array $tunes): array {
122158
private static function styleAttr(array $tunes, ?array $styles = null): string {
123159
$styles = array_merge(self::getPaddingStylesFromTunes($tunes), $styles ?? array());
124160

125-
if (empty($styles)) {
126-
return '';
127-
}
128-
129-
$rules = array();
130-
131-
foreach ($styles as $key => $value) {
132-
$value = preg_replace('/[<>]/', '', $value);
133-
$key = strtolower(preg_replace('/([A-Z])/', '-$1', $key));
134-
$rules[] = "$key: $value;";
135-
}
136-
137-
return 'style="' . join(' ', $rules) . '"';
161+
return self::renderStyles($styles);
138162
}
139163

140164
/**

automad/src/server/Engine/Processors/MetaProcessor.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use Automad\Core\Automad;
4141
use Automad\Core\Cache;
4242
use Automad\Core\Debug;
43+
use Automad\Core\FileSystem;
4344
use Automad\Core\I18n;
4445
use Automad\Core\Str;
4546
use Automad\Engine\Document\Head;
@@ -93,13 +94,13 @@ public function addMetaTags(string $html): string {
9394
$base = AM_SERVER . AM_BASE_INDEX;
9495
$content = array_merge(
9596
array(
96-
'title' => $this->Page->get(Fields::TITLE) . ' | ' . $this->Shared->get(Fields::SITENAME),
97+
'title' => Str::stripTags($this->Page->get(Fields::TITLE) . ' | ' . $this->Shared->get(Fields::SITENAME)),
9798
'description' => Str::shorten(Str::stripTags(Str::findFirstParagraph($html)), 150)
9899
),
99100
array_filter(
100101
array(
101-
'title' => $this->Page->get(Fields::META_TITLE),
102-
'description' => $this->Page->get(Fields::META_DESCRIPTION)
102+
'title' => Str::stripTags($this->Page->get(Fields::META_TITLE)),
103+
'description' => Str::stripTags($this->Page->get(Fields::META_DESCRIPTION))
103104
),
104105
'strlen'
105106
)
@@ -114,7 +115,7 @@ public function addMetaTags(string $html): string {
114115
}
115116

116117
$html = $this->addMetaTagOnce('property', 'twitter:card', 'summary_large_image', $html);
117-
$html = $this->addMetaTagOnce('property', 'og:url', $base . $this->Page->url, $html);
118+
$html = $this->addMetaTagOnce('property', 'og:url', $base . AM_REQUEST, $html);
118119
$html = $this->addMetaTagOnce('property', 'og:type', 'website', $html);
119120
$html = $this->addMetaTagOnce('property', 'og:image', $ogImage, $html);
120121
$html = $this->addMetaTagOnce('property', 'og:description', $content['description'], $html);
@@ -125,12 +126,16 @@ public function addMetaTags(string $html): string {
125126
$meta = '<meta name="Generator" content="Automad ' . App::VERSION . '">';
126127
$meta .= '<link rel="canonical" href="' . $base . AM_REQUEST . '">';
127128

129+
if (!preg_match('/\<meta[^>]+charset=/', $html)) {
130+
$meta .= '<meta charset="utf-8">';
131+
}
132+
128133
if (!preg_match('/\<title\>/', $html)) {
129134
$meta .= '<title>' . $content['title'] . '</title>';
130135
}
131136

132137
if (AM_FEED_ENABLED) {
133-
$sitename = $this->Shared->get(Fields::SITENAME);
138+
$sitename = Str::stripTags($this->Shared->get(Fields::SITENAME));
134139
$meta .= '<link rel="alternate" type="application/rss+xml" title="' . $sitename . ' | RSS" href="' . $base . AM_FEED_URL . '">';
135140
}
136141

@@ -311,6 +316,7 @@ private function createOpenGraphImage(): string {
311316
);
312317
}
313318

319+
FileSystem::makeDir(dirname($file));
314320
imagepng($image, $file);
315321

316322
return $url;

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/vendor/composer/installed.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php return array(
22
'root' => array(
33
'name' => 'automad/lib',
4-
'pretty_version' => '2.0.0-alpha.15',
5-
'version' => '2.0.0.0-alpha15',
6-
'reference' => '5a52e1f46c54db96395f6dbe25ff9dd11af7c643',
4+
'pretty_version' => '2.0.0-alpha.16',
5+
'version' => '2.0.0.0-alpha16',
6+
'reference' => '53cab745c3b45291f0c8a3e450543d10a38e9d98',
77
'type' => 'library',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -22,9 +22,9 @@
2222
'dev_requirement' => false,
2323
),
2424
'automad/lib' => array(
25-
'pretty_version' => '2.0.0-alpha.15',
26-
'version' => '2.0.0.0-alpha15',
27-
'reference' => '5a52e1f46c54db96395f6dbe25ff9dd11af7c643',
25+
'pretty_version' => '2.0.0-alpha.16',
26+
'version' => '2.0.0.0-alpha16',
27+
'reference' => '53cab745c3b45291f0c8a3e450543d10a38e9d98',
2828
'type' => 'library',
2929
'install_path' => __DIR__ . '/../../',
3030
'aliases' => array(),
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
<@ set_teaser_variable.php @>
2-
<@ set { :description: @{ metaDescription | def(@{ :teaser | stripTags }) } } @>
3-
<@ Automad/MetaTags {
4-
description: @{ :description },
5-
ogTitle: @{ metaTitle | def('@{ sitename } / @{ title | def ("404") }') },
6-
ogDescription: @{ :description },
7-
ogType: 'website',
8-
ogImage: @{
9-
ogImage |
10-
def('@{ +hero | findFirstImage }') |
11-
def('@{ +main | findFirstImage }') |
12-
def('*.jpg, *.png, *.gif, /shared/*.jpg, /shared/*.png, /shared/*.gif')
13-
}
14-
} @>
1+
<?php if (substr(AM_VERSION, 0, 1) == '1') { ?>
2+
<@ set_teaser_variable.php @>
3+
<@ set { :description: @{ metaDescription | def(@{ :teaser | stripTags }) } } @>
4+
<@ Automad/MetaTags {
5+
description: @{ :description },
6+
ogDescription: @{ :description },
7+
ogType: 'website',
8+
ogTitle: @{ metaTitle | def('@{ sitename } / @{ title | def ("404") }') },
9+
ogImage: @{
10+
ogImage |
11+
def('@{ +hero | findFirstImage }') |
12+
def('@{ +main | findFirstImage }') |
13+
def('*.jpg, *.png, *.gif, /shared/*.jpg, /shared/*.png, /shared/*.gif')
14+
}
15+
} @>
16+
<?php } else { ?>
17+
<@ Automad/MetaTags { ogTitle: false, ogImage: @{ ogImage } } @>
18+
<?php } ?>

packages/automad/standard-v1/templates/post.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
<head>
44
<meta http-equiv="X-UA-Compatible" content="IE=edge">
55
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<title>@{ metaTitle | def('@{ sitename } / @{ title | def ("404") }') }</title>
6+
<?php if (substr(AM_VERSION, 0, 1) == '1') { ?>
7+
<title>@{ metaTitle | def('@{ sitename } / @{ title | def ("404") }') }</title>
8+
<?php } ?>
79
<@ elements/metatags.php @>
810
<@ elements/favicons.php @>
911
<#

vendor/composer/installed.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,24 @@
9898
},
9999
{
100100
"name": "automad/standard-v1",
101-
"version": "1.0.2",
102-
"version_normalized": "1.0.2.0",
101+
"version": "1.0.7",
102+
"version_normalized": "1.0.7.0",
103103
"source": {
104104
"type": "git",
105105
"url": "https://github.com/automadcms/automad-standard-v1.git",
106-
"reference": "27bdfe14556c41f3255c54aaeda4caf40bae1233"
106+
"reference": "2da4e944d487ea68b008242fbd7d260a4cc94f5e"
107107
},
108108
"dist": {
109109
"type": "zip",
110-
"url": "https://api.github.com/repos/automadcms/automad-standard-v1/zipball/27bdfe14556c41f3255c54aaeda4caf40bae1233",
111-
"reference": "27bdfe14556c41f3255c54aaeda4caf40bae1233",
110+
"url": "https://api.github.com/repos/automadcms/automad-standard-v1/zipball/2da4e944d487ea68b008242fbd7d260a4cc94f5e",
111+
"reference": "2da4e944d487ea68b008242fbd7d260a4cc94f5e",
112112
"shasum": ""
113113
},
114114
"require": {
115115
"automad/meta-tags": "^1.1 || dev-master",
116116
"automad/package-installer": "^1.1 || dev-master"
117117
},
118-
"time": "2024-02-19T16:35:21+00:00",
118+
"time": "2024-12-14T10:16:58+00:00",
119119
"type": "automad-package",
120120
"installation-source": "dist",
121121
"notification-url": "https://packagist.org/downloads/",
@@ -138,7 +138,7 @@
138138
],
139139
"support": {
140140
"issues": "https://github.com/automadcms/automad-standard-v1/issues",
141-
"source": "https://github.com/automadcms/automad-standard-v1/tree/1.0.2"
141+
"source": "https://github.com/automadcms/automad-standard-v1/tree/1.0.7"
142142
},
143143
"funding": [
144144
{

0 commit comments

Comments
 (0)