wiki:ImportDataSpecs

Version: 0.5

Terminology: Terms 'scalar', 'mapping' and 'sequence' are used below with the same meaning as in  YAML 1.1 specification.


Blogs

Import data for blogs is a directory with a following structure:

/
|-- init.yml
|-- templates/
|    |-- [slug1].html
|    |-- [slug2].html
|    -
|
|-- files/
|    |-- stylesheet.css
|    |-- image_1.jpg
-    -
  • init.yml: YAML 1.1 file that contains data for the blog and its boxes
  • templates: A directory with a number of HTML chunks (a chunk per .html file) with templates for the blog and its boxes in them.
  • files: A directory with various files (usually, stylesheets and images) that is copied to a directory accessible by web server and not accessible by Django framework.

init.yml

This file accepts two first-level mappings: blog and boxes (in that order) blog mapping has three required scalars, name, title and template, and a number of optional scalars that MUST represent actual fields in the database (check apps.front.models.Blog for more information).

  • name: (scalar) a unique name for this blog (only letters, numbers and underscores are allowed)
  • title: (scalar) blog's title
  • template: (scalar) filename that represents a file in the templates directory that contains a layout markup (i.e. Grid) for this blog

Second mapping, boxes, contains a number of child mappings, one box per mapping. Each mapping MUST have a unique name because it is used as a name field in the database. Each mapping has only one required scalar, `template, and a number of optional scalars that MUST represent actual fields in the database (check apps.front.models.Box for more information).

  • template: (scalar) filename that represents a file in the templates directory that contains a template (in Django template language) for the box

Example:

blog:
  name: alapos
  title: "Alapos"
  template: "alapos.html"
  external_stylesheet: "/var/files/alapos/alapos.css"

boxes:
  # static boxes
  image:
    template: "image.html"

  title:
    template: "title.html"

  featured:
    template: "featured.html"
    tag: "alapos:featured"
    limit: 1

  politics:
    template: "articles.html"
    tag: "alapos:politics"
    limit: 2
  
  science:
    template: "articles.html"
    tag: "alapos:science"
    limit: 2

Layout markup (i.e. Grid)

Grid is presented as a simple (X)HTML 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. Allowed tags: TABLE, TR, TD and CONTENTBOX. All other tags will be removed while saving to the database.

  • CONTENTBOX: a self-closing tag. Has one required argument "src" that is a link (blog_name:box_name) to the corresponding content box in the database. It also has a number of optional arguments: inline properties. All inline properties are presented in templates as simple variables.

Example:

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

Box template

Box template is an HTML chunk with Django template tags and webmore tags enabled.

Example:

{% for article in articles %}
<h4><a href="{{ article.get_absolute_url }}">{{ article.title }}</a></h4>

<p>{% webmore_text article.intro %}</p>
{% endfor %}

Articles

Import data for articles is a directory with a following structure:

/
|-- init.yml
|-- contents/
|    |-- [slug1].html
|    |-- [slug2].html
-    -
  • init.yml: YAML 1.1 file that contains data for the articles
  • contents: A directory with a number of HTML chunks (a chunk per .html file) with articles text in them.

init.yml

It accepts a number of first-level mappings, one mapping per article. Each mapping MUST have a unique name because it is used as name (i.e. slug). Each mapping accepts a number of scalars that MUST represent actual fields in the database (see apps.front.models.Article and apps.front.models.Part for more information). Two scalars, author and default_journal, are foreign keys: you MUST write a username for the author scalar and a blog name for the default_journal.

A mapping can have an optional comments sequence. Each item in a sequence is a mapping that represents actual fields in the database. Scalars author and default_journal act the same way as in its parent mapping.

Example:

# Science
animals:
  title: Do animals feel empathy?
  author: anton
  tags: "science"
  default_journal: alapos

memories:
  title: Recovering long-lost memories (with comments)
  author: anton
  tags: "science"
  default_journal: alapos
  comments:
    - {anchor: 1587722819, author: anton, content: "Mice everywhere, OMG!"}
    - {anchor: 1587722819, author: baldvin, content: "I do not really believe you, mister Rat."}
    - {anchor: 693577342, author: rooslan, content: "I am silent, very silent"}

Article content

Article content is retrieved from the file that is stored in content/ directory and has a name [article_name].html (e.g. for an articles above files should be content/animals.html and content/memories.html) This file is a simple HTML chunk with <webmore /> tags enabled.

Example:

<p>
  The ability to retrieve long-term memories is essential: Without
  access to old memories, we have no personal
  histories. Unfortunately, there are neurodegenerative diseases,
  including Alzheimer's disease, in which old memories are
  lost. <webmore anchor='693577342' />For example, people with
  advanced Alzheimer's disease can no longer recognize their family
  members.
  <!-- [...] -->
</p>

Users

Import data for users is a YAML 1.1 file. It accepts a number of first-level mappings, one mapping per user. Each mapping MUST have a unique name because it is used as username. Each mapping accepts a number of scalars that MUST represent actual fields in the database (see django.contrib.auth.models.User for more information).

If a second-level profile mapping is provided, it will be used for UserProfile model (apps.auth.models.UserProfile). It accepts a number of scalars that MUST represent actual fields in the database.

Example:

baldvin:
  first_name: Baldvin
  last_name: Kovács
  email: some@email.com
  profile:
    collapsed_bubbles_color: ECF3E1
    expanded_bubbles_color: E5ECF9

anton:
  first_name: Anton
  last_name: Kovalyov
  email: some@email.com
  profile:
    collapsed_bubbles_color: ECF3E1
    expanded_bubbles_color: E5ECF9
    openid_url: http://antonkovalyov.livejournal.com/

rooslan:
  first_name: Rooslan
  last_name: Khayrov
  email: some@email.com