Commit 9693bdeb authored by Markus Willman's avatar Markus Willman

finish special handling for devhub.log

parent ae22fd6b
......@@ -47,29 +47,28 @@ class LogHandler extends AbstractHandler
{
// This has to reference a path within DCBASE_ROOT_PATH
$file = new SplFileInfo(DCLOG_DEVHUB_FILE);
if ($file->isFile() && $file->isReadable())
return static::serveLogFile($request, $file, '@extension/devhub_log.html.twig', new DCLogParser(), $file->isLink());
}
// skip directories and non-existent files
if (!$file->isFile() || !$file->isReadable())
return false;
$response = false;
return static::serveLogFile($request, $file, '@extension/dclog_view.html.twig', new DCLogParser());
}
protected static function serveLogFile(WebRequest $request, SplFileInfo $file, string $template_name, ParserInterface $parser, bool $allow_links = false)
{
try
{
$response = static::serveLogFile($request, $file, '@extension/dclog_view.html.twig', new DCLogParser());
$target_file_path = ResponseHelper::getTemplateName($request, $file, $allow_links);
}
catch (Exception $e)
{
$response = WebResponse::error($request, 403);
return WebResponse::error($request, 403);
}
return $response;
}
protected static function serveLogFile(WebRequest $request, SplFileInfo $file, $template_name, ParserInterface $parser)
{
$target_file_path = ResponseHelper::getTemplateName($request, $file);
if ($request->variable('download', false) !== false)
return WebResponse::file($request, $file, true);
......
......@@ -10,14 +10,20 @@
{% import '@template/macros.twig' as util %}
{% set git_info = git_info(log_file) %}
{% set template_file = log_file %} {# We replace the template_file global because this file is a wrapper #}
{% set container_class = 'container full' %}
{% set page_subtitle = 'Log file: ' ~ log_file %}
{% set hide_menu = true %}
{% set source_view = false %}
{% if git_info is not defined %}
{% set git_info = git_info(log_file) %}
{% endif %}
{% if page_subtitle is not defined %}
{% set page_subtitle = 'Log file: ' ~ log_file %}
{% endif %}
{% block styles -%}
{{ parent() }}
......@@ -54,7 +60,7 @@
{% endblock %}
{% block content -%}
<h4 class="float-left d-print-none">Log file: {{ log_file }}</h4>
<h4 class="float-left d-print-none">{{ page_subtitle }}</h4>
<div class="text-right d-print-none">
<a class="btn btn-primary" role="button" href="{{ util.sanitize_url(page_url, 'source=raw') }}">
<i class="fas fa-file-alt" aria-hidden="true"></i> Raw Log
......
{#
*
* @package dcbase
* @copyright (c) 2019 Direct Connect Network Foundation / www.dcbase.org
* @license https://www.dcbase.org/DCBase/LICENSE GNU General Public License v2
*
#}
{% extends '@extension/dclog_view.html.twig' %}
{% import '@template/macros.twig' as util %}
{% set git_info = false %}
{% set page_subtitle = 'Development Hub Chat' %}
{% block scripts -%}
{{ parent() }}
<script>
$(function () {
var chat = $('.dclog');
chat.scrollTop(chat.get(0).scrollHeight);
});
</script>
{% endblock %}
{% block content -%}
{{ parent() }}
<div class="alert alert-warning fade show d-print-none" role="alert">
<i class="fas fa-info-circle fa-lg" title="Info:"></i> Note that DCNF is not responsible for comments made by individuals that freely visit the organization hub. <strong>This page is an automated verbatim copy of recent chat activity, always use discretion when following any links on this page.</strong>
</div>
{% endblock %}
......@@ -35,9 +35,9 @@ class ResponseHelper
/// private final constructor so no instances can be created
final private function __construct() { }
public static function getTemplateName(WebRequest $request, SplFileInfo $file, $allow_links = false)
public static function getTemplateName(WebRequest $request, SplFileInfo $file, bool $allow_links = false)
{
$real_path = (!$allow_links) ? $file->getRealPath() : $file->getPathname();
$real_path = ($allow_links === false) ? $file->getRealPath() : $file->getPathname();
if (str::strpos($real_path, $request->getContentRoot()) === 0)
return str::substr($real_path, str::strlen($request->getContentRoot()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment