Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Commit 65514a4

Browse files
author
Alexander Wirt
committed
Redesign navbar and improve user handling
- templates/navbar: Restructured the sidebar into clear sections (Paste, User, Pastes, Links). Added a 'Make new paste' action button and a dedicated user profile area with login/logout buttons. - pastebin.css: Added CSS for the new navbar components (.menu-content, .action-btn, .user-content) matching the existing design language. - lib/Paste/Controller/Main.pm: Updated _create to respect the user's chosen name (poster) even when authenticated, persisting it to the session if changed. This allows users to paste with a different name than their GitLab username.
1 parent 3435880 commit 65514a4

File tree

3 files changed

+104
-14
lines changed

3 files changed

+104
-14
lines changed

lib/Paste/Controller/Main.pm

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,28 @@ sub _create {
324324
);
325325
}
326326

327-
my $name = $c->param('poster') || 'anonymous';
327+
my $form_name = $c->param('poster');
328+
my $name;
328329

329330
my $authenticated = $c->current_user ? 1 : 0;
330331
my $session_id;
331332

332333
if ($authenticated) {
333334
# If logged in, use the user's stable session ID
334335
$session_id = sha1_hex( $c->current_user->{id} );
335-
$name = $c->current_user->{name} if $c->current_user->{name};
336+
337+
# Use provided name or fallback to session name
338+
$name = (defined $form_name && length $form_name) ? $form_name : $c->current_user->{name};
339+
340+
# Update session if name changed
341+
if ( defined $form_name && length $form_name && $name ne ($c->current_user->{name} // '') ) {
342+
my $u = $c->session('user');
343+
$u->{name} = $name;
344+
$c->session(user => $u);
345+
}
336346
} else {
337-
# Anonymous paste (no persistent session)
347+
# Anonymous paste
348+
$name = $form_name || 'anonymous';
338349
$session_id = sha1_hex( rand() . time() );
339350
}
340351

pastebin.css

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ h1 {
2929
margin-top: 0px;
3030
}
3131

32-
3332
p {
3433
font:11px/20px verdana, arial, helvetica, sans-serif;
3534
margin:0px 10px 10px 10px;
@@ -106,7 +105,7 @@ code { font-size:12px;}
106105
margin-bottom: 11px;
107106
}
108107

109-
.nav { margin: 0px 5px 0px 5px; }
108+
.nav { margin: 0px 5px 0px 5px; }
110109

111110
li.highlight{ background-color: #ccccff; }
112111

@@ -146,7 +145,7 @@ li {
146145
overflow: hidden;
147146

148147
/* IE5 Hack */
149-
voice-family: "\"}\"";
148+
voice-family: "}"" ;
150149
voice-family:inherit;
151150
width:155px;
152151
}
@@ -238,3 +237,63 @@ A:active { color: #F00; background: white none }
238237
.synTodo { color: #0000FF ; background: #FFFF00 none }
239238
pre { display: inline; }
240239

240+
241+
/*Navbar Improvements */
242+
.menu-content {
243+
padding: 8px;
244+
margin-bottom: 10px;
245+
border-left: 1px solid #3d8ea8;
246+
border-right: 1px solid #3d8ea8;
247+
border-bottom: 1px solid #005069;
248+
background-color: #f9f9f9;
249+
}
250+
251+
.action-btn {
252+
display: block;
253+
text-align: center;
254+
background-color: #3d8ea8;
255+
color: #ffffff !important;
256+
padding: 6px;
257+
text-decoration: none;
258+
font-weight: bold;
259+
border-radius: 3px;
260+
border: 1px solid #005069;
261+
}
262+
263+
.action-btn:hover {
264+
background-color: #005069;
265+
color: #ffffff !important;
266+
text-decoration: none;
267+
}
268+
269+
.action-btn.secondary {
270+
background-color: #eee;
271+
color: #333 !important;
272+
border: 1px solid #ccc;
273+
}
274+
275+
.action-btn.secondary:hover {
276+
background-color: #ddd;
277+
color: #000 !important;
278+
}
279+
280+
.user-content {
281+
text-align: center;
282+
}
283+
284+
.logged-in-user {
285+
margin-bottom: 5px;
286+
font-weight: bold;
287+
border-bottom: 1px solid #dcdcdc;
288+
padding-bottom: 5px;
289+
word-wrap: break-word;
290+
}
291+
292+
.user-icon {
293+
font-size: 1.2em;
294+
vertical-align: middle;
295+
}
296+
297+
.user-links a {
298+
font-size: 0.9em;
299+
}

templates/navbar

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,34 @@
33
<div id="menu">
44

55
<h1>Paste</h1>
6-
<a href="[% base_url %]">Make new paste</a>
7-
<br />
6+
<div class="menu-content">
7+
<a href="[% base_url %]" class="action-btn">Make new paste</a>
8+
</div>
89

910
[% IF auth_enabled %]
10-
[% IF current_user %]
11-
<div>Signed in as [% current_user.name | html %] | <a href="[% base_url %]/logout">Logout</a></div>
12-
[% ELSE %]
13-
<div><a href="[% base_url %]/auth/login">Login with GitLab</a></div>
14-
[% END %]
11+
<div class="user-section">
12+
<h1>User</h1>
13+
<div class="menu-content user-content">
14+
[% IF current_user %]
15+
<div class="logged-in-user">
16+
<span class="user-icon">👤</span>
17+
<span class="username">[% current_user.name | html %]</span>
18+
</div>
19+
<div class="user-links">
20+
<a href="[% base_url %]/logout">Logout</a>
21+
</div>
22+
[% ELSE %]
23+
<div class="login-action">
24+
<a href="[% base_url %]/auth/login" class="action-btn secondary">Login with GitLab</a>
25+
</div>
26+
[% END %]
27+
</div>
28+
</div>
1529
[% END %]
1630

1731
[% IF current_user && user_pastes.size > 0 -%]
1832
<h1>Your pastes</h1>
33+
<div class="menu-content">
1934
<ul>
2035
[% FOREACH post = user_pastes %]
2136
<li>
@@ -38,9 +53,14 @@
3853
</li>
3954
[% END %]
4055
</ul>
56+
</div>
4157
[% END %]
58+
59+
<div class="links-section">
4260
[% INCLUDE links %]
4361
</div>
4462

63+
</div>
64+
4565
[%# vim: syntax=html sw=4 ts=4 noet shiftround
46-
%]
66+
%]

0 commit comments

Comments
 (0)