Skip to content

Commit 8a4f3e2

Browse files
committed
refs #106 Changed allow markdown for comments
1 parent 56af2b3 commit 8a4f3e2

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

app/Models/Comment.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,6 @@ public function hasReplies(): bool
8888
return count($this->replies) > 0;
8989
}
9090

91-
/**
92-
* Convert URLs in text to HTML links.
93-
*
94-
* @param string|null $text
95-
*
96-
* @return string
97-
*/
98-
protected function urlFromTextToHtmlUrl(?string $text = null): string
99-
{
100-
return Str::of($text)
101-
->replaceMatches('/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/u', fn ($url) => "<a href='$url[0]' target='_blank'>$url[0]</a> ");
102-
}
103-
10491
/**
10592
* Convert mentioned usernames to HTML links.
10693
*
@@ -112,7 +99,7 @@ protected function mentionedUserToHtmlUrl(?string $text = null): string
11299
{
113100
return Str::of($text)
114101
->replaceMatches('/\@([a-zA-Z0-9_]+)/u', function ($mention) {
115-
$href = route('user.show', $mention[1]); // над наверное заменить на route('profile', $mention[1])
102+
$href = route('profile', $mention[1]);
116103
$name = Str::of($mention[0])->trim();
117104

118105
return "<a href='$href' class='text-decoration-none'>$name</a>";
@@ -140,10 +127,9 @@ public function prettyComment(): string
140127
{
141128
$safe = htmlspecialchars($this->content ?? '', ENT_NOQUOTES, 'UTF-8');
142129

143-
$withLinks = $this->urlFromTextToHtmlUrl($safe);
144-
$withMention = $this->mentionedUserToHtmlUrl($withLinks);
130+
$withMention = $this->mentionedUserToHtmlUrl($safe);
145131

146-
return $this->nl2br($withMention);
132+
return Str::of($this->nl2br($withMention))->inlineMarkdown();
147133
}
148134

149135
/**

public/build/assets/app-5NDRV0iF.css renamed to public/build/assets/app-CNtEabs8.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"src": "public/img/ui/warning.svg"
1313
},
1414
"resources/css/app.scss": {
15-
"file": "assets/app-5NDRV0iF.css",
15+
"file": "assets/app-CNtEabs8.css",
1616
"src": "resources/css/app.scss",
1717
"isEntry": true
1818
},

resources/css/thread.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@
5151
background-color: rgba($gray-700, 0.2);
5252
}
5353

54+
img {
55+
max-width: 100%;
56+
max-height: 300px;
57+
@extend .rounded;
58+
}
59+
5460
/*
5561
.comment-reply {
5662
.comment {

0 commit comments

Comments
 (0)