visual improvements in frame and communities sidebox

This commit is contained in:
2025-10-17 13:38:05 -06:00
parent be5b3a426d
commit 7a755aac77
3 changed files with 56 additions and 34 deletions
+33 -22
View File
@@ -37,6 +37,7 @@ type RenderedSidebox struct {
Title string Title string
Subtext *string Subtext *string
Items []RenderedSideboxItem Items []RenderedSideboxItem
Flags map[string]bool
} }
/* buildCommunitiesSidebox creates the data for the "My/Featured Communities" sidebox. /* buildCommunitiesSidebox creates the data for the "My/Featured Communities" sidebox.
@@ -48,31 +49,41 @@ type RenderedSidebox struct {
* Standard Go error status. * Standard Go error status.
*/ */
func buildCommunitiesSidebox(uid int32, out *RenderedSidebox, in *database.Sidebox) error { func buildCommunitiesSidebox(uid int32, out *RenderedSidebox, in *database.Sidebox) error {
var err error user, err := database.AmGetUser(uid)
var anon bool
anon, err = database.AmIsUserAnon(uid)
if err == nil { if err == nil {
if anon { var g *database.Globals
out.Title = "Featured Communities" g, err = database.AmGlobals()
} else {
out.Title = "Your Communities"
}
var l []*database.Community
l, err = database.AmGetCommunitiesForUser(uid)
if err == nil { if err == nil {
out.Items = make([]RenderedSideboxItem, len(l)) if user.IsAnon {
for i, c := range l { out.Title = "Featured Communities"
out.Items[i].Text = c.Name } else {
lk := fmt.Sprintf("/comm/%s/profile", c.Alias) out.Title = "Your Communities"
out.Items[i].Link = &lk }
out.Items[i].Flags = make(map[string]bool) var l []*database.Community
var level uint16 l, err = database.AmGetCommunitiesForUser(uid)
level, err = database.AmGetCommunityAccessLevel(uid, c.Id) if err == nil {
if err == nil && database.AmTestPermission("Community.ShowAdmin", level) { out.Items = make([]RenderedSideboxItem, len(l))
out.Items[i].Flags["admin"] = true for i, c := range l {
} out.Items[i].Text = c.Name
lk := fmt.Sprintf("/comm/%s/profile", c.Alias)
out.Items[i].Link = &lk
out.Items[i].Flags = make(map[string]bool)
var level uint16
level, err = database.AmGetCommunityAccessLevel(uid, c.Id)
if err == nil && database.AmTestPermission("Community.ShowAdmin", level) {
out.Items[i].Flags["admin"] = true
}
}
out.Flags = make(map[string]bool)
if user.IsAnon {
out.Flags["canManage"] = false
out.Flags["canCreate"] = false
} else {
out.Flags["canManage"] = true
out.Flags["canCreate"] = user.BaseLevel >= uint16(g.CommunityCreateLevel)
}
out.TemplateName = "sb_ftrcomm.jet"
} }
out.TemplateName = "sb_ftrcomm.jet"
} }
} }
_ = in _ = in
+8 -6
View File
@@ -26,9 +26,9 @@
<div class="flex items-center justify-between px-2 py-2"> <div class="flex items-center justify-between px-2 py-2">
<!-- Site Logo --> <!-- Site Logo -->
<div class="w-1/5"> <div class="w-1/5">
<a href="https://git.erbosoft.com/amy/amsterdam"> <a href="/">
<img src="/img/builtin/powered-by-amsterdam.png" <img src="/img/builtin/powered-by-amsterdam.png"
alt="Amsterdam Test" alt="{{ GlobalConfig.Site.Title }}"
class="w-35 h-20 mx-2 my-2"> class="w-35 h-20 mx-2 my-2">
</a> </a>
</div> </div>
@@ -36,9 +36,7 @@
<!-- Navigation Links --> <!-- Navigation Links -->
<div class="w-2/5 text-center"> <div class="w-2/5 text-center">
<div class="text-white font-bold text-base mb-2"> <div class="text-white font-bold text-base mb-2">
<a href="/" class="text-yellow-300 hover:text-yellow-400"> <a href="/" class="text-yellow-300 hover:text-yellow-400">Front Page</a>
Front Page
</a>
</div> </div>
<div class="text-white font-bold text-base"> <div class="text-white font-bold text-base">
<a href="/TODO/help" class="text-yellow-300 hover:text-yellow-400">Help</a> <a href="/TODO/help" class="text-yellow-300 hover:text-yellow-400">Help</a>
@@ -69,6 +67,10 @@
{{ if !isset(amsterdam_suppressLogin) || !amsterdam_suppressLogin }} {{ if !isset(amsterdam_suppressLogin) || !amsterdam_suppressLogin }}
<span class="mx-2">-</span> <span class="mx-2">-</span>
<a href="/logout" class="text-yellow-300 hover:text-yellow-400">Log Out</a> <a href="/logout" class="text-yellow-300 hover:text-yellow-400">Log Out</a>
{{ if !.CurrentUser().VerifyEMail }}
<span class="mx-2">|</span>
<a href="/verify" class="text-yellow-300 hover:text-yellow-400">Verify E-Mail</a>
{{ end }}
<span class="mx-2">|</span> <span class="mx-2">|</span>
<a href="/profile" class="text-yellow-300 hover:text-yellow-400">Profile</a> <a href="/profile" class="text-yellow-300 hover:text-yellow-400">Profile</a>
{{ end }} {{ end }}
@@ -124,4 +126,4 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>
+15 -6
View File
@@ -26,11 +26,20 @@
<div class="text-small">You are not a member of any communities.</div> <div class="text-small">You are not a member of any communities.</div>
{{ end }} {{ end }}
</div> </div>
<div class="mt-3 text-center"> {{ if sb.Flags["canManage"] || sb.Flags["canCreate"] }}
<span class="text-black text-xs font-bold"> <div class="mt-3 text-center">
[ <a href="/TODO/manage_comms" class="text-blue-700 hover:text-blue-900">Manage</a> | <span class="text-black text-xs font-bold">
<a href="/TODO/create_comm" class="text-blue-700 hover:text-blue-900">Create New</a> ] [
</span> {{ if sb.Flags["canManage"] }}
</div> <a href="/TODO/manage_comms" class="text-blue-700 hover:text-blue-900">Manage</a>
{{ if sb.Flags["canCreate"] }}|{{ end }}
{{ end }}
{{ if sb.Flags["canCreate"] }}
<a href="/TODO/create_comm" class="text-blue-700 hover:text-blue-900">Create New</a>
{{ end }}
]
</span>
</div>
{{ end }}
</div> </div>
</div> </div>