-
Notifications
You must be signed in to change notification settings - Fork 329
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
API or route to produce CSS resource #1097
Comments
Hmm .. what are the security issues here? Could someone craft a particular CSS resource, attach it via a brew via @import, and then publish the /share/:id for that brew and somehow hurt visitors to the that shared brew? Can JS be embedded inside CSS, for example? |
Oh, nevermind, here comes IE ... |
I don't know... A separate CSS page was something @stolksdorf had originally planned and it would be nice to have. We already allow custom CSS directly within the main brew text, so I don't know that allowing a separate CSS import from a Homebrewery document would be any worse. We can prevent loading if the browser is IE. We can sanitize other input to some extent. What do you think? If this would be a security issue, it seems we already have this problem because people could make a malicious document and share it via the existing share/:id links, right? In any case, I think I want to keep this issue open. I think this could benefit from more discussion and research before we definitively say it's off the table. |
Good points. I was assuming the render of the brew is sanitized, including any I've not tested what happens with |
I'm all for this, but have nothing more to contribute than that...Was just searching to find out why a .css file hosted on my github was not loading on homebrewery. |
Quite some time has passed, and we now have a separate editor pane for CSS. The contents of which are stored however in the same mongo document as the brew contents, not a separate document. I think a I would suggest though that it only returns the css document part, and not scan thru the brew for any |
I would love to be able to have common CSS between files, and be able to edit them all at the same time while watching the brew. |
Probably not that tricky. This is how Lines 188 to 209 in 52dcc3b
That, and adding some brief documentation into Lines 80 to 81 in 52dcc3b
|
My first thought is that if the two are that similar, we might be able to create a unified function to avoid code duplication. |
This is stepping on the toes of Custom Themes, which is already designated as the preferred approach to common CSS. Adding a
|
The browser will resolve circular dependencies via caching. 😁 Themes are excellent, though they are a sledgehammer solution. Sometimes an author just wants something lighter, some common css bits and bobs. For example, I'd want to copy in some simple css for easily doing better |
You're talking about custom snippets, #1722. |
I have a mish mash of tweaks I add to brews, usually as I need them, to align with a preferred house style. Things like boxed text, nested lists using disc/circle/square bullets, nested lists not being so heavily indented, blockquotes, and more I've forgotten I've written (usually until about 5 minutes after re-inventing the wheel, yet again). The pain I'm identifying is having to add in each custom snippet into my Style Editor tab for each new brew as the need is identified, along with knowing that if I tweak or fix for one brew I would need to go back and edit many multiple older brews. That and finding the older brew in which I did indeed already solve the problem so I can then copy/paste the Style Editor snippet. Was it this brew? Or does this one have the up to date version? |
I may be missing something, but this sounds like the exact use case for Custom Themes. |
Not quite. I want to extend standard themes with a small set of tweaks and extensions. Unless custom themes are designed to layer over the top of an existing theme, and not completely swap in replace? That is, I can have one custom theme for my house extensions, and then apply that to brews that use the PHB or DMG (or whatever) theme as their base. |
Yeah, custom themes are built with a hierarchy. That’s why there is a Base theme, which PHB builds off of. You can see it in the themes folder…a json that includes a property whose value indicates which existing theme you are appending to. |
I thought the built-in hierarchy of built-in themes is a separate thing from author managed custom themes. From the author's p.o.v., they select select a built-in theme (with the built-in hierarchy all managed behind the scenes, it's just code), and optionally also specify a share :id of a brew to use as a custom theme extension, which gets transcluded into the source such that it is applied after the selected brew theme but before the brew style editor css. Is that how it works? If I specify a custom theme it doesn't unload the underlying main theme (and it's base theme)? |
The way it is designed now, a custom theme would be a brew layered onto an HB theme. So you have:
2 and 3 can be skipped if the user wants to build a whole theme from scratch using only the blank theme. Then when another user wants to use that custom theme in another brew, they optionally select an HB theme, or select the shareId of the custom Theme, which brings with it it's inherited base themes, so the new brew now has:
with 1-4 baked together from the custom theme. |
So Custom themes are inherently tied to a base theme and a main theme. You want to be able to import custom CSS that isn't tied to any specific base theme? |
I'd want to supply a reference to a custom collection of css rules that get applied to a document after that document's base theme has been applied, but before that document's brew.style. So .. I could then import the same custom CSS into brews that use a different base theme. This is particularly useful for e.g. PHB theme vs DMG theme, which are nearly identical .. othewise I'd need to create a "Custom Theme (PHB version)" alongside a "Custom Theme (DMG version)" [etc]. |
I think the User Brew-based themes solve for this problem. Where it doesn't/can't, we could look at using the same code that #3501 uses to abstract proxy CSS loading. |
Due to some (many?) browsers being particularly persnicketty about cross-domain requests, it's getting increasingly harder to reference a CSS style sheet resource from a 3rd party domain.
This would normally be done with
However, unless that resource is hosted by a server that knows to issue the correct media-type, the receiving browser will reject due to cross-domain concerns.
What would be handy would be for a HomeBrewery user is that they create a HB document into which they type all their CSS code (without wrapping with
<style>
and</style>
), and then in their other brews they can write an @import to the same-domain resource (e.g.@import url("/css/mumblecode")
.The HB server mostly only needs to respond to
/css/:id
requests with just the brew content, no metadata, no UI chrome; and with the http header ofContent-Type: text/css
. It probably should do some sanitizing, just in case.The text was updated successfully, but these errors were encountered: