mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +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:
@@ -1,21 +1,22 @@
|
|||||||
{{$name := .name}}
|
{{$name := .name}}
|
||||||
{{$id := .message.Id}}
|
{{$id := .message.Id}}
|
||||||
<div id="emailActions">
|
<div id="emailActions">
|
||||||
<a href="javascript:deleteMessage('{{.message.Id}}');">Delete</a>
|
<a href="/link/{{$name}}/{{$id}}">Link</a>
|
||||||
<a href="javascript:messageSource('{{.message.Id}}');">Source</a>
|
<a href="javascript:deleteMessage('{{.message.Id}}');">Delete</a>
|
||||||
{{if .htmlAvailable}}
|
<a href="javascript:messageSource('{{.message.Id}}');">Source</a>
|
||||||
<a href="javascript:htmlView('{{.message.Id}}');">HTML</a>
|
{{if .htmlAvailable}}
|
||||||
{{end}}
|
<a href="javascript:htmlView('{{.message.Id}}');">HTML</a>
|
||||||
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<table id="emailHeader">
|
<table id="emailHeader">
|
||||||
<tr>
|
<tr>
|
||||||
<th>From:</th>
|
<th>From:</th>
|
||||||
<td>{{.message.From}}</td>
|
<td>{{.message.From}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date:</th>
|
<th>Date:</th>
|
||||||
<td>{{.message.Date}}</td>
|
<td>{{.message.Date}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
{{with .attachments}}
|
{{with .attachments}}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
{{define "script"}}
|
{{define "script"}}
|
||||||
<script>
|
<script>
|
||||||
|
var selected = "{{.selected}}"
|
||||||
function listLoaded() {
|
function listLoaded() {
|
||||||
$('.listEntry').hover(
|
$('.listEntry').hover(
|
||||||
function() {
|
function() {
|
||||||
@@ -19,6 +20,10 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
$("#messageList").slideDown()
|
$("#messageList").slideDown()
|
||||||
|
if (selected != "") {
|
||||||
|
$("#" + selected).click()
|
||||||
|
selected = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadList() {
|
function loadList() {
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ type JsonMessageBody struct {
|
|||||||
|
|
||||||
func MailboxIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
|
func MailboxIndex(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
|
||||||
name := req.FormValue("name")
|
name := req.FormValue("name")
|
||||||
|
selected := req.FormValue("id")
|
||||||
|
|
||||||
if len(name) == 0 {
|
if len(name) == 0 {
|
||||||
ctx.Session.AddFlash("Account name is required", "errors")
|
ctx.Session.AddFlash("Account name is required", "errors")
|
||||||
http.Redirect(w, req, reverse("RootIndex"), http.StatusSeeOther)
|
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{}{
|
return RenderTemplate("mailbox/index.html", w, map[string]interface{}{
|
||||||
"ctx": ctx,
|
"ctx": ctx,
|
||||||
"name": name,
|
"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) {
|
func MailboxList(w http.ResponseWriter, req *http.Request, ctx *Context) (err error) {
|
||||||
// Don't have to validate these aren't empty, Gorilla returns 404
|
// Don't have to validate these aren't empty, Gorilla returns 404
|
||||||
name := ctx.Vars["name"]
|
name := ctx.Vars["name"]
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ func setupRoutes(cfg config.WebConfig) {
|
|||||||
// Root
|
// Root
|
||||||
r.Path("/").Handler(handler(RootIndex)).Name("RootIndex").Methods("GET")
|
r.Path("/").Handler(handler(RootIndex)).Name("RootIndex").Methods("GET")
|
||||||
r.Path("/status").Handler(handler(RootStatus)).Name("RootStatus").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").Handler(handler(MailboxIndex)).Name("MailboxIndex").Methods("GET")
|
||||||
r.Path("/mailbox/{name}").Handler(handler(MailboxList)).Name("MailboxList").Methods("GET")
|
r.Path("/mailbox/{name}").Handler(handler(MailboxList)).Name("MailboxList").Methods("GET")
|
||||||
r.Path("/mailbox/{name}").Handler(handler(MailboxPurge)).Name("MailboxPurge").Methods("DELETE")
|
r.Path("/mailbox/{name}").Handler(handler(MailboxPurge)).Name("MailboxPurge").Methods("DELETE")
|
||||||
|
|||||||
Reference in New Issue
Block a user