wiki:LayoutManagementSystem

Layout management system

Grid

Grid is presented as a simple (X)HTML table. Example:

<table>
  <tr>
    <td><!-- ... --></td>
    <td><contentbox src="alapos:news" /></td>
  </tr>
  <tr>
    <td colspan="2"><!-- ... --></td>
  </tr>
</table>

Each field is specified by the TD tag. It can has another table or a special <contentbox /> tag that acts as a link to the corresponding content box (more about this below). content box object in the database.

Allowed tags: TABLE, TR, TD and CONTENTBOX. All other tags will be removed while saving to the database.

Content box

A content box object is a mainly a django template with some metadata. It has a slug field (name), position number, template code, tag, query, several properties and a hash. Here is the pseudocode example:

ContentBox:
  name = String
  position = Integer (default:0)
  template = Text
  tag = String (can be None)
  query = String (can be None)
  limit = Integer (default:10)
  unique_only = Booblean(default:true)
  meta = Hash (can be None)

When a page is to be rendered, all the content boxes in it are ordered according to their position numbers, and they are to be rendered in that order. (It is important: a box must be able to show just the articles which did not yet appeared before. For example, you don't want to show the main headline article twice, once in the big headline box, then in the box of the 5 main articles.)

Upon execution, a content box uses a query function to retrieve articles from the database. The default query function uses the tag, limit, just_new_articles parameters to select the most recent "limit" number or articles having the given tag.

Meaning of "most recent" regarding articles: when an article gets tagged with the ContentBox?.tag tag, that tagging is physically a record creation in a database table. That record should keep at least two datetime fields: 1. tagging date, 2. priority. They both should be initialized to 'now'. Priority will be manually editable by the blog owner (who also owns the rights to that tag!). Articles are to be ordered according to that priority value.

Query is a path to the function somewhere in the codebase that takes some parameters and returns a list of articles, retrieved from the database.

If unique_only flag is set, only unique articles (i.e. articles that were not displayed anywhere on that page before) should be selected.

meta is a free hash that has no required items in it.

As for template, users can use loops, conditional operators and HTML to display their data.

Our system should be able to easily export and import both grids and content boxes into the human-readable XML format.

Export/import XML

Input data for export to XML is a Grid layout and data in the database (for boxes). Output data is a directory with the following structure:

/
|-- layout.xml
|-- templates/
|    |-- [slug1].html
|    |-- [slug2].html
|    -
|
|-- files/
|    |-- stylesheet.css
|    |-- image_1.jpg
-    -

File layout.xml contains exported content of the Grid's layout and a collection of boxes and their properties. Directory templates/ contains several html files (one per box) with django's template code. Directory files/ is simply a copy of the user's directory on server.

Input data for import from XML is a directory as one descibed above and output data is a Grid's layout and data in the database.

TODOs

  1. Update models for both the blog's layout and content boxes according to the description above. (#343)
  2. Create a simple parser that will take a layout, static boxes and generate a page based on that data. (#344)
  3. Create a default query function that will run a database query according to box's properties and return a list of articles. (#345)
  4. Integrate parser with the query function described in #345 and above in the text. (#346)
  5. Implement an availability to use external files (#347).
  6. Update Alapos.hu's initial data for our new layout management system. (#351)
  7. Merge layout management branch with the trunk (#348).