Miril::Manual - Why and how to use Miril, the static content management sytem.
Miril is written in perl and uses the CGI::Application framework.
Miril stores your data in a backend (text files, a database, etc.) and publishes it to static pages. Unlike homegrown static publishing solutions (e.g. scripts using the Template Toolkit), Miril provides a nice user interface for editing content.
Miril has been designed from the very start to be extremely easy to deploy. The main distribution only has pure-perl dependencies. The immediate plans include bundling all prerequisites in a single file and shipping Miril as a standalone cgi script, to that installing on a typical shared host should be a no-brainer.
Miril has been designed with small to medium-sized websites in mind, i.e. websites with hundreds of pages as opposed to thousands of pages. If you have a typical small website such as a corporate website or a personal blog Miril may be a better deal for you than full-blown content management systems since it is faster to deploy, easier to manage, and generally has less administrative overhead both for the site administrator and for the users.
Miril has a user interface that has been deliberately kept extremely simple and uncluttered. The goal is for the end users of Miril (those in charge of managing content) to require little or no training to start using it. This means that some of the administrative tasks (such as user management and adding special types of pages) can only be performed by editing the configuration files and templates manually. For a similar reason, Miril also takes a very simplistic approach towards access management and does not provide roles or complex permissions. In fact, Miril has been designed to be used in teams where 1) users generally can trust each other and complicated access management is not necessary and 2) there is at least one tech-savvy user who can take care of the occasional administrative tasks.
Miril is extensible. You can (or at least you will be able to in the near future) choose between different storage backends (or models), different templating systems, etc.
Miril is run as a cgi script. This means that:
On a shared host, you can run Miril from your cgi-bin directory. It will run slower than in a mod_perl environment, but since Miril will be used only when managing content this should not be a problem.
cgi-bin
mod_perl
Of course, if you have sufficient control over your environment and the load on Miril demands it, you can accelerate Miril by running it under FastCGI or mod_perl.
FastCGI
Because Miril ultimately produces static content only, you can run it from your local machine and then synchronize your local output directory with the web server. This way you can manage websites on servers that don't even have perl installed, or where installing Miril would be difficult.
perl
Currently Miril is installable only from CPAN. Simply run install Miril from your favourite CPAN shell.
CPAN
install Miril
Once you have installed Miril, create a cgi script named miril.pl or miril.cgi with the following content:
miril.pl
miril.cgi
#!usr/bin/perl use strict; use warnings; use Miril; my $app = Miril->new( PARAMS => { cfg_file => 'miril.config' } ); $app->run;
Change the shebang line to wherever your perl is located and change miril.config to wherever you configuration file (see below) is located. The configuration file path can be relative to the location of the cgi script. If this option is not provided, Miril will try to load a file named miril.config and located in the same directory as the cgi script itself. Put that script in your cgi-bin directory.
miril.config
Make sure you create your configuration file in the location that you chose above. Currently only XML is supported for the configuration file format.
A minimal configuration file has the following content:
<xml> <data_path>../miril/data</data_path> <tmpl_path>../miril/tmpl</tmpl_path> <cache_path>../miril/cache</cache_path> <cfg_path>../miril/cfg</cfg_path> <files_path>../htdocs/files</files_path> <output_path>../htdocs</output_path> <http_dir></http_dir> <files_http_dir>/files</files_http_dir> <domain>http://www.example.com</domain> <secret>Some secret line</secret> </xml>
The options are explained here:
This is where Miril stores your content when it uses a file-based model (such as Miril::Model::File::XMLTPP, which is the only model currently available). Miril must have read-write access to this directory.
This is where you are going to put all the templates that Miril will use to build your website (see below). Miril must have read access to this directory.
Miril may use this directory to store random information. It must have read-write access.
This is the directory where the file with information about Miril's users will be located. Miril must have read-write access to this file. You may want to put in in the same directory with your main configuration file.
This is the directory where files (e.g. images, pdf files, etc.) uploaded by Miril users will be stored. Miril must have read-write access to this directory. In a typical installation this directory will be somewhere below your server's document root.
This is the directory where Miril will place all the output files it produces. In a typical installation this directory will be somewhere below your server's document root.
This is the base URL of your website and Miril will use this string to prefix all URL's that it produces. If your website is located at http://www.example.com, you would set http_root to http://www.example.com to produce fully qualified URL's. If you want your website to have relative URL's, you need to leave this option empty. If your website is located at http://www.example.com/mywebsite, you would set http_root to http://www.example.com/mywebsite for fully qualified URL's and to /mywebsite for relative URL's.
http://www.example.com
http_root
http://www.example.com/mywebsite
/mywebsite
This option specifies the base URL for accessing the files managed by the files_path option above. It follows the same rules as http_root.
files_path
If you have specified a relative URL in http_root above, use this option to provide the domain name of your website for cases where fully qualified URL's are needed, such as RSS feeds. Leave empty if you have set http_root to a fully-qualified URL.
A random phrase used for security purposes when encrypting authentication data stored in cookies (required by CGI::Applciation::Plugin::Authentication::Cookie).
Which view module, or templating system, will be used to render your site. Default is HTML::Template, which will load Miril::View::HTML::Template. You can also set this to Text::Template, and additional templating systems may be added in the future.
HTML::Template
Text::Template
Next you may need to configure your content types. This is what a basic configuration looks like:
<xml> ... <types> <type> <name>Story</name> <id>story</id> <location>story</location> <template>item.tmpl</template> </type> <type> <name>Page</name> <id>page</id> <location></location> <template>page.tmpl</template> </type> </types> ... </xml>
You will get these two content types by default if you have not specified your own content types in the configuration file.
The user-friendly name of the content type, as it would appear to the end user.
A unique alphanumeric string identifying the content type, used internally by Miril.
The location, relative to output_path, where Miril will write entries of this content type.
output_path
The template file Miril will use to create html pages of this content type.
Miril allows you to create special pages which combine data from multiple items - e.g. a list of articles, a RSS feed, etc. This is how you configure lists:
<xml> ... <lists> <list> <id>news</id> <template>news.tmpl</template> <location>news.html</location> <match> <type>story</type> <status>published</status> <last>6</last> </match> </list> <list> <id>feed</id> <template>atom.tmpl</template> <location>atom.xml</location> <match> <type>news</type> <status>published</status> <last>10</last> </match> </list> </lists> ... </xml>
A unique alphanumeric string identifying the list.
The template file Miril will use to create this list.
The location of the file, relative to output_path, where Miril will write this list.
The match elemement is used to determine which items are included in the list. The filtering criteria are:
match
Only return items with this type id.
Only return items with the specified author.
Only return items with the specified topic id.
Only return the N most recent items matching the above criteria.
Only published items can be included in the list (i.e. items whose status is published and not draft).
published
draft
Miril allows you to specify the author of each post. The list of authors is specified in the confuguration file as follows:
<xml> ... <authors> <author>J. R. R. Tolkien</author> <author>J. K. Rowling</author> </authors> ... </xml>
Note that any registered user can specify any author name for any post, so this is used only to display post information in the published site rather than to control access. This is part of Miril's design philosophy (trusted team).
Miril has basic support for topics, or categories. The list of topics is specified in the confuguration file as follows:
<xml> ... <topics> <topic> <id>flowers</id> <name>Flowers</name> </topic> <topic> <id>animals</id> <name>Fuzzy Animals</name> </topic> <topic> <id>bananas</id> <name>Bananas</name> </topic> </topics> ... </xml>
Each post can then be associated with one or more topics.
You need a file with information about users and passwords in order to run Miril. The file must be named usres.xml and be located in the directory specified by the cfg_path option in the main configuration file. Currently only XML is supported as the configuration file format. The structure is as follows:
usres.xml
cfg_path
<xml> <user> <name>J. R. R. Tolkien</name> <password>123456</password> <username>tolkien</username> </user> <user> <name>J. K. Rowling</name> <password>123456</password> <username>rowling</username> </user> </xml>
Passwords can be stored either in plain text, or encrypted (using the MD5 algorithm). When you create a new user, you initially specify their password in plain text and them tell them to log in with this password but change it immediately afterwards. When a password is changed using Miril's user interface, it will be stored encrypted in the above XML file. Similarly, if a user has forgotten their password, you can temporarily reset it manually to a plain-text password and ask them to change it again.
Miril is not accessible to unregistered users. All registered users have identical permissions and can edit and publish all types of content.
Once the configuration and users files have been set up, you can run Miril and edit content. In order to publish content, however, you need to provide the templates which will be used to render your pages. The templates are located in the directory specified by the tmpl_path option in the configuration file, and must contain all the templates specified when configuring content types and lists, as well as any additional templates referenced by them (such as headers and footers). Currently the only supported template format is HTML::Template with HTML::Template::Plugin::Dot. The templates are initialised with the die_on_bad_params option set to false, and the global_vars option set to true.
tmpl_path
die_on_bad_params
global_vars
Each template used to generate a page of a certain content type is passed an item paremeter, which is an object containing all information about the item being rendered. The structure of the item object is as follows:
item
The title of the post.
The alphanumerical id of the post.
The teaser of the post, rendered into html.
The full text of the post, rendered into html.
The type of the post (e.g. "page").
The url at which the post will be accessible (e.g. "/news/my_first_post.html").
Contains the post url preceded by whatever is in the domain configuration option (e.g. "http://www.example.com/news/my_first_post.html").
domain
The author of the post.
The time when the post was published, in epoch format (e.g. "1249899886").
The time when the post was published, in iso format (e.g. "2009-08-10T13:24:46FLE Daylight Time").
The date when the post was published, in numeric format (e.g. "2009.08.10").
The date when the post was published, in word format (e.g. "Monday, 10 Aug 2009").
Same as above, but refers to the time when the post was last modified.
An arreyref of topics associated with this post. Each topic is an object with two properties: id and name.
id
name
Each template used to generate a list is passed an items paremeter, which is a list of objects containing all information about the items being rendered. The structure of those objects is the same as of the item objects described above.
items
Once you have configured Miril, you can access it by typing the url of the cgi script you created, e.g. http://www.examle.com/cgi-bin/miril.pl. Miril's user interface has the following elements:
http://www.examle.com/cgi-bin/miril.pl
This is the main screen. It displays a list of all content entries. It provides links to search entries or to post a new entry.
Displays a list of all files the user has uploaded and a link to a file upload form.
This screen is displayed when creating a new item or when modifying an existing one. Most of the options should be self explanatory, but there are a few things to keep in mind:
The ID field is an aplphanumeric string which servers as an unique id for this item. Future versions may create this id automatically and hide it from the user altogether. It may be useful, however, to specify it manually, since this id is used to generate the url of the output file (usually by attacing .html at the end) and the user may want to have control over the url for SEO purposes.
.html
The status field has two options - draft and published. Items marked as draft will be available for viewing and editing from Miril's UI, but will not be published to the live website.
The item text is run through a filter before publishing. Currently only Markdown is available via the Text::MultiMarkdown module.
Additionally, you can break your post into a teaser and full text by inserting the <!-- BREAK --> string somewhere in the item text. The content before the break mark will be available in the teser property of the item object passed to your templates.
<!-- BREAK -->
teser
There are no tests yet.
The code is currently pretty messy - this is still an alpha release!
The API is going to be changing a lot before the 1.0 release, so be sure to keep up with the development process (see "SUPPORT" below) if you plann to use Miril at this stage. Things that are going to change include the structure of the configuration file, the structure of the item objects, and the API for extending Miril (which has not been documented yet anyway).
The Miril website will be located at http://www.miril.org.
Please use the Github issue tracker at http://github.com/pshangov/miril/issues to report bugs and request features.
Support can be obtained via the Google Groups page: http://groups.google.com/group/miril.
Miril is hosted on Github at http://github.com/pshangov/miril.
Peter Shangov, <pshangov at yahoo.com>
<pshangov at yahoo.com>
Copyright 2009 Peter Shangov.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Miril, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Miril
CPAN shell
perl -MCPAN -e shell install Miril
For more information on module installation, please visit the detailed CPAN module installation guide.