Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

Saturday, February 28, 2009

Bespin - experimenting with embedded preview

While a browser based text editor or web development environment has many disadvantages compared to the desktop variant, there a also some great possibilities which haven't been explored yet with bespin. Possibilities such as having direct browser DOM access for previewing and possibly manipulating content and that is not limited to text. Images (img tags and background images) can also be edited live (with a bit of canvas magic, as e.g. in pixastic) and server round trips are only required to store the edited images. Traditional editors can only dream of this and adding this possibilities to monster IDEs makes them even more complex.
So here is my proposal (including fully functional early stage prototype) for a live preview, see the screenshots above, just clicking on the eye icon at the toolbar and at the place of the editor canvas with the HML source code, a preview panel gets blended in. Unfortunately there are a few issues. Lets take a look at the style definition of the example. It has defined properties for the "body". But we don't want to change the bespin body properties. So what I am doing to prevent a visual and usability disaster is parsing (not really in the lexical sense) the HTML template, extracting styles and injecting them as filtered CSS rules into the page when rendering the preview and removing the rules when switching off the preview.

So far this is only for HTML templates. But my idea is to have a pluggable template parser system so we can expand PHP, django or other templates. While this is not easy, I have done it before (ErlyDTL, the Django template language for Erlang) and I have used a javascript template system before: dojox.dtl - dojo django rendering. So why not use dojox.dtl for bespin template rendering ? Well, first it is specific for django, second it is text and node based (for performance reasons). That is good for an app where template parts get swapped frequently, but just for preview we don't need a node based template system, at least not for now because it adds a lot of complexity.

And one more thing to consider are the edge cases in which this approach won't work. Hopefully with enough trickery the embedded preview will work good enough in most cases. The bespin toolbar and commando line will anyway prevent a full-browser preview, unless they are blended out as well, which is currently not implemented and I am not even sure whether it would be a good idea to do so.

If you wanna contribute to the technical discussion, please user the google bespin core group.

Friday, February 22, 2008

Dojo theming tutorial and more at dojocampus

Ever wanted to know how to create flexible-size background images for rounded corners or other CSS effects specifically for custom-theming Dojo widgets ? Unless you have already intimate knowledge of the Sliding Doors technique and CSS sprites, you should checkout the "Rounded tabs" tutorial on the recently started DojoCampus site. There is also other great stuff there such as a video about the dojo grid and Firebug tips.

Tuesday, July 31, 2007

Messing around with code and colors

Inspired by this article I put together an erlang function to convert colors form HSL to RGB model. I will use it with the erlycairo imaging library and dynamic CSS generation as supported in erlyweb to get the colors right, hopefully !

Update:

How do erlang code snippets look like, just copy-pasted into google blogger and converted to courier font ? They get screwed up, because some special characters need proper escaping. Fortunately aquamacs, my preferred editor on the mac, has the htmlize mode, which turns anything into HTML. And also had to add some CSS from the generated emacs HTML output to the blogger template to make the snippet look more readable .

hsl_to_rgb(_H, S, L) when S == 0.0 ->
[L, L, L];

hsl_to_rgb(H, S, L) ->
Q = q(H,
S, L),
P = 2.0 * L - Q,
H1 = H / 360.0,
TList = [ t(T) || T <- [H1 + 1.0 / 3.0, H1, H1 - 1.0 / 3.0]],
[ c(P, Q, T) || T <- TList ].


q(_H, S, L) when (L < 0.5) ->
L * (1.0 + S);
q(_H, S, L) ->
L + S - L * S.

t(T) when (T < 0) ->
T + 1.0;
t(T) when (T > 1.0) ->
T - 1.0;
t(T) ->
T.

c(P, Q, T) when T < 1.0 / 6.0 ->
P + ((Q - P) * 6.0 * T);
c(P, Q, T) when 1.0 / 6.0 =< T, T < 0.5 ->
Q;
c(P, Q, T) when 0.5 =< T, T < 2.0 / 3.0 ->
P + ((Q - P) * (2.0 / 3.0 - T) * 6.0);
c(P, Q, T) ->
P.