Zotonic: the Erlang Content Management System
Zotonic is first and foremost a content management system—that is what it says on the tin. Now that you have a running version of Zotonic, you can try out the content management features.
Point your browser at http://127.0.0.1:8000/admin. You will see a login screen, and as this is your first login, you need to set the password.
Use the login name “admin”, leave the password field empty, and click Log On. You will see the create password form.
Once you have set your password, you are presented with the Zotonic admin dashboard. Down on the left-hand side is the admin menu. Much of it is straightforward, but one of the more interesting items here is modules.
In the Modules menu item, there's a list of available modules, some of them activated, others not. Activate the comments module to see the comments form appear at the bottom of your blog posts.
You can create a new blog post by creating a new page of category “article”.
In the list of pages, find the home page. You also can find it by searching for “home” using the search box on the top right of the admin page.
Open this page for editing, and scroll down it until you see advanced options. Expand the advanced options section, and notice that the home page has a unique name of page_home set. This is useful for referring to this page later in your code.
Zotonic uses a modified version of Erlydtl for templating. Erlydtl is an Erlang implementation of the Django templating language.
Look in the templates folder of the default Zotonic site (priv/sites/default/templates). Here you will find a collection of .tpl files, which are templates that define the site. Templates that start with an underscore are not intended to be rendered alone, but rather can be included in another template.
Most of the templates in this directory inherit from base.tpl, which includes the site's header, menu and footer. This site uses article.tpl for displaying pages of the category “article” and uses home.tpl to display the home page.
Dispatch rules map URIs to resources. Look in the file priv/sites/default/dispatch/dispatch. The following two dispatch rules are defined:
{
home, [],
resource_page,
[ {template, "home.tpl"}, {id, page_home} ]
},
{
article, ["article", id, slug],
resource_page,
[ {template, "article.tpl"}, {cat, article} ]
},
The first rule states that you render the page with the unique name of page_home using the template home.tpl.
The second rule says that you want to render all pages of category article to article.tpl. You also define the structure of the URL in this rule. Each article will have an address of this form: /article/id/page-name.
In both of these examples, you use resource_page to do the actual rendering. This renders a resource as an HTML page and gives you access to the ID and category of the page from the template.
Other text pages you create will be rendered to page.tpl by default.
An about page, with the unique name page_about already exists in the default Zotonic site; it is currently rendered to page.tpl. Let's try making our own template to display the about page.
Create a template in the templates directory called about.tpl, and put the following code in it:
{% extends "base.tpl" %}
{% block title %}
{{ m.rsc[id].title }}
{% endblock %}
{% block content %}
<h1>{{ m.rsc[id].title }}
-- {{ m.rsc[id].summary }}</h1>
<h2>Hello, this is my about page!</h2>
{{ m.rsc[id].body|show_media }}
{% endblock %}
Add the following to your dispatch rules:
{about, ["about"],
resource_page,
[
{template, "about.tpl"},
{id, page_about}
]
}
Stop Zotonic, and run make.
Start Zotonic again. Now, if you go to http://127.0.0.1:8000/about in your browser, you will see the text from the default about page rendered using the new template you created.
Having access to the ID of the about resource from the template, you can make calls to the database to retrieve other information to display. As you can see from the template above, I used the title (m.rsc[id].title), the summary (m.rsc[id].summary) and the body (m.rsc[id].body). I also used a “filter” called show_media to convert image markers in the body text into actual image tags for display.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Web Development News
Developer Poll
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Home, My Backup Data Center
- A Topic for Discussion - Open Source Feature-Richness?
- Dart: a New Web Programming Experience
- Developer Poll
- What's the tweeting protocol?
- May 2013 Issue of Linux Journal: Raspberry Pi
- Reply to comment | Linux Journal
27 min 34 sec ago - Reply to comment | Linux Journal
1 hour 44 min ago - great post
2 hours 19 min ago - Google Docs
2 hours 42 min ago - Reply to comment | Linux Journal
7 hours 30 min ago - Reply to comment | Linux Journal
8 hours 17 min ago - Web Hosting IQ
9 hours 51 min ago - Thanks for taking the time to
11 hours 27 min ago - Linux is good
13 hours 25 min ago - Reply to comment | Linux Journal
13 hours 42 min ago









Comments
Quitting Out of the Erlang Interpreter
Instead of ctrl-C + abort, the faster and cleaner way out of the erlang interpreter command prompt >:
q().
Kind of like typing quit() at a python interpreter command prompt, but shorter and ending with a period/full stop. (Don't all good sentences end with a period? They do in Erlang.)