diff --git a/ArchiveServer.go b/ArchiveServer.go
index 8436d6f..cbcbe21 100644
--- a/ArchiveServer.go
+++ b/ArchiveServer.go
@@ -12,6 +12,7 @@ const (
type ArchiveServer struct {
timezone *time.Location
cfg *Config
+ startup time.Time
}
func NewArchiveServer(cfg *Config) (*ArchiveServer, error) {
@@ -37,5 +38,6 @@ func NewArchiveServer(cfg *Config) (*ArchiveServer, error) {
return &ArchiveServer{
timezone: tz,
cfg: cfg,
+ startup: time.Now(),
}, nil
}
diff --git a/ArchiveState.go b/ArchiveState.go
index 7ce0ee7..a477345 100644
--- a/ArchiveState.go
+++ b/ArchiveState.go
@@ -12,23 +12,34 @@ type ArchiveState struct {
logBestSlug string
query string
queryIsRegex bool
- nonce string
ym YearMonth
page int
highestPage int
}
-func NewArchiveState(svr *ArchiveServer, log *LogSource) (*ArchiveState, error) {
- logBestSlug, err := svr.bestSlugFor(log)
+func NewArchiveState(svr *ArchiveServer) *ArchiveState {
+ return &ArchiveState{svr: svr}
+}
+
+func (this *ArchiveState) selectSource(log *LogSource) error {
+ logBestSlug, err := this.svr.bestSlugFor(log)
if err != nil {
- return nil, err
+ return err
}
- return &ArchiveState{
- svr: svr,
- log: log,
- logBestSlug: logBestSlug,
- }, nil
+ this.log = log
+ this.logBestSlug = logBestSlug
+ return nil
+}
+
+func (this *ArchiveState) renderError(w http.ResponseWriter, msg string) {
+ this.renderTemplate(w, []byte(template.HTMLEscapeString(msg)))
+}
+
+func (this *ArchiveState) renderTemplate(w http.ResponseWriter, body []byte) {
+ this.renderTemplateHead(w)
+ w.Write(body)
+ this.renderTemplateFoot(w)
}
func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
@@ -75,7 +86,7 @@ func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
slug, _ := this.svr.bestSlugFor(&this.svr.cfg.Logs[i])
current := (this.log == &this.svr.cfg.Logs[i])
- w.Write([]byte(``))
+ w.Write([]byte(``))
}
w.Write([]byte(`
@@ -165,7 +176,7 @@ func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
func (this *ArchiveState) renderTemplateFoot(w http.ResponseWriter) {
w.Write([]byte(`
-
+