Hi,
I'm thinking about the layout of pages in zim files. I have some ideas, what to do and I would like to share thes with you. Especially I would like to hear your expectations about the content of zim files.
Let me explain the problem. In the german wikipedia DVD the layout of the page was partly hardcoded into the reader. The html-frame, css, images and javascript-files were compiled into the application. With a special namespace '-', these files were accessable. E.g. "/-/monobookde.css" loads the css file from the application.
It is easy to move these into the zim file.
The html-frame is more difficult, since it contains dynamic parts like "<title>...</title>" or the actual article text. So to move this page into the zim file, we need some placeholders, which need to be parsed at runtime.
My plan is to introduce a special syntax for these placeholders. The tag "<%something%>" may be replaced. This "something" need to be defined. This syntax may be used in the layout page, which is already in the zim file header as well as in arbitrary pages. We might also add a special mime type in addition to zimMimeTextHtml, where the zimlib parses these tags.
This "something" may be: <%title%> title of the page <%url%> the url of the page (e.g. /A/Linux) <%namespace%> the namespace <%/A/Linux%> insert another article here <%content%> placeholder for the article content in the layout page ... (maybe more in the future)
In the zim lib we have a class "zim::Article". This has a method "getData()", which returns the article data of the page. I would add a new method "getPage()", which uses the layout page to return the complete page.
This layout page should only be used, when the mime type is zimMimeTextHtml.
This way the creator of the zim file can specify, how to show pages without repeating the html-header and footer on each page. A reader may ignore this layout if wanted.
Tommi
I am generally okay with that, it seems to be the most flexible solution.
At the Developers Meeting we also discussed another solution:
Having a header and a footer part inside the ZIM file, so the HTML page would be constructed by the reader by concatenating header, article and footer together.
But I think that the solution with the parser is much better.
In the zim lib we have a class "zim::Article". This has a method "getData()", which returns the article data of the page. I would add a new method "getPage()", which uses the layout page to return the complete page.
This layout page should only be used, when the mime type is zimMimeTextHtml.
Wouldn't it be sensible to be able to have also templates for other MIME types? I think of the J or U namespaces for image and category description pages?
Greets,
Manuel