From 50f0815a06bf3c0069802100b5b8574842fc48bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Fri, 4 Mar 2022 11:16:50 +0100 Subject: [PATCH] docs: adapt landing page --- config/config.go | 3 ++ handlers/index.go | 14 +++++-- views/index.tpl.html | 88 ++++++++++++++++++++++++++++++--------- views/static/favicon.png | Bin 0 -> 5861 bytes 4 files changed, 82 insertions(+), 23 deletions(-) create mode 100644 views/static/favicon.png diff --git a/config/config.go b/config/config.go index e4a4516..df35ce2 100644 --- a/config/config.go +++ b/config/config.go @@ -39,6 +39,7 @@ const ( var cfg *BotConfig type BotConfig struct { + Env string Token string Mode string BaseUrl string @@ -105,6 +106,7 @@ func readBlacklist(path string) []string { func Get() *BotConfig { if cfg == nil { + envPtr := flag.String("env", "production", "Environment to run in (dev or production)") tokenPtr := flag.String("token", "", "Your Telegram Bot Token from Botfather") modePtr := flag.String("mode", "poll", "Update mode ('poll' for development, 'webhook' for production)") baseUrlPtr := flag.String("baseUrl", "", "A relative URL different from '/', required to run the bot on a subpath. E.g. to run bot under 'https://exmaple.org/wh2tg' set baseUrl to '/wh2tg'") @@ -134,6 +136,7 @@ func Get() *BotConfig { } cfg = &BotConfig{ + Env: *envPtr, Token: *tokenPtr, Mode: *modePtr, BaseUrl: *baseUrlPtr + "/", diff --git a/handlers/index.go b/handlers/index.go index 568b379..0ce434c 100644 --- a/handlers/index.go +++ b/handlers/index.go @@ -15,12 +15,18 @@ type indexData struct { } func NewIndexHandler() *IndexHandler { - return &IndexHandler{ - Tpl: template.Must(template.ParseFiles("views/index.tpl.html")), - Config: config.Get(), - } + h := &IndexHandler{Config: config.Get()} + h.loadTemplates() + return h } func (h *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if h.Config.Env == "dev" { + h.loadTemplates() + } h.Tpl.Execute(w, indexData{Config: h.Config}) } + +func (h *IndexHandler) loadTemplates() { + h.Tpl = template.Must(template.ParseFiles("views/index.tpl.html")) +} diff --git a/views/index.tpl.html b/views/index.tpl.html index 6ff465f..c0e53be 100644 --- a/views/index.tpl.html +++ b/views/index.tpl.html @@ -3,6 +3,7 @@ Telepush + -

telepush

- -
- Bot: - @MiddleManBot -
-
- API Entrypoint: - /api -
-
- GitHub: - muety/telepush -
- - + +

telepush

+

Send Telegram push notifications easily via HTTP

+ +
+ +

Usage

+

Step 1: Get a token

+

+ Start a chat with TelepushBot (or your own bot) and type /start to obtain a recipient token. +

+

Step 2: Send your message

+ +

+ curl -XPOST \
+    -d '{ "text": "Hello there" }' \
+    api/messages +

+ +
+
+
+ +
+ Bot: + @MiddleManBot +
+
+ API Entrypoint: + /api +
+
+ Code & Docs: + muety/telepush +
+ + + + \ No newline at end of file diff --git a/views/static/favicon.png b/views/static/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..f5fff1f6226cde63352b3485b424664bd32e7d28 GIT binary patch literal 5861 zcmai2WmJ^k*L`Maq#Hzr?rxBFKv1N+Lw=x0NH?Q&qjYyjmvl1@AT2R;iZn;JBGpS#xm@T`09+2`zic7%r7OMF}!TmS&@Rg|Gxs1^2aVq>DdeKM9qs0GJa+0YdL zNH+gXkOijY57Z{Lo1%f6w$p!Zo|Y~)fTyP??>k3(S8GdW8(t?D+l)gg8UUbhQGv?q zcx4`B`TCJ^dmeQIz?4 z+uWP*;mgxO$m#xV`{{mX*Kqr(SvH7Y;D3y3qfclblWim@0Y}#S!Eo`;1vMxqagwi8 zwg_76IQqWFEhm&)30k|L1nnoPr2!uPc(f5J8hJv&2CZ)2Dhmp%@qtBLK*4-7d>b>a z|5UHACk>cAxY#2;9tnut2L48tm0jxV>1E?I1yEE4^{r7MCnk;=fJK6P;Q&g*wHc>h zQ5s!&0N@#!-`tU#YoXel6vhH;Z*M0C{t^PIG-ce3hb;N}efR@~Y|t}K#zPSew^sH@ zCkiq$c!+kO0k~%FLmaq!k^Xdr==eQjYvC;+asA2ZsjaS#j&P`Umx>c7CnwD*YJz=Oo6`U3SjH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