mirror of
https://github.com/makew0rld/amfora.git
synced 2025-02-02 15:07:34 -05:00
Add handleAbout()
This commit is contained in:
parent
5722c50432
commit
62102d4f98
@ -576,25 +576,8 @@ func Reload() {
|
||||
// URL loads and handles the provided URL for the current tab.
|
||||
// It should be an absolute URL.
|
||||
func URL(u string) {
|
||||
// Some code is copied in followLink()
|
||||
|
||||
if u == "about:bookmarks" { //nolint:goconst
|
||||
Bookmarks(tabs[curTab])
|
||||
tabs[curTab].addToHistory("about:bookmarks")
|
||||
return
|
||||
}
|
||||
if u == "about:subscriptions" { //nolint:goconst
|
||||
Subscriptions(tabs[curTab])
|
||||
tabs[curTab].addToHistory("about:subscriptions")
|
||||
return
|
||||
}
|
||||
if u == "about:newtab" {
|
||||
temp := newTabPage // Copy
|
||||
setPage(tabs[curTab], &temp)
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(u, "about:") {
|
||||
Error("Error", "Not a valid 'about:' URL.")
|
||||
if u[:6] == "about:" {
|
||||
handleAbout(tabs[curTab], u)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -163,6 +163,35 @@ func handleFavicon(t *tab, host, old string) {
|
||||
cache.AddFavicon(host, emoji)
|
||||
}
|
||||
|
||||
// handleAbout can be called to deal with any URLs that start with
|
||||
// 'about:'. It will display errors if the URL is not recognized,
|
||||
// but not display anything if an 'about:' URL is not passed.
|
||||
//
|
||||
// It returns a bool indicating if the provided URL could be handled.
|
||||
func handleAbout(t *tab, u string) bool {
|
||||
if u[:6] != "about:" {
|
||||
return false
|
||||
}
|
||||
|
||||
switch u {
|
||||
case "about:bookmarks":
|
||||
Bookmarks(t)
|
||||
t.addToHistory("about:bookmarks")
|
||||
return true
|
||||
case "about:subscriptions":
|
||||
Subscriptions(t)
|
||||
t.addToHistory("about:subscriptions")
|
||||
return true
|
||||
case "about:newtab":
|
||||
temp := newTabPage // Copy
|
||||
setPage(t, &temp)
|
||||
return true
|
||||
}
|
||||
|
||||
Error("Error", "Not a valid 'about:' URL.")
|
||||
return false
|
||||
}
|
||||
|
||||
// handleURL displays whatever action is needed for the provided URL,
|
||||
// and applies it to the current tab.
|
||||
// It loads documents, handles errors, brings up a download prompt, etc.
|
||||
@ -215,14 +244,8 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) {
|
||||
|
||||
App.SetFocus(t.view)
|
||||
|
||||
// To allow linking to the bookmarks page, and history browsing
|
||||
if u == "about:bookmarks" {
|
||||
Bookmarks(t)
|
||||
return ret("about:bookmarks", true)
|
||||
}
|
||||
if u == "about:subscriptions" {
|
||||
Subscriptions(t)
|
||||
return ret("about:subscriptions", true)
|
||||
if u[:6] == "about:" {
|
||||
return ret(u, handleAbout(t, u))
|
||||
}
|
||||
|
||||
u = normalizeURL(u)
|
||||
|
@ -19,20 +19,8 @@ import (
|
||||
// Not when a URL is opened on a new tab for the first time.
|
||||
// It will handle setting the bottomBar.
|
||||
func followLink(t *tab, prev, next string) {
|
||||
|
||||
// Copied from URL()
|
||||
if next == "about:bookmarks" {
|
||||
Bookmarks(t)
|
||||
t.addToHistory("about:bookmarks")
|
||||
return
|
||||
}
|
||||
if next == "about:subscriptions" {
|
||||
Subscriptions(t)
|
||||
t.addToHistory("about:subscriptions")
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(next, "about:") {
|
||||
Error("Error", "Not a valid 'about:' URL for linking")
|
||||
if next[:6] == "about:" {
|
||||
handleAbout(t, next)
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user