Use neutral original labels in viewer
This commit is contained in:
parent
cebb6e6ab2
commit
3849cc75cc
1 changed files with 21 additions and 11 deletions
|
|
@ -112,8 +112,8 @@ func renderViewerTree(w http.ResponseWriter) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
found = true
|
found = true
|
||||||
source := sourceAccountLabel(account)
|
source := sourceDisplayLabel(account)
|
||||||
fmt.Fprintf(w, `<div class="tree-node account">%s</div>`, html.EscapeString(source))
|
fmt.Fprintf(w, `<div class="tree-node account">%s</div>`, html.EscapeString(sourceDisplayLabel(account)))
|
||||||
for _, path := range mboxes {
|
for _, path := range mboxes {
|
||||||
folder := strings.TrimSuffix(filepath.Base(path), ".mbox")
|
folder := strings.TrimSuffix(filepath.Base(path), ".mbox")
|
||||||
fmt.Fprintf(w, `<a class="tree-node" href="#" hx-get="/view?source=%s&folder=%s" hx-target="#list" hx-swap="innerHTML">%s</a>`,
|
fmt.Fprintf(w, `<a class="tree-node" href="#" hx-get="/view?source=%s&folder=%s" hx-target="#list" hx-swap="innerHTML">%s</a>`,
|
||||||
|
|
@ -141,13 +141,13 @@ func renderMessageList(w http.ResponseWriter, account, folder, q string) {
|
||||||
if q != "" {
|
if q != "" {
|
||||||
filtered = filterEntries(path, entries, q)
|
filtered = filterEntries(path, entries, q)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, `<div class="pane-head">%s / %s (%d)</div>`, html.EscapeString(sourceAccountLabel(account)), html.EscapeString(folder), len(filtered))
|
fmt.Fprintf(w, `<div class="pane-head">%s / %s (%d)</div>`, html.EscapeString(sourceDisplayLabel(account)), html.EscapeString(folder), len(filtered))
|
||||||
fmt.Fprintf(w, `<form class="searchbar" hx-get="/view" hx-target="#list" hx-swap="innerHTML">
|
fmt.Fprintf(w, `<form class="searchbar" hx-get="/view" hx-target="#list" hx-swap="innerHTML">
|
||||||
<input type="hidden" name="source" value="%s">
|
<input type="hidden" name="source" value="%s">
|
||||||
<input type="hidden" name="folder" value="%s">
|
<input type="hidden" name="folder" value="%s">
|
||||||
<input class="input search-input" type="search" name="q" value="%s" placeholder="Suchen">
|
<input class="input search-input" type="search" name="q" value="%s" placeholder="Suchen">
|
||||||
<button class="btn secondary search-btn" type="submit">Suchen</button>
|
<button class="btn secondary search-btn" type="submit">Suchen</button>
|
||||||
</form>`, html.EscapeString(sourceAccountLabel(account)), html.EscapeString(folder), html.EscapeString(q))
|
</form>`, html.EscapeString(sourceDisplayLabel(account)), html.EscapeString(folder), html.EscapeString(q))
|
||||||
for _, entry := range filtered {
|
for _, entry := range filtered {
|
||||||
subject := entry.Subject
|
subject := entry.Subject
|
||||||
if subject == "" {
|
if subject == "" {
|
||||||
|
|
@ -158,7 +158,7 @@ func renderMessageList(w http.ResponseWriter, account, folder, q string) {
|
||||||
from = "(ohne Absender)"
|
from = "(ohne Absender)"
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, `<a class="msg-row" href="#" hx-get="/view/message?source=%s&folder=%s&index=%d" hx-include="#target-account-select" hx-target="#read" hx-swap="innerHTML"><span class="msg-from">%s</span><span class="msg-subject">%s</span><span class="msg-date">%s</span></a>`,
|
fmt.Fprintf(w, `<a class="msg-row" href="#" hx-get="/view/message?source=%s&folder=%s&index=%d" hx-include="#target-account-select" hx-target="#read" hx-swap="innerHTML"><span class="msg-from">%s</span><span class="msg-subject">%s</span><span class="msg-date">%s</span></a>`,
|
||||||
urlEsc(sourceAccountLabel(account)), urlEsc(folder), entry.Index,
|
urlEsc(sourceDisplayLabel(account)), urlEsc(folder), entry.Index,
|
||||||
html.EscapeString(from), html.EscapeString(subject), html.EscapeString(entry.Date))
|
html.EscapeString(from), html.EscapeString(subject), html.EscapeString(entry.Date))
|
||||||
}
|
}
|
||||||
if len(entries) == 0 {
|
if len(entries) == 0 {
|
||||||
|
|
@ -341,7 +341,7 @@ func renderTargetAccountSelect(account, folder, selected string, index int) stri
|
||||||
<input type="hidden" name="folder" value="%s">
|
<input type="hidden" name="folder" value="%s">
|
||||||
<input type="hidden" name="index" value="%d">
|
<input type="hidden" name="index" value="%d">
|
||||||
<select id="target-account-select" name="target_account" class="target-select">
|
<select id="target-account-select" name="target_account" class="target-select">
|
||||||
<option value="">Automatisch</option>`, html.EscapeString(sourceAccountLabel(account)), html.EscapeString(folder), index)
|
<option value="">Automatisch</option>`, html.EscapeString(sourceDisplayLabel(account)), html.EscapeString(folder), index)
|
||||||
for _, opt := range options {
|
for _, opt := range options {
|
||||||
attr := ""
|
attr := ""
|
||||||
if opt.Value == selected {
|
if opt.Value == selected {
|
||||||
|
|
@ -354,8 +354,9 @@ func renderTargetAccountSelect(account, folder, selected string, index int) stri
|
||||||
}
|
}
|
||||||
|
|
||||||
type viewerAccount struct {
|
type viewerAccount struct {
|
||||||
Name string
|
Name string
|
||||||
SourceLabel string
|
SourceLabel string
|
||||||
|
DisplayLabel string
|
||||||
}
|
}
|
||||||
|
|
||||||
type targetAccountOption struct {
|
type targetAccountOption struct {
|
||||||
|
|
@ -380,13 +381,20 @@ func viewerAccounts() []viewerAccount {
|
||||||
}
|
}
|
||||||
a := labels[entry.Name()]
|
a := labels[entry.Name()]
|
||||||
if a.Name == "" {
|
if a.Name == "" {
|
||||||
a = viewerAccount{Name: entry.Name(), SourceLabel: entry.Name()}
|
a = viewerAccount{Name: entry.Name(), SourceLabel: entry.Name(), DisplayLabel: "Original"}
|
||||||
}
|
}
|
||||||
out = append(out, a)
|
out = append(out, a)
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sourceDisplayLabel(mboxDir string) string {
|
||||||
|
if a := accountLabels()[mboxDir]; a.DisplayLabel != "" {
|
||||||
|
return a.DisplayLabel
|
||||||
|
}
|
||||||
|
return "Original"
|
||||||
|
}
|
||||||
|
|
||||||
func sourceAccountLabel(mboxDir string) string {
|
func sourceAccountLabel(mboxDir string) string {
|
||||||
if a := accountLabels()[mboxDir]; a.SourceLabel != "" {
|
if a := accountLabels()[mboxDir]; a.SourceLabel != "" {
|
||||||
return a.SourceLabel
|
return a.SourceLabel
|
||||||
|
|
@ -403,7 +411,7 @@ func resolveViewerAccount(account, source string) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
for dir, label := range accountLabels() {
|
for dir, label := range accountLabels() {
|
||||||
if strings.EqualFold(label.SourceLabel, source) {
|
if strings.EqualFold(label.SourceLabel, source) || strings.EqualFold(label.DisplayLabel, source) {
|
||||||
return dir
|
return dir
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -419,13 +427,15 @@ func accountLabels() map[string]viewerAccount {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
n := 0
|
||||||
for _, a := range accounts {
|
for _, a := range accounts {
|
||||||
dir := accountMboxDir(a)
|
dir := accountMboxDir(a)
|
||||||
source := a.SrcUser
|
source := a.SrcUser
|
||||||
if source == "" {
|
if source == "" {
|
||||||
source = a.Name
|
source = a.Name
|
||||||
}
|
}
|
||||||
out[dir] = viewerAccount{Name: dir, SourceLabel: source}
|
n++
|
||||||
|
out[dir] = viewerAccount{Name: dir, SourceLabel: source, DisplayLabel: fmt.Sprintf("Original %d", n)}
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue