My personal blog. https://blog.airikr.me
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

76 lines
2.0 KiB

<?php
require_once 'site-settings.php';
header('Content-Type: application/json;charset=utf-8');
$get_posts = sql("SELECT *
FROM posts
WHERE is_inenglish ".($viewing_in_english == false ? "IS" : "IS NOT")." NULL
ORDER BY timestamp_published DESC
", Array());
$arr_posts = [];
$arr_tags = [];
foreach($get_posts AS $post) {
$get_tags = sql("SELECT t.name
FROM tags AS t
JOIN tags_linked AS tl
ON t.id = tl.id_tag
WHERE tl.id_post = :_idpost
", Array(
'_idpost' => (int)$post['id']
));
foreach($get_tags AS $tag) {
$arr_tags[] = $tag['name'];
}
$string = [
'id' => (int)$post['id'],
'url' => $og_url.'/read:'.$post['id_unique'],
'title' => $post['subject'],
'image' => $og_url.'/cover:'.$post['cover_hash'],
'banner_image' => $og_url.'/cover:'.$post['cover_hash'],
'summary' => $Parsedown->text($post['content_beforebreak']),
'content_html' => $Parsedown->text($post['content_beforebreak']) . ($post['content_afterbreak'] == null ? '' : $Parsedown->text($post['content_afterbreak'])),
'content_text' => null,
'tags' => (empty($arr_tags) ? null : $arr_tags),
'date_published' => date('Y-m-d\TH:i:s', $post['timestamp_published']),
'date_modified' => date('Y-m-d\TH:i:s', $post['timestamp_edited']),
'author' => [
'name' => $config_author_name,
'url' => $og_url,
'avatar' => $og_image
]
];
$arr_posts[] = $string;
}
$json = [
'version' => 'https://jsonfeed.org/version/1',
'title' => $og_title,
'icon' => $og_image,
'home_page_url' => $og_url,
'feed_url' => $og_url.'/rss.json',
'description' => $og_description,
'user_comment' => ($viewing_in_english == false ? '' : ''),
'expired' => false,
'author' => [
'name' => 'Erik Edgren',
'url' => $og_url,
'avatar' => $og_image
],
'items' => $arr_posts
];
# echo json_encode($json);
file_put_contents('rss'.($viewing_in_english == false ? '' : '-en').'.json', json_encode($json));
?>