Skip to content
Permalink
Browse files

Process special timestamp notation in notices

  • Loading branch information...
SeinopSys committed Sep 11, 2019
1 parent 23ae8ac commit ddd4728b0b0ec470c2cf5bc362be9ae6776718f3
Showing with 35 additions and 18 deletions.
  1. +0 −2 app/Controllers/DiscordAuthController.php
  2. +15 −0 app/Models/Notice.php
  3. +1 −1 app/Time.php
  4. +18 −14 assets/scss/theme.scss
  5. +1 −1 templates/layout/_notices.html.twig
@@ -125,8 +125,6 @@ private function _setTarget($params) {
}
public function sync($params) {
Response::fail('The Discord account link got severed, you will need to re-link your account.', ['segway' => true]);
$this->_setTarget($params);
$discordUser = $this->_target->discord_member;
@@ -3,6 +3,7 @@
namespace App\Models;
use ActiveRecord\DateTime;
use App\Time;
/**
* @property string id
@@ -31,4 +32,18 @@ public static function list() {
'conditions' => 'hide_after > now()',
]);
}
public function getMessage(): string {
$message = $this->message_html;
$message = preg_replace_callback('~@ts\(([^)]+)\)~', function($match){
$ts = strtotime($match[1]);
return sprintf(
'<span class="dynt-el">%s</span> (<time datetime="%s">%s</time>)',
Time::format($ts, Time::FORMAT_READABLE),
$match[1],
Time::format($ts, Time::FORMAT_FULL),
);
},$message);
return $message;
}
}
@@ -88,7 +88,7 @@ private static function _from(int $timestamp, $now = null):string {
}
public const
FORMAT_FULL = 'jS F Y, H:i:s T',
FORMAT_FULL = 'l, jS F Y, H:i:s T',
FORMAT_READABLE = 'readable';
/**
@@ -288,22 +288,26 @@
}
#main {
padding-left: $SidebarWidth + $MainMargin;

&:before {
content: "";
display: block;
position: absolute;
top: 0;
left: $SidebarWidth;
$size: 8px;
width: $size;
height: $size;
background: url('/img/sidebar-corner.svg') no-repeat top left;
background-size: $size * 2;
}
}
#above-content {
padding-left: $SidebarWidth
padding-left: $SidebarWidth;

#breadcrumbs {
position: relative;
&:before {
content: "";
display: block;
position: absolute;
$size: 8px;
left: 0;
bottom: -$size;
z-index: 5;
width: $size;
height: $size;
background: url('/img/sidebar-corner.svg') no-repeat top left;
background-size: $size * 2;
}
}
}

header nav ul {
@@ -1,6 +1,6 @@
{# @var site_notices \App\Models\Notice[] #}
{% if site_notices is defined and site_notices is not empty %}
{% for notice in site_notices %}
<div class='notice {{ notice.type }}'>{{ notice.message_html }}</div>
<div class='notice {{ notice.type }}'>{{ notice.message }}</div>
{% endfor %}
{% endif %}

0 comments on commit ddd4728

Please sign in to comment.
You can’t perform that action at this time.