|
ColdFusion Bookmark ManagerIn an attempt to learn some ColdFusion basics, I decided to implement a project I've been meaning to do for a long time in PHP: A central Bookmark manager. While any web browser worth its salt has a feature for saving favorite URLs, users of more than one computer or browser (Mozilla, MSIE, Lynx, Opera, Home, work, laptop, etc) often find themselves with several different bookmark lists, each one out of sync. By centralizing those bookmarks in a web-based application, the user can easily maintain a single bookmark list from anywhere on the web. By using JavaScript "Bookmarklet" links in the browser's personal links toolbar, adding a bookmark to the ColdFusion application is as easy as adding it to the browser's native favorites page. This project was my first foray into the world of ColdFusion, and makes use of some of the following tags:
Source CodeThis is my first ColdFusion programming effort and as such it's not much for careful planning, consistent variable and file naming, heavy security, or portability, but as long as I've got the code lying around you're welcome to use it under the terms of the GNU General Public License:
Installation Notes (also included in the download) How it WorksSecurityThe first task was to implement some very basic password protection. Each page of the application checks for the presence of a cookie indicating logged-in status. If the cookie is not present, the user is automatically redirected to a login form. The referring URL is saved as a hidden form variable from the URL variable scope, and once logged in the user is sent back to the page they were trying to access. The username/password for this simple application are hard-coded into the login script; hardly robust, but adequate for learning purposes. The "Add Bookmark" LinkTo make adding bookmarks convenient, a JavaScript bookmark is added to the browser's link toolbar. This is the link URL: javascript:void window.open("http://localhost/cf/bookmark/add.cfm?pageurl=" + escape(document.location) + "&pagetitle=" + document.title, "cfbookmark", "width=300,height=150") The link pops open a small window and tells it to load the "add" page, sending it the URL and Title of the document the user is currently viewing. Adding a BookmarkTaking the URL and Title information from the URL variable scope and retrieving a list of categories from the bookmark database, add.cfm presents the user with a form where they can select a category for the link and indicate whether or not they want the link to be "public". By giving links a public or private designation, it becomes simple to automagically generate a links web page for the user's own web site, featuring only those links marked "public". If the user selects an existing category, the new bookmark is inserted into the database and the popup window closes itself. Adding a new CategoryIf the user selects <New Category> when adding a link, they are directed to an "Add Category" form. The bookmark information is preserved as hidden form fields, and upon submission the new Category is inserted into the database, and then the new bookmark. The popup window then closes itself. Viewing BookmarksIn addition to bookmark URLs and page titles, the database also stores the date upon which the bookmark was last visited; in this way the bookmarks.cfm page can display a convenient "Recently Visited" section at the top of the page, and organize bookmarks in order of recent visitation. Following LinksIn order to keep "Last Visited" information about each bookmark up to date, each link on the Bookmarks page actually passes the Bookmark's database ID number to a local script called exodus.cfm, which updates the bookmark's last_visited timestamp and then uses <cflocation> to send the user to the correct URL. Screen Shots![]() If the user is not logged in, they are redirected to this screen.
![]() The smaller window pops up when the user clicks the "Add Bookmark" link in their browser favorites. The user can edit the bookmark title, but the existing page title is used by default. The category menu is pulled down in this shot. (Categories are displayed in the order in which they have been added to the database.)
![]() When the user selects <New Category> from the menu on the "Add Bookmark" screen, they are directed to this form where they can enter the new category name.
![]() The bookmark page itself, which displays links in the order of most recent visitation.
Room for ImprovementI can think of all kinds of enhancements for this project, but since my hosting provider doesn't support ColdFusion and my own evaluation copy is going to expire in about 25 days, they will probably have to wait until I put together a PHP implementation. Nevertheless, here are some possible improvements:
|