Air-Quality-Web/logic/Actions/Changelog.php

45 lines
981 B
PHP
Raw Permalink Normal View History

2019-01-26 21:46:33 +00:00
<?php
namespace AirQuality\Actions;
use \SBRL\TomlConfig;
class Changelog implements IAction {
/** @var TomlConfig */
private $settings;
2019-06-20 23:02:26 +00:00
/** @var \SBRL\PerformanceCounter */
private $perfcounter;
2019-01-26 21:46:33 +00:00
/** @var \ParsedownExtra */
private $parsedown_ext;
public function __construct(
TomlConfig $in_settings,
2019-06-20 23:02:26 +00:00
\ParsedownExtra $in_parsedown_ext,
\SBRL\PerformanceCounter $in_perfcounter) {
2019-01-26 21:46:33 +00:00
$this->settings = $in_settings;
$this->parsedown_ext = $in_parsedown_ext;
2019-06-20 23:02:26 +00:00
$this->perfcounter = $in_perfcounter;
2019-01-26 21:46:33 +00:00
}
public function handle() : bool {
global $start_time;
// 1: Parse markdown
2019-06-20 23:02:26 +00:00
$this->perfcounter->start("parse");
2019-01-26 21:46:33 +00:00
$result = $this->parsedown_ext->text(file_get_contents(ROOT_DIR."Changelog.md"));
2019-06-20 23:02:26 +00:00
$this->perfcounter->end("parse");
2019-01-26 21:46:33 +00:00
// 2: Send response
header("content-length: " . strlen($result));
header("content-type: text/html");
2019-06-20 23:02:26 +00:00
header("x-time-taken: " . $this->perfcounter->render());
2019-01-26 21:46:33 +00:00
echo($result);
return true;
}
}