Add userinfo in navigation
authorr <r@freesoftwareextremist.com>
Tue, 24 Dec 2019 14:55:05 +0000 (14:55 +0000)
committerr <r@freesoftwareextremist.com>
Tue, 24 Dec 2019 14:55:05 +0000 (14:55 +0000)
renderer/model.go
service/service.go
static/main.css
templates/navigation.tmpl

index 2719dbe680d55f40ed316bf55f714cf9caa8316b..9ec4a9adad6f66a0b8c6db1dbf9d9ec578829cfb 100644 (file)
@@ -6,12 +6,14 @@ import (
 )
 
 type NavbarTemplateData struct {
+       User              *mastodon.Account
        NotificationCount int
 }
 
-func NewNavbarTemplateData(notificationCount int) *NavbarTemplateData {
+func NewNavbarTemplateData(notificationCount int, user *mastodon.Account) *NavbarTemplateData {
        return &NavbarTemplateData{
                NotificationCount: notificationCount,
+               User:              user,
        }
 }
 
index 27ee6bf774af23ee03420fc95972a98d57c3287f..8a262b62edb2a46121584c799f47d117c0dbc9be 100644 (file)
@@ -478,7 +478,12 @@ func (svc *service) getNavbarTemplateData(ctx context.Context, client io.Writer,
                }
        }
 
-       data = renderer.NewNavbarTemplateData(notificationCount)
+       u, err := c.GetAccountCurrentUser(ctx)
+       if err != nil {
+               return
+       }
+
+       data = renderer.NewNavbarTemplateData(notificationCount, u)
 
        return
 }
index a4a069d9aaf5d6a0d44469ef563410918be68db9..8237abb32151b5332b5d9f076eb47c0ceaa2a966 100644 (file)
        font-size: 23pt;
 }
 
-.navigation {
-       margin: 4px 0;
-}
-
-.navigation a {
-       margin-right: 8px;
-}
-
 .post-form {
        margin: 8px 0;
 }
 .post-form-emoji-link i {
        font-size: 14pt !important;
 }
+
+.user-info {
+       margin-bottom: 8px;
+}
+
+.user-info-img-container {
+       display: inline-block;
+       vertical-align: top;
+}
+
+.user-info-img {
+       max-height: 64px;
+       max-width: 64px;
+       object-fit: contain;
+       vertical-align: middle;
+}
+
+.user-info-details-container {
+       display: inline-block;
+       vertical-align: middle;
+}
+
+.user-info-details-container>div {
+       margin-bottom: 4px;
+}
+
+.nav-link {
+       margin-right: 2px;
+}
+
index 53386772afbbfc5a67a0ef8945f7cb8c7e3b50f0..0e745a2446ad4afd60e7bb00724a1dd8025a8db2 100644 (file)
@@ -1,6 +1,23 @@
-<div class="navigation">
-       <a href="/timeline">home</a>
-       <a href="/notifications">notifications{{if gt .NotificationCount 0}} ({{.NotificationCount}}){{end}}</a>
-       <a href="/about">about</a>
-       <a href="/signout">sign out</a>
+<div class="user-info">
+       <div class="user-info-img-container">
+               <a class="img-link" href="/timeline" title="home">
+                       <img class="user-info-img" src="{{.User.AvatarStatic}}" alt="profile-avatar" />
+               </a>
+       </div>
+       <div class="user-info-details-container">
+               <div>
+                       <span class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </span>  
+                       <a class="nav-link" href="/user/{{.User.ID}}">
+                               <span class="status-uname"> {{.User.Acct}} </span>
+                       </a>
+               </div>
+               <div>
+                       <a class="nav-link" href="/timeline">home</a>
+                       <a class="nav-link" href="/notifications">notifications{{if gt .NotificationCount 0}}({{.NotificationCount}}){{end}}</a>
+                       <a class="nav-link" href="/about">about</a>
+               </div>
+               <div>
+                       <a class="nav-link" href="/signout">sign out</a>
+               </div>
+       </div>
 </div>