Executive summary

I had fun this summer. New Writeups needs new styling in most themes. New Writeups - Zen is broken. There are some bugs in ecore.

Gory details

I had some spare time and felt like hacking over the summer, so I had some fun continuing my pet project, aiming to finish off the front page.

To provide for consistency by doing things in one place, I created a function to output content and information about content wherever it might be. The idea is that this will gradually take over presentation of all user-contributed content. This needed more and different arguments than an htmlcode can deal with, but it was impractical to put it into ecore. So I call it like this:

&{ evalCode('sub {'.getCode('show content').'}') }( $arg1 , $arg2 , $arg3 ) ;


Editing reallycool nodelet - zen (Cream of the Cool) and weblog (for Front Page News) to use this function was fairly simple and left the code much shorter.

New Writeups also appears on the front page and contains information about content, which is prepared by the htmlcode zenwriteups. Since hitting the database to ask it about new writeups every time a guest user loaded a page would be bad for performance, it used a cached feed in which an array of 50 hashrefs is stored as text. For logged-in users the database was queried for vote information, and for all page loads the code iterated through the items in the feed leaving out the hidden writeups except for editors who wanted to see them. When it included the hidden writeups, it counted them wrong.

I rewrote the zenwriteups to get all information including the votes on the precise number of new writeups required by the user with one SQL request and then present it with the new function. For Guest User I created a nodelet calling the same htmlcode, which is updated periodically along with the other cached nodelets. The net result is that Guest User's version of New Writeups requires approximately no database access and minimal perl processing, while logged-in users still hit the database once each time they load it as before, with a query that shouldn't be (much) heavier, but get an up-to-the-second version.

Another nodelet, Logs, is very similar to New Writeups and worked in a similar way but with a feed that only queried the database for new writeups of type log. So I adjusted the zenwriteups htmlcode to accept an argument specifying a SQL WHERE parameter and adapted the nodelet to use it. No Guest User caching is required for this nodelet, since Guest User doesn't see it.

As a result of the change in zenwriteups to accept the argument, my new version of New Writeups broke, due to a bug in htmlcode in ecore: when an htmlcode that can use an argument is called with no argument, it gets its own code as argument. I fixed New Writeups to use an empty argument, but didn't look at the old test nodelet New Writeups - Zen, since I didn't realise anyone was using it.

The htmlcode bug and the fact that the hack I mentioned above worked provoked me into doing some work on ecore.

I carried out a consultation exercise on the changes I was working on.

The changes I had made to the html would break a lot of styling, so I started coding a function to fix it automatically. The function is called to fix sheets on the fly and also by the autofix button on the editing page. Obviously, the function needed testing on a large number of stylesheets, and to make that practical I created a quick theme test function, which was implemented on the production server, and which I then adapted on the dev server to test fixed versions of production stylsheets on the changed html. Since New Writeups was completely different in structure from the old version, I told the styleseet fixer to disable rules for it that would probably have unintended effects.

Having an automatic stylesheet fixer made it realistic to make some more changes in the html, giving nodelets ids based on their name rather than their number, and similarly adjusting the classes and ids on the body element (which aren't widely used, but are nonetheless very useful). This led to some pages having a body with class 'writeup', which was already in use. Rather than complicate the code for body element classes, I replaced the old 'writeup' class on the writeup and e2node display pages with the generic class 'item'.

Finally, to obviate the need to autofix the default stylesheet, I patched Kernel Blue. After consultation with archiewood I did the same for Jukka Emulation.

The result of all of this as of last Thursday was a new function on the production server and 16 production-ready patches on the devel server, 12 of which all needed importing at the same time. I briefly considered writing a bulk patch importer function, but then just put numbers on them and trusted the gods to work quickly.

After implementation surprisingly little went wrong. The Ajaxed chatterbox was briefly broken until Oolong fixed it. There turned out to be a bug in the New Writeups rule disabling function that messed up my own stylesheet (fixed that), and another bug related to importing that messed up my own stylesheets (won't affect others, fixed the stylesheets), and it turned out that New Writeups - Zen was still in use. Some people were rather disconcerted by the completely usable and entirely sane structure of New Writeups, others merely missed its former multi-hued beauty.

Log in or register to write something here or to contact authors.