Skip to content

Commit c49740a

Browse files
committed
Added paste details
1 parent 64ec0aa commit c49740a

File tree

5 files changed

+88
-19
lines changed

5 files changed

+88
-19
lines changed

public/css/main.css

+27-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/main.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/main.scss

+39-6
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,45 @@ form {
120120
}
121121

122122
#paste {
123-
h1 {
124-
margin-left: 4vw;
125-
margin-bottom: 0;
126-
font-size: 25px;
127-
margin-top: 8px;
123+
margin-left: 4vw;
124+
125+
#header {
126+
127+
img {
128+
width: 40px;
129+
height: 40px;
130+
margin-right: 10px;
131+
display: inline-block;
132+
}
133+
134+
#data {
135+
display: inline-block;
136+
height: 40px;
137+
138+
h1 {
139+
margin-bottom: 0;
140+
font-size: 18px;
141+
}
142+
143+
#row {
144+
@extend .flex;
145+
}
146+
147+
p {
148+
margin-top: 5px;
149+
}
150+
151+
#username::before {
152+
@extend .icon;
153+
content: '\f007';
154+
}
155+
156+
#date::before {
157+
@extend .icon;
158+
content: '\f073';
159+
margin-left: 10px;
160+
}
161+
}
128162
}
129163

130164
ol {
@@ -133,7 +167,6 @@ form {
133167
color: #666666;
134168
margin-top: 8px;
135169
border: 1px solid #AAA;
136-
margin-left: 4vw;
137170

138171
li {
139172
border-left: 1px solid #AAA;

src/Controller/RootController.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
use App\Entity\Paste;
66
use App\Form\PasteType;
7+
use App\Repository\UserRepository;
78
use App\Service\RecaptchaService;
89
use App\Utils\Utils;
910
use DateTime;
11+
use Doctrine\ORM\EntityManagerInterface;
1012
use Psr\Log\LoggerInterface;
1113
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1214
use Symfony\Component\Form\FormError;
@@ -61,11 +63,10 @@ public function root(Request $request, RecaptchaService $recaptchaService) {
6163
]);
6264
}
6365

64-
6566
/**
6667
* @Route("/view/{name}", name="app_paste")
6768
*/
68-
public function paste(string $name) {
69+
public function paste(string $name, UserRepository $userRepository) {
6970
$paste = $this->getDoctrine()->getRepository(Paste::class)->findOneByName($name);
7071
if ($paste == null) {
7172
return $this->render('paste.html.twig', [
@@ -75,7 +76,8 @@ public function paste(string $name) {
7576

7677
return $this->render('paste.html.twig', [
7778
'content' => explode('[new-line]', base64_decode($paste->getContent())),
78-
'paste' => $paste
79+
'paste' => $paste,
80+
'username' => $paste->getOwner() != null ? $userRepository->findOneBy(['id' => $paste->getOwner()])->getUsername() : 'Guest'
7981
]);
8082
}
8183
}

templates/paste.html.twig

+16-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@
88
<h1>Paste not found</h1>
99
{% else %}
1010
<div id="paste">
11-
{% if paste.title != null %}
12-
<h1>{{ paste.title }}</h1>
13-
{% endif %}
11+
<div id="header">
12+
<img src="{{ asset('images/guest.png') }}" alt=""/> <!-- TODO: User avatars -->
13+
<div id="data">
14+
<h1>
15+
{% if paste.title != null %}
16+
{{ paste.title }}
17+
{% else %}
18+
Untitled
19+
{% endif %}
20+
</h1>
21+
<div id="row">
22+
<p id="username">{{ username }}</p>
23+
<p id="date">{{ paste.uploadDate.format('d M Y G:i') }}</p>
24+
</div>
25+
</div>
26+
</div>
1427
<ol>
1528
{% for line in content %}
1629
<li>{{ line }}</li>

0 commit comments

Comments
 (0)