diff --git a/pkg/db/db.go b/pkg/db/db.go index 65e58b0..3b15096 100644 --- a/pkg/db/db.go +++ b/pkg/db/db.go @@ -45,9 +45,9 @@ type File struct { func formattedDate(t time.Time, utcOffset int) string { loc, err := time.LoadLocation(fmt.Sprintf("Etc/GMT%+d", utcOffset)) if err != nil { - return t.Format("Jan 2 3:04pm 2006") + return t.Format("3:04pm Jan 2 2006") } - return t.In(loc).Format("Jan 2 3:04pm 2006") + return t.In(loc).Format("3:04pm Jan 2 2006") } func (f File) CreatedDate(utcOffset int) string { diff --git a/template_render.go b/template_render.go index 7fdd6aa..03d66d1 100644 --- a/template_render.go +++ b/template_render.go @@ -484,6 +484,10 @@ func (tr *TemplateRender) handleViewEdit(w http.ResponseWriter, r *http.Request) } log.Debugf("checked domain %s", time.Since(timerStart)) + // check whether want to serve raw + showRaw := r.URL.Query().Get("raw") != "" + log.Debugf("raw page: '%v'", showRaw) + trBytes, err := tr.rwt.fs.GetCacheHTML(pageID) if err == nil { err = json.Unmarshal(trBytes, &tr) @@ -491,6 +495,14 @@ func (tr *TemplateRender) handleViewEdit(w http.ResponseWriter, r *http.Request) log.Error(err) } else { log.Debug("using cache") + if showRaw { + w.Header().Set("Content-Encoding", "gzip") + w.Header().Set("Content-Type", "text/plain") + gz := gzip.NewWriter(w) + defer gz.Close() + _, err = gz.Write([]byte(tr.File.Data)) + return + } w.Header().Set("Content-Encoding", "gzip") w.Header().Set("Content-Type", "text/html") gz := gzip.NewWriter(w) @@ -550,6 +562,15 @@ func (tr *TemplateRender) handleViewEdit(w http.ResponseWriter, r *http.Request) } tr.File = f + if showRaw { + w.Header().Set("Content-Encoding", "gzip") + w.Header().Set("Content-Type", "text/plain") + gz := gzip.NewWriter(w) + defer gz.Close() + _, err = gz.Write([]byte(tr.File.Data)) + return + } + // get a specific version version := r.URL.Query().Get("version") if version != "" { diff --git a/templates/header.html b/templates/header.html index 98250b9..06e3acf 100644 --- a/templates/header.html +++ b/templates/header.html @@ -204,7 +204,7 @@ cursor: pointer; } .smaller { - font-size: 70%; + font-size: 85%; } .grayed { @@ -223,7 +223,9 @@ /* rwtxt specific */ - +summary { + margin-bottom: 0.5em; +} textarea { background: rgb(253, 253, 253); width: 100%; diff --git a/templates/list.html b/templates/list.html index f0a332d..2209b2d 100644 --- a/templates/list.html +++ b/templates/list.html @@ -6,13 +6,19 @@ New page{{end}}

{{.NumResults}} results for '{{.Search}}'

Currently in the {{.Domain}} domain.

- {{range .Files}} -

- {{.Slug}} - {{ if $.RWTxtConfig.OrderByCreated}}{{.CreatedDate $.UTCOffset}}{{else}}{{.ModifiedDate $.UTCOffset}}{{end}} - -

{{.DataHTML}}
-

- {{end}} + +
+ {{range .Files}} +
+
+ {{.Slug}} +
+
+ {{ if $.RWTxtConfig.OrderByCreated}}{{.CreatedDate $.UTCOffset}}{{else}}{{.ModifiedDate $.UTCOffset}}{{end}} +
+ {{with .DataHTML}}
{{.}}
{{end}} +
+ {{end}} +
{{template "footer" .}} \ No newline at end of file diff --git a/templates/main.html b/templates/main.html index e5fcdf2..caac7ba 100644 --- a/templates/main.html +++ b/templates/main.html @@ -43,32 +43,39 @@

{{if eq .Domain "public"}}Welcome{{else}}{{.Domain}}{{end}}

{{ if .Files }}

Most recent (all posts)

- + {{end}} {{ $length := len .MostActiveList }}{{ if ge $length 8 }} -

Most edited

- + {{end}} {{end}} {{ if and (.SignedIn) (ne .Domain "public")}} +
Options
diff --git a/templates/viewedit.html b/templates/viewedit.html index 0bbdded..9201985 100644 --- a/templates/viewedit.html +++ b/templates/viewedit.html @@ -15,11 +15,15 @@



- /{{.Domain}}/{{.File.ID}}
- {{.File.ModifiedDate .UTCOffset }}
- {{.File.Views}} views
{{ if (eq .Domain "public") }}{{else}}{{ if .SimilarFiles}} - Related: {{ range .SimilarFiles }}{{.Slug}} {{end}} - {{end}}{{end}} +
+ {{.File.ModifiedDate .UTCOffset }} + /{{.Domain}}/{{.File.ID}}
+ {{.File.Views}} views
+ +
+
{{ end }}