Danh mục

Embedding Perl in HTML with Mason Chapter 8: Building a Mason Site-P1

Số trang: 34      Loại file: pdf      Dung lượng: 143.57 KB      Lượt xem: 8      Lượt tải: 0    
Jamona

Hỗ trợ phí lưu trữ khi tải xuống: 14,000 VND Tải xuống file đầy đủ (34 trang) 0

Báo xấu

Xem trước 4 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu embedding perl in html with mason chapter 8: building a mason site-p1, công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Embedding Perl in HTML with Mason Chapter 8: Building a Mason Site-P1 Chapter 8: Building a Mason Site-P1This chapter covers, in detail, a full-fledged working web application. Ourapplication is the Perl Apprenticeship site at http://apprentice.perl.org/. Backat OReillys 2001 Open Source Conference, Adam Turoff suggested that thePerl community needed a site where people who had project ideas, but eithernot enough time or not enough expertise, could hook up with otherprogrammers who could supply the missing pieces.An experienced developer with a really neat idea and not nearly enough timeto do it can post a project idea and offer to mentor a less experienceddeveloper in its implementation. Conversely, a less experienced developerwith a really neat idea who isnt quite sure how to go forward on it can lookfor a mentor to help him bring that idea to life.This is a pretty basic database-backed web application, the kind of thing thatMason gets used for all the time. It didnt require anything too terriblycomplicated, but it shows off a number of Masons features quite well,including how components can be used to isolate individual site elements,autohandlers and dhandlers, and a simple use of blocks.One thing worth noting is that for database access we chose to use Alzabo,which is a project created and maintained by Dave Rolsky. Alzabo is adatabase-to-object mapper built on top of the DBI. It allows us to easilycreate Perl objects representing things in our database, like users or projects.We will not be going into detail on our schema or our Alzabo-related codehere, as this is largely incidental to the goal of this chapter. Our hope is thatif you dont understand any particular piece of the Alzabo functionality, youcan just treat it as pseudocode.1 More information on Alzabo is availableonline at http://www.alzabo.org/. Alzabo is also available from the CPAN.The code for the site is available at this books site,http://www.masonbook.com/. This includes an installer that should help youget the site up and running without too much trouble.2I probably would not create a site this way any more, and even back when Iwrote the book I wouldnt have done it exactly the way I did. The bookexample intentionally put more stuff in Mason components to avoid havinglots of extra modules to deal with.Nowadays, Id probably use Catalyst (http://catalyst.perl.org) as theframework. This means that all of the form submission handling, user auth,and other non-display code would be in Catalyst controllers, not Masoncomponents.Dave, 2007FunctionalityThe first issue at hand is determining what sort of functionality the site hasto have in order to be useful. Our site is fairly simple. It needs to implementthe following features: • Index page The index page will have a welcome message, site news, and a featured project selected by the site administrator. • Consistent and context-sensitive menu The lefthand side of the site is a navigation menu that is context- sensitive. Logged-in users see different options than guest users. Users with site admin options see an additional set of options. However, these options remain the same from page to page. Underneath the menu the site shows the five most recent projects entered into the system.• User information Some user information will be publicly viewable. This will be users usernames and email addresses (displayed in an altered form to protect them from robots) and the list of projects with which they are involved. Their real names are not displayed.• Project browsing Since we do not anticipate an extremely large number of submissions, at least initially, we decided not to create any complicated search mechanism. The two ways to find projects will be to view a list of all the projects in the system or to browse the projects by category. The user can click on any displayed project to see more detailed information about it.• User accounts Users need to be able to create new accounts, retrieve a forgotten password, log in, and log out. In addition, wed like to let them edit their own accounts. Users have the following properties: o Username o Password o Real name o Email address o Status -- available, semi-available, or busy o Admin flag -- is this user a site administrator?• Project editing Logged-in users should be able to add a new project and edit an existing one for which they have admin privileges. This includes the ability to add and remove project members. Projects have the following properties: o Name o Description o Creation date o Difficulty -- from one to ten o Project status -- idea or active o Support level -- a l ...

Tài liệu được xem nhiều: