Show API URL endpoints in user interface
This commit is contained in:
parent
b0442e0277
commit
b78172033f
11 changed files with 99 additions and 14 deletions
2
Makefile
2
Makefile
|
@ -25,7 +25,7 @@ build: linux linux-arm darwin
|
|||
|
||||
run:
|
||||
@ go generate
|
||||
@ go run main.go
|
||||
@ go run main.go -debug
|
||||
|
||||
clean:
|
||||
@ rm -f $(APP)-*
|
||||
|
|
|
@ -55,7 +55,11 @@ func (c *Config) HasDebugMode() bool {
|
|||
|
||||
// BaseURL returns the application base URL.
|
||||
func (c *Config) BaseURL() string {
|
||||
return c.get("BASE_URL", defaultBaseURL)
|
||||
baseURL := c.get("BASE_URL", defaultBaseURL)
|
||||
if baseURL[len(baseURL)-1:] == "/" {
|
||||
baseURL = baseURL[:len(baseURL)-1]
|
||||
}
|
||||
return baseURL
|
||||
}
|
||||
|
||||
// DatabaseURL returns the database URL.
|
||||
|
|
39
config/config_test.go
Normal file
39
config/config_test.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2017 Frédéric Guillot. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetCustomBaseURL(t *testing.T) {
|
||||
os.Clearenv()
|
||||
os.Setenv("BASE_URL", "http://example.org")
|
||||
cfg := NewConfig()
|
||||
|
||||
if cfg.BaseURL() != "http://example.org" {
|
||||
t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCustomBaseURLWithTrailingSlash(t *testing.T) {
|
||||
os.Clearenv()
|
||||
os.Setenv("BASE_URL", "http://example.org/folder/")
|
||||
cfg := NewConfig()
|
||||
|
||||
if cfg.BaseURL() != "http://example.org/folder" {
|
||||
t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDefaultBaseURL(t *testing.T) {
|
||||
os.Clearenv()
|
||||
cfg := NewConfig()
|
||||
|
||||
if cfg.BaseURL() != "http://localhost" {
|
||||
t.Fatalf(`Unexpected base URL, got "%s"`, cfg.BaseURL())
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ func routes(cfg *config.Config, store *storage.Storage, feedHandler *feed.Handle
|
|||
middleware.NewSessionMiddleware(cfg, store).Handler,
|
||||
))
|
||||
|
||||
router.Handle("/fever/", feverHandler.Use(feverController.Handler))
|
||||
router.Handle("/fever/", feverHandler.Use(feverController.Handler)).Name("feverEndpoint")
|
||||
|
||||
router.Handle("/v1/users", apiHandler.Use(apiController.CreateUser)).Methods("POST")
|
||||
router.Handle("/v1/users", apiHandler.Use(apiController.Users)).Methods("GET")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-01-20 00:27:28.368359 +0100 CET m=+0.034072224
|
||||
// 2018-01-31 21:53:31.21983716 -0800 PST m=+0.044009238
|
||||
|
||||
package locale
|
||||
|
||||
|
@ -430,7 +430,11 @@ var translations = map[string]string{
|
|||
"Logged as %s": "Connecté en tant que %s",
|
||||
"Unread Items": "Éléments non lus",
|
||||
"Change entry status": "Changer le statut de l'élément",
|
||||
"Read": "Lu"
|
||||
"Read": "Lu",
|
||||
"Fever API endpoint:": "Point de terminaison de l'API Fever :",
|
||||
"Miniflux API": "API de Miniflux",
|
||||
"API Endpoint": "Point de terminaison de l'API",
|
||||
"Your account password": "Le mot de passe de votre compte"
|
||||
}
|
||||
`,
|
||||
}
|
||||
|
@ -438,5 +442,5 @@ var translations = map[string]string{
|
|||
var translationsChecksums = map[string]string{
|
||||
"de_DE": "c518cb7782b391da612d7d8d72fc746aa5ae25e107afc995d29b85990e2f07e8",
|
||||
"en_US": "6fe95384260941e8a5a3c695a655a932e0a8a6a572c1e45cb2b1ae8baa01b897",
|
||||
"fr_FR": "776658a9a09c49d25f1f259fea794b48c4fa39b92024318d0f223bafb9164aad",
|
||||
"fr_FR": "e6305fd54508a4f54d630e3ef231a8eadc2335ed0ffac7b5266b2ec751824e28",
|
||||
}
|
||||
|
|
|
@ -204,5 +204,9 @@
|
|||
"Logged as %s": "Connecté en tant que %s",
|
||||
"Unread Items": "Éléments non lus",
|
||||
"Change entry status": "Changer le statut de l'élément",
|
||||
"Read": "Lu"
|
||||
"Read": "Lu",
|
||||
"Fever API endpoint:": "Point de terminaison de l'API Fever :",
|
||||
"Miniflux API": "API de Miniflux",
|
||||
"API Endpoint": "Point de terminaison de l'API",
|
||||
"Your account password": "Le mot de passe de votre compte"
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ func (h *Handler) RefreshFeed(userID, feedID int64) error {
|
|||
logger.Debug("[Handler:RefreshFeed] Looking for feed icon")
|
||||
icon, err := icon.FindIcon(originalFeed.SiteURL)
|
||||
if err != nil {
|
||||
logger.Error("[Handler:RefreshFeed] %v", err)
|
||||
logger.Debug("[Handler:RefreshFeed] %v", err)
|
||||
} else {
|
||||
h.store.CreateFeedIcon(originalFeed, icon)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-01-02 21:59:10.075345511 -0800 PST m=+0.002720840
|
||||
// 2018-01-31 21:53:31.179267411 -0800 PST m=+0.003439489
|
||||
|
||||
package sql
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-01-18 20:15:20.47432327 -0800 PST m=+0.053802055
|
||||
// 2018-01-31 21:53:31.216689995 -0800 PST m=+0.040862073
|
||||
|
||||
package template
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
|
||||
<label for="form-fever-password">{{ t "Fever Password" }}</label>
|
||||
<input type="password" name="fever_password" id="form-fever-password" value="{{ .form.FeverPassword }}">
|
||||
|
||||
<p>{{ t "Fever API endpoint:" }} <strong>{{ baseURL }}{{ route "feverEndpoint" }}</strong></p>
|
||||
</div>
|
||||
|
||||
<h3>Pinboard</h3>
|
||||
|
@ -98,8 +100,23 @@
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<h3>{{ t "Miniflux API" }}</h3>
|
||||
<div class="panel">
|
||||
<ul>
|
||||
<li>
|
||||
{{ t "API Endpoint" }} = <strong>{{ baseURL }}/v1/</strong>
|
||||
</li>
|
||||
<li>
|
||||
{{ t "Username" }} = <strong>{{ .user.Username }}</strong>
|
||||
</li>
|
||||
<li>
|
||||
{{ t "Password" }} = <strong>{{ t "Your account password" }}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h3>{{ t "Bookmarklet" }}</h3>
|
||||
<div class="panel">
|
||||
<h3>{{ t "Bookmarklet" }}</h3>
|
||||
<p>{{ t "This special link allows you to subscribe to a website directly by using a bookmark in your web browser." }}</p>
|
||||
|
||||
<div class="bookmarklet">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// 2018-01-18 20:15:20.459420484 -0800 PST m=+0.038899269
|
||||
// 2018-01-31 21:53:31.195099265 -0800 PST m=+0.019271343
|
||||
|
||||
package template
|
||||
|
||||
|
@ -808,6 +808,8 @@ var templateViewsMap = map[string]string{
|
|||
|
||||
<label for="form-fever-password">{{ t "Fever Password" }}</label>
|
||||
<input type="password" name="fever_password" id="form-fever-password" value="{{ .form.FeverPassword }}">
|
||||
|
||||
<p>{{ t "Fever API endpoint:" }} <strong>{{ baseURL }}{{ route "feverEndpoint" }}</strong></p>
|
||||
</div>
|
||||
|
||||
<h3>Pinboard</h3>
|
||||
|
@ -867,8 +869,23 @@ var templateViewsMap = map[string]string{
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<h3>{{ t "Miniflux API" }}</h3>
|
||||
<div class="panel">
|
||||
<ul>
|
||||
<li>
|
||||
{{ t "API Endpoint" }} = <strong>{{ baseURL }}/v1/</strong>
|
||||
</li>
|
||||
<li>
|
||||
{{ t "Username" }} = <strong>{{ .user.Username }}</strong>
|
||||
</li>
|
||||
<li>
|
||||
{{ t "Password" }} = <strong>{{ t "Your account password" }}</strong>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h3>{{ t "Bookmarklet" }}</h3>
|
||||
<div class="panel">
|
||||
<h3>{{ t "Bookmarklet" }}</h3>
|
||||
<p>{{ t "This special link allows you to subscribe to a website directly by using a bookmark in your web browser." }}</p>
|
||||
|
||||
<div class="bookmarklet">
|
||||
|
@ -1196,7 +1213,7 @@ var templateViewsMapChecksums = map[string]string{
|
|||
"feeds": "65b0a47c4438810b9d51c60f3f3b2519690e56ff74029e6296c68626b83a470b",
|
||||
"history": "d2476fd727e4f53428b5ed1f3f9423063583337ec8cfe1dd9c931fcb03852a20",
|
||||
"import": "73b5112e20bfd232bf73334544186ea419505936bc237d481517a8622901878f",
|
||||
"integrations": "3c14d7de904911aad7f3ebec6d1a20b50843287f58125c526e167f429f3d455d",
|
||||
"integrations": "a677434e9a8be1f80cfbc1d04828dacc7abcec2a22b45c80594d49cc2ba7c0e5",
|
||||
"login": "7d83c3067c02f1f6aafdd8816c7f97a4eb5a5a4bdaaaa4cc1e2fbb9c17ea65e8",
|
||||
"sessions": "9a3609c52b071a280b85fd886f15d4b91c76bb0ab93a99ad132c695a216ac5cf",
|
||||
"settings": "ea2505b9d0a6d6bb594dba87a92079de19baa6d494f0651693a7685489fb7de9",
|
||||
|
|
Loading…
Reference in a new issue