moodle-an-hochschulen / moodle-theme_boost_union

Theme Boost Union is an enhanced child theme of Boost which is intended, on the one hand, to make Boost simply more configurable and, on the other hand, to provide helpful additional features for the daily Moodle operation of admins, teachers and students.
GNU General Public License v3.0
61 stars 54 forks source link

Changes in preset-files in folder scss/preset/ aren't recognized reliably #366

Closed madamadami closed 6 months ago

madamadami commented 1 year ago

We've encountered a very strange and unpredictable behavior in boost union (v4.0-r20 / 2022080940; moodle v4.1) when making changes to scss preset files in folder scss/preset/. When doing changes in the files plain.scss, default.scss or custom preset files added via the theme's settings.php, these changes don't get rendered despite clearing caches several times.

Worth mentioning: Preset files that got uploaded with moodle UI are processed corretly. On another moodle instance with boost union v4.1-r2 / 2023010502 editing preset files is working, changes get reflected after clearing cache.

danowar2k commented 1 year ago

It's unclear to me what you're referring to. Which of these are you doing:

Or do you mean you tried one after the other and nothing worked?

madamadami commented 1 year ago

In order to find a convenient way to develop a customized theme without creating a boost union child theme, I duplicated theme_boost_union/scss/preset/default.scss to theme_boost_union/scss/preset/my-preset.scss, registered it in boost union's settings.php, and finally chose it in the boost union UI as preset file. With this approach, I can edit the file directly and conveniently on the server via FTP. But changes made in this file just aren't recognized/rendered. So for testing purpose, I directly edited the existing file theme_boost_union/scss/preset/default.scss, but again, the changes didn't take effect despite heavy cache clearing. But if I take such a customized file, rename it let's say to my-preset-2.scss, upload it by using the boost union UI, and set it as preset, the changes take effect. So on the bottom line what I wanted to say is that customizing files in boost union's folder structure under theme_boost_union/scss/preset/ isn't woking, while files uploaded via UI do work. Hope now it's comprehensible.

danowar2k commented 1 year ago

Aha! So there are really two versions of my-preset.scss present on the server: a) the one in theme_boost_union/scss/preset/my-preset.scss b) the one you uploaded via UI in moodledata/files/xy/z2/contenthashed-my-preset-scss

If you edit a) you will never see any changes unless you reupload it again via the UI If you edit b) ...you really shouldn't because the contenthash would change and this would probably confuse the hell out of Moodle.

So, did you edit a) and reupload the file?

danowar2k commented 1 year ago

The way to add personal scss changes without doing what you did is probably to edit pre.scss (to add or change variables) and post.scss (to prepend or append additional rules) of theme_boost_union. If that's your goal...

danowar2k commented 1 year ago

If what you mean by "registered it in boost union's settings.php" is you added it's filename as an option, see https://github.com/moodle-an-hochschulen/moodle-theme_boost_union/blob/f5d593275c6ec4e8d2e446e3f82a51823e2f6e87/settings.php#L134-L151, so basically

$choices['my-preset.scss'] = 'my-preset.scss';

that wouldn't help you alone, because in lib.php, see https://github.com/moodle-an-hochschulen/moodle-theme_boost_union/blob/f5d593275c6ec4e8d2e446e3f82a51823e2f6e87/lib.php#L107-L117 one can see that the added my-preset.scss choice is not directly read with its path but it must have been uploaded as a file via the UI filemanager.

haw-fachadmin commented 1 year ago

I see, so uploading the file via UI is mandatory, isn't it?

But uploading via UI while developing is a pain, I want to develop file-based, just editing the scss directly … so therefore a few months ago I succeeded with a different approach: While development, I edited the file theme_boost_union/scss/preset/default.scss directly and when automatically clearing design cache was enabled, changes were present after page reload. Once development was finished, I copied the content of default.scss to a new file and uploaded it via UI. Worked perfectly. But now, it seems to me this approach isn't working anymore for some reason; changes in theme_boost_union/scss/preset/default.scss don't take effect.

So what's your suggestion for a good and convenient development workflow?

danowar2k commented 1 year ago

Hm. Going by the code of the lib.php, if your preset setting has an empty value, boost_union should fallback to loading the contents of default.scss . See https://github.com/moodle-an-hochschulen/moodle-theme_boost_union/blob/f5d593275c6ec4e8d2e446e3f82a51823e2f6e87/lib.php#L116.

So your approach of directly editing default.scss should (!) work. You should probably check whether the preset setting is empty and there are no stored files for 'preset'. And maybe check your browser what contents the complete CSS file has. And use xdebug to check what scss code is returned at the end of the function theme_boost_union_get_main_scss_content()

wiebkemueller-hsh commented 11 months ago

Hi, did you have a look at https://github.com/moodle-an-hochschulen/moodle-theme_boost_union/issues/41? Does this solve your issue?

abias commented 6 months ago

Hi all,

unfortunately, I am quite late to join this discussion here.

First, #41 is unrelated to this issue.

Then: We had to see recently that the presets feature was broken in Boost Union. This might have cause trouble for anyone who tried to used it, sorry for that. In the latest Boost Union release, we removed the preset feature completely from Boost Union in a way that the preset which is set in Boost Core is also applied to Boost Union.

This means, if you want to use a preset from now on, please upload it in Boost Core and it should work.

Cheers, Alex