Site Sponsors:
The HTML Sandwich 
This morning I decided to take one of my open-source projects to the next level. -By moving it to the 'web, not only would I add spell checking, but better cross-platform & mobilization options, as well.



The 1-Hour Tech Assessment


At the time of this writing I had been 'giging for a few years on a single set of technologies. Reviewing the web-side implementation options available for a new server-side plunge, as usual we had far too many choices: PHP CRUD, ASP.NET, GWT, Signed Java Applets, Java Server Pages (JSP), Java Server Faces (JSF), etc, etc...

--Such is the dilemma when you know & adore so many technologies!

Full-time Job


In the case of this particular project however, after considering the rate of disruption of everything I knew, I decided to simply use a Servlet.

Why did I select such a basic server-side technology set?

I chose Java because both PHP and .NET seem to ever threaten to leave our code legacies behind. We thereafter decided upon Servlets because - as the foundation of virtually everything on the Java-Web - I likewise tire of the sheer rate of disruption on just about everything built atop of Java Servlet Technology. --Unlike all-things served (Server-ed?) up as Servlet a-la-mode, those good 'ol HTTPRequest & HTTPResponse wrappers have not changed much since their ultimate incarnation.

Lamentations


There are also far too many closed, self-obsoleting standards out there today. -After a few years everyone gets tired of trudging along any cold, hard, forced-march: Those bleak book-biting ascensions along that "upgrade to the latest NOW - that last greatest thing we did was wrong" mountain pass.



Decades after their "me too" d├ębut, has anyone ever heard of SNOBOL or RATFOR?

(-Yea: Ruby-on-Rails is great. Gotcha. (I loved Smalltalk. -Learned Perl, too.))

Sabo


Now don't get me wrong: If you have a full-time IT staff, then ASP.NET, JSTL, JSF, (etc, etc) are great. -Yet for 90% of the planet however, our site traffic is well under ~250 visitors per second. In as much as that traffic stream is well within the capability of your typical rented-server, if you don't want to spend days catching up on the latest comparative innovations de-jur, then Servlets will do just fine. (Imagine a Qui-Gon Jinn attempt to use a mind trick on Watto...)

Yes.... Just fine.

Indeed, as an army of one, like most low-budget entrepreneurs I simply want to do things once - then get back to doing other things. We'll do it one better if folks like it?

Simple Templates


So the problem arises: Given that one may frequently want to change the style of any given web site, how to do so without tag libraries, code injectors, faces, adaptors, POJOs, entities, and an eager staff of software developers?

At the end of the day, what is the absolute easiest way to skin a site?

... how 'bout an HTML Sandwich?


package com.soft9000.html;

import java.io.File;

/**
*
* @author profnagy
*/
public class HtmlTemplate {

static final String sTEMPLATE_DELIM = ".template.";
static final String sTEMPLATE_FILE = ".template.txt";
private File file;
private String delim;

private String prefix = null;
private String suffix = null;

public HtmlTemplate() {
this(new File(sTEMPLATE_FILE), sTEMPLATE_DELIM);
}

public HtmlTemplate(File file) {
this(file, sTEMPLATE_DELIM);
}

public HtmlTemplate(File file, String sDelimiter) {
this.file = file;
this.delim = sDelimiter;
}

public boolean isNull() {
return (file == null || delim == null);
}

public void getHtml(StringBuilder sb, String content) {
if (sb == null) {
return;
}
if (prefix == null && split() == false) {
return;
}
sb.append(prefix);
sb.append(content);
sb.append(suffix);

}

private boolean split() {
if (isNull()) {
return false;
}
String str = com.soft9000.file.TextReaderF.Read(file);
String[] set = com.soft9000.Text.Split(str, this.delim);
if (set.length != 2) {
return false;
}
this.prefix = set[0];
this.suffix = set[1];
return true;
}

}


Simple, eh?

Rube


Inspired by PHP CRUD's "template21", the way that the above class works is easy to understand: By allowing us to specify the name of an external template file, we simply use the "top" and "bottom" of the file as a wrapper around our content. getHtml.

So deign a web page for your entire site, or a subsection thereof. Use graphics, google cookies, style sheets -just the way you want it!

Next, simply put a unique token where you want dynamic content to be inserted then vola! - you will have just what we need to create an "HTML Sandwich Web Site."



Of course, that swap-out could also be for more than a single unique token. -Perhaps a triple, or n-decker, sandwich? ... a 'dagwood? (Yet clearly with a 'tad more bread-foundation, and a allot less baloney (pun intended.))

new Books_required == NULL. Future ReLearningCurve = 0L;

Etc.


Over time, for internationalization, subscription, and / or other reasons our templates might even be generated dynamically, taken from an SQL CLOB, deducted from competitive web pages, (etc.)

Indeed, no matter if we are using Java, PHP, VB.NET, RUBY, C# or even CGI -w- C/C++ any language can take a byte of that same sandwich.

The server-ed side don't get any easier than that!



Sharing is caring,


-Rn


[ add comment ] ( 22 views )   |  permalink  |  related link
"An Interview with a Saint" 
Didja know that some readers tell me that I have penned a classic?

No - the book is not on UML, SQL, Java, .NET, LAMP, or C/C++. If it were, I would not be so willing to practically give the title away. :-)



Formerly selling for $14.98, we just cut the paperback price by more than 50%.

For a limited time (just a few more days), the kindle edition is only $0.99.


Sharing is caring!

-Rn

[ add comment ] ( 58 views )   |  permalink  |  related link

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>