comments from functions

This commit is contained in:
Michael 2019-06-27 01:41:18 +01:00
parent 1313fa6949
commit 5e6f81a527
3 changed files with 12 additions and 62 deletions

18
api.go
View File

@ -65,7 +65,7 @@ func Category() map[string]interface{} {
return m
}
// Category returns category json data
// CategoryTopic returns category json data
func CategoryTopic(path string) map[string]interface{} {
var topics CategoryTopics
resp, err := Request("/c/" + path)
@ -78,22 +78,6 @@ func CategoryTopic(path string) map[string]interface{} {
return m
}
// About gets json data from about page
func About() map[string]interface{} {
var about AutoGen
resp, err := Request("about")
if err != nil {
m := structs.Map(err)
return m
}
json.Unmarshal(resp, &about)
for i := 0; i < len(about.About.Admins); i++ {
about.About.Admins[i].AvatarTemplate = strings.ReplaceAll(about.About.Admins[i].AvatarTemplate, "{size}", "120")
}
m := structs.Map(about)
return m
}
// Tag returns tags json data
func Tag() map[string]interface{} {
var tags Tags

53
data.go
View File

@ -4,6 +4,7 @@ import (
"time"
)
// Headers API request headers
type Headers struct {
Headers []struct {
Name string `json:"name"`
@ -11,6 +12,7 @@ type Headers struct {
} `json:"headers"`
}
// Options main program options
type Options struct {
Title string `json:"title"`
Description string `json:"description"`
@ -25,7 +27,7 @@ type Options struct {
} `json:"options"`
}
// Contacts list
// Contacts lists contact information
type Contacts struct {
Contacts []struct {
Name string `json:"name"`
@ -34,49 +36,7 @@ type Contacts struct {
} `json:"contacts"`
}
// AutoGen about page data
type AutoGen struct {
About struct {
Stats struct {
TopicCount int `json:"topic_count"`
PostCount int `json:"post_count"`
UserCount int `json:"user_count"`
Topics7Days int `json:"topics_7_days"`
Topics30Days int `json:"topics_30_days"`
Posts7Days int `json:"posts_7_days"`
Posts30Days int `json:"posts_30_days"`
Users7Days int `json:"users_7_days"`
Users30Days int `json:"users_30_days"`
ActiveUsers7Days int `json:"active_users_7_days"`
ActiveUsers30Days int `json:"active_users_30_days"`
LikeCount int `json:"like_count"`
Likes7Days int `json:"likes_7_days"`
Likes30Days int `json:"likes_30_days"`
} `json:"stats"`
Description string `json:"description"`
Title string `json:"title"`
Locale string `json:"locale"`
Version string `json:"version"`
HTTPS bool `json:"https"`
Moderators []struct {
ID int `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
AvatarTemplate string `json:"avatar_template"`
Title string `json:"title"`
LastSeenAt time.Time `json:"last_seen_at"`
} `json:"moderators"`
Admins []struct {
ID int `json:"id"`
Username string `json:"username"`
Name string `json:"name"`
AvatarTemplate string `json:"avatar_template"`
Title string `json:"title"`
LastSeenAt time.Time `json:"last_seen_at"`
} `json:"admins"`
} `json:"about"`
}
// Tags list of forum tags
type Tags struct {
Tags []struct {
ID string `json:"id"`
@ -95,11 +55,12 @@ type TagTopics struct {
} `json:"topic_list"`
}
// TopicsList list of topics from tags
type TopicsList struct {
Topic []Topic
}
// Topic data
// Topic lists data from a forum topic
type Topic struct {
PostStream struct {
Posts []struct {
@ -123,6 +84,7 @@ type Topic struct {
} `json:"details"`
}
// Categories list of categories
type Categories struct {
CategoryList struct {
CanCreateCategory bool `json:"can_create_category"`
@ -170,6 +132,7 @@ type Categories struct {
} `json:"category_list"`
}
// CategoryTopics lists topics from categories
type CategoryTopics struct {
Users []struct {
ID int `json:"id"`

View File

@ -22,6 +22,7 @@ func File(path string) ([]byte, *logger.HTTPError) {
return byteValue, nil
}
// Header get header data from json file
func Header() (headers *Headers, err *logger.HTTPError) {
resp, err := File("./assets/json/headers.json")
if err != nil {
@ -31,6 +32,7 @@ func Header() (headers *Headers, err *logger.HTTPError) {
return
}
// Option get options data from json file
func Option() (options *Options) {
resp, err := File("./assets/json/options.json")
if err != nil {
@ -40,6 +42,7 @@ func Option() (options *Options) {
return
}
// Contact get contact information from json file
func Contact() map[string]interface{} {
var contact Contacts
resp, err := File("./assets/json/contacts.json")