The Simplest Article System
A Very Simple System for Displaying Web Articles
I would love to be an innovator in Web technologies. I dream of coming up
with the Next Big Thing, that million-dollar Web page or trendy facepage for
bored college students. But then I'd have to put up with interviews from
60 Minutes, Time Magazine covers, lunch with Bill Gates, and all that bother.
Maybe that is really a hollow ambition?
Although software developers can at time be innovators, it is not a given that
we all have that potential. In fact, most of us are saddled with
conflicting committments, inappropriate training and skills, and a fascination
with technology for its own sake. Take, for example, the simple Web Log.
We tell civilians that Web Logs (or blogs for the jargon-wise) are just online
diaries, journals written about whatever interests the author. But how
many journals have pings, trackbacks, moderated comments, RSS or Atom or
Whathaveyou feeds, Diggs, and a hundred little features only a techy would love
or understand? Blogs aren't simple! Heck, few A-List bloggers even
set up their own blogs.
While I think regular people will understand what this project is about, I'm
going to do some extra explanation for you techies. I'll try to put it in
jargon that you understand, not so simple that you turn away in disgust.
I'll even wrap up this article by showing you several ways to make this system
somewhat more complicated. If you are not a tech head, I have created a
very simple way to publish a few articles on the Internet. The system
allows you to write Web pages using any HTML editor of your choosing (many are
free). Simply transferring that file to a directory on your Website,
wherever it is hosted, will automatically link it in to your article index Web
page. The idea is to focus on writing, not on editing other parts of a
Website to display your article.
VSSDWA for Tech Heads
We consider first a minimalist implementation of Web content publication, which
will provide insight into some basic considerations for aspects of Web Content
Management. This allows transmografication of the code to demonstrate
alternative implementations using a variety of architectural paradigms,
including, but not limited to, MVC (Model-View-Controller) or other contemporary
approaches. The simple requirement to display articles in a Web page next
to an article index are facilitated by scanning the current directory for HTML
files, building the index from the file names, and then injecting the HTML files
into a content display area next to the index. We will discuss how this
basic, flexible foundation can be augmented with powerful features to enable
rich client scenarios well beyond this quick demonstration-only code.
How It Works
Websites originally operated on a few simple ideas. The Web address you
type into the browser (or link to from somewhere else on the Web) allows your
browser to fetch a particular Web page and its associated content. In the
early days, that Web page was usually described in a layout file in Hyper-Text
Markup Language (HTML) that combined text, layout instructions for the browser,
links to pictures and graphics for the page, and links to other content.
The scheme delivers content very efficiently, straight out of the file system of
the Web server. Now it is very common to produce Web pages from databases
and by invoking remarkable amounts of computer code, even on the browser itself.
This simple article system attempts to add a very small amount of code to help
publish articles in a modern Website at minimal impact to its performance.
One basic assumption is that everyone (and especially Web authors) understands
how to use WYSIWYG HTML editors and graphical FTP applications to transfer
articles to a Website, but editing additional pages in the Website or
recompiling a complex Website is not practical for the article author. I
am also attempting to make things very simple for the Web developer. All
the action occurs in two ASP.NET Web user controls, each with seven lines of
code. Just lay out a page with an area for the article index and another
for an article, drop the controls in those spots, and it is good to go.
The index control, called IndexDirHTMLFiles, scans the Webpage directory for
HTML files. It creates a link index that adds the article file name
(without the file extension) to the index. Each link gets the parent page
with a query string containing the article file name. The article content
control, called DisplayDirHTMLFile, responds to the article query string and
injects the article file contents into the Web page. A default article
(ArticleDefault.htm) is displayed if there is no article in the query string.
The default article can be used to describe the theme for articles uploaded to
the directory, give credit to the author(s), or anything else you like.
Here is the project in Visual Studio 2008.
How It Doesn't Work
Frankly, I'm really happy with this little project. I'm even using it on
one of my Websites. But it is not only demo code, it has the reek of demo
code. It doesn't handle blank spaces in file names, so the article index
looks bad. Articles have to reasonably fit in one Web page, no multi-page
articles here! The true horror: contemporary Web design requires CSS
files. This demo doesn't have any. If you notice table tags in the
project, please look away before you barf on your keyboard. I'd hate to be
responsible for that. You can't control the sequence of articles in the
index. I could go on and on.
Addressing any of these things would spoil the project. This is really
meant to be the absolute minimum that does the job. Speaking of jobs, this
project is small enough to be a very practical interview quiz. You can
show it to a prospective hire and quickly see how they think and what they know.
A Path to Proper Publishing
I was lying when I said "We will discuss how this basic, flexible foundation
can be augmented with powerful features to enable rich client scenarios well
beyond this quick demonstration-only code." I had no intention of going
there. You see, I think there is a great value to the back-to-basics idea
that made me write 14 lines of C# code and this much longer article.
Besides, there are plenty of sizable CMS applications out there (I'm checking
out Telligent's Back-to-Simplicity Graffiti as I write this).
Here is a hint of what I am thinking. First, the articles shouldn't
reside in the same directory as the Article.aspx file. The author should
be able to build up their content directories without non-article files, and it
should be easy to backup and transport articles around to different directories
or Websites. It should be possible to publish books or chapters or other
content organization schemes, especially articles or sections that are displayed
across multiple Web pages. The displayed indexes should be independent of
the article file names, and should be expandable to a proper Table of Contents
for a large publication. All this should be possible without a database.
Mix in a little SEO and suddenly we're into probably a thousand lines of C#
code. But get this: the articles would still be performant HTML files in
the file system, and regular Web authors would be able to deal with all aspects
of their content without engaging a consultant or purchasing a special
publishing program.
|