From 92238bcfa2e8bde61cff69b98a97757f839694b6 Mon Sep 17 00:00:00 2001 From: Kumi Date: Tue, 24 Sep 2024 08:02:05 +0200 Subject: [PATCH] feat: add theme support and refactor assets Introduce support for themes by adding a `theme` parameter to the site generation process and as an argument to the main script. Created separate CSS files for different themes and adjusted the structure to accommodate the style changes. Also, updated the use of assets with new SVG images and logos. Refactored HTML templates to dynamically select the theme and updated path references to images accordingly. Improved the development experience by adding a default "plain" theme and enhancing command-line argument parsing for theme selection. Closes #7 --- assets/css/base.css | 4 - assets/css/theme/plain.css | 15 +++ assets/css/theme/pride.css | 19 ++++ assets/img/logo-inv.svg | 70 ++++++------- assets/img/logo-inv_grad.svg | 190 +++++++++++++++++------------------ assets/img/logo-white.svg | 68 +++++++++++++ assets/img/logo.svg | 70 ++++++------- main.py | 9 +- templates/base.html | 6 +- templates/index.html | 6 +- 10 files changed, 278 insertions(+), 179 deletions(-) create mode 100644 assets/css/theme/plain.css create mode 100644 assets/css/theme/pride.css create mode 100644 assets/img/logo-white.svg diff --git a/assets/css/base.css b/assets/css/base.css index ea5db83..ad4bbd6 100644 --- a/assets/css/base.css +++ b/assets/css/base.css @@ -148,10 +148,6 @@ h5 { fill: var(--bs-primary-bg-subtle); } -.bg-pride-gradient { - background: linear-gradient(45deg, #FF7878, #FFC898, #FFF89A, #CDF2CA, #A2CDCD, #D1E8E4, #CAB8FF); -} - /* Responsive Styles */ @media (max-width: 991px) { p.text-center.special-header { diff --git a/assets/css/theme/plain.css b/assets/css/theme/plain.css new file mode 100644 index 0000000..ea2c72e --- /dev/null +++ b/assets/css/theme/plain.css @@ -0,0 +1,15 @@ +#logoContainer { + background-image: url(../../img/logo-inv_grad.svg); + background-size: contain; + max-width: 400px; + max-height: 400px; + width: 80vh; + height: 80vh; +} + +#smallLogoContainer { + background-image: url(../../img/logo-inv_grad.svg); + background-size: contain; + width: 64px; + height: 64px; +} \ No newline at end of file diff --git a/assets/css/theme/pride.css b/assets/css/theme/pride.css new file mode 100644 index 0000000..5d14a33 --- /dev/null +++ b/assets/css/theme/pride.css @@ -0,0 +1,19 @@ +.bg-primary-gradient { + background: linear-gradient(45deg, #FF7878, #FFC898, #FFF89A, #CDF2CA, #A2CDCD, #D1E8E4, #CAB8FF); +} + +#logoContainer { + background-image: url(../../img/logo-white.svg); + background-size: contain; + max-width: 400px; + max-height: 400px; + width: 80vh; + height: 80vh; +} + +#smallLogoContainer { + background-image: url(../../img/logo-inv_grad.svg); + background-size: contain; + width: 64px; + height: 64px; +} \ No newline at end of file diff --git a/assets/img/logo-inv.svg b/assets/img/logo-inv.svg index e6c0963..b41e7de 100644 --- a/assets/img/logo-inv.svg +++ b/assets/img/logo-inv.svg @@ -12,38 +12,38 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/assets/img/logo-inv_grad.svg b/assets/img/logo-inv_grad.svg index 80f99ac..972fe25 100644 --- a/assets/img/logo-inv_grad.svg +++ b/assets/img/logo-inv_grad.svg @@ -14,98 +14,98 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/img/logo-white.svg b/assets/img/logo-white.svg new file mode 100644 index 0000000..49e32a1 --- /dev/null +++ b/assets/img/logo-white.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/assets/img/logo.svg b/assets/img/logo.svg index 80d53ce..8e8e752 100644 --- a/assets/img/logo.svg +++ b/assets/img/logo.svg @@ -14,38 +14,38 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"> - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/main.py b/main.py index 5d9f5a3..0c44857 100644 --- a/main.py +++ b/main.py @@ -56,16 +56,18 @@ def render_template_to_file(template_name, output_name, **kwargs): try: template = env.get_template(template_name) output_path = output_dir / output_name + kwargs.setdefault("theme", "plain") with open(output_path, "w", encoding="utf-8") as f: f.write(template.render(**kwargs)) except TemplateNotFound: print(f"Template {template_name} not found.") -def generate_static_site(development_mode=False): +def generate_static_site(development_mode=False, theme="plain"): # Common context kwargs = { "timestamp": int(datetime.datetime.now().timestamp()), + "theme": theme, } if development_mode: @@ -171,10 +173,13 @@ if __name__ == "__main__": parser.add_argument( "--port", type=int, default=8000, help="Port to serve the site on" ) + parser.add_argument( + "--theme", type=str, default="plain", help="Theme to use for the site" + ) args = parser.parse_args() - generate_static_site(development_mode=args.dev) + generate_static_site(development_mode=args.dev, theme=args.theme) if args.serve: server = TCPServer(("", args.port), StaticPageHandler) diff --git a/templates/base.html b/templates/base.html index f0201d8..dd0b0ea 100644 --- a/templates/base.html +++ b/templates/base.html @@ -44,10 +44,11 @@ name="twitter:image" content="https://private.coffee/assets/img/logo-inv_grad.png" /> - + {% block title %}{% endblock %} - Private.coffee + @@ -56,8 +57,7 @@