-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Download page: Added options #2162
base: master
Are you sure you want to change the base?
Download page: Added options #2162
Conversation
This is fantastic work @RunDevelopment! I haven't looked at the code very closely, but the functionality is sorely needed! |
Thanks. And I need to revisit the Custom Class implementation. I used Prism to parse CSS because it was convenient but come on. I should do this the right way. |
I did that a few days ago 😊 (to parse JS though, not CSS) |
Ok. No CSS parser. I wasn't able to find a good CSS parser that just works on the web and preserves spaces and comments. Prism-parsing it is then. I also found another major pain point for the Custom class prefix option: To which classes do we add the prefix?
|
You can also just do regex replace on the fetched CSS, theme CSS is pretty simple, so that should work quite well.
Would not prefixing the token class itself alleviate any of these? I suspect it's not a very commonly used name... Also, perhaps we need to bite the bullet and bake this functionality into the core instead of making custom classes a plugin. It seems like fairly important functionality… (Aaand this is where I wish we had usage stats for plugins...) |
Not really. Most plugins search for specific tokens by their type. Given that Prism supports arbitrary prefixes and even remapping (via Custom Class), you could argue that the plugin (e.g. Match Braces) is at fault. Right now, the only thing nobody modifies during the conversion from token stream to markup are attributes, so I could use marker attributes instead of marker classes to implement Match Braces. The plugin will then be implemented partly in To make this more stable we could make a
We don't have those? I always assumed that we did. I'm not very familiar with Google Analytics but if they also collect information on the hash of the URL of the download page, then we have these stats. |
This adds a new 'Options' section to the download page where plugins and Prism itself can be configured.
The basic idea here is that there are options which are a collection of option items. An option can require any number of components and is only enabled if all required components are enabled. Only options that are enabled will be visible.
Every option item translates to one label + one input element. An item is responsible for validating inputs. I added support for 3 types of inputs: boolean (->
input[type=checkbox]
), number (->input[type=number]
), and string (->input[type=text]
). But right now, I don't use the number type.The option will then be used to apply changes to the JS and CSS source code according to the values of its items.
The item values of all enabled options will be stored in the URL if the value differs from the default value.
I added 3 options:
filterKnown
and to add CSS selectors. (not enabled in the image)To apply the prefix to the theme, I used Prism's CSS language to tokenize the CSS code and get all selectors and replaced all token names using a regular expression.