diff --git a/ui/templates.go b/ui/templates.go index c414728..cd2ab04 100644 --- a/ui/templates.go +++ b/ui/templates.go @@ -207,6 +207,19 @@ func makeYearRange(a jet.Arguments) reflect.Value { } } +// extractCommunityLogo extracts a community logo URL from a community. +func extractCommunityLogo(a jet.Arguments) reflect.Value { + rc := "/img/builtin/default-community.jpg" + comm := a.Get(0).Convert(reflect.TypeFor[*database.Community]()).Interface().(*database.Community) + ci, err := comm.ContactInfo() + if err == nil { + if ci.PhotoURL != nil && *ci.PhotoURL != "" { + rc = *ci.PhotoURL + } + } + return reflect.ValueOf(rc) +} + // SetupTemplates is called to set up the template renderer after the configuration is loaded. func SetupTemplates() { views = jet.NewSet( @@ -222,6 +235,7 @@ func SetupTemplates() { views.AddGlobalFunc("GetMonthList", getMonthList) views.AddGlobalFunc("MakeIntRange", makeIntRange) views.AddGlobalFunc("MakeYearRange", makeYearRange) + views.AddGlobalFunc("ExtractCommunityLogo", extractCommunityLogo) views.AddGlobalFunc("GetCountryList", func(a jet.Arguments) reflect.Value { return reflect.ValueOf(internalGetCountryList()) diff --git a/ui/views/menu_left_comm.jet b/ui/views/menu_left_comm.jet index 8717c98..8e07a4d 100644 --- a/ui/views/menu_left_comm.jet +++ b/ui/views/menu_left_comm.jet @@ -10,8 +10,7 @@ {{ comm := .CurrentCommunity() }}
+