welcome: add welcome page
This commit is contained in:
parent
2b072bcc76
commit
2bfed8533e
|
@ -36,6 +36,7 @@ from bebop.navigation import (
|
|||
)
|
||||
from bebop.page import Page
|
||||
from bebop.page_pad import PagePad
|
||||
from bebop.welcome import WELCOME_PAGE
|
||||
|
||||
|
||||
class Browser:
|
||||
|
@ -106,16 +107,13 @@ class Browser:
|
|||
def setup_special_pages(self):
|
||||
"""Return a dict with the special pages functions."""
|
||||
return {
|
||||
"welcome": { "open": self.open_welcome_page },
|
||||
"help": { "open": self.open_help },
|
||||
"history": { "open": self.open_history },
|
||||
"bookmarks": {
|
||||
"open": self.open_bookmarks,
|
||||
"source": lambda: str(get_bookmarks_path())
|
||||
},
|
||||
"help": {
|
||||
"open": self.open_help,
|
||||
},
|
||||
"history": {
|
||||
"open": self.open_history,
|
||||
},
|
||||
}
|
||||
|
||||
def run(self, *args, **kwargs):
|
||||
|
@ -309,6 +307,8 @@ class Browser:
|
|||
if num_words == 1:
|
||||
if command in ("q", "quit"):
|
||||
self.running = False
|
||||
elif command in ("h", "home"):
|
||||
self.open_home()
|
||||
return
|
||||
if command in ("o", "open"):
|
||||
self.open_url(words[1])
|
||||
|
@ -643,3 +643,11 @@ class Browser:
|
|||
)
|
||||
except FileNotFoundError as exc:
|
||||
self.set_status_error(f"Failed to run command: {exc}")
|
||||
|
||||
def open_home(self):
|
||||
"""Open the home page."""
|
||||
self.open_url(self.config["home"])
|
||||
|
||||
def open_welcome_page(self):
|
||||
"""Open the default welcome page."""
|
||||
self.open_internal_page("welcome", WELCOME_PAGE)
|
||||
|
|
|
@ -13,7 +13,8 @@ DEFAULT_CONFIG = {
|
|||
"command_editor": ["vi"],
|
||||
"history_limit": 1000,
|
||||
"external_commands": {},
|
||||
"external_command_default": ["xdg-open"]
|
||||
"external_command_default": ["xdg-open"],
|
||||
"home": "bebop:welcome",
|
||||
}
|
||||
|
||||
|
||||
|
|
13
bebop/welcome.py
Normal file
13
bebop/welcome.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
"""Welcome page."""
|
||||
|
||||
WELCOME_PAGE = """\
|
||||
# Bebop
|
||||
|
||||
Hi! Welcome to the Bebop browser.
|
||||
|
||||
Press "?" to see the keybinds, commands and more, or click the link below by \
|
||||
pressing its link ID (1).
|
||||
|
||||
=> bebop:help Help
|
||||
=> gemini://dece.space/dev/bebop.gmi Bebop @ dece.space
|
||||
"""
|
Reference in a new issue