<?php

$file_str = file_get_contents("fsad.json");
$j = json_decode($file_str, true);
$cur_date = date('m/d');
$data = NULL;
foreach( $j as $v) {
  if ($v["Date"] == $cur_date) {
    $data = $v;
    break;
  }
}
if (!$data) {
  die("Unable to find date data");
}

?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Folk Song A Day</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
      body{width:90%;max-width:800px;background:#222;color:#bbb;font-family:monospace;font-size:1.1rem}
      :any-link{color:goldenrod}
      footer{font-size:0.8em;padding-top:2em;margin-top:2em;border-top:2px dashed goldenrod}
      header{margin-bottom:3em;color:gold}
      main{border-left:4px solid goldenrod;padding-left:1em}
      main h2{color:orange}
    </style>
  </head>
  <body>
    <header>
      <h1>A Folk Song a Day</h1>
    </header>
    <main>
      <h2><?php echo $data["Title"]; ?></h2>
      <audio controls><source src="<?php echo $data["AudioUrl"]; ?>"></audio>
      <p>Date: <strong><?php echo $data["Date"]; ?></strong></p>
      <?php echo html_entity_decode($data["Text"]); ?>
    </main>
    <footer>
      <p>This page is generated from data found on the <a href="https://www.afolksongaday.com" target="_blank">&ldquo;A Folk Song a Day&rdquo;</a> blog/podcast/website. I did not create any of it and make no claim of ownership or creation. I am simply providing a view into their data (the audio still comes from their website). I created this page because I found their website cumbersome. I wanted to hear a song per day and just have it automatically be here and not have to dig for it.</p>
    </footer>
  </body>
</html>
