Commit 2f0ab0ec authored by Ronny Bangsund's avatar Ronny Bangsund

Expiry improved.

-Option defaults to a day
-Cookie is saved to keep the last time used
parent 589c3509
......@@ -15,9 +15,9 @@
{{end}}
<form name="scrap" style="position:relative;left:-9px;top:0;" method="post" action="/submit">
<select name="expiry" style="position:relative; left:10px; top:0;">
<option value="hour" >An hour</option>
<option value="day" >A day</option>
<option value="week" >A week</option>
<option {{if eq "hour" .Expiry}}selected="selected" {{end}}value="hour" >An hour</option>
<option {{if eq "day" .Expiry}}selected="selected" {{end}}value="day" >A day</option>
<option {{if eq "week" .Expiry}}selected="selected" {{end}}value="week" >A week</option>
</select>
<select name="language" style="position:relative;left:10px;top:0;">
{{with .}}{{$x := .Fave}}
......
......@@ -14,6 +14,7 @@ type IndexPage struct {
Languages map[string]string
View bool
Language string
Expiry string
Fave string
Content string
Username string
......@@ -55,6 +56,11 @@ func get_index(ctx *web.Context, arg string) {
if err == nil {
fave = cookie.Value
}
expiry := "day"
cookie, err = ctx.Request.Cookie("expirecookie")
if err == nil {
expiry = cookie.Value
}
buildLinks()
title := cfg.Main.Sitename
name := cfg.Main.Sitename
......@@ -74,6 +80,7 @@ func get_index(ctx *web.Context, arg string) {
Languages: languages,
View: view,
Language: lang,
Expiry: expiry,
Fave: fave,
Content: s.Content,
Username: user,
......@@ -97,6 +104,10 @@ func post_scrap(ctx *web.Context) {
ctx.SetCookie(web.NewCookie("langcookie", lang, 1209600))
content := p["content"]
expiry := sane(p["expiry"])
if expiry != "" {
ctx.SetCookie(web.NewCookie("expirecookie", expiry, 1209600))
}
info("COOKIE! %s", expiry)
when := int64(0)
now := time.Now().Unix()
if expiry != "burn" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment