36 lines
No EOL
1.1 KiB
PHP
36 lines
No EOL
1.1 KiB
PHP
$hashtag = $this->yellow->system->get("mastodonapiHashtag"); // Filter-Hashtag
|
|
$tag = $this->yellow->system->get("mastodonapiTag"); // Yellow-Tag
|
|
|
|
foreach ($statuses as $status) {
|
|
// Nur Posts mit dem gewünschten Hashtag importieren
|
|
if (!empty($hashtag) && stripos($status["content"], "#$hashtag") === false) {
|
|
continue;
|
|
}
|
|
|
|
$content = strip_tags($status["content"]);
|
|
$createdAt = $status["created_at"];
|
|
$title = mb_substr(preg_replace("/\\s+/", " ", $content), 0, 50);
|
|
$slug = strtolower(preg_replace("/[^a-z0-9]+/", "-", $title));
|
|
$datePrefix = date("Y-m-d", strtotime($createdAt));
|
|
$fileName = "$datePrefix-$slug.md";
|
|
$path = $this->yellow->system->get("coreServerDocument") . $folder . $fileName;
|
|
|
|
if (file_exists($path)) continue;
|
|
|
|
$markdown = <<<MARKDOWN
|
|
---
|
|
Title: $title
|
|
TitleSlug: $slug
|
|
Published: $createdAt
|
|
Author: $author
|
|
Layout: blog
|
|
Tag: $tag
|
|
---
|
|
> "$content"
|
|
> — [@{$status["account"]["acct"]}]({$status["account"]["url"]})
|
|
MARKDOWN;
|
|
|
|
if (file_put_contents($path, $markdown) !== false) {
|
|
$postsCreated++;
|
|
}
|
|
} |