1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 10:07:02 +00:00

Add a Link button to messages

Allows users to copy the URL for a specific message and send it to
another person.
This commit is contained in:
James Hillyerd
2013-10-25 13:29:26 -07:00
parent ea7274e5dd
commit 47cba08c33
4 changed files with 33 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
{{$name := .name}}
{{$id := .message.Id}}
<div id="emailActions">
<a href="/link/{{$name}}/{{$id}}">Link</a>
<a href="javascript:deleteMessage('{{.message.Id}}');">Delete</a>
<a href="javascript:messageSource('{{.message.Id}}');">Source</a>
{{if .htmlAvailable}}

View File

@@ -3,6 +3,7 @@
{{define "script"}}
<script>
var selected = "{{.selected}}"
function listLoaded() {
$('.listEntry').hover(
function() {
@@ -19,6 +20,10 @@
}
)
$("#messageList").slideDown()
if (selected != "") {
$("#" + selected).click()
selected = ""
}
}
function loadList() {

View File

@@ -31,6 +31,8 @@ type JsonMessageBody struct {
func MailboxIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
name := req.FormValue("name")
selected := req.FormValue("id")
if len(name) == 0 {
ctx.Session.AddFlash("Account name is required", "errors")
http.Redirect(w, req, reverse("RootIndex"), http.StatusSeeOther)
@@ -40,9 +42,19 @@ func MailboxIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err e
return RenderTemplate("mailbox/index.html", w, map[string]interface{}{
"ctx": ctx,
"name": name,
"selected": selected,
})
}
func MailboxLink(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
name := ctx.Vars["name"]
id := ctx.Vars["id"]
uri := fmt.Sprintf("%s?name=%s&id=%s", reverse("MailboxIndex"), name, id)
http.Redirect(w, req, uri, http.StatusSeeOther)
return nil
}
func MailboxList(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
// Don't have to validate these aren't empty, Gorilla returns 404
name := ctx.Vars["name"]

View File

@@ -34,6 +34,7 @@ func setupRoutes(cfg config.WebConfig) {
// Root
r.Path("/").Handler(handler(RootIndex)).Name("RootIndex").Methods("GET")
r.Path("/status").Handler(handler(RootStatus)).Name("RootStatus").Methods("GET")
r.Path("/link/{name}/{id}").Handler(handler(MailboxLink)).Name("MailboxLink").Methods("GET")
r.Path("/mailbox").Handler(handler(MailboxIndex)).Name("MailboxIndex").Methods("GET")
r.Path("/mailbox/{name}").Handler(handler(MailboxList)).Name("MailboxList").Methods("GET")
r.Path("/mailbox/{name}").Handler(handler(MailboxPurge)).Name("MailboxPurge").Methods("DELETE")