From 225e13f43bedc853ef6deed42adda660b941c003 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 11 Jan 2023 23:29:28 -0600 Subject: [PATCH] Allow all external dependency URLs to be set in config so can host all files locally if needed. we also now assume all themes support buefy unless otherwise configured --- tailbone/templates/themes/falafel/base.mako | 20 ++++++++------------ tailbone/util.py | 11 +++-------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/tailbone/templates/themes/falafel/base.mako b/tailbone/templates/themes/falafel/base.mako index 3cfa00a2..888b3bb6 100644 --- a/tailbone/templates/themes/falafel/base.mako +++ b/tailbone/templates/themes/falafel/base.mako @@ -107,25 +107,21 @@ <%def name="jquery()"> - ## jQuery 1.12.4 - ${h.javascript_link('https://code.jquery.com/jquery-1.12.4.min.js')} + ${h.javascript_link(request.rattail_config.get('tailbone', 'liburl.jquery', default='https://code.jquery.com/jquery-1.12.4.min.js'))} <%def name="vuejs()"> - ${h.javascript_link('https://unpkg.com/vue@{}/dist/vue.min.js'.format(vue_version))} - - ## vue-resource - ## (needed for e.g. this.$http.get() calls, used by grid at least) - ## TODO: make this configurable also - ${h.javascript_link('https://cdn.jsdelivr.net/npm/vue-resource@1.5.1')} + ${h.javascript_link(request.rattail_config.get('tailbone', 'liburl.vue', default='https://unpkg.com/vue@{}/dist/vue.min.js'.format(vue_version)))} + ## TODO: make this version configurable also + ${h.javascript_link(request.rattail_config.get('tailbone', 'liburl.vue_resource', default='https://cdn.jsdelivr.net/npm/vue-resource@1.5.1'))} <%def name="buefy()"> - ${h.javascript_link('https://unpkg.com/buefy@{}/dist/buefy.min.js'.format(buefy_version))} + ${h.javascript_link(request.rattail_config.get('tailbone', 'liburl.buefy', default='https://unpkg.com/buefy@{}/dist/buefy.min.js'.format(buefy_version)))} <%def name="fontawesome()"> - + <%def name="extra_javascript()"> @@ -163,14 +159,14 @@ ${h.stylesheet_link(buefy_css)} % else: ## upstream Buefy CSS - ${h.stylesheet_link('https://unpkg.com/buefy@{}/dist/buefy.min.css'.format(buefy_version))} + ${h.stylesheet_link(request.rattail_config.get('tailbone', 'liburl.buefy.css', default='https://unpkg.com/buefy@{}/dist/buefy.min.css'.format(buefy_version)))} % endif ## TODO: this is only being referenced by the progress template i think? ## (so, should make a Buefy progress page at least) <%def name="jquery_theme()"> - ${h.stylesheet_link('https://code.jquery.com/ui/1.11.4/themes/dark-hive/jquery-ui.css')} + ${h.stylesheet_link(request.rattail_config.get('tailbone', 'liburl.jquery.css', default='https://code.jquery.com/ui/1.11.4/themes/dark-hive/jquery-ui.css'))} <%def name="extra_styles()"> diff --git a/tailbone/util.py b/tailbone/util.py index c1d39eac..a9aa3bf3 100644 --- a/tailbone/util.py +++ b/tailbone/util.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2022 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -109,13 +109,8 @@ def should_use_buefy(request): if buefy is not None: return buefy - # TODO: should not hard-code this surely, but works for now... - if theme == 'falafel': - return True - - # TODO: probably should not use this fallback? it was the first setting - # i tested with, but is poorly named to say the least - return request.rattail_config.getbool('tailbone', 'grids.use_buefy', default=False) + # otherwise assume buefy is in effect + return True def pretty_datetime(config, value):