попытка реализовать галерею. так сыро потому что мне скоро уезжать
This commit is contained in:
parent
a8633b828f
commit
ed031b3530
@ -52,7 +52,7 @@ func Router() {
|
|||||||
// пути
|
// пути
|
||||||
switch e {
|
switch e {
|
||||||
default:
|
default:
|
||||||
skunky.httperr(404)
|
skunky.ReturnHTTPError(404)
|
||||||
case "/", "":
|
case "/", "":
|
||||||
open_n_send("html/index.htm")
|
open_n_send("html/index.htm")
|
||||||
case "post":
|
case "post":
|
||||||
@ -62,7 +62,7 @@ func Router() {
|
|||||||
skunky.Search()
|
skunky.Search()
|
||||||
case "dd":
|
case "dd":
|
||||||
skunky.DD()
|
skunky.DD()
|
||||||
case "group":
|
case "group_user":
|
||||||
skunky.GRUser()
|
skunky.GRUser()
|
||||||
|
|
||||||
case "media":
|
case "media":
|
||||||
|
198
app/util.go
198
app/util.go
@ -2,11 +2,38 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
"git.macaw.me/skunky/devianter"
|
"git.macaw.me/skunky/devianter"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// парсинг темплейтов
|
||||||
|
func (s skunkyart) ExecuteTemplate(file string, data any) {
|
||||||
|
var buf strings.Builder
|
||||||
|
tmp, e := template.ParseFiles(file)
|
||||||
|
err(e)
|
||||||
|
err(tmp.Execute(&buf, &data))
|
||||||
|
wr(s.Writer, buf.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s skunkyart) ReturnHTTPError(status int) {
|
||||||
|
s.Writer.WriteHeader(status)
|
||||||
|
|
||||||
|
// пострйока с помощью strings.Builder, потому что такой метод быстрее обычного сложения
|
||||||
|
var msg strings.Builder
|
||||||
|
msg.WriteString(`<html><link rel="stylesheet" href="/gui/css/skunky.css" />`)
|
||||||
|
msg.WriteString("<h1>")
|
||||||
|
msg.WriteString(strconv.Itoa(status))
|
||||||
|
msg.WriteString(" - ")
|
||||||
|
msg.WriteString(http.StatusText(status))
|
||||||
|
msg.WriteString("</h1></html>")
|
||||||
|
|
||||||
|
wr(s.Writer, msg.String())
|
||||||
|
}
|
||||||
|
|
||||||
type text struct {
|
type text struct {
|
||||||
TXT string
|
TXT string
|
||||||
from int
|
from int
|
||||||
@ -87,3 +114,174 @@ func ParseDescription(dscr devianter.Text) string {
|
|||||||
|
|
||||||
return parseddescription.String()
|
return parseddescription.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// навигация по страницам
|
||||||
|
type dlist struct {
|
||||||
|
Pages int
|
||||||
|
More bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: на некоротрых артах первая страница может вызывать полное отсутствие панели навигации.
|
||||||
|
func (s skunkyart) NavBase(c dlist) string {
|
||||||
|
// TODO: сделать понятнее
|
||||||
|
// навигация по страницам
|
||||||
|
var list strings.Builder
|
||||||
|
list.WriteString("<br>")
|
||||||
|
p := s.Page
|
||||||
|
|
||||||
|
// функция для генерации ссылок
|
||||||
|
prevrev := func(msg string, page int, onpage bool) {
|
||||||
|
if !onpage {
|
||||||
|
list.WriteString(`<a href="?p=`)
|
||||||
|
list.WriteString(strconv.Itoa(page))
|
||||||
|
if s.Type != 0 {
|
||||||
|
list.WriteString("&type=")
|
||||||
|
list.WriteRune(s.Type)
|
||||||
|
}
|
||||||
|
if s.Query != "" {
|
||||||
|
list.WriteString("&q=")
|
||||||
|
list.WriteString(s.Query)
|
||||||
|
}
|
||||||
|
list.WriteString(`">`)
|
||||||
|
list.WriteString(msg)
|
||||||
|
list.WriteString("</a> ")
|
||||||
|
} else {
|
||||||
|
list.WriteString(strconv.Itoa(page))
|
||||||
|
list.WriteString(" ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// вперёд-назад
|
||||||
|
if p > 1 {
|
||||||
|
prevrev("<= Prev |", p-1, false)
|
||||||
|
} else {
|
||||||
|
p = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.Pages > 0 {
|
||||||
|
// назад
|
||||||
|
for x := p - 6; x < p && x > 0; x++ {
|
||||||
|
prevrev(strconv.Itoa(x), x, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// вперёд
|
||||||
|
for x := p; x <= p+6; x++ {
|
||||||
|
if x == p {
|
||||||
|
prevrev("", x, true)
|
||||||
|
x++
|
||||||
|
}
|
||||||
|
|
||||||
|
if x > p {
|
||||||
|
prevrev(strconv.Itoa(x), x, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// вперёд-назад
|
||||||
|
if c.More {
|
||||||
|
prevrev("| Next =>", p+1, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
return list.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s skunkyart) DeviationList(devs []devianter.Deviation, content ...dlist) string {
|
||||||
|
var list strings.Builder
|
||||||
|
list.WriteString(`<div class="content">`)
|
||||||
|
for _, data := range devs {
|
||||||
|
url := devianter.UrlFromMedia(data.Media)
|
||||||
|
|
||||||
|
list.WriteString(`<a title="open/download" href="`)
|
||||||
|
list.WriteString(url)
|
||||||
|
list.WriteString(`"><div class="block"><img src="`)
|
||||||
|
list.WriteString(url)
|
||||||
|
list.WriteString(`" width="15%"></a><br><a href="`)
|
||||||
|
list.WriteString("/post/")
|
||||||
|
list.WriteString(data.Author.Username)
|
||||||
|
list.WriteString("/")
|
||||||
|
list.WriteString(data.Url[27:][strings.Index(data.Url[27:], "/art/")+5:])
|
||||||
|
list.WriteString(`">`)
|
||||||
|
list.WriteString(data.Author.Username)
|
||||||
|
list.WriteString(" - ")
|
||||||
|
list.WriteString(data.Title)
|
||||||
|
|
||||||
|
// шильдики нсфв, аи и ежедневного поста
|
||||||
|
if data.NSFW {
|
||||||
|
list.WriteString(` [<span class="nsfw">NSFW</span>]`)
|
||||||
|
}
|
||||||
|
if data.AI {
|
||||||
|
list.WriteString(" [🤖]")
|
||||||
|
}
|
||||||
|
if data.DD {
|
||||||
|
list.WriteString(` [<span class="dd">DD</span>]`)
|
||||||
|
}
|
||||||
|
|
||||||
|
list.WriteString("</a></div>")
|
||||||
|
}
|
||||||
|
list.WriteString("</div>")
|
||||||
|
list.WriteString(s.NavBase(content[0]))
|
||||||
|
|
||||||
|
return list.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: первый комментарий не отображается.
|
||||||
|
func (s skunkyart) ParseComments(c devianter.Comments) string {
|
||||||
|
var cmmts strings.Builder
|
||||||
|
replied := make(map[int]string)
|
||||||
|
|
||||||
|
cmmts.WriteString("<details><summary>Comments: <b>")
|
||||||
|
cmmts.WriteString(strconv.Itoa(c.Total))
|
||||||
|
cmmts.WriteString("</b></summary>")
|
||||||
|
for _, x := range c.Thread {
|
||||||
|
replied[x.ID] = x.User.Username
|
||||||
|
cmmts.WriteString(`<div class="msg`)
|
||||||
|
if x.Parent > 0 {
|
||||||
|
cmmts.WriteString(` reply`)
|
||||||
|
}
|
||||||
|
cmmts.WriteString(`"><p id="`)
|
||||||
|
cmmts.WriteString(strconv.Itoa(x.ID))
|
||||||
|
cmmts.WriteString(`"><img src="/media/`)
|
||||||
|
cmmts.WriteString(x.User.Username)
|
||||||
|
cmmts.WriteString(`?type=a" width="30px" height="30px"><a href="/group_user?type=about&q=`)
|
||||||
|
cmmts.WriteString(x.User.Username)
|
||||||
|
cmmts.WriteString(`"><b`)
|
||||||
|
cmmts.WriteString(` class="`)
|
||||||
|
if x.User.Banned {
|
||||||
|
cmmts.WriteString(`banned`)
|
||||||
|
}
|
||||||
|
if x.Author {
|
||||||
|
cmmts.WriteString(`author`)
|
||||||
|
}
|
||||||
|
cmmts.WriteString(`">`)
|
||||||
|
cmmts.WriteString(x.User.Username)
|
||||||
|
cmmts.WriteString("</b></a> ")
|
||||||
|
|
||||||
|
if x.Parent > 0 {
|
||||||
|
cmmts.WriteString(` In reply to <a href="#`)
|
||||||
|
cmmts.WriteString(strconv.Itoa(x.Parent))
|
||||||
|
cmmts.WriteString(`">`)
|
||||||
|
if replied[x.Parent] == "" {
|
||||||
|
cmmts.WriteString("???")
|
||||||
|
} else {
|
||||||
|
cmmts.WriteString(replied[x.Parent])
|
||||||
|
}
|
||||||
|
cmmts.WriteString("</a>")
|
||||||
|
}
|
||||||
|
cmmts.WriteString(" [")
|
||||||
|
cmmts.WriteString(x.Posted.UTC().String())
|
||||||
|
cmmts.WriteString("]<p>")
|
||||||
|
|
||||||
|
cmmts.WriteString(x.Comment)
|
||||||
|
cmmts.WriteString("<p>👍: ")
|
||||||
|
cmmts.WriteString(strconv.Itoa(x.Likes))
|
||||||
|
cmmts.WriteString(" ⏩: ")
|
||||||
|
cmmts.WriteString(strconv.Itoa(x.Replies))
|
||||||
|
cmmts.WriteString("</p></div>\n")
|
||||||
|
}
|
||||||
|
cmmts.WriteString(s.NavBase(dlist{
|
||||||
|
Pages: 0,
|
||||||
|
More: c.HasMore,
|
||||||
|
}))
|
||||||
|
cmmts.WriteString("</details>")
|
||||||
|
return cmmts.String()
|
||||||
|
}
|
||||||
|
362
app/wraper.go
362
app/wraper.go
@ -1,14 +1,13 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.macaw.me/skunky/devianter"
|
"git.macaw.me/skunky/devianter"
|
||||||
@ -17,206 +16,108 @@ import (
|
|||||||
var wr = io.WriteString
|
var wr = io.WriteString
|
||||||
|
|
||||||
type skunkyart struct {
|
type skunkyart struct {
|
||||||
Writer http.ResponseWriter
|
Writer http.ResponseWriter
|
||||||
Args url.Values
|
Args url.Values
|
||||||
Type rune
|
Type rune
|
||||||
Query string
|
Query string
|
||||||
Page int
|
Page int
|
||||||
}
|
Templates struct {
|
||||||
|
GroupUser struct {
|
||||||
|
GR devianter.GRuser
|
||||||
|
CreationDate string
|
||||||
|
|
||||||
// парсинг темплейтов
|
About struct {
|
||||||
func (s skunkyart) exe(file string, data any) {
|
A devianter.About
|
||||||
var buf bytes.Buffer
|
|
||||||
tmp, e := template.ParseFiles(file)
|
|
||||||
err(e)
|
|
||||||
tmp.Execute(&buf, &data)
|
|
||||||
wr(s.Writer, buf.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s skunkyart) httperr(status int) {
|
DescriptionFormatted string
|
||||||
s.Writer.WriteHeader(status)
|
Interests, Social string
|
||||||
|
Comments string
|
||||||
// пострйока с помощью strings.Builder, потому что такой метод быстрее обычного сложения
|
BG string
|
||||||
var msg strings.Builder
|
BGMeta devianter.Deviation
|
||||||
msg.WriteString(`<html><link rel="stylesheet" href="/gui/css/skunky.css" />`)
|
|
||||||
msg.WriteString("<h1>")
|
|
||||||
msg.WriteString(strconv.Itoa(status))
|
|
||||||
msg.WriteString(" - ")
|
|
||||||
msg.WriteString(http.StatusText(status))
|
|
||||||
msg.WriteString("</h1></html>")
|
|
||||||
|
|
||||||
wr(s.Writer, msg.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
// навигация по страницам
|
|
||||||
type dlist struct {
|
|
||||||
Pages int
|
|
||||||
More bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: на некоротрых артах первая страница может вызывать полное отсутствие панели навигации.
|
|
||||||
func (s skunkyart) NavBase(c dlist) string {
|
|
||||||
// TODO: сделать понятнее
|
|
||||||
// навигация по страницам
|
|
||||||
var list strings.Builder
|
|
||||||
list.WriteString("<br>")
|
|
||||||
p := s.Page
|
|
||||||
|
|
||||||
// функция для генерации ссылок
|
|
||||||
prevrev := func(msg string, page int, onpage bool) {
|
|
||||||
if !onpage {
|
|
||||||
list.WriteString(`<a href="?p=`)
|
|
||||||
list.WriteString(strconv.Itoa(page))
|
|
||||||
if s.Type != 0 {
|
|
||||||
list.WriteString("&type=")
|
|
||||||
list.WriteRune(s.Type)
|
|
||||||
}
|
|
||||||
if s.Query != "" {
|
|
||||||
list.WriteString("&q=")
|
|
||||||
list.WriteString(s.Query)
|
|
||||||
}
|
|
||||||
list.WriteString(`">`)
|
|
||||||
list.WriteString(msg)
|
|
||||||
list.WriteString("</a> ")
|
|
||||||
} else {
|
|
||||||
list.WriteString(strconv.Itoa(page))
|
|
||||||
list.WriteString(" ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// вперёд-назад
|
|
||||||
if p > 1 {
|
|
||||||
prevrev("<= Prev |", p-1, false)
|
|
||||||
} else {
|
|
||||||
p = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.Pages > 0 {
|
|
||||||
// назад
|
|
||||||
for x := p - 6; x < p && x > 0; x++ {
|
|
||||||
prevrev(strconv.Itoa(x), x, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// вперёд
|
|
||||||
for x := p; x <= p+6; x++ {
|
|
||||||
if x == p {
|
|
||||||
prevrev("", x, true)
|
|
||||||
x++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if x > p {
|
Gallery struct {
|
||||||
prevrev(strconv.Itoa(x), x, false)
|
Pages int
|
||||||
|
List string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Search struct {
|
||||||
|
Content devianter.Search
|
||||||
|
List string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// вперёд-назад
|
|
||||||
if c.More {
|
|
||||||
prevrev("| Next =>", p+1, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s skunkyart) GRUser() {
|
func (s skunkyart) GRUser() {
|
||||||
var group struct {
|
|
||||||
GR devianter.GRuser
|
|
||||||
CreationDate string
|
|
||||||
|
|
||||||
About struct {
|
|
||||||
A devianter.About
|
|
||||||
|
|
||||||
DescriptionFormatted string
|
|
||||||
Interests string
|
|
||||||
Social string
|
|
||||||
BG devianter.Deviation
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(s.Query) < 1 {
|
if len(s.Query) < 1 {
|
||||||
s.httperr(400)
|
s.ReturnHTTPError(400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var g devianter.Group
|
var g devianter.Group
|
||||||
g.Name = s.Query
|
g.Name = s.Query
|
||||||
group.GR = g.GroupFunc()
|
s.Templates.GroupUser.GR = g.GroupFunc()
|
||||||
|
group := &s.Templates.GroupUser
|
||||||
|
|
||||||
if g := group.GR; !g.Owner.Group {
|
switch s.Type {
|
||||||
for _, x := range g.Gruser.Page.Modules {
|
case 'a':
|
||||||
var about = group.About.A
|
if g := group.GR; !g.Owner.Group {
|
||||||
if x.ModuleData.About.RegDate != 0 {
|
for _, x := range g.Gruser.Page.Modules {
|
||||||
about = x.ModuleData.About
|
switch x.Name {
|
||||||
}
|
case "about":
|
||||||
group.About.DescriptionFormatted = ParseDescription(about.Description)
|
group.About.A = x.ModuleData.About
|
||||||
|
var about = group.About.A
|
||||||
|
group.About.DescriptionFormatted = ParseDescription(about.Description)
|
||||||
|
group.About.Comments = s.ParseComments(devianter.CommentsFunc(
|
||||||
|
strconv.Itoa(group.GR.Gruser.ID),
|
||||||
|
"",
|
||||||
|
s.Page,
|
||||||
|
4,
|
||||||
|
))
|
||||||
|
|
||||||
for _, val := range x.ModuleData.About.Interests {
|
for _, val := range x.ModuleData.About.SocialLinks {
|
||||||
var interest strings.Builder
|
var social strings.Builder
|
||||||
interest.WriteString(val.Label)
|
social.WriteString(`<a target="_blank" href="`)
|
||||||
interest.WriteString(": <b>")
|
social.WriteString(val.Value)
|
||||||
interest.WriteString(val.Value)
|
social.WriteString(`">`)
|
||||||
interest.WriteString("</b><br>")
|
social.WriteString(val.Value)
|
||||||
group.About.Interests += interest.String()
|
social.WriteString("</a><br>")
|
||||||
}
|
group.About.Social += social.String()
|
||||||
|
}
|
||||||
|
|
||||||
for _, val := range x.ModuleData.About.SocialLinks {
|
for _, val := range x.ModuleData.About.Interests {
|
||||||
var social strings.Builder
|
var interest strings.Builder
|
||||||
social.WriteString(`<a target="_blank" href="`)
|
interest.WriteString(val.Label)
|
||||||
social.WriteString(val.Value)
|
interest.WriteString(": <b>")
|
||||||
social.WriteString(`">`)
|
interest.WriteString(val.Value)
|
||||||
social.WriteString(val.Value)
|
interest.WriteString("</b><br>")
|
||||||
social.WriteString("</a><br>")
|
group.About.Interests += interest.String()
|
||||||
group.About.Social += social.String()
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if rd := x.ModuleData.About.RegDate; rd != 0 {
|
if rd := x.ModuleData.About.RegDate; rd != 0 {
|
||||||
group.CreationDate = time.Unix(time.Now().Unix()-rd, 0).UTC().String()
|
group.CreationDate = time.Unix(time.Now().Unix()-rd, 0).UTC().String()
|
||||||
|
}
|
||||||
|
case "cover_deviation":
|
||||||
|
group.About.BGMeta = x.ModuleData.CoverDeviation.Deviation
|
||||||
|
group.About.BG = devianter.UrlFromMedia(group.About.BGMeta.Media)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
case 'g':
|
||||||
|
gallery := g.Gallery(s.Page)
|
||||||
|
fmt.Println(gallery)
|
||||||
|
for _, x := range gallery.Content.Gruser.Page.Modules {
|
||||||
|
group.Gallery.List = s.DeviationList(x.ModuleData.Folder.Deviations, dlist{
|
||||||
|
Pages: x.ModuleData.Folder.Pages,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
s.ReturnHTTPError(400)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.exe("html/gruser.htm", &group)
|
s.ExecuteTemplate("html/gruser.htm", &s)
|
||||||
}
|
|
||||||
|
|
||||||
func (s skunkyart) DeviationList(devs []devianter.Deviation, content ...dlist) string {
|
|
||||||
var list strings.Builder
|
|
||||||
list.WriteString(`<div class="content">`)
|
|
||||||
for _, data := range devs {
|
|
||||||
url := devianter.UrlFromMedia(data.Media)
|
|
||||||
|
|
||||||
list.WriteString(`<a title="open/download" href="`)
|
|
||||||
list.WriteString(url)
|
|
||||||
list.WriteString(`"><div class="block"><img src="`)
|
|
||||||
list.WriteString(url)
|
|
||||||
list.WriteString(`" width="15%"></a><br><a href="`)
|
|
||||||
list.WriteString("/post/")
|
|
||||||
list.WriteString(data.Author.Username)
|
|
||||||
list.WriteString("/")
|
|
||||||
list.WriteString(data.Url[27:][strings.Index(data.Url[27:], "/art/")+5:])
|
|
||||||
list.WriteString(`">`)
|
|
||||||
list.WriteString(data.Author.Username)
|
|
||||||
list.WriteString(" - ")
|
|
||||||
list.WriteString(data.Title)
|
|
||||||
|
|
||||||
// шильдики нсфв, аи и ежедневного поста
|
|
||||||
if data.NSFW {
|
|
||||||
list.WriteString(` [<span class="nsfw">NSFW</span>]`)
|
|
||||||
}
|
|
||||||
if data.AI {
|
|
||||||
list.WriteString(" [🤖]")
|
|
||||||
}
|
|
||||||
if data.DD {
|
|
||||||
list.WriteString(` [<span class="dd">DD</span>]`)
|
|
||||||
}
|
|
||||||
|
|
||||||
list.WriteString("</a></div>")
|
|
||||||
}
|
|
||||||
list.WriteString("</div>")
|
|
||||||
list.WriteString(s.NavBase(content[0]))
|
|
||||||
|
|
||||||
return list.String()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// посты
|
// посты
|
||||||
@ -250,115 +151,52 @@ func (s skunkyart) Deviation(author, postname string) {
|
|||||||
post.Tags += tag.String()
|
post.Tags += tag.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: первый комментарий не отображается.
|
post.Comments = s.ParseComments(devianter.CommentsFunc(id, post.Post.Comments.Cursor, s.Page, 1))
|
||||||
// генерация комментов
|
|
||||||
var cmmts strings.Builder
|
|
||||||
replied := make(map[int]string)
|
|
||||||
c := devianter.CommentsFunc(id, post.Post.Comments.Cursor, s.Page, 1)
|
|
||||||
|
|
||||||
cmmts.WriteString("<details><summary>Comments: <b>")
|
s.ExecuteTemplate("html/deviantion.htm", &post)
|
||||||
cmmts.WriteString(strconv.Itoa(c.Total))
|
|
||||||
cmmts.WriteString("</b></summary>")
|
|
||||||
for _, x := range c.Thread {
|
|
||||||
replied[x.ID] = x.User.Username
|
|
||||||
cmmts.WriteString(`<div class="msg`)
|
|
||||||
if x.Parent > 0 {
|
|
||||||
cmmts.WriteString(` reply`)
|
|
||||||
}
|
|
||||||
cmmts.WriteString(`"><p id="`)
|
|
||||||
cmmts.WriteString(strconv.Itoa(x.ID))
|
|
||||||
cmmts.WriteString(`"><img src="/media/`)
|
|
||||||
cmmts.WriteString(x.User.Username)
|
|
||||||
cmmts.WriteString(`?type=a" width="30px" height="30px"><a href="/user/`)
|
|
||||||
cmmts.WriteString(x.User.Username)
|
|
||||||
cmmts.WriteString(`"><b`)
|
|
||||||
cmmts.WriteString(` class="`)
|
|
||||||
if x.User.Banned {
|
|
||||||
cmmts.WriteString(`banned`)
|
|
||||||
}
|
|
||||||
if x.Author {
|
|
||||||
cmmts.WriteString(`author`)
|
|
||||||
}
|
|
||||||
cmmts.WriteString(`">`)
|
|
||||||
cmmts.WriteString(x.User.Username)
|
|
||||||
cmmts.WriteString("</b></a> ")
|
|
||||||
|
|
||||||
if x.Parent > 0 {
|
|
||||||
cmmts.WriteString(` In reply to <a href="#`)
|
|
||||||
cmmts.WriteString(strconv.Itoa(x.Parent))
|
|
||||||
cmmts.WriteString(`">`)
|
|
||||||
if replied[x.Parent] == "" {
|
|
||||||
cmmts.WriteString("???")
|
|
||||||
} else {
|
|
||||||
cmmts.WriteString(replied[x.Parent])
|
|
||||||
}
|
|
||||||
cmmts.WriteString("</a>")
|
|
||||||
}
|
|
||||||
cmmts.WriteString(" [")
|
|
||||||
cmmts.WriteString(x.Posted.UTC().String())
|
|
||||||
cmmts.WriteString("]<p>")
|
|
||||||
|
|
||||||
cmmts.WriteString(x.Comment)
|
|
||||||
cmmts.WriteString("<p>👍: ")
|
|
||||||
cmmts.WriteString(strconv.Itoa(x.Likes))
|
|
||||||
cmmts.WriteString(" ⏩: ")
|
|
||||||
cmmts.WriteString(strconv.Itoa(x.Replies))
|
|
||||||
cmmts.WriteString("</p></div>\n")
|
|
||||||
}
|
|
||||||
cmmts.WriteString(s.NavBase(dlist{
|
|
||||||
Pages: 0,
|
|
||||||
More: c.HasMore,
|
|
||||||
}))
|
|
||||||
cmmts.WriteString("</details>")
|
|
||||||
|
|
||||||
post.Comments = cmmts.String()
|
|
||||||
|
|
||||||
s.exe("html/deviantion.htm", &post)
|
|
||||||
} else {
|
} else {
|
||||||
s.httperr(400)
|
s.ReturnHTTPError(400)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s skunkyart) DD() {
|
func (s skunkyart) DD() {
|
||||||
dd := devianter.DailyDeviationsFunc(s.Page)
|
dd := devianter.DailyDeviationsFunc(s.Page)
|
||||||
s.exe("html/list.htm", s.DeviationList(dd.Deviations, dlist{
|
s.ExecuteTemplate("html/list.htm", s.DeviationList(dd.Deviations, dlist{
|
||||||
Pages: 0,
|
Pages: 0,
|
||||||
More: dd.HasMore,
|
More: dd.HasMore,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s skunkyart) Search() {
|
func (s skunkyart) Search() {
|
||||||
// тут всё и так понятно
|
var e error
|
||||||
|
ss := &s.Templates.Search
|
||||||
switch s.Type {
|
switch s.Type {
|
||||||
case 'a', 't', 'g':
|
case 'a', 't':
|
||||||
var srch struct {
|
ss.Content, e = devianter.SearchFunc(s.Query, s.Page, s.Type)
|
||||||
Search devianter.Search
|
case 'g':
|
||||||
List string
|
ss.Content, e = devianter.SearchFunc(s.Query, s.Page, s.Type, s.Args.Get("usr"))
|
||||||
}
|
|
||||||
|
|
||||||
var e error
|
|
||||||
srch.Search, e = devianter.SearchFunc(s.Query, s.Page, s.Type)
|
|
||||||
err(e)
|
|
||||||
srch.List = s.DeviationList(srch.Search.Results, dlist{
|
|
||||||
Pages: srch.Search.Pages,
|
|
||||||
More: srch.Search.HasMore,
|
|
||||||
})
|
|
||||||
|
|
||||||
s.exe("html/search.htm", &srch)
|
|
||||||
default:
|
default:
|
||||||
s.httperr(400)
|
s.ReturnHTTPError(400)
|
||||||
}
|
}
|
||||||
|
err(e)
|
||||||
|
|
||||||
|
ss.List = s.DeviationList(ss.Content.Results, dlist{
|
||||||
|
Pages: ss.Content.Pages,
|
||||||
|
More: ss.Content.HasMore,
|
||||||
|
})
|
||||||
|
|
||||||
|
s.ExecuteTemplate("html/search.htm", &s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s skunkyart) Emojitar(name string) {
|
func (s skunkyart) Emojitar(name string) {
|
||||||
if name != "" && (s.Type == 'a' || s.Type == 'e') {
|
if name != "" && (s.Type == 'a' || s.Type == 'e') {
|
||||||
ae, e := devianter.AEmedia(name, s.Type)
|
ae, e := devianter.AEmedia(name, s.Type)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
s.httperr(404)
|
s.ReturnHTTPError(404)
|
||||||
println(e.Error())
|
println(e.Error())
|
||||||
}
|
}
|
||||||
wr(s.Writer, ae)
|
wr(s.Writer, ae)
|
||||||
} else {
|
} else {
|
||||||
s.httperr(400)
|
s.ReturnHTTPError(400)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,4 +83,11 @@ form input, button, select {
|
|||||||
.block p {
|
.block p {
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
.ubg {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.ubg img {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</header>
|
</header>
|
||||||
<figure>
|
<figure>
|
||||||
<img src="/media/{{.Post.Deviation.Author.Username}}?type=a" width="30px">
|
<img src="/media/{{.Post.Deviation.Author.Username}}?type=a" width="30px">
|
||||||
<span><strong><a href="/user/{{.Post.Deviation.Author.Username}}">{{.Post.Deviation.Author.Username}}</a></strong> — {{if (.Post.Deviation.DD)}}
|
<span><strong><a href="/group_user?type=about&q={{.Post.Deviation.Author.Username}}">{{.Post.Deviation.Author.Username}}</a></strong> — {{if (.Post.Deviation.DD)}}
|
||||||
<span class="dd" title="Daily Deviation!"><b>{{.Post.Deviation.Title}}</b></span>
|
<span class="dd" title="Daily Deviation!"><b>{{.Post.Deviation.Title}}</b></span>
|
||||||
{{else}}{{.Post.Deviation.Title}}{{end}}
|
{{else}}{{.Post.Deviation.Title}}{{end}}
|
||||||
{{if (ne .Post.Deviation.License "none")}}<mark title="License">{{.Post.Deviation.License}}</mark>{{end}} {{if (.Post.Deviation.AI)}}[🤖]{{end}}
|
{{if (ne .Post.Deviation.License "none")}}<mark title="License">{{.Post.Deviation.License}}</mark>{{end}} {{if (.Post.Deviation.AI)}}[🤖]{{end}}
|
||||||
|
@ -1,43 +1,74 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SkunkyArt | {{.GR.Owner.Username}}</title>
|
<title>SkunkyArt |
|
||||||
|
{{if eq .Type 'a'}}
|
||||||
|
{{.Templates.GroupUser.GR.Owner.Username}}
|
||||||
|
{{else}}
|
||||||
|
gallery of {{.Templates.GroupUser.GR.Owner.Username}}
|
||||||
|
{{end}}
|
||||||
|
</title>
|
||||||
<link rel="stylesheet" href="/gui/css/skunky.css">
|
<link rel="stylesheet" href="/gui/css/skunky.css">
|
||||||
</head>
|
</head>
|
||||||
<main>
|
<main>
|
||||||
<header>
|
<header>
|
||||||
<h1><a href="/">HOME</a> | <a href="/dd">DD</a></h1>
|
<h1><a href="/">HOME</a> | <a href="/dd">DD</a>
|
||||||
<form method="get" action="/search">
|
| <a href="?q={{.Templates.GroupUser.GR.Owner.Username}}&type={{if eq .Type 'a'}}gallery">Gallery</a></h1>{{else}}about">About</a></h1>
|
||||||
<input type="text" name="q" placeholder="Search for ..." autocomplete="off" autocapitalize="none" spellcheck="false">
|
{{end}}
|
||||||
|
<form method="get" action="/search">
|
||||||
|
<input type="gallery" name="q" placeholder="Search for ..." autocomplete="off" autocapitalize="none" spellcheck="false">
|
||||||
|
<input type="hidden" name="usr" value="{{.Templates.GroupUser.GR.Owner.Username}}">
|
||||||
<select name="type">
|
<select name="type">
|
||||||
<option value="all">All</option>
|
<option value="all">All</option>
|
||||||
<option value="tag">Tag</option>
|
<option value="tag">Tag</option>
|
||||||
|
<option value="gallery">Gallery</option>
|
||||||
</select>
|
</select>
|
||||||
<button type="submit">Search!</button>
|
<button type="submit">Search!</button>
|
||||||
</form>
|
</form>
|
||||||
</header>
|
</header>
|
||||||
<img src="/media/{{.GR.Owner.Username}}?type=a" width="30px" height="30px"> <b>{{.GR.Owner.Username}}</b>
|
{{if eq .Type 'a'}}
|
||||||
{{if (eq .About.A.Gender "male")}}
|
{{if ne .Templates.GroupUser.About.BG ""}}
|
||||||
♂️
|
<a href="{{.Templates.GroupUser.About.BGMeta.Url}}" class="ubg"><img title="{{if ne .Templates.GroupUser.GR.Owner.Username .Templates.GroupUser.About.BGMeta.Author.Username}}
|
||||||
|
{{.Templates.GroupUser.About.BGMeta.Author.Username}} - {{end}}{{.Templates.GroupUser.About.BGMeta.Title}}" src="{{.Templates.GroupUser.About.BG}}"></a>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
<img src="/media/{{.Templates.GroupUser.GR.Owner.Username}}?type=a" width="30px" height="30px"> <b>{{.Templates.GroupUser.GR.Owner.Username}}</b>
|
||||||
|
{{if (eq .Templates.GroupUser.About.A.Gender "male")}}
|
||||||
|
♂️
|
||||||
|
{{end}}
|
||||||
|
{{if (eq .Templates.GroupUser.About.A.Gender "female")}}
|
||||||
|
♀️
|
||||||
|
{{end}}
|
||||||
|
[<span title="UID">{{.Templates.GroupUser.GR.Gruser.ID}}</span>]
|
||||||
|
[<span title="Registration date">{{.Templates.GroupUser.CreationDate}}</span>]
|
||||||
|
{{if ne .Templates.GroupUser.GR.Extra.Tag ""}}
|
||||||
|
<i title="User's Tag">"{{.Templates.GroupUser.GR.Extra.Tag}}"</i>{{end}} (<b>{{.Templates.GroupUser.About.A.Country}}</b>)
|
||||||
|
|
||||||
|
<h3 id="stats"><a href="#stats">#</a> Statistics</h3>
|
||||||
|
<p>Favourites: <b>{{.Templates.GroupUser.GR.Extra.Stats.Favourites}}</b>; Deviations: <b>{{.Templates.GroupUser.GR.Extra.Stats.Deviations}}</b>; Watchers: <b>{{.Templates.GroupUser.GR.Extra.Stats.Watchers}}</b>
|
||||||
|
<p>Watching: <b>{{.Templates.GroupUser.GR.Extra.Stats.Watching}}</b>; Pageviews: <b>{{.Templates.GroupUser.GR.Extra.Stats.Pageviews}}</b>; Comments Made: <b>{{.Templates.GroupUser.GR.Extra.Stats.CommentsMade}}</b>; Friends: <b>{{.Templates.GroupUser.GR.Extra.Stats.Friends}}</b></p>
|
||||||
|
|
||||||
|
{{if ne .Templates.GroupUser.About.Interests ""}}
|
||||||
|
<h3 id="interests"><a href="#interests">#</a> Interests</h3>
|
||||||
|
{{.Templates.GroupUser.About.Interests}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if ne .Templates.GroupUser.About.Social ""}}
|
||||||
|
<h3 id="social"><a href="#social">#</a> Social Links</h3>
|
||||||
|
{{.Templates.GroupUser.About.Social}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{if ne .Templates.GroupUser.About.DescriptionFormatted ""}}
|
||||||
|
<h3 id="about"><a href="#about">#</a> About me</h3>
|
||||||
|
{{.Templates.GroupUser.About.DescriptionFormatted}}
|
||||||
|
{{end}}
|
||||||
|
{{if ne .Templates.GroupUser.About.Comments ""}}
|
||||||
|
<br>
|
||||||
|
<h3 id="comments"><a href="#comments">#</a> Comments</h3>
|
||||||
|
{{.Templates.GroupUser.About.Comments}}
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
{{.Templates.GroupUser.Gallery.List}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if (eq .About.A.Gender "female")}}
|
|
||||||
♀️
|
|
||||||
{{end}}
|
|
||||||
[<span title="UID">{{.GR.Gruser.ID}}</span>]
|
|
||||||
[<span title="Registration date">{{.CreationDate}}</span>]
|
|
||||||
<i title="User's Tag">"{{.GR.Extra.Tag}}"</i>
|
|
||||||
|
|
||||||
<h3 id="stats"><a href="#stats">#</a> Statistics</h3>
|
|
||||||
<p>Favourites: <b>{{.GR.Extra.Stats.Favourites}}</b>; Deviations: <b>{{.GR.Extra.Stats.Deviations}}</b>; Watchers: <b>{{.GR.Extra.Stats.Watchers}}</b>
|
|
||||||
<p>Watching: <b>{{.GR.Extra.Stats.Watching}}</b>; Pageviews: <b>{{.GR.Extra.Stats.Pageviews}}</b>; Comments Made: <b>{{.GR.Extra.Stats.CommentsMade}}</b>; Friends: <b>{{.GR.Extra.Stats.Friends}}</b></p>
|
|
||||||
|
|
||||||
<h3 id="interests"><a href="#interests">#</a> Interests</h3>
|
|
||||||
{{.About.Interests}}
|
|
||||||
|
|
||||||
<h3 id="social"><a href="#social">#</a> Social Links</h3>
|
|
||||||
{{.About.Social}}
|
|
||||||
|
|
||||||
<h3 id="about"><a href="#about">#</a> About me</h3>
|
|
||||||
{{.About.DescriptionFormatted}}
|
|
||||||
</main>
|
</main>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SkunkyArt | Search</title>
|
<title>SkunkyArt | Search "{{.Query}}"</title>
|
||||||
<link rel="stylesheet" href="/gui/css/skunky.css">
|
<link rel="stylesheet" href="/gui/css/skunky.css">
|
||||||
</head>
|
</head>
|
||||||
<main>
|
<main>
|
||||||
@ -16,11 +16,11 @@
|
|||||||
<button type="submit">Search!</button>
|
<button type="submit">Search!</button>
|
||||||
</form>
|
</form>
|
||||||
</header>
|
</header>
|
||||||
{{if (ne .List "")}}
|
{{if ne .Templates.Search.List ""}}
|
||||||
{{if (ne .Search.Total 0)}}
|
{{if ne .Templates.Search.Content.Total 0}}
|
||||||
<h1>Total resuls: {{.Search.Total}}</h1>
|
<h1>Total resuls: {{.Templates.Search.Content.Total}}</h1>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{.List}}
|
{{.Templates.Search.List}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>No results :(</p>
|
<p>No results :(</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Loading…
Reference in New Issue
Block a user