welcome: add welcome page

This commit is contained in:
dece 2021-05-15 19:44:50 +02:00
parent 2b072bcc76
commit 2bfed8533e
4 changed files with 30 additions and 8 deletions

View file

@ -19,7 +19,7 @@ TODO DONE
media files media files
identity management identity management
logging logging
home page home page

View file

@ -36,6 +36,7 @@ from bebop.navigation import (
) )
from bebop.page import Page from bebop.page import Page
from bebop.page_pad import PagePad from bebop.page_pad import PagePad
from bebop.welcome import WELCOME_PAGE
class Browser: class Browser:
@ -106,16 +107,13 @@ class Browser:
def setup_special_pages(self): def setup_special_pages(self):
"""Return a dict with the special pages functions.""" """Return a dict with the special pages functions."""
return { return {
"welcome": { "open": self.open_welcome_page },
"help": { "open": self.open_help },
"history": { "open": self.open_history },
"bookmarks": { "bookmarks": {
"open": self.open_bookmarks, "open": self.open_bookmarks,
"source": lambda: str(get_bookmarks_path()) "source": lambda: str(get_bookmarks_path())
}, },
"help": {
"open": self.open_help,
},
"history": {
"open": self.open_history,
},
} }
def run(self, *args, **kwargs): def run(self, *args, **kwargs):
@ -309,6 +307,8 @@ class Browser:
if num_words == 1: if num_words == 1:
if command in ("q", "quit"): if command in ("q", "quit"):
self.running = False self.running = False
elif command in ("h", "home"):
self.open_home()
return return
if command in ("o", "open"): if command in ("o", "open"):
self.open_url(words[1]) self.open_url(words[1])
@ -643,3 +643,11 @@ class Browser:
) )
except FileNotFoundError as exc: except FileNotFoundError as exc:
self.set_status_error(f"Failed to run command: {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)

View file

@ -13,7 +13,8 @@ DEFAULT_CONFIG = {
"command_editor": ["vi"], "command_editor": ["vi"],
"history_limit": 1000, "history_limit": 1000,
"external_commands": {}, "external_commands": {},
"external_command_default": ["xdg-open"] "external_command_default": ["xdg-open"],
"home": "bebop:welcome",
} }

13
bebop/welcome.py Normal file
View 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
"""