From e078383e6d93ad0872de5cb0860e050d1bdd5462 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 10 Dec 2017 12:50:19 +1300 Subject: [PATCH] add archiveState.URL() method --- ArchiveState.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ArchiveState.go b/ArchiveState.go index aaa10a6..70e9636 100644 --- a/ArchiveState.go +++ b/ArchiveState.go @@ -35,6 +35,22 @@ func NewArchiveState(svr *ArchiveServer) *ArchiveState { } } +func (this *ArchiveState) URL() string { + if len(this.query) > 0 { + if this.queryIsRegex { + return fmt.Sprintf(`/%s/rx/%s`, this.logBestSlug, url.QueryEscape(this.query)) + } else { + return fmt.Sprintf(`/%s/search/%s`, this.logBestSlug, url.QueryEscape(this.query)) + } + } else { + if this.page == pageNotSet { + return fmt.Sprintf(`/%s/%s/%s`, this.logBestSlug, this.ym.Year, this.ym.Month) + } else { + return fmt.Sprintf(`/%s/%s/%s/page-%d`, this.logBestSlug, this.ym.Year, this.ym.Month, this.page) + } + } +} + func (this *ArchiveState) selectSource(log *LogSource, slug string) { this.log = log this.logBestSlug = slug