/packages CGI HTML modernization

Warren Young warren@etr-usa.com
Fri Jun 20 16:54:00 GMT 2014

On 6/19/2014 22:43, Achim Gratz wrote:

>    background-size: 1em 1em;

No.  The original gray ball bitmap is 20x20, and the current layout 
scales it to 10x10, on purpose.  Scaling it to "em"s makes the size 

Ideally, cygwin.com would have its own bullet image so it doesn't have 
to be scaled in the browser.  The result wouldn't need to be padded, 
either, since CSS can take care of positioning and margins.

>     width: 30%;

You can do both, of course.  Set the width of the package name column to 
30% -- or whatever -- in the static CSS, so that at least you'll have a 
sensible default in the noscript case.

I do now see that the page already uses JavaScript.

On revisiting this, I've come up with several refinements, with the end 
result that the new concept fully replicates the existing look.

First, the <span> around the <a> is redundant.  You can address the 
package name link element directly.

Second, by putting the description in a span, you can make it wrap 
inside the second column width just as the current <table> based 
implementation does.

The second change makes the gray ball list bullet disappear for some 
reason if you leave it on the <li> element, but I figured out how to get 
it to appear as part of the <a> element.  It means the bullet is now 
clickable, which is odd, but this doesn't bother me.

Each <li> now looks like this:

     <li><a href="x86/pkg">pkg</a><span>description</span></li>

The CSS is now:

   <style type="text/css">
     ul.pkglist li {
       display: block;
       clear: both;

     a {
       background: url('http://sourceware.org/icons/ball.gray.gif')
       background-position: 0px 0.7em;
       background-size: 10px 10px;
       float: left;
       padding-left: 20px;
       padding-top: 0.4em;

     span {
       float: left;
       padding-top: 0.4em;

and the JS is now:

     <script type="text/javascript">
       var lw = $('ul.pkglist').width();
       var mw = 0;
       $('ul.pkglist a').each(function(i, e) {
         mw = Math.max(mw, $(e).width());
       }).css('width', mw + 10 + 'px');
       $('ul.pkglist span').css('width', lw - mw - 40 + 'px');

The "40" constant subtracts out some of the padding the browser adds. 
If it gets too small -- or you leave it out -- the <span> becomes too 
wide and has to wrap below the <a>.

I made these changes to a copy of the /packages generated HTML, and the 
page weight and render time both dropped roughly in half.

More information about the Cygwin-patches mailing list