diff --git a/internal/config/config.go b/internal/config/config.go index 96b9424..af9cf42 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -56,7 +56,8 @@ type Config struct { DisablePreParseMultipartForm bool `env:"HTTP_DISABLE_PARSE_MULTIPART_FORM,default=true"` } Branding struct { - ThanksMessage string `env:"BRANDING_THANKS_MESSAGE"` + ThanksMessage string `env:"BRANDING_THANKS_MESSAGE"` + FooterExtraMessage string `env:"BRANDING_FOOTER_EXTRA"` } LogLevel string `env:"LOG_LEVEL,default=info"` Notion struct { diff --git a/internal/server/http/routes/calendar.go b/internal/server/http/routes/calendar.go index 9ea5e3a..b455248 100644 --- a/internal/server/http/routes/calendar.go +++ b/internal/server/http/routes/calendar.go @@ -20,7 +20,6 @@ type CalendarRoutes struct { router *fiber.App notion *notionClient.NotionClient publicHostname string - thanksMessage string limiterHandler fiber.Handler cacheHandler fiber.Handler @@ -91,7 +90,6 @@ func (r *CalendarRoutes) downloadHandler(c *fiber.Ctx) error { } return c.Render("download", fiber.Map{ - "thanksMessage": r.thanksMessage, "calendarSubscriptionUrl": r.publicHostname + "/calendar.ics?" + string(c.Request().Body()), "calendarICSUrl": r.publicHostname + "/calendar.ics?" + string(c.Request().Body()), }) @@ -157,7 +155,6 @@ func NewCalendarRoutes(logger *zap.Logger, cfg *config.Config) *CalendarRoutes { notion: cfg.Notion.Client, router: fiber.New(), publicHostname: cfg.Http.PublicHostname, - thanksMessage: cfg.Branding.ThanksMessage, limiterHandler: limiter.New(limiter.Config{ Max: cfg.Routes.Calendar.LimiterMaxRequest, Expiration: cfg.Routes.Calendar.LimiterExpiration, diff --git a/internal/server/http/server.go b/internal/server/http/server.go index 9874ac7..37c57d6 100644 --- a/internal/server/http/server.go +++ b/internal/server/http/server.go @@ -32,6 +32,12 @@ func (s *HttpServer) Setup(cfg *config.Config) { Logger: s.logger, CacheHeader: "X-Cache", })). + Use(func(c *fiber.Ctx) error { + c.Locals("branding_thanks_message", cfg.Branding.ThanksMessage) + c.Locals("branding_footer_extra", cfg.Branding.FooterExtraMessage) + c.Locals("calendar_cache_time", cfg.Routes.Calendar.CacheExpiration.String()) + return c.Next() + }). Use(recover.New()). Mount(cfg.Routes.System.Path, routes.NewSystemRoutes(s.logger, cfg).Setup().Router()). Mount(cfg.Routes.Static.Path, routes.NewStaticRoutes(s.logger, cfg).Setup().Router()). diff --git a/internal/server/http/views/base.django b/internal/server/http/views/base.django index 5c00249..bbb058a 100644 --- a/internal/server/http/views/base.django +++ b/internal/server/http/views/base.django @@ -21,6 +21,7 @@ Open source | Service Status | Contact + {% if branding_footer_extra %}| {{ branding_footer_extra }}{% endif %} diff --git a/internal/server/http/views/download.django b/internal/server/http/views/download.django index b2377af..f1289bd 100644 --- a/internal/server/http/views/download.django +++ b/internal/server/http/views/download.django @@ -3,9 +3,10 @@ {% block content %}

You calendar is ready!

-

Now you can download your calendar as an.ICS file or subscribe to it using the following URL:

+

You can download it by clicking here to have an offline copy, or you can subscribe using your favourite calendar client using the following URL:

{{ calendarSubscriptionUrl }}

-

{{ thanksMessage }}

-

Go back home

+

Note that calendars are cached for {{ calendar_cache_time }} so please set up your refresh interval accordingly.

+

{{ branding_thanks_message }}

+

Go back to the index

{% endblock %} diff --git a/internal/server/http/views/index.django b/internal/server/http/views/index.django index 3755740..cd175b0 100644 --- a/internal/server/http/views/index.django +++ b/internal/server/http/views/index.django @@ -3,12 +3,12 @@ {% block content %}

- Online tool to convert a Notion database into an iCalendar subscripbable URL or downloadable ICS file. + Online tool to convert a Notion database into an iCalendar subscription URL or downloadable ICS file.

How it works

1.

- Give access to Notion2iCal to your notion database by using the Share button + Give access to Notion2iCal to your Notion database by using the Share button on the top right of your database and searching for Notion2iCal. Only read permissions are required.

@@ -18,7 +18,7 @@

2.

- +

diff --git a/internal/server/http/views/wizard.django b/internal/server/http/views/wizard.django index d33844e..4b2e509 100644 --- a/internal/server/http/views/wizard.django +++ b/internal/server/http/views/wizard.django @@ -6,6 +6,8 @@ We are going to setup a calendar for the {{ databaseName }} database.

+ +

1.

+ +

2.