BML SchemesChanging your site's layoutBML is the language used to serve pages to users that they don't manage
themselves. To get an idea of what BMLis, the following is a quote from the
BML manual:
The Better Markup LanguageBML is a server-side markup language that lets you define your own
BML blocks and use them as templates within your BML
pages. Your templates don't even have to be static. Because BML pages are
converted to HTML on the server when users request them, this also enables
you to embed live code within your BML pages, just like a
CGI script.
With LiveJournal, we used BML because it makes it easier for us to write the
layouts that comprise LiveJournal, without requiring frequent changes or rewrites on our part
to come up with a customized look and feel. In the next section you will read how to make the
necessary additions to the LiveJournal schemes to tailor your LiveJournal installation to your
exact needs.
For more information on BML, please refer to .Writing a BML SchemeBML is essentially a simple macro language. Macros are called
templates in BML. Templates are defined in
lookup files and are invoked in
BML files. Templates accept parameters and are divided into several types
according to how parameters are transmitted and how the definition of the template is able to make
use of them. Definitions of templates are essentially chunks of HTML with
potentially more recursive BML template invocations inside them.
For LiveJournal, the most common templates are defined in the file
$LJHOME/cgi-bin/bml/scheme/global.look; all other
schemes either replace all of the templates, or inherit whichever
is not replaced.
To write your own scheme, all you have to do is write your own BML
lookup file that use the same templates as $LJHOME/cgi-bin/bml/global.look.
Then, implementing a new scheme becomes pretty painless:
Creating a new BML scheme: foo:
Create a new file under $LJHOME/cgi-bin/bml/scheme, labelled
after the scheme name (foo). For example:
$LJHOME/cgi-bin/bml/scheme/foo.look.
This file should contain all of the BML directives you've written for your unique layout.
The first line in this file should be _parent=>global.look.
If you don't have a local BML configuration file (_config-local.bml)
in your $LJHOME/htdocs/ directory, you should create one now.
The contents of that file should look like:
Sample _config-local.bmlDefaultScheme foo
Manually restart the apache process.
After you've written your scheme, consider adding it to the array in , so that
your users can use their preferred scheme.
BML Template ReferenceFor reference, here are the most commonly used BML templates in the LiveJournal repository:Pre-configuredThe following are BML templates that are set from configuration options in $LJHOME/cgi-bin/ljconfig.pl.
All templates here are defined as S (static).DOMAINIMGPREFIXSTATPREFIXSITEROOTSITENAMEADMIN_EMAILSUPPORT_EMAILThe following BML templates are defined in $LJHOME/cgi-bin/bml/scheme/global.look
and are available in every scheme.GlobalSECURITYPRIVATEHTML image sourcing from /img/icon_private.gifSECURITYPROTECTEDHTML image sourcing from /img/icon_protected.gifLJUSERGiven a username, it creates a properly formated LiveJournal username referenceLJCOMMGiven a community username, it creates a properly formatted LiveJournal community username referenceLJUSERFSame as LJUSER, except that the link to the userinfo page includes the additional user informationHELPGiven a URL, this provides a small link with the caption helpINERRDisplays an error message in an easily identifiable manner (bold red text)NEEDLOGINA small blurb that's included on pages where the user is not logged in and is required to beBADINPUTAn error message that displays when there is an encoding problem with the user's browserREQUIREPOSTAn error message explaining that certain user actions require POSTing information through an HTML form, rather than manually GETting the pageLOAD_PAGE_INFOInitializes and populates a perl array that is used to create a sidebar of links along a page layoutH1Top level header on a pageH2Sub level header on a pagePGeneric HTML paragraph wrapperSTANDOUTGiven a block of text, this template tries grab the user's attention by using different text and background colorsBADCONTENTAn error message that displays when a problem (that the user can fix) has occurred during a requestDEA template that de-emphasizes textEMCOLOREMCOLORLITEHOTCOLORVarious emphasis colorsSCREENEDBARCOLORA color that is used to highlight screened comments in comment threadsCHOICEGiven 3 arguments (a URL, a title, and an explanatory blurb), this template fashions an item to be used in a CHOICES listCHOICESGiven 2 arguments, this template tries to construct a side by side list of options and appropriate linksPAGEThis template is the BML template that governs the look of the entire scheme, and takes 4 arguments:
titleThe page titleheadPage-specific elements that belong in a HTML headbodyoptsAdditional attributes for the HTML body elementbodyThe main content of the page