mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-14 00:39:22 +02:00
Added page about instance
This commit is contained in:
parent
fe304f60e9
commit
7dd90ac015
|
@ -17,6 +17,8 @@ type Instance struct {
|
||||||
Stats *InstanceStats `json:"stats,omitempty"`
|
Stats *InstanceStats `json:"stats,omitempty"`
|
||||||
Languages []string `json:"languages"`
|
Languages []string `json:"languages"`
|
||||||
ContactAccount *Account `json:"account"`
|
ContactAccount *Account `json:"account"`
|
||||||
|
MaxTootChars *int64 `json:"max_toot_chars"`
|
||||||
|
Pleroma *PleromaInstance `json:"pleroma"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstanceStats hold information for mastodon instance stats.
|
// InstanceStats hold information for mastodon instance stats.
|
||||||
|
@ -26,6 +28,16 @@ type InstanceStats struct {
|
||||||
DomainCount int64 `json:"domain_count"`
|
DomainCount int64 `json:"domain_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For about instance if this Pleroma
|
||||||
|
type PleromaInstance struct {
|
||||||
|
MetaData MetaData `json:"metadata"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MetaData struct {
|
||||||
|
Features *[]string `json:"features"`
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// GetInstance return Instance.
|
// GetInstance return Instance.
|
||||||
func (c *Client) GetInstance(ctx context.Context) (*Instance, error) {
|
func (c *Client) GetInstance(ctx context.Context) (*Instance, error) {
|
||||||
var instance Instance
|
var instance Instance
|
||||||
|
|
|
@ -119,6 +119,11 @@ type AboutData struct {
|
||||||
*CommonData
|
*CommonData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AboutInstanceData struct {
|
||||||
|
*CommonData
|
||||||
|
Instance *mastodon.Instance
|
||||||
|
}
|
||||||
|
|
||||||
type EmojiData struct {
|
type EmojiData struct {
|
||||||
*CommonData
|
*CommonData
|
||||||
Emojis []*mastodon.Emoji
|
Emojis []*mastodon.Emoji
|
||||||
|
|
|
@ -27,6 +27,7 @@ const (
|
||||||
UserPage = "user.tmpl"
|
UserPage = "user.tmpl"
|
||||||
UserSearchPage = "usersearch.tmpl"
|
UserSearchPage = "usersearch.tmpl"
|
||||||
AboutPage = "about.tmpl"
|
AboutPage = "about.tmpl"
|
||||||
|
AboutInstance = "aboutinstance.tmpl"
|
||||||
EmojiPage = "emoji.tmpl"
|
EmojiPage = "emoji.tmpl"
|
||||||
LikedByPage = "likedby.tmpl"
|
LikedByPage = "likedby.tmpl"
|
||||||
RetweetedByPage = "retweetedby.tmpl"
|
RetweetedByPage = "retweetedby.tmpl"
|
||||||
|
|
|
@ -737,6 +737,19 @@ func (s *service) AboutPage(c *client) (err error) {
|
||||||
return s.renderer.Render(c.rctx, c.w, renderer.AboutPage, data)
|
return s.renderer.Render(c.rctx, c.w, renderer.AboutPage, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *service) AboutInstance(c *client) (err error) {
|
||||||
|
cdata := s.cdata(c, "about", 0, 0, "")
|
||||||
|
instance, err := c.GetInstance(c.ctx)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
data := &renderer.AboutInstanceData{
|
||||||
|
CommonData: cdata,
|
||||||
|
Instance: instance,
|
||||||
|
}
|
||||||
|
return s.renderer.Render(c.rctx, c.w, renderer.AboutInstance, data)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *service) EmojiPage(c *client) (err error) {
|
func (s *service) EmojiPage(c *client) (err error) {
|
||||||
emojis, err := c.GetInstanceEmojis(c.ctx)
|
emojis, err := c.GetInstanceEmojis(c.ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -220,6 +220,10 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
||||||
aboutPage := handle(func(c *client) error {
|
aboutPage := handle(func(c *client) error {
|
||||||
return s.AboutPage(c)
|
return s.AboutPage(c)
|
||||||
}, SESSION, HTML)
|
}, SESSION, HTML)
|
||||||
|
|
||||||
|
aboutInstance := handle(func(c *client) error {
|
||||||
|
return s.AboutInstance(c)
|
||||||
|
}, SESSION, HTML)
|
||||||
|
|
||||||
emojisPage := handle(func(c *client) error {
|
emojisPage := handle(func(c *client) error {
|
||||||
return s.EmojiPage(c)
|
return s.EmojiPage(c)
|
||||||
|
@ -721,6 +725,7 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
|
||||||
r.HandleFunc("/user/{id}/{type}", userPage).Methods(http.MethodGet)
|
r.HandleFunc("/user/{id}/{type}", userPage).Methods(http.MethodGet)
|
||||||
r.HandleFunc("/usersearch/{id}", userSearchPage).Methods(http.MethodGet)
|
r.HandleFunc("/usersearch/{id}", userSearchPage).Methods(http.MethodGet)
|
||||||
r.HandleFunc("/about", aboutPage).Methods(http.MethodGet)
|
r.HandleFunc("/about", aboutPage).Methods(http.MethodGet)
|
||||||
|
r.HandleFunc("/aboutinstance", aboutInstance).Methods(http.MethodGet)
|
||||||
r.HandleFunc("/emojis", emojisPage).Methods(http.MethodGet)
|
r.HandleFunc("/emojis", emojisPage).Methods(http.MethodGet)
|
||||||
r.HandleFunc("/search", searchPage).Methods(http.MethodGet)
|
r.HandleFunc("/search", searchPage).Methods(http.MethodGet)
|
||||||
r.HandleFunc("/settings", settingsPage).Methods(http.MethodGet)
|
r.HandleFunc("/settings", settingsPage).Methods(http.MethodGet)
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
{{with .Data}}
|
||||||
|
{{template "header.tmpl" (WithContext .CommonData $.Ctx)}}
|
||||||
|
|
||||||
|
<div class="page-title"> About {{.Instance.Title}} </div>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
{{.Instance.Description}}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<details>
|
||||||
|
<summary>Logo instance</summary>
|
||||||
|
<img src="{{.Instance.Thumbnail}}" height="512"></img>
|
||||||
|
</details>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page-title"> Contact E-mail: {{.Instance.EMail}} </div>
|
||||||
|
|
||||||
|
{{if .Instance.Stats}}
|
||||||
|
<div class="page-title"> Statistics: </div>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
Domains federated: {{.Instance.Stats.DomainCount}}<br>
|
||||||
|
Registered users: {{.Instance.Stats.UserCount}}<br>
|
||||||
|
Statuses writen: {{.Instance.Stats.StatusCount}}<br>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
<div class="page-title"> Features: </div>
|
||||||
|
<div>
|
||||||
|
{{if .Instance.Pleroma}}
|
||||||
|
{{range .Instance.Pleroma.MetaData.Features}}
|
||||||
|
{{.}}<br>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page-title"> Version: {{.Instance.Version}} </div>
|
||||||
|
|
||||||
|
|
||||||
|
{{template "footer.tmpl"}}
|
||||||
|
{{end}}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
<input type="submit" value="signout" class="btn-link nav-link" title="Signout">
|
<input type="submit" value="signout" class="btn-link nav-link" title="Signout">
|
||||||
</form>
|
</form>
|
||||||
<a class="nav-link" href="/about" accesskey="9" title="About (9)">about</a>
|
<a class="nav-link" href="/about" accesskey="9" title="About (9)">about</a>
|
||||||
|
<a class="nav-link" href="/aboutinstance" title="Info about instance">instance</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue