On Thu, 28 Apr 2005 13:09:48 -0500, in
comp.infosystems.
www.authoring.stylesheets Big Slim <skinny@bones.com>
wrote:
[color=blue]
>| In article <d4q2vt$ll7$1@news6.zwoll1.ov.home.nl>, Martin!
>| <m.l.smidt@gmail.komkommer> wrote:
>|
>| > Jeff North wrote:
>| > > On Wed, 27 Apr 2005 16:29:03 -0500, in
>| > > comp.infosystems.
www.authoring.stylesheets Big Slim <skinny@bones.com>
>| > > wrote:
>| > >
>| > >
>| > >>| In article <1114635447.805e218ca45779b77652af66747f6d39@teran ews>,
>| > >>| Mr.Clean <mrclean@p&g.com> wrote:
>| > >>|
>| > >>| > In article <1114633159.afc5e0ddeb0e4458d0312b537b89968e@teran ews>,
>| > >>| >
skinny@bones.com says...
>| > >>| > > I'm working on a web application that makes heavy use of CSS, but I
>| > >>| > > would like users to have a degree of control over some of the classes
>| > >>| > > and attributes. To accomplish this, I want to store my CSS classes in
>| > >>| > > a
>| > >>| > > SQL database.
>| > >>| > >
>| > >>| > > The only problem is, I'm having a heck of a time trying to design the
>| > >>| > > database tables in a normalized way. I have searched high and low for
>| > >>| > > examples of CSS entity-relationship diagrams--to no avail.
>| > >>| > >
>| > >>| > > Has anyone here done something similar, and if so, do you have an
>| > >>| > > example I can borrow? I feel like I'm reinventing the wheel every time
>| > >>| > > I take a stab at this, and it is difficult trying to visualize how to
>| > >>| > > separate the tables. It also seems like it is going to be a ton of
>| > >>| > > work. For example, I am starting to think there will be no end to the
>| > >>| > > number of tables I'll need: CssColors, CssAlignments, CssFontStyles,
>| > >>| > > CssFontFamilies, CssBorderStyles, etc.
>| > >>| >
>| > >>| > AFAICS, you only need one table with fields for:
>| > >>| > at-rule : String
>| > >>| > selector : String
>| > >>| > property : String
>| > >>| > value : String
>| > >>| > important : Boolean
>| > >>| >
>| > >>|
>| > >>| True. It would mean I would have to build a lot of constraints for the
>| > >>| columns, though. For instance, I wouldn't want there to be a chance you
>| > >>| could pick an invalid (or non-web-safe) hexadecimal code for the
>| > >>| colors. Also, I wouldn't want to allow invalid font sets, inappropriate
>| > >>| alignment choices, or non-existent border styles.
>| > >>|
>| > >>| Even more importantly, though, if several classes share the same font
>| > >>| family or colors, I wouldn't want to have to manage that information in
>| > >>| multiple rows of a single master table.
>| > >>|
>| > >>| What if, for example, one user wants to use a blue theme one day and a
>| > >>| green theme the next? I would have to change a hexadecimal value in
>| > >>| multiple rows, rather than one row in one table. Even though I still
>| > >>| can't visualize it, I think there must be a way to normalize CSS
>| > >>| relationships.
>| > >
>| > >
>| > > I think that you are making this far too complicated. Your users would
>| > > have to have a good grasp of CSS to alter their schemes. You would
>| > > also need to write a full blown CSS application (ala TopStyle) just to
>| > > maintain the information and valid options.
>| > >
>| > > What I have found is that user wants to have a selection of colour and
>| > > layout choices. They want to view the different options and just click
>| > > a button. This can be achieved by using predefined CSS files. The user
>| > > selection is saved to the database, read when they log in and applied
>| > > to each page that they view.
>| >
>| > make me wonder what the OP's intentions are with this rather complex
>| > construction. maybe mr S could elaborate a little on this ?
>|
>| My intention goes along these lines: a financial web application I am
>| writing (in Java) retrieves thousands of rows of data from a database.
>| Depending on the values in one (or more) of the columns, a particular
>| row of data may or may not be highlighted (i.e., mapped to a particular
>| CSS class). Also, the highlight color of the row may change depending
>| on exactly which value appears in the particular column.
>|
>| An oversimplified example: say there is a price-change column. When the
>| value in this column is negative, the entire row gets highlighted in
>| red. When the value is positive, but below a certain number, the row is
>| not highlighted. When the value is above the threshold number, the row
>| gets highlighted in blue. Above another number, the row gets
>| highlighted in green, etc.
>|
>| Users want to change these highlighting colors to suite their own
>| tastes. They can already change filters that determine when rows will
>| be highlighted anyway.[/color]
If they only want to change the colours then there is no need for the
complicated rules that you are planning.
In an application that I wrote I allowed the user to change 7
properties, main background colour, font colour, border styles and
colours and layout modes.
I stored this information in a single field in the database i.e.
#FF00FF|#00FF00|1 px solid #FF0000 etc
The server-side would get this data, split it apart and write out the
necessary ccs statements. In jscript it looked like:
var CSS = db.Fields.Item("CSS").Value;
var CSSArray = new Array();
CSSArray = CSS.Split("|");
to generate the client-side CSS I used:
<style>
..mainBG {
background-color: <%=CSSArray[0]%>;
color: <%=CSSArray[3]%>
margin: 0;
padding: 0 4px 0 6px;
}
..hilite { color : <%=CSSArray[1]%>; }
..boxed { <%=CSSArray[2]%>; }
etc etc
The user configuration page consisted only of the items that they were
allowed to change.
If the user wanted a style like:
..mainBG {
background-color: #9400D3;
color: #FF00FF;
font-family: cursive;
font-size: 10px;
font-weight: bold;
}
my coding didn't stop them from having what they wanted. Believe me
someone actually wanted this scheme and dispite the advice from myself
and 2 other graphic designers the user still persisted. It wasn't
until they started getting complaints from their users that they
decided on a different scheme.
The moral of the story: not everyone is a graphic designer (including
myself) so it is up to you, the programmer, to note the users
limitations and set your rules accordingly.
Your configuration page would control the rules i.e. if the user
selected a light colour background then you must offer them an
appropriate contrasting colour for the text colour.
Also, if the user forgot to set an option you must either prompt the
user to set it or user an appropriate default i.e. if the user
selected a dark green background then you wouldn't want the default
text colour of black.
[color=blue]
>| I don't want to deal with separate CSS files. In fact, I don't want any
>| CSS files at all. Instead, the CSS should be generated dynamically at
>| compile time in the HEAD area of the page based on CSS information in a
>| set of SQL tables that get joined to a user account table.[/color]
Agreed. Your further explanation rules out the need for multiple CSS
files.
[color=blue]
>| The question is, how would you organize these SQL tables in a way that
>| is normalized? I wonder if this question belongs in another NG?[/color]
No tables, just a single field in a table.
---------------------------------------------------------------
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------