0.1 5d00907

appserver.go RawHistoryFolder

1package server
2
3import (
4	"database/sql"
5	"fmt"
6	"io/fs"
7	"time"
8
9	"github.com/bnema/gordon/internal/common"
10	"github.com/bnema/gordon/internal/db"
11	_ "github.com/joho/godotenv/autoload"
12)
13
14type App struct {
15	TemplateFS      fs.FS
16	PublicFS        fs.FS
17	LocYML          []byte // strings.yml contains the strings for the current language
18	DBDir           string
19	DBFilename      string
20	DBPath          string
21	InitialChecksum string
22	Config          common.Config
23	DB              *sql.DB
24	DBTables        DBTables
25	StartTime       time.Time
26}
27
28type DBTables struct {
29	User     db.User     `sql:"user"`
30	Account  db.Account  `sql:"account"`
31	Sessions db.Sessions `sql:"sessions"`
32	Provider db.Provider `sql:"provider"`
33	Clients  db.Clients  `sql:"clients"`
34}
35
36// GenerateOauthCallbackURL generates the OAuth callback URL
37func (a *App) GenerateOauthCallbackURL() string {
38	var scheme, port string
39	config := a.Config
40
41	if config.Http.Https {
42		scheme = "https"
43		port = ""
44	}
45
46	if !config.Http.Https {
47		scheme = "http"
48		port = fmt.Sprintf(":%s", a.Config.Http.Port)
49	}
50
51	domain := config.Http.Domain
52	if config.Http.SubDomain != "" {
53		domain = fmt.Sprintf("%s.%s", config.Http.SubDomain, config.Http.Domain)
54	}
55
56	return fmt.Sprintf("%s://%s%s%s/login/oauth/callback", scheme, domain, port, config.Admin.Path)
57}
58
59func (a *App) IsDevEnvironment() bool {
60	return a.Config.Build.RunEnv == "dev"
61}
62
63func (a *App) GetUptime() string {
64	uptime := time.Since(a.StartTime)
65	return uptime.String()
66}
67
68// GetVersion returns the version of the app
69func (a *App) GetVersionstring() string {
70	return fmt.Sprint(a.Config.Build.BuildVersion)
71}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close