Build initial index page

This commit is contained in:
Starbeamrainbowlabs 2018-03-07 22:40:54 +00:00
parent b8b8b1af18
commit 5b7341c905
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
7 changed files with 122 additions and 17 deletions

40
Actions/Index.php Normal file
View File

@ -0,0 +1,40 @@
<?php
namespace Sandpiper\Actions;
use \Yosymfony\Toml\Toml;
use \SBRL\Utilities\SimpleXmlWriter;
class index extends \Sandpiper\AbstractAction
{
public function __construct()
{
}
public function handle() {
global $settings;
$writer = new SimpleXmlWriter();
$writer->add_xslt("/theme/project-list.xslt");
$writer->open("index");
$writer->addtag("data_dir", [], $settings->get("data_dir"));
$writer->open("places");
foreach($settings->get("places") as $next_place) {
$writer->open("place");
$writer->addtag("name", [], $next_place["name"]);
$writer->addtag("dirname", [], slugify($next_place["name"]));
$writer->close();
}
$writer->closeall();
header("content-type: application/xml");
header("content-length: " . strlen($writer->render()));
header("etag: " . sha1($writer->render()));
exit($writer->render());
}
}

View File

@ -59,7 +59,7 @@ class Report extends \Sandpiper\AbstractAction
if(!file_exists($report_filename)) {
$writer = new \SBRL\Utilities\SimpleXmlWriter(); // It's started automagically
$writer->prettyprint = true;
$writer->add_xslt("/theme/stack_traces.xslt");
$writer->add_xslt("/theme/stack-traces.xslt");
$writer->open("error_info");
$writer->addtag("project_name", [], $place["name"]); // For aesthetic purposes
$writer->addtag("summary", [], $new_report->summary);
@ -97,7 +97,7 @@ class Report extends \Sandpiper\AbstractAction
$writer = new SimpleXmlWriter();
$writer->prettyprint = true;
$writer->add_xslt("/theme/error_index.xslt");
$writer->add_xslt("/theme/error-index.xslt");
$writer->open("errors_index");
$writer->addtag("project_name", [], $place["name"]);
$writer->open("error_list");

View File

@ -21,12 +21,12 @@ function send_error($code, $message) {
header("content-type: text/plain");
exit("$message\n");
}
if(empty($_GET["action"]))
send_error(400, "No action specified.");
$action = $_GET["action"];
$action = $_GET["action"] ?? "Index";
$handler_name = "Sandpiper\\Actions\\$action";
if(!class_exists($handler_name))
send_error(404, "Unknown action $handler_name.");
$handler = new $handler_name();
$handler->handle();

View File

@ -12,8 +12,11 @@
</head>
<body>
<h1>Sandpiper - <xsl:value-of select="/errors_index/project_name" /></h1>
<div class="project-list">
<div class="project-list-header">
<a class="back-button-main" href="../../../">« Back</a>
<div class="error-list">
<div class="error-list-header">
<span>Error</span>
<span>Last Updated</span>
<span>Reports</span>

View File

@ -39,7 +39,38 @@ pre {
/*****************************************************************************/
.project-list
.back-button-main {
grid-column-start: side-right;
grid-row-start: header;
justify-self: center;
align-self: center;
}
/*****************************************************************************/
.project-list {
grid-column-start: main;
grid-row-start: main;
justify-self: center;
}
.project-list > a {
display: inline-block;
margin: 1em;
padding: 1em 2em;
background: hsl(202, 76%, 50%);
color: inherit;
font-size: 2em;
text-decoration: none;
}
/*****************************************************************************/
.error-list
{
grid-column-start: main;
grid-row-start: main;
@ -52,7 +83,7 @@ pre {
background: hsla(22, 76%, 50%, 0.68);
}
.project-list-header > span {
.error-list-header > span {
display: table-cell;
margin: 0.25em 0;
@ -61,26 +92,26 @@ pre {
font-weight: bold;
}
.project-list > a, .project-list > div {
.error-list > a, .error-list > div {
display: table-row;
}
.project-list > a {
.error-list > a {
color: inherit;
text-decoration: none;
}
.project-list > a > span {
.error-list > a > span {
display: table-cell;
padding: 0.5em 0;
}
.project-list .summary {
.error-list .summary {
width: auto;
}
.project-list .last-updated {
.error-list .last-updated {
width: 10%;
}
.project-list .reports-count {
.error-list .reports-count {
width: 3em;
text-align: center;

29
theme/project-list.xslt Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" indent="yes" />
<xsl:template match="/">
<!-- <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text> -->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sandpiper</title>
<link rel="stylesheet" href="/theme/main.css" />
</head>
<body>
<h1>Sandpiper</h1>
<div class="project-list">
<xsl:for-each select="/index/places/place">
<a>
<xsl:attribute name="href"><xsl:value-of select="/index/data_dir" />/places/<xsl:value-of select="dirname" />/index.xml</xsl:attribute>
<xsl:value-of select="name" />
</a>
</xsl:for-each>
</div>
</body>
</html>
</xsl:template>
</xsl:transform>

View File

@ -19,6 +19,8 @@
<h2><xsl:value-of select="/error_info/summary" /></h2>
<h1>Sandpiper - <xsl:value-of select="/error_info/project_name" /></h1>
<a class="back-button-main" href="index.xml">« Back</a>
<div class="report-list">
<xsl:for-each select="/error_info/reports/report">