From ce5bb9a4475e27a9883f70a364263fe2c6e7ce19 Mon Sep 17 00:00:00 2001 From: Simon Bazley Date: Tue, 5 Nov 2024 10:04:07 +0000 Subject: [PATCH 1/2] Added support for theme from settings.py rather than just from the cli --- README.md | 1 + grip/app.py | 3 +++ grip/settings.py | 3 +++ 3 files changed, 7 insertions(+) diff --git a/README.md b/README.md index be556d2..095d1c6 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,7 @@ To customize Grip, create `~/.grip/settings.py`, then add one or more of the fol - `AUTOREFRESH`: Whether to automatically refresh the Readme content when the file changes, `True` by default - `QUIET`: Do not print extended information, `False` by default - `STYLE_URLS`: Additional URLs that will be added to the rendered page, `[]` by default +- `THEME`: The theme to use when not provided as a CLI argument, `light` by default - `USERNAME`: The username to use when not provided as a CLI argument, `None` by default - `PASSWORD`: The password or [personal access token][] to use when not provided as a CLI argument (*Please don't save your passwords here.* Instead, use an access token or drop in this code [grab your password from a password manager][keychain-access]), `None` by default diff --git a/grip/app.py b/grip/app.py index 25593bb..1562893 100644 --- a/grip/app.py +++ b/grip/app.py @@ -112,6 +112,9 @@ def __init__(self, source=None, auth=None, renderer=None, log = logging.getLogger('werkzeug') log.setLevel(logging.ERROR) self.theme = theme + localtheme = self.config['THEME'] + if localtheme: + self.theme = (localtheme or 'light') # Overridable attributes if self.renderer is None: diff --git a/grip/settings.py b/grip/settings.py index 7d8ba08..ce26579 100644 --- a/grip/settings.py +++ b/grip/settings.py @@ -29,3 +29,6 @@ # Custom styles STYLE_URLS = [] + +# Custome theme +THEME = 'light' From 9764fd188a3b161e45adf4e86feafc3731118be4 Mon Sep 17 00:00:00 2001 From: Simon Bazley Date: Tue, 5 Nov 2024 10:13:37 +0000 Subject: [PATCH 2/2] Removed default option from code, in favour of it being in settings.py --- grip/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grip/app.py b/grip/app.py index 1562893..3c53f8c 100644 --- a/grip/app.py +++ b/grip/app.py @@ -114,7 +114,7 @@ def __init__(self, source=None, auth=None, renderer=None, self.theme = theme localtheme = self.config['THEME'] if localtheme: - self.theme = (localtheme or 'light') + self.theme = localtheme # Overridable attributes if self.renderer is None: