add archiveState.URL() method

This commit is contained in:
mappu 2017-12-10 12:50:19 +13:00
parent 8568c4bdc2
commit e078383e6d
1 changed files with 16 additions and 0 deletions

View File

@ -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