<?php
    include("config.php");
    include("classes/Markdown.php");
    include("classes/Post.php");
    include("classes/Comment.php");

    $postUrl = htmlspecialchars(strip_tags($_GET["url"], ENT_QUOTES));
    $Parsedown = new Parsedown();
    
    // check if posturl exists
    if(!$postUrl) {
        exit("That post does not exist.");
    }

    $post = new Post($con, $postUrl);

    $postUrl = $post->getPostUrl();
    $postAuthor = $post->getPostAuthor();
    $postPublishedDate = $post->getPublishedDate();
    //$postContent = $Parsedown->text($post->getPostContent());
    $postContent = $post->getPostContent();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Win on Win's Feed: "<?php echo $postContent ?>"</title>
    
    <meta name="title" content="Win @<?php echo $postAuthor . " · " . $postPublishedDate ?>">
    <meta name="description" content="<?php echo $postContent; ?>">
    <meta name="theme-color" content="#22b14c">

    <!-- Open Graph / Facebook -->
    <meta property="og:type" content="website">
    <meta property="og:site_name" content="Win's Personal Feed">
    <meta property="og:url" content="https://posts.winsdominoes.net/status.php?url=<?php echo $postUrl ?>">
    <meta property="og:title" content="Win (@<?php echo $postAuthor . ") · " . $postPublishedDate ?>">
    <meta property="og:description" content="<?php echo $postContent; ?>">

    <!-- Twitter -->
    <meta property="twitter:card" content="summary_large_image">
    <meta property="twitter:url" content="https://posts.winsdominoes.net/status.php?url=<?php echo $postUrl ?>">
    <meta property="twitter:title" content="Win @<?php echo $postAuthor . " · " . $postPublishedDate ?>">
    <meta property="twitter:description" content="<?php echo $postContent; ?>">

    <!-- bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

    <!-- my custom css files-->
    <link rel="stylesheet" href="assets/css/style.css">

    <!-- twitter css and js -->
    <link rel="stylesheet" href="assets/css/twitter.css">
    <script src="assets/js/twitter.js"></script>
</head>

<body>
    <header>
            <div class="container header">
                <br>
                <a href="index.php"><h1><u>Win's Personal Posts</u></h1></a>

                <hr>
            </div>
            
    </header>
