changed some types

This commit is contained in:
Felipe M 2022-08-14 23:19:57 +02:00
parent b3dce9f0e4
commit fbc2e7a1af
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
7 changed files with 21 additions and 10 deletions

View File

@ -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 {

View File

@ -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,

View File

@ -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()).

View File

@ -21,6 +21,7 @@
<a href="https://github.com/fmartingr/notion2ical">Open source</a> |
<a href="">Service Status</a> |
<a href="https://fmartingr.com/about/">Contact</a>
{% if branding_footer_extra %}| {{ branding_footer_extra }}{% endif %}
</footer>
</body>

View File

@ -3,9 +3,10 @@
{% block content %}
<div>
<p>You calendar is ready!</p>
<p>Now you can <a href="{{ calendarICSUrl }}"><b>download your calendar as an.ICS file</b></a> or subscribe to it using the following URL:</p>
<p>You can download it <a href="{{ calendarICSUrl }}"><b>by clicking here</b></a> to have an offline copy, or you can subscribe using your favourite calendar client using the following URL:</p>
<p><pre>{{ calendarSubscriptionUrl }}</pre></p>
<p>{{ thanksMessage }}<p>
<p><a href="/">Go back home</a></p>
<p>Note that calendars <b>are cached for {{ calendar_cache_time }}</b> so please set up your refresh interval accordingly.</p>
<p>{{ branding_thanks_message }}<p>
<p><a href="/">Go back to the index</a></p>
</div>
{% endblock %}

View File

@ -3,12 +3,12 @@
{% block content %}
<div class="text-center">
<p>
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.
</p>
<h2 id="how-it-works">How it works</h2>
<h3>1.</h3>
<p>
Give access to Notion2iCal to your notion database by using the <kbd>Share</kbd> button
Give access to Notion2iCal to your Notion database by using the <kbd>Share</kbd> button
on the top right of your database and searching for <i>Notion2iCal</i>. Only read permissions
are required.
</p>
@ -18,7 +18,7 @@
<form action="/wizard" method="post">
<h3>2.</h3>
<p>
<label>After giving access, paste your database URL here to start the Wizard</label>
<label>After giving access, paste your Notion database URL here to setup your calendar.</label>
<input type="url" name="database_url" placeholder="https://notion.so/workspace/...">
</p>

View File

@ -6,6 +6,8 @@
We are going to setup a calendar for the <b>{{ databaseName }}</b> database.
</p>
<form action="/download" method="post">
<h3>1.</h3>
<p>
<label for="name_property">Select the property that will be used as event name:</label>
<select name="name_property">
@ -14,6 +16,8 @@
{% endfor %}
</select>
</p>
<h3>2.</h3>
<p>
<label for="date_property">Select the property that will be used as event date:</label>
<select name="date_property">
@ -31,6 +35,7 @@
<em>Otherwise we will <u>try</u> to use a Start/End date from the property selected above.</em>
</p>
<h3>3.</h3>
<input type="hidden" name="database_id" value="{{ databaseID }}" />
<button type="submit">Generate calendar</button>
</form>