@@ -44,7 +44,14 @@ def __init__(self):
44
44
self .output_style = self .bulma_settings .get ("output_style" , "nested" )
45
45
self .storage = FileSystemStorage (simple_bulma_path )
46
46
47
- def _get_extension_imports (self ) -> str :
47
+ # Make a list of all the finders except this one.
48
+ # We use this in the custom SCSS handler.
49
+ other_finders = settings .STATICFILES_FINDERS .copy ()
50
+ other_finders .remove ("django_simple_bulma.finders.SimpleBulmaFinder" )
51
+ self .other_finders = [get_finder (finder ) for finder in other_finders ]
52
+
53
+ @staticmethod
54
+ def _get_extension_imports () -> str :
48
55
"""Return a string that, in SASS, imports all enabled extensions."""
49
56
scss_imports = ""
50
57
@@ -56,13 +63,35 @@ def _get_extension_imports(self) -> str:
56
63
57
64
return scss_imports
58
65
59
- def _unpack_variables (self , variables : dict ) -> str :
66
+ @staticmethod
67
+ def _unpack_variables (variables : dict ) -> str :
60
68
"""Unpacks SASS variables from a dictionary to a compilable string."""
61
69
scss_string = ""
62
70
for var , value in variables .items ():
63
71
scss_string += f"${ var } : { value } ;\n "
64
72
return scss_string
65
73
74
+ @staticmethod
75
+ def _get_bulma_js () -> List [str ]:
76
+ """Return a list of all the js files that are needed for the users selected extensions."""
77
+ return list (get_js_files ())
78
+
79
+ @staticmethod
80
+ def find_relative_staticfiles (path : Union [str , Path ]) -> Union [Path , None ]:
81
+ """
82
+ Returns a given path, relative to one of the paths in STATICFILES_DIRS.
83
+
84
+ Returns None if the given path isn't available within STATICFILES_DIRS.
85
+ """
86
+ if not isinstance (path , Path ):
87
+ path = Path (abspath (path ))
88
+
89
+ for directory in settings .STATICFILES_DIRS :
90
+ directory = Path (abspath (directory ))
91
+
92
+ if directory in path .parents :
93
+ return path .relative_to (directory )
94
+
66
95
def _get_bulma_css (self ) -> List [str ]:
67
96
"""Compiles the bulma css files for each theme and returns their relative paths."""
68
97
# If the user has the sass module installed in addition to libsass,
@@ -132,12 +161,8 @@ def _get_custom_css(self) -> str:
132
161
relative_path = scss_path .split ("static/" , 1 )[- 1 ]
133
162
134
163
# Check that we can find this file with one of the other finders.
135
- other_finders = settings .STATICFILES_FINDERS
136
- other_finders .remove ("django_simple_bulma.finders.SimpleBulmaFinder" )
137
- other_finders = [get_finder (finder ) for finder in other_finders ]
138
164
absolute_path = None
139
-
140
- for finder in other_finders :
165
+ for finder in self .other_finders :
141
166
if absolute_path := finder .find (relative_path ):
142
167
break
143
168
@@ -172,26 +197,6 @@ def _get_custom_css(self) -> str:
172
197
173
198
return paths
174
199
175
- def _get_bulma_js (self ) -> List [str ]:
176
- """Return a list of all the js files that are needed for the users selected extensions."""
177
- return list (get_js_files ())
178
-
179
- @staticmethod
180
- def find_relative_staticfiles (path : Union [str , Path ]) -> Union [Path , None ]:
181
- """
182
- Returns a given path, relative to one of the paths in STATICFILES_DIRS.
183
-
184
- Returns None if the given path isn't available within STATICFILES_DIRS.
185
- """
186
- if not isinstance (path , Path ):
187
- path = Path (abspath (path ))
188
-
189
- for directory in settings .STATICFILES_DIRS :
190
- directory = Path (abspath (directory ))
191
-
192
- if directory in path .parents :
193
- return path .relative_to (directory )
194
-
195
200
def find (self , path : str , all : bool = False ) -> Union [List [str ], str ]:
196
201
"""
197
202
Given a relative file path, find an absolute file path.
0 commit comments