Joe (erebrandir) wrote in lj_dev,
Joe
erebrandir
lj_dev

PATCHES: User bio can be marked preformatted

Abstract

With these patches, the user bio can be marked as preformatted.

Description

In the course of trying to work on the bio for a community, I realized, to my exasperation, that the user bio is auto-formatted (i.e. line breaks are added). When using heavy HTML, especially with tables and lists, this mangles the rendering atrociously, leaving unsightly gaps of whitespace. In the cases of events/entries and comments/responses, there is an option to mark the code as preformatted, thereby preventing the HTML cleaner from adding line breaks. It only goes to reason that a similar option should be available for the user bio.

So, I added one. This implementation adds a new column opt_preformatted to the table userbio, and adds appropriate support to editinfo.bml and userinfo.bml.

I followed some of the handling of the options on the table user, making the new column a char(1), and using values of "Y" and "N". This could be changed, if necessary.

I wasn't exactly sure of the procedure for adding new columns to the database, so I tried to follow what had been done before. I added a section in update-db-general.pl to ALTER the table and add the column, and also added the column to that table's CREATE TABLE section.

Question: Isn't this way of doing things—adding ALTER statements to the script to explicitly alter tables—a bit inefficient? Would it be possible to write a script to check the tables in the database against a table definition file, and make alterations if any differences are found between the existing schema and the definition file?

Patches

livejournal/htdocs/editinfo.bml Tested
livejournal/htdocs/userinfo.bml Tested
livejournal/bin/upgrading/en.dat Tested
livejournal/bin/upgrading/update-db-general.pl Tested

All patches tested locally.

Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 15 comments