mirror of https://github.com/realaravinth/gitpad
feat: conditionally display profile link
parent
3e42c621fb
commit
9fb203de32
|
@ -63,7 +63,7 @@ impl NewGist {
|
|||
payload: Option<&[FieldNames<&str>]>,
|
||||
) -> Self {
|
||||
const FIELDNAMES_KEY: &str = "fieldnames";
|
||||
let mut ctx = auth_ctx(username, settings);
|
||||
let mut ctx = auth_ctx(Some(username), settings);
|
||||
ctx.insert("visibility_private", GistVisibility::Private.to_str());
|
||||
ctx.insert("visibility_unlisted", GistVisibility::Unlisted.to_str());
|
||||
ctx.insert("visibility_public", GistVisibility::Public.to_str());
|
||||
|
|
|
@ -97,11 +97,16 @@ pub fn context(s: &Settings) -> Context {
|
|||
ctx
|
||||
}
|
||||
|
||||
pub fn auth_ctx(username: &str, s: &Settings) -> Context {
|
||||
pub fn auth_ctx(username: Option<&str>, s: &Settings) -> Context {
|
||||
use routes::GistProfilePathComponent;
|
||||
let profile_link = PAGES
|
||||
.gist
|
||||
.get_profile_route(GistProfilePathComponent { username });
|
||||
let mut profile_link = None;
|
||||
if let Some(name) = username {
|
||||
profile_link = Some(
|
||||
PAGES
|
||||
.gist
|
||||
.get_profile_route(GistProfilePathComponent { username: name }),
|
||||
);
|
||||
}
|
||||
let mut ctx = Context::new();
|
||||
let footer = Footer::new(s);
|
||||
ctx.insert("footer", &footer);
|
||||
|
|
|
@ -16,9 +16,11 @@
|
|||
<div class="nav__link-container">
|
||||
<a class="nav__link" rel="noreferrer" href="{{ page.gist.new }}">New Paste</a>
|
||||
</div>
|
||||
<div class="nav__link-container">
|
||||
<a class="nav__link" rel="noreferrer" href="{{ loggedin_user }}">Profile</a>
|
||||
</div>
|
||||
{% if loggedin_user %}
|
||||
<div class="nav__link-container">
|
||||
<a class="nav__link" rel="noreferrer" href="{{ loggedin_user }}">Profile</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="nav__link-container">
|
||||
<a class="nav__link" rel="noreferrer" href="{{ page.auth.logout }}">Log out</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue