LuteOrg / lute-v3

LUTE = Learning Using Texts: learn languages through reading.
https://luteorg.github.io/lute-manual/
MIT License
490 stars 46 forks source link

Read themes from a directory. #287

Closed shetozz closed 6 months ago

shetozz commented 8 months ago

Is your feature request related to a problem? Please describe.

Currently, in order to add a theme, you have to add it yourself or the user has to make it as a custom style -which is tedious to edit-

Describe the solution you'd like

The ability to read CSS style sheets from disk.

Additional context

This will make adding more themes easier for you, and the user, as it can be maintained in a community repo, so the user can just clone the repo, or copy the themes they want into their lute theme directory.

jzohrab commented 8 months ago

Dev notes: the themes are all loaded from an internal directory, lute/themes/css/*.css (approximately). Rather than loading from two locations (the internal plus the external), the easiest would just be to copy those themes to that css folder. For dev the only problem would be that git is tracking that folder, so recommend added a .gitignore to that folder with a big note to say that the folder is ignored, and that anything added will need "git add --force" or whatever.

This could be done on startup, and that's it. Would work for both docker and pip, no other changes needed.

todo:

EDIT: need to read from both, see subsequent comment.

jzohrab commented 8 months ago

Hi @shetozz - for this to work (easily!!) the themes directory would need to be in the Lute's "data" folder. It needs to be there b/c that folder is mounted in Docker, and I don't want to go to the trouble of having a separate configurable folder.

So I'll do this as part of the "data" folder for an initial v1 iteration of this idea.

jzohrab commented 8 months ago

Just had a thought while considering this: only loading at startup would mean that the theme couldn't be changed on-the-fly by user during running, which is likely needed as people work on themes. So the theme code would need to read from both locations. Not a dealbreaker, the theme service would just need to handle that.

jzohrab commented 6 months ago

Done in the develop branch, now have to update the manual with usage notes.

Summary:

There's a folder in the data directory called "userthemes". Put your CSS files in there. New files (e.g. "my_theme.css") are just added to the theme dropdown list. If the css file already exists in the built-in themes (e.g. "Apple_Books.css") , the user css is added after the built-in styles, so you can tweak little parts of the built-in styles if you want.

jzohrab commented 6 months ago

Added a page to the manual. The manual will be updated, I'll probably do another launch pretty soon.

jzohrab commented 6 months ago

Launched in 3.3.3