Simplify
This commit is contained in:
parent
5d290410ee
commit
5265ac59b1
3 changed files with 8 additions and 10 deletions
|
@ -181,7 +181,7 @@ func newIMAPBaseRenderData(ctx *alps.Context,
|
||||||
|
|
||||||
var categorized CategorizedMailboxes
|
var categorized CategorizedMailboxes
|
||||||
|
|
||||||
for i, _ := range mailboxes {
|
for i := range mailboxes {
|
||||||
// Populate unseen & active states
|
// Populate unseen & active states
|
||||||
if active != nil && mailboxes[i].Name == active.Name {
|
if active != nil && mailboxes[i].Name == active.Name {
|
||||||
mailboxes[i].Unseen = int(active.Unseen)
|
mailboxes[i].Unseen = int(active.Unseen)
|
||||||
|
@ -403,6 +403,9 @@ type MessageRenderData struct {
|
||||||
|
|
||||||
func handleGetPart(ctx *alps.Context, raw bool) error {
|
func handleGetPart(ctx *alps.Context, raw bool) error {
|
||||||
_, uid, err := parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid"))
|
_, uid, err := parseMboxAndUid(ctx.Param("mbox"), ctx.Param("uid"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
ibase, err := newIMAPBaseRenderData(ctx, alps.NewBaseRenderData(ctx))
|
ibase, err := newIMAPBaseRenderData(ctx, alps.NewBaseRenderData(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -468,9 +471,8 @@ func handleGetPart(ctx *alps.Context, raw bool) error {
|
||||||
|
|
||||||
if len(partPath) == 0 {
|
if len(partPath) == 0 {
|
||||||
return part.WriteTo(ctx.Response())
|
return part.WriteTo(ctx.Response())
|
||||||
} else {
|
|
||||||
return ctx.Stream(http.StatusOK, mimeType, part.Body)
|
|
||||||
}
|
}
|
||||||
|
return ctx.Stream(http.StatusOK, mimeType, part.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
view, err := viewMessagePart(ctx, msg, part)
|
view, err := viewMessagePart(ctx, msg, part)
|
||||||
|
|
|
@ -19,9 +19,7 @@ var templateFuncs = template.FuncMap{
|
||||||
"tuple": func(values ...interface{}) []interface{} {
|
"tuple": func(values ...interface{}) []interface{} {
|
||||||
return values
|
return values
|
||||||
},
|
},
|
||||||
"pathescape": func(s string) string {
|
"pathescape": url.PathEscape,
|
||||||
return url.PathEscape(s)
|
|
||||||
},
|
|
||||||
"formatdate": func(t time.Time) string {
|
"formatdate": func(t time.Time) string {
|
||||||
return t.Format("Mon Jan 02 15:04")
|
return t.Format("Mon Jan 02 15:04")
|
||||||
},
|
},
|
||||||
|
@ -47,9 +45,7 @@ var templateFuncs = template.FuncMap{
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"join": func(l []string, sep string) string {
|
"join": strings.Join,
|
||||||
return strings.Join(l, sep)
|
|
||||||
},
|
|
||||||
"formatinputdate": func(t time.Time) string {
|
"formatinputdate": func(t time.Time) string {
|
||||||
if t.IsZero() {
|
if t.IsZero() {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
@ -134,7 +134,7 @@ func registerRoutes(p *alps.GoPlugin, u *url.URL) {
|
||||||
var dates [7 * 6]time.Time
|
var dates [7 * 6]time.Time
|
||||||
initialDate := start.UTC()
|
initialDate := start.UTC()
|
||||||
initialDate = initialDate.AddDate(0, 0, -int(initialDate.Weekday()))
|
initialDate = initialDate.AddDate(0, 0, -int(initialDate.Weekday()))
|
||||||
for i := 0; i < len(dates); i += 1 {
|
for i := 0; i < len(dates); i++ {
|
||||||
dates[i] = initialDate
|
dates[i] = initialDate
|
||||||
initialDate = initialDate.AddDate(0, 0, 1)
|
initialDate = initialDate.AddDate(0, 0, 1)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue