From 8b839f94063704782872cc11251975cfeae4584c Mon Sep 17 00:00:00 2001 From: lost+skunk Date: Fri, 5 Jul 2024 11:08:32 +0300 Subject: временная реализация RSS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/router.go | 3 ++ app/util.go | 102 ++++++++++++++++++++++++++++++++++++++++++---------------- app/wraper.go | 14 ++++++-- 3 files changed, 89 insertions(+), 30 deletions(-) (limited to 'app') diff --git a/app/router.go b/app/router.go index 4da2f7d..d7f48b8 100644 --- a/app/router.go +++ b/app/router.go @@ -60,6 +60,9 @@ func Router() { } p, _ := strconv.Atoi(arg("p")) skunky.Page = p + if arg("atom") == "true" { + skunky.atom = true + } // пути switch path[1] { diff --git a/app/util.go b/app/util.go index cda0ffc..0d36fd8 100644 --- a/app/util.go +++ b/app/util.go @@ -200,39 +200,87 @@ func (s skunkyart) NavBase(c dlist) string { func (s skunkyart) DeviationList(devs []devianter.Deviation, content ...dlist) string { var list strings.Builder - list.WriteString(`
`) + if !s.atom { + list.WriteString(`
`) + } else { + list.WriteString(``) + list.WriteString(`SkunkyArt`) + // list.WriteString(``) + } for _, data := range devs { url := devianter.UrlFromMedia(data.Media) + if s.atom { + id := strconv.Itoa(data.ID) + list.WriteString(``) + list.WriteString(data.Author.Username) + list.WriteString(``) + list.WriteString(data.Title) + list.WriteString(``) + list.WriteString(id) + list.WriteString(``) + list.WriteString(data.PublishedTime.UTC().Format("Mon, 02 Jan 2006 15:04:05 -0700")) + list.WriteString(``) + list.WriteString(``) + list.WriteString(data.Title) + list.WriteString(`

`) + list.WriteString(ParseDescription(data.TextContent)) + list.WriteString(`

`) + } else { + list.WriteString(`") + if s.atom { + list.WriteString("
") + s.Writer.Write([]byte(list.String())) + return "" + } else { + list.WriteString("
") + list.WriteString(s.NavBase(content[0])) } - list.WriteString("
") - list.WriteString(s.NavBase(content[0])) return list.String() } diff --git a/app/wraper.go b/app/wraper.go index f3f025d..757602c 100644 --- a/app/wraper.go +++ b/app/wraper.go @@ -20,6 +20,7 @@ type skunkyart struct { Type rune Query string Page int + atom bool Templates struct { GroupUser struct { GR devianter.GRuser @@ -64,6 +65,7 @@ func (s skunkyart) GRUser() { 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": @@ -173,7 +175,9 @@ func (s skunkyart) GRUser() { s.ReturnHTTPError(400) } - s.ExecuteTemplate("html/gruser.htm", &s) + if !s.atom { + s.ExecuteTemplate("html/gruser.htm", &s) + } } // посты @@ -217,13 +221,17 @@ func (s skunkyart) Deviation(author, postname string) { func (s skunkyart) DD() { dd := devianter.DailyDeviationsFunc(s.Page) - s.ExecuteTemplate("html/list.htm", s.DeviationList(dd.Deviations, dlist{ + ddparsed := s.DeviationList(dd.Deviations, dlist{ Pages: 0, More: dd.HasMore, - })) + }) + if !s.atom { + s.ExecuteTemplate("html/list.htm", &ddparsed) + } } func (s skunkyart) Search() { + s.atom = false var e error ss := &s.Templates.Search switch s.Type { -- cgit v1.2.3