Start page

Mykola Zharkikh (Kyiv)

Personal site

?

Smerefs

While talking about document addressing in Smereka one primarily should clearly distinguish the absolute (or direct) links to other documents and abstract references or smerefs (smeref = Smereka reference)

If one want to make link to another site, there is no another opportunity except direct link: <a href="http://example.com">Example</a>.

But if one want to refer to another document on the same site (to another node in Smereka tree), both direct links and smerefs can be used.

Let our document tree looks like (in brackets – node ids):

ThePope [1]

Was [2]

MoscowPatriarchate [10]

Is [3]

Autocefalic [11]

Have [4]

TheDog [12]

WillBe [5]

Atheist [13]

Now we can use in Smereka documents absolute references:

<a href="http://example.com/index.php?Node=12">Pope and Dog story</a>

(using numerical addressing);

<a href="http://example.com/index.php?Path=ThePope/Have/TheDog">Pope and Dog story</a>

(using symbolic addressing);

<a href="http://example.com/ThePope/Have/TheDog">Pope and Dog story</a>

(using virtual addressing);

All these links are absolute; Smereka did not modify them anywhere and include their text to the final HTML document literally.

For these links one can use smerefs following:

<Smereka Func="Smeref" NodeId="12">Pope and Dog story</Smereka>

This code denotes smeretag or lookup field, which is translated into one of the Smereka absolute forms, described above. The form is context-sensitive. In edit mode, Smereka always uses numeric addressing, which is Smereka internal standard. In view mode, intended for external users, the form is determined by $URLMode parameter in the file customsettings.php. This parameter can be set to 'ById', 'ByPath', 'Virtual' values.

Number addressing is designed mainly for debugging mode. If everything works right, it can change to symbolic or virtual.

Smerefs used not only in the form of lookup fields; Smereka generates them when processing other smeretags such as navigators or aggregators. Thus, their behavior also depends on the $URLMode parameter.

Virtual addressing

This addressing mode will only work together with the relevant configured addresses rewrite rules (mod_rewrite in Apache). Please be aware that the number and character addresses remain valid within virtual addressing.

Virtual addressing imposes very little restriction on the configuration of the website physical directories :

1. There should be no other files in root directory, except index.php and .htaccess. Rather, other files can be placed, but they will not be accessible via http protocol in effect of address rewriting.

2. A directory files should be created in the root directory, where one can put different files to be accessible via http protocol (there is no address rewriting in this directory, unless you made specific settings).

3. In the document tree one should not give a symbolic name files to nodes, which is directly subordinate to the domain or subdomain root node. (Symbolic names are case-sensitive, so Files is acceptable, but we do not want to have to create confusion…)

Under these conditions, the external virtual address translation is quite simple:

http://example.com/en/ThePope/Have/TheDog

translated in:

http://example.com/index.php?Lang=en&Path=ThePope/Have/TheDog

Address:

http://example.com/ThePope/Have/TheDog

translated in:

http://example.com/index.php?Lang=uk&Path=ThePope/Have/TheDog

In the latter case, when a virtual catalog of the zero-level does not define the language version, Smereka used the default language (oftenly it is the Ukrainian language).

Note that within Smereka there is no difference between files and directories: a node simultaneously possesses information as a file and subordinate nodes as a directory. Therefore, a known problem "last slash (/)" it's not important for Smereka. URLs http://example.com/ThePope/Have/TheDog (where TheDog is like a file) and http://example.com/ThePope/Have/TheDog/ (where TheDog is like a directory) are handled identically and translated to the same node. So, Smereka ignores the last slash in the URL.

Default extension

Smereka does not need node symbolic name contain an extension (such as TheDog.html or TheDog.php). However, such extensions can be used.

If the extension is set directly in the «symbolic name» node field, it will always be displayed as is. According address this page should contain this expansion.

If the node symbolic name does not contain extension, the Smereka can append the default extension to make the reader look what he reads (e.g.) a static .html file.

To do this, one should set the variable $DefaultExt in the file customsettings.php. Example:

$DefaultExt = 'html';

This default extension automatically attached to the name of the terminal node, and omitted during the interpretation of the URL. Thus, if node symbolic name – TheDog (without extension), then addresses http://example.com/ThePope/Have/TheDog and http://example.com/ThePope/Have/TheDog.html will point to one document. Of course, will be better to observe certain disciplines, and if use the default extension, then use it everywhere, and does not to confuse search engines so-called doubling documents.