package app
import (
"io"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
"time"
"git.macaw.me/skunky/devianter"
)
var wr = io.WriteString
type skunkyart struct {
Writer http.ResponseWriter
Args url.Values
BasePath string
Type rune
Query, QueryRaw string
Page int
Atom bool
Templates struct {
About struct {
Proxy bool
Nsfw bool
}
SomeList string
Deviation struct {
Post devianter.Post
StringTime string
Tags string
Comments string
}
GroupUser struct {
GR devianter.GRuser
Admins string
Group bool
CreationDate string
About struct {
A devianter.About
DescriptionFormatted string
Interests, Social string
Comments string
BG string
BGMeta devianter.Deviation
}
Gallery struct {
Folders string
Pages int
List string
}
}
Search struct {
Content devianter.Search
List string
}
}
}
// var Templates struct {
// Index string
// About string
//
// GRuser string
// Deviation string
// List string
// Search string
// }
// //go:embed ../html/*
// var Templates embed.FS
func (s skunkyart) GRUser() {
if len(s.Query) < 1 {
s.ReturnHTTPError(400)
return
}
var g devianter.Group
g.Name = s.Query
s.Templates.GroupUser.GR = g.GroupFunc()
group := &s.Templates.GroupUser
switch s.Type {
case 'a':
g := group.GR
s.Atom = false
for _, x := range g.Gruser.Page.Modules {
switch x.Name {
case "about", "group_about":
switch g.Owner.Group {
case true:
var about = &x.ModuleData.GroupAbout
group.Group = true
group.CreationDate = x.ModuleData.GroupAbout.FoundatedAt.UTC().String()
group.About.DescriptionFormatted = ParseDescription(about.Description)
case false:
group.About.A = x.ModuleData.About
var about = &group.About.A
group.CreationDate = time.Unix(time.Now().Unix()-x.ModuleData.About.RegDate, 0).UTC().String()
group.About.DescriptionFormatted = ParseDescription(about.Description)
for _, val := range x.ModuleData.About.SocialLinks {
var social strings.Builder
social.WriteString(``)
social.WriteString(val.Value)
social.WriteString("
")
group.About.Social += social.String()
}
for _, val := range x.ModuleData.About.Interests {
var interest strings.Builder
interest.WriteString(val.Label)
interest.WriteString(": ")
interest.WriteString(val.Value)
interest.WriteString("
")
group.About.Interests += interest.String()
}
}
group.About.Comments = s.ParseComments(devianter.CommentsFunc(
strconv.Itoa(group.GR.Gruser.ID),
"",
s.Page,
4,
))
case "cover_deviation":
group.About.BGMeta = x.ModuleData.CoverDeviation.Deviation
group.About.BGMeta.Url = s.ConvertDeviantArtUrlToSkunkyArt(group.About.BGMeta.Url)
group.About.BG = s.ParseMedia(group.About.BGMeta.Media)
case "group_admins":
var htm strings.Builder
for _, z := range x.ModuleData.GroupAdmins.Results {
htm.WriteString(`
`) htm.WriteString(z.User.Username) htm.WriteString(`
`) } group.Admins += htm.String() } } case 'g': folderid, _ := strconv.Atoi(s.Args.Get("folder")) if s.Page == 0 { s.Page++ } gallery := g.Gallery(s.Page, folderid) if folderid > 0 { group.Gallery.List = s.DeviationList(gallery.Content.Results, dlist{ More: gallery.Content.HasMore, }) } else { for _, x := range gallery.Content.Gruser.Page.Modules { if l := len(x.ModuleData.Folders.Results); l != 0 { var folders strings.Builder folders.WriteString(`