ShowReplies bool `json:"show_replies"`
ReplyMap map[string][]ReplyInfo `json:"reply_map"`
ReplyNumber int `json:"reply_number"`
+ ThreadInNewTab bool `json:"thread_in_new_tab"`
}
// Context hold information for mastodon context.
--- /dev/null
+package model
type Settings struct {
DefaultVisibility string `json:"default_visibility"`
CopyScope bool `json:"copy_scope"`
+ ThreadInNewTab bool `json:"thread_in_new_tab"`
+}
+
+func NewSettings() *Settings {
+ return &Settings{
+ DefaultVisibility: "public",
+ CopyScope: true,
+ ThreadInNewTab: false,
+ }
}
}
sessionID = util.NewSessionId()
- err = svc.sessionRepo.Add(model.Session{
+ session := model.Session{
ID: sessionID,
InstanceDomain: instance,
- })
+ Settings: *model.NewSettings(),
+ }
+ err = svc.sessionRepo.Add(session)
if err != nil {
return
}
return err
}
+ for i := range statuses {
+ statuses[i].ThreadInNewTab = c.Session.Settings.ThreadInNewTab
+ }
+
if len(maxID) > 0 && len(statuses) > 0 {
hasPrev = true
prevLink = fmt.Sprintf("/timeline/$s?min_id=%s", timelineType, statuses[0].ID)
}
http.SetCookie(w, &http.Cookie{
- Name: "session_id",
- Value: sessionID,
- Expires: time.Now().Add(365 * 24 * time.Hour),
+ Name: "session_id",
+ Value: sessionID,
+ Expires: time.Now().Add(365 * 24 * time.Hour),
})
w.Header().Add("Location", url)
visibility := req.FormValue("visibility")
copyScope := req.FormValue("copy_scope") == "true"
+ threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
settings := &model.Settings{
DefaultVisibility: visibility,
CopyScope: copyScope,
+ ThreadInNewTab: threadInNewTab,
}
err := s.SaveSettings(ctx, w, nil, settings)
r.HandleFunc("/signout", func(w http.ResponseWriter, req *http.Request) {
// TODO remove session from database
http.SetCookie(w, &http.Cookie{
- Name: "session_id",
- Value: "",
- Expires: time.Now(),
+ Name: "session_id",
+ Value: "",
+ Expires: time.Now(),
})
w.Header().Add("Location", "/")
w.WriteHeader(http.StatusFound)
<input id="copy-scope" name="copy_scope" type="checkbox" value="true" {{if .Settings.CopyScope}}checked{{end}}>
<label for="copy-scope"> Copy scope when replying </label>
</div>
+ <div class="settings-form-field">
+ <input id="thread-tab" name="thread_in_new_tab" type="checkbox" value="true" {{if .Settings.ThreadInNewTab}}checked{{end}}>
+ <label for="thread-tab"> Open threads in new tab from timeline </label>
+ </div>
<button type="submit"> Save </button>
</form>
<a class="status-you" href="/thread/{{.ID}}?reply=true#status-{{.ID}}" title="reply">
<i class="fa fa-reply"></i>
</a>
- <a class="status-action-count" href="/thread/{{.ID}}#status-{{.ID}}">
+ <a class="status-action-count" href="/thread/{{.ID}}#status-{{.ID}}" {{if .ThreadInNewTab}}target="_blank"{{end}}>
<span> {{DisplayInteractionCount .RepliesCount}} </span>
</a>
</div>
</a>
</div>
<div class="status-action">
- <a class="status-time" href="/thread/{{.ID}}#status-{{.ID}}">
+ <a class="status-time" href="/thread/{{.ID}}#status-{{.ID}}" {{if .ThreadInNewTab}}target="_blank"{{end}}>
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{.CreatedAt}}"> {{TimeSince .CreatedAt}} </time>
</a>
</div>