You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rich Bowen <rb...@rcbowen.com> on 2009/12/27 21:18:47 UTC

Autoindex patch

A couple years back, the IndexStyleSheet directive was introduced, but  
was of limited usefulness for some of the stuff folks wanted to use it  
for, simply because the HTML didn't contain any CSS classes. The  
attached patch is a simple proof-of concept, introducing the CSS  
classes ai_table, ai_th, ai_tr, ai_tr_odd and ai_tr_even that you can  
then style in an IndexStyleSheet. This allows you to do things such as  
alternating rows in the directory listing.

Yes, technically I have commit rights, and I'm aware that trunk is  
CTR, but since I've never actually committed outside of the docs, I  
wanted to run this by dev@ for feedback.

Yes, there will be docs to go along with it if/when it is committed.


Re: Autoindex patch

Posted by Rich Bowen <rb...@rcbowen.com>.
On Dec 27, 2009, at 15:38 , Nick Kew wrote:

> Alternating <tr> classes support
> trendy striped tables (for whatever that's worth),
...

So, since my intent was, in fact, just to add "trendy striped tables",  
here it is again:

Index: mod_autoindex.c
===================================================================
--- mod_autoindex.c     (revision 894107)
+++ mod_autoindex.c     (working copy)
@@ -1482,6 +1482,7 @@
                                 char direction, const char *colargs)
  {
      int x;
+    int row_count;
      apr_size_t rv;
      char *name = r->uri;
      char *tp;
@@ -1658,7 +1659,23 @@
          }

          if (autoindex_opts & TABLE_INDEXING) {
-            ap_rputs("<tr>", r);
+            ap_rputs("<tr", r);
+
+            /* Even/Odd rows for IndexStyleSheet */
+            if (d->style_sheet != NULL) {
+                ap_rputs(" class=\"", r);
+                if ( row_count % 2 == 0 ) {
+                    ap_rputs("ai_tr_even", r);
+                }
+                else {
+                    ap_rputs("ai_tr_odd", r);
+                }
+                ap_rputs("\"", r);
+                row_count++;
+            }
+
+            ap_rputs(">", r);
+
              if (!(autoindex_opts & SUPPRESS_ICON)) {
                  ap_rputs("<td valign=\"top\">", r);
                  if (autoindex_opts & ICONS_ARE_LINKS) {




--
Rich Bowen
rbowen@rcbowen.com




Re: Autoindex patch

Posted by Rich Bowen <rb...@rcbowen.com>.
On Dec 27, 2009, at 15:38 , Nick Kew wrote:

> Any classes you attach are by definition arbitrary.  A class for  
> <table>
> adds absolutely nothing.  Neither does <th> unless you use different
> classes for different instances of it.  Alternating <tr> classes  
> support
> trendy striped tables (for whatever that's worth), but IMHO if we're
> going down that road, we'd be better taking the HTML out of the code
> altogether and turning it into a template the webmaster can hack
> at leisure.

I started with just the alternating tr classes, but then thought,  
well, someone is going to complain that I didn't go far enough, and so  
added the other stuff, even though I, personally, only have use for  
the alternating tr classes. I suppose that'll teach me to go father  
than my own itch.

--
Rich Bowen
rbowen@rcbowen.com




Re: Autoindex patch

Posted by Nick Kew <ni...@webthing.com>.
Rich Bowen wrote:
> A couple years back, the IndexStyleSheet directive was introduced, but 
> was of limited usefulness for some of the stuff folks wanted to use it 
> for, simply because the HTML didn't contain any CSS classes.

Nothing wrong with that.  You hook to the elements, including as much
hierarchy as you need.  In fact, you can address pretty much everything
individually that way, by virtue of knowing the structure of the page.

>	 The 
> attached patch is a simple proof-of concept, introducing the CSS classes 
> ai_table, ai_th, ai_tr, ai_tr_odd and ai_tr_even that you can then style 
> in an IndexStyleSheet. This allows you to do things such as alternating 
> rows in the directory listing.

Any classes you attach are by definition arbitrary.  A class for <table>
adds absolutely nothing.  Neither does <th> unless you use different
classes for different instances of it.  Alternating <tr> classes support
trendy striped tables (for whatever that's worth), but IMHO if we're
going down that road, we'd be better taking the HTML out of the code
altogether and turning it into a template the webmaster can hack
at leisure.

That'll teach you to post here for review: if you'd just gone ahead
and committed, I'd probably have shut up :-)

-- 
Nick Kew