Skip to content

Commit 3e11916

Browse files
committed
Show author footer on documents and packets
1 parent cf9620c commit 3e11916

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

src/static/a/main.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ main > article > footer {
184184
min-height: 20px;
185185
padding: 10px;
186186
}
187+
article > footer img.avatar {
188+
border-radius: 3px;
189+
float: left;
190+
max-height: 22px;
191+
max-width: 22px;
192+
margin: 0px 8px 0px 0px;
193+
}
187194
main > p.pagination {
188195
text-align: center;
189196
margin-left: 232px;

src/static/a/news.css

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,3 @@ article > section > img.category {
1717
padding: 8px 0px;
1818
vertical-align: top;
1919
}
20-
article > footer img.avatar {
21-
border-radius: 3px;
22-
float: left;
23-
max-height: 22px;
24-
max-width: 22px;
25-
margin: 0px 8px 0px 0px;
26-
}

src/templates/Document/View.phtml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ $this->opengraph->attach(new Pair("type", "article"));
1616

1717
$url = Common::relativeUrlToAbsolute("/document/" . urlencode($object_id));
1818
if ($object) {
19+
1920
$url .= "/" . Common::sanitizeForUrl($object->getTitle(), true);
2021
$this->opengraph->attach(new Pair("url", "/document/" . urlencode($object_id)
2122
. "/" . Common::sanitizeForUrl($object->getTitle(), true)));
22-
$title = htmlspecialchars($object->getTitle(), ENT_HTML5, "UTF-8");
23+
24+
$title = htmlspecialchars($object->getTitle(), ENT_HTML5, "UTF-8");
2325
$description = Common::stripUpTo(trim(filter_var(
2426
$object->getContent(true), FILTER_SANITIZE_STRING
2527
)), "\n", 300);
28+
29+
$user_name = $object->getUser()->getName();
30+
$user_id = $object->getUserId();
31+
$user_url = Common::relativeUrlToAbsolute("/user/" . $user_id . "/" . Common::sanitizeForUrl($user_name, true));
32+
$user_avatar = "https:" . (new Gravatar($object->getUser()->getEmail()))->getUrl(22, "identicon");
33+
2634
} else {
2735
$this->opengraph->attach(new Pair("url", "/document/" . urlencode($object_id)));
2836
}
@@ -40,6 +48,14 @@ require("./header.inc.phtml");
4048
<section>
4149
<?php echo $object->getContent(true); ?>
4250
</section>
51+
<footer>
52+
<span class="float-left"><a href="<?php echo $user_url; ?>"><img class="avatar" src="<?php echo $user_avatar; ?>"/> <?php echo htmlspecialchars($user_name, ENT_HTML5, "UTF-8"); ?></a></span>
53+
<?php if ($object->getEditedDateTime() !== null) { ?>
54+
<span class="float-right"><?php echo $object->getCreatedDateTime()->format("l, F j, Y"); ?> | Edited: <?php echo $object->getEditedDateTime()->format("l, F j, Y"); ?></span>
55+
<?php } else { ?>
56+
<span class="float-right"><?php echo $object->getCreatedDateTime()->format("l, F j, Y"); ?></span>
57+
<?php } ?>
58+
</footer>
4359
</article>
4460
<article>
4561
<header>Comments</header>

src/templates/Packet/View.phtml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,26 @@ if ($object) {
2121
. "/" . Common::sanitizeForUrl($object->getPacketName(), true)));
2222

2323
$packet_id = $object->getPacketId(true);
24+
2425
$title = htmlspecialchars($object->getPacketDirectionTag(), ENT_HTML5, "UTF-8")
2526
. " " . $packet_id . " "
2627
. htmlspecialchars($object->getPacketName(), ENT_HTML5, "UTF-8");
2728
$description = Common::stripUpTo(trim(filter_var(
2829
$object->getPacketRemarks(true), FILTER_SANITIZE_STRING
2930
)), "\n", 300);
31+
32+
if ($object->getUserId() !== null) {
33+
$user_name = $object->getUser()->getName();
34+
$user_id = $object->getUserId();
35+
$user_url = Common::relativeUrlToAbsolute("/user/" . $user_id . "/" . Common::sanitizeForUrl($user_name, true));
36+
$user_avatar = "https:" . (new Gravatar($object->getUser()->getEmail()))->getUrl(22, "identicon");
37+
} else {
38+
$user_name = null;
39+
$user_id = null;
40+
$user_url = null;
41+
$user_avatar = null;
42+
}
43+
3044
} else {
3145
$this->opengraph->attach(new Pair("url", "/packet/" . urlencode($object_id)));
3246
}
@@ -65,6 +79,14 @@ require("./header.inc.phtml");
6579
<section>
6680
<?php echo $object->getPacketRemarks(true); ?>
6781
</section>
82+
<footer>
83+
<span class="float-left"><a href="<?php echo $user_url; ?>"><img class="avatar" src="<?php echo $user_avatar; ?>"/> <?php echo htmlspecialchars($user_name, ENT_HTML5, "UTF-8"); ?></a></span>
84+
<?php if ($object->getEditedDateTime() !== null) { ?>
85+
<span class="float-right"><?php echo $object->getCreatedDateTime()->format("l, F j, Y"); ?> | Edited: <?php echo $object->getEditedDateTime()->format("l, F j, Y"); ?></span>
86+
<?php } else { ?>
87+
<span class="float-right"><?php echo $object->getCreatedDateTime()->format("l, F j, Y"); ?></span>
88+
<?php } ?>
89+
</footer>
6890
</article>
6991
<article>
7092
<header>Comments</header>

0 commit comments

Comments
 (0)