Lasso Examples Pack - Blog

This example shows how to create an online diary, or web log. Each blog consists of a title, a description and a series of entries. A blog entry consists of a title, a body, a time-stamp and a series of comments. Comments can be posted by any visitor, authenticated or not.

When a new user who has not yet initialized their blog visits the site, they are allowed to enter a name and description for their blog. Once that is completed, the user may proceed to add entries to their blog. A blog owner is permitted to delete their entries, including all comments posted for that entry. They are also allowed to delete individual comments posted for their entries.

The blog example can be used as-is to allow site visitors to post their own entries. By customizing the HTML and CSS of the example the look of the blog can be made to better fit into the look of your Web site. The blog example can also be studied for ideas of how to create dynamic Web sites using Lasso.

This documentation is split into two parts. The first part introduces the blog example and shows how your users can use it to create a blog. The second part dissects the example and provides a description of what operations each page performs.

Using the Blog

The blog consists of three pages: a list of authors who have created blogs, a list of entries in each blog, and a detail page for each entry including comments.

Blog Authors - The blog list page lists all of the users who have blog entries in the system. The list consists of each author's name, the number of blog entries they have posted, and the date that the last entry was posted. Clicking on an author will lead to the author's blog entry list page. This page also displays the current user's name if they have been authenticated, or a link to authenticate if they haven't. If the user is authenticated, the page will show the new blog post form, which allows a user to author and submit a new post.

Blog Entries - The blog entry list page shows all the blog entries for a particular user. Displayed are the entry's title, date and body text. Below each entry, the number of comments posted for that entry is shown. Blog entries are shown with the newest entry first. Clicking on a blog entry's title or on the comment's summary will lead to the blog entry detail page.

Entry Detail - The blog entry detail page shows the same blog details as on the entry list page, but only that single entry is displayed and each comment is shown in detail. Also on this page is a form which allows the reader to post a new comment which will be added to the end of the comments list. This form consists of only a comment author name and the comment body text area. The comment author name can be any name and defaults to 'anonymous', i.e. it does not have to be an actual Lasso user name and no authentication is required.

Implementation Details

This section describes how the blog example is implemented. It is not necessary to read this section in order to use the blog on a site. You should read this section if you want to understand how the blog example works, if you want to customize the appearance or behavior of the example, or if you want to use it as the basis for a different solution.

Index.Lasso - The logic for displaying a page in the blog is contained in this file. This file (and the other files in the example) is commented extensively within the Lasso code. The LassoScript within the file determines what blogs, entries, or comments should be shown.

Author_List.Lasso - This page lists all of the users who have blogs. If the user is logged in and has previously initialized their blog, then the New Blog Entry form is shown. If the user is logged in and has not initialized their blog, then the blog initialization form is shown.

Entry_List.Lasso - This page displays all the blog entries created by a given user. If the current user is the blog's owner, then each entry will have a link that can be used to delete that entry and the New Blog Entry form will be shown.

Entry_Detail.Lasso - This page shows the details of a particular blog entry. It also shows all the comments posted for that entry and the form that is used to create a comment. If the current user is the blog's owner, then each comment has a link that can be used to delete the comment.