Commit 8b839f9406
Unsigned
Layout: unified · split
app/router.go +3
| @@ -60,6 +60,9 @@ func Router() { | |||
| 60 | } | 60 | } |
| 61 | p, _ := strconv.Atoi(arg("p")) | 61 | p, _ := strconv.Atoi(arg("p")) |
| 62 | skunky.Page = p | 62 | skunky.Page = p |
| 63 | if arg("atom") == "true" { | ||
| 64 | skunky.atom = true | ||
| 65 | } | ||
| 63 | 66 | ||
| 64 | // пути | 67 | // пути |
| 65 | switch path[1] { | 68 | switch path[1] { |
app/util.go +75 −27
| @@ -200,39 +200,87 @@ func (s skunkyart) NavBase(c dlist) string { | |||
| 200 | 200 | ||
| 201 | func (s skunkyart) DeviationList(devs []devianter.Deviation, content ...dlist) string { | 201 | func (s skunkyart) DeviationList(devs []devianter.Deviation, content ...dlist) string { |
| 202 | var list strings.Builder | 202 | var list strings.Builder |
| 203 | list.WriteString(`<div class="content">`) | 203 | if !s.atom { |
| 204 | list.WriteString(`<div class="content">`) | ||
| 205 | } else { | ||
| 206 | list.WriteString(`<?xml version="1.0" encoding="UTF-8"?><feed xmlns:media="http://search.yahoo.com/mrss" xmlns="http://www.w3.org/2005/Atom">`) | ||
| 207 | list.WriteString(`<title>SkunkyArt</title>`) | ||
| 208 | // list.WriteString(`<link rel="alternate" href="HOMEPAGE_URL"/><link href="FEED_URL" rel="self"/>`) | ||
| 209 | } | ||
| 204 | for _, data := range devs { | 210 | for _, data := range devs { |
| 205 | url := devianter.UrlFromMedia(data.Media) | 211 | url := devianter.UrlFromMedia(data.Media) |
| 212 | if s.atom { | ||
| 213 | id := strconv.Itoa(data.ID) | ||
| 214 | list.WriteString(`<entry><author><name>`) | ||
| 215 | list.WriteString(data.Author.Username) | ||
| 216 | list.WriteString(`</name></author><title>`) | ||
| 217 | list.WriteString(data.Title) | ||
| 218 | list.WriteString(`</title><link rel="alternate" type="text/html" href="`) | ||
| 219 | list.WriteString(CFG.Base_uri) | ||
| 220 | list.WriteString("/post/") | ||
| 221 | list.WriteString(data.Author.Username) | ||
| 222 | list.WriteString("/atom-") | ||
| 223 | list.WriteString(id) | ||
| 224 | list.WriteString(`"/><id>`) | ||
| 225 | list.WriteString(id) | ||
| 226 | list.WriteString(`</id><published>`) | ||
| 227 | list.WriteString(data.PublishedTime.UTC().Format("Mon, 02 Jan 2006 15:04:05 -0700")) | ||
| 228 | list.WriteString(`</published>`) | ||
| 229 | list.WriteString(`<media:group><media:title>`) | ||
| 230 | list.WriteString(data.Title) | ||
| 231 | list.WriteString(`</media:title><media:thumbinal url="`) | ||
| 232 | list.WriteString(url) | ||
| 233 | list.WriteString(`"/></media:group><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="`) | ||
| 234 | list.WriteString(data.Url) | ||
| 235 | list.WriteString(`"><img src="`) | ||
| 236 | list.WriteString(url) | ||
| 237 | list.WriteString(`"/></a><p>`) | ||
| 238 | list.WriteString(ParseDescription(data.TextContent)) | ||
| 239 | list.WriteString(`</p></div></content></entry>`) | ||
| 240 | } else { | ||
| 241 | list.WriteString(`<div class="block">`) | ||
| 242 | if url != "" { | ||
| 243 | list.WriteString(`<a title="open/download" href="`) | ||
| 244 | list.WriteString(url) | ||
| 245 | list.WriteString(`"><img src="`) | ||
| 246 | list.WriteString(url) | ||
| 247 | list.WriteString(`" width="15%"></a>`) | ||
| 248 | } else { | ||
| 249 | list.WriteString(`<h1>[ TEXT ]</h1>`) | ||
| 250 | } | ||
| 251 | list.WriteString(`<br><a href="`) | ||
| 252 | list.WriteString("/post/") | ||
| 253 | list.WriteString(data.Author.Username) | ||
| 254 | list.WriteString("/") | ||
| 255 | list.WriteString(data.Url[27:][strings.Index(data.Url[27:], "/art/")+5:]) | ||
| 256 | list.WriteString(`">`) | ||
| 257 | list.WriteString(data.Author.Username) | ||
| 258 | list.WriteString(" - ") | ||
| 259 | list.WriteString(data.Title) | ||
| 206 | 260 | ||
| 207 | list.WriteString(`<a title="open/download" href="`) | 261 | // шильдики нсфв, аи и ежедневного поста |
| 208 | list.WriteString(url) | 262 | if data.NSFW { |
| 209 | list.WriteString(`"><div class="block"><img src="`) | 263 | list.WriteString(` [<span class="nsfw">NSFW</span>]`) |
| 210 | list.WriteString(url) | 264 | } |
| 211 | list.WriteString(`" width="15%"></a><br><a href="`) | 265 | if data.AI { |
| 212 | list.WriteString("/post/") | 266 | list.WriteString(" [🤖]") |
| 213 | list.WriteString(data.Author.Username) | 267 | } |
| 214 | list.WriteString("/") | 268 | if data.DD { |
| 215 | list.WriteString(data.Url[27:][strings.Index(data.Url[27:], "/art/")+5:]) | 269 | list.WriteString(` [<span class="dd">DD</span>]`) |
| 216 | list.WriteString(`">`) | 270 | } |
| 217 | list.WriteString(data.Author.Username) | 271 | |
| 218 | list.WriteString(" - ") | 272 | list.WriteString("</a></div>") |
| 219 | list.WriteString(data.Title) | ||
| 220 | |||
| 221 | // шильдики нсфв, аи и ежедневного поста | ||
| 222 | if data.NSFW { | ||
| 223 | list.WriteString(` [<span class="nsfw">NSFW</span>]`) | ||
| 224 | } | ||
| 225 | if data.AI { | ||
| 226 | list.WriteString(" [🤖]") | ||
| 227 | } | ||
| 228 | if data.DD { | ||
| 229 | list.WriteString(` [<span class="dd">DD</span>]`) | ||
| 230 | } | 273 | } |
| 274 | } | ||
| 231 | 275 | ||
| 232 | list.WriteString("</a></div>") | 276 | if s.atom { |
| 277 | list.WriteString("</feed>") | ||
| 278 | s.Writer.Write([]byte(list.String())) | ||
| 279 | return "" | ||
| 280 | } else { | ||
| 281 | list.WriteString("</div>") | ||
| 282 | list.WriteString(s.NavBase(content[0])) | ||
| 233 | } | 283 | } |
| 234 | list.WriteString("</div>") | ||
| 235 | list.WriteString(s.NavBase(content[0])) | ||
| 236 | 284 | ||
| 237 | return list.String() | 285 | return list.String() |
| 238 | } | 286 | } |
app/wraper.go +11 −3
| @@ -20,6 +20,7 @@ type skunkyart struct { | |||
| 20 | Type rune | 20 | Type rune |
| 21 | Query string | 21 | Query string |
| 22 | Page int | 22 | Page int |
| 23 | atom bool | ||
| 23 | Templates struct { | 24 | Templates struct { |
| 24 | GroupUser struct { | 25 | GroupUser struct { |
| 25 | GR devianter.GRuser | 26 | GR devianter.GRuser |
| @@ -64,6 +65,7 @@ func (s skunkyart) GRUser() { | |||
| 64 | switch s.Type { | 65 | switch s.Type { |
| 65 | case 'a': | 66 | case 'a': |
| 66 | g := group.GR | 67 | g := group.GR |
| 68 | s.atom = false | ||
| 67 | for _, x := range g.Gruser.Page.Modules { | 69 | for _, x := range g.Gruser.Page.Modules { |
| 68 | switch x.Name { | 70 | switch x.Name { |
| 69 | case "about", "group_about": | 71 | case "about", "group_about": |
| @@ -173,7 +175,9 @@ func (s skunkyart) GRUser() { | |||
| 173 | s.ReturnHTTPError(400) | 175 | s.ReturnHTTPError(400) |
| 174 | } | 176 | } |
| 175 | 177 | ||
| 176 | s.ExecuteTemplate("html/gruser.htm", &s) | 178 | if !s.atom { |
| 179 | s.ExecuteTemplate("html/gruser.htm", &s) | ||
| 180 | } | ||
| 177 | } | 181 | } |
| 178 | 182 | ||
| 179 | // посты | 183 | // посты |
| @@ -217,13 +221,17 @@ func (s skunkyart) Deviation(author, postname string) { | |||
| 217 | 221 | ||
| 218 | func (s skunkyart) DD() { | 222 | func (s skunkyart) DD() { |
| 219 | dd := devianter.DailyDeviationsFunc(s.Page) | 223 | dd := devianter.DailyDeviationsFunc(s.Page) |
| 220 | s.ExecuteTemplate("html/list.htm", s.DeviationList(dd.Deviations, dlist{ | 224 | ddparsed := s.DeviationList(dd.Deviations, dlist{ |
| 221 | Pages: 0, | 225 | Pages: 0, |
| 222 | More: dd.HasMore, | 226 | More: dd.HasMore, |
| 223 | })) | 227 | }) |
| 228 | if !s.atom { | ||
| 229 | s.ExecuteTemplate("html/list.htm", &ddparsed) | ||
| 230 | } | ||
| 224 | } | 231 | } |
| 225 | 232 | ||
| 226 | func (s skunkyart) Search() { | 233 | func (s skunkyart) Search() { |
| 234 | s.atom = false | ||
| 227 | var e error | 235 | var e error |
| 228 | ss := &s.Templates.Search | 236 | ss := &s.Templates.Search |
| 229 | switch s.Type { | 237 | switch s.Type { |
atom.xml added +43
| @@ -0,0 +1,43 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <feed xmlns:yt="http://www.youtube.com/xml/schemas/2015" xmlns:media="http://search.yahoo.com/mrss/" xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"> | ||
| 3 | <link rel="self" href="https://inv.clovius.club/feed/channel/UCuxpxCCevIlF-k-K5YU8XPA"/> | ||
| 4 | <id>yt:channel:UCuxpxCCevIlF-k-K5YU8XPA</id> | ||
| 5 | <yt:channelId>UCuxpxCCevIlF-k-K5YU8XPA</yt:channelId> | ||
| 6 | <icon>https://yt3.googleusercontent.com/ytc/AIdro_n7bKr9iusclFjvYw3U8UR74iTCoMcdGTKI3h55SOG8mSsY=s900-c-k-c0x00ffffff-no-rj</icon> | ||
| 7 | <title>Test</title> | ||
| 8 | <link rel="alternate" href="https://skunky.ebloid.ru"/> | ||
| 9 | <author> | ||
| 10 | <name>lost+skunk</name> | ||
| 11 | <uri>https://skunky.ebloid.ru</uri> | ||
| 12 | </author> | ||
| 13 | <image> | ||
| 14 | <url>https://ebloid.ru/_matrix/media/v3/download/ebloid.ru/enfAtfdjzCQMRNBgLXmiURfJ?allow_redirect=true</url> | ||
| 15 | <title>lost+skunk</title> | ||
| 16 | <link rel="self" href="https://skunky.ebloid.ru"/> | ||
| 17 | </image> | ||
| 18 | <entry> | ||
| 19 | <title>Test</title> | ||
| 20 | <link rel="alternate" href="https://2ip.ua"/> | ||
| 21 | <author> | ||
| 22 | <name>lost+skunk</name> | ||
| 23 | <uri>https://skunky.ebloid.ru</uri> | ||
| 24 | </author> | ||
| 25 | <content type="xhtml"> | ||
| 26 | <div xmlns="http://www.w3.org/1999/xhtml"> | ||
| 27 | <a href="https://2ip.ua"> | ||
| 28 | <img src="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/526e735c-e3da-4542-a339-72ccdf827a00/dh3mfuq-5bd6472c-68f4-428d-bb90-8d461fc21410.jpg/v1/fill/w_1920,h_1080/image.gif?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7ImhlaWdodCI6Ijw9MTA4MCIsInBhdGgiOiJcL2ZcLzUyNmU3MzVjLWUzZGEtNDU0Mi1hMzM5LTcyY2NkZjgyN2EwMFwvZGgzbWZ1cS01YmQ2NDcyYy02OGY0LTQyOGQtYmI5MC04ZDQ2MWZjMjE0MTAuanBnIiwid2lkdGgiOiI8PTE5MjAifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6aW1hZ2Uub3BlcmF0aW9ucyJdfQ.S_1DGdd29F5l6Y46Q_bumtGlEEUf_WawZsmF8kBygBs"/> | ||
| 29 | </a> | ||
| 30 | <p>test</p> | ||
| 31 | </div> | ||
| 32 | </content> | ||
| 33 | <published>2024-07-04T00:37:55+00:00</published> | ||
| 34 | <media:group> | ||
| 35 | <media:title>GM Just Announced Their Shutting Down Production in America and Firing Their Workers</media:title> | ||
| 36 | <media:thumbnail url="https://ebloid.ru/_matrix/media/v3/download/ebloid.ru/enfAtfdjzCQMRNBgLXmiURfJ?allow_redirect=true" width="320" height="180"/> | ||
| 37 | <media:description>test</media:description> | ||
| 38 | </media:group> | ||
| 39 | <media:community> | ||
| 40 | <media:statistics views="91247"/> | ||
| 41 | </media:community> | ||
| 42 | </entry> | ||
| 43 | </feed> | ||
html/gruser.htm +2 −2
| @@ -13,8 +13,8 @@ | |||
| 13 | <main> | 13 | <main> |
| 14 | <header> | 14 | <header> |
| 15 | <h1><a href="/">HOME</a> | <a href="/dd">DD</a> | 15 | <h1><a href="/">HOME</a> | <a href="/dd">DD</a> |
| 16 | | <a href="?q={{.Templates.GroupUser.GR.Owner.Username}}&type={{if eq .Type 'a'}}gallery">Gallery</a></h1>{{else}}about">About</a></h1> | 16 | | <a href="?q={{.Templates.GroupUser.GR.Owner.Username}}&type={{if eq .Type 'a'}}gallery">Gallery{{else}}about">About{{end}}</a> |
| 17 | {{end}} | 17 | | <a href="?q={{.Templates.GroupUser.GR.Owner.Username}}&type=gallery&atom=true">RSS</a></h1> |
| 18 | <form method="get" action="/search"> | 18 | <form method="get" action="/search"> |
| 19 | <input type="gallery" name="q" placeholder="Search for ..." autocomplete="off" autocapitalize="none" spellcheck="false"> | 19 | <input type="gallery" name="q" placeholder="Search for ..." autocomplete="off" autocapitalize="none" spellcheck="false"> |
| 20 | <input type="hidden" name="usr" value="{{.Templates.GroupUser.GR.Owner.Username}}"> | 20 | <input type="hidden" name="usr" value="{{.Templates.GroupUser.GR.Owner.Username}}"> |
html/list.htm +1 −1
| @@ -6,7 +6,7 @@ | |||
| 6 | </head> | 6 | </head> |
| 7 | <main> | 7 | <main> |
| 8 | <header> | 8 | <header> |
| 9 | <h1><a href="/">HOME</a> | <a href="/dd">DD</a></h1> | 9 | <h1><a href="/">HOME</a> | <a href="/dd">DD</a> | <a href="?atom=true">RSS</a></h1> |
| 10 | <form method="get" action="/search"> | 10 | <form method="get" action="/search"> |
| 11 | <input type="text" name="q" placeholder="Search for ..." autocomplete="off" autocapitalize="none" spellcheck="false"> | 11 | <input type="text" name="q" placeholder="Search for ..." autocomplete="off" autocapitalize="none" spellcheck="false"> |
| 12 | <select name="type"> | 12 | <select name="type"> |