Journal

/A/ /M/A/G/N/I/F/I/C/E/N/T/ /P/L/A/C/E/ 

June 2009

00:15 Sunday 21 June 2009

Site PHP code updated, updated...

Around the beginning of December 2008 I began working on a new version of the PHP scripts generating the pages of this website. A couple of months later I'd got bored, left it unfinished, and was working on XorCurses instead.

A week or so ago I returned to my website code and resumed where I'd left off. There's not actually much different to see. The main Journal page now displays links by date for viewing journal entries instead of the older and oldest links it used to display.

The visual design of the pages has been modified subtly also, but most of the changes are invisible to the end user as it is the actual PHP scripts I have written which have completely changed - but produce almost exactly the same result - ie a webpage such as this.

So what are the benefits of this time spent rewriting code to produce more or less exactly the same thing?

When I had first produced a working version of this new code, tests on my home computer running the Apache2 web server showed Apache2 processing the pages faster, so the code is marginally more efficient. However, due to the development process, fixing things, adding missing things, the code is now running marginally slower than the old version. However, certain pages, specifically the Keywords page, is vastly more efficient as far as the server is concerned.

The way the data for each page is stored has been cleaned up. Specifically, the format of the text files describing a page is marginally improved upon. Ways of doing things which previously were defined in incongruous syntaxes now have a syntax which shares much more in common.

Then there were my ambitions for the project. It was meant to be a more fully featured Content Management System (CMS), but that would have meant lots of very complicated code to handle session management I never really had any intention of completing. So I stuck to how it works now: to add a new page you create a text file and use a relatively simple syntax to specify the content of the page. You'll find having Secure Shell (SSH) access to your web server handy here (which most basic web hosting packages do not provide) plus the ability to have a running server process on your desktop PC a distinct advantage (which is where Free Open Source Operating System such as GNU/Linux come in useful) so you can design pages and preview them and upload them once you've finished.

But there'd be no point to all this if it only was suitable for my use and designed for my website. For this reason I created an abstraction for specifying details of generic page layout - the format of every page on the site. This is not so successful as I hoped. The implementation is not powerful enough to fully specify the generic page layout in the layout file - there is still a lot implemented in the code itself. Still, it does provide more power to the designer using it. Sections of pages can be disabled via the layout. Comments can be disabled via the layout. The location of data files for pages is specified in the layout. Variables can be setup in the layout and acted upon in various ways, using basic variable substitution.

The layout file I'm using to as a generic 'template' for this site is something like this:

page_vars<<END_PAGE_VARS
// setup some variables for pages...
// theme is determined from filename portion of URL ( path and extension removed by code )
// directories relative to public_html

data_dir=       ../layouts/main/
home_page=      home
email=          james@jwm-art.net
theme=          @=*filename=@
style_dir=      style/
style_prefix=   @=*style_dir=@@=*theme=@
logo=           @=*style_prefix=@_jwm-art-logo.gif@;jwm-art.net logo@//'
minilogo=       @=*style_prefix=@_jwm-art-logo-small.gif@;jwm-art.net mini logo@//'

    END_PAGE_VARS

page_head<<END_PAGE_HEAD
    
raw_processed<<END_RAW
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--@=*url=@-->
<html>
<head>
<title>jwm-art.net: @=*title=@</title>
  END_RAW

meta=           keywords @=*keywords=@
meta=           description @=*descr=@

generate_meta=  TRUE
css_link=       @=*style_prefix=@_main.css
css_link=       @=*style_dir=@common_main.css
generate_css=   TRUE
raw=</head>
nl=
    END_PAGE_HEAD

//----------------------------------------------------------------------------------------

page_body<<END_PAGE_BODY

raw<<END_RAW
<body>
<div id=tlc></div>
<div id=main>
<div><!--stops links dancing about floating div-->
  END_RAW


if=@=*no_page_heading=@==FALSE
heading=@=*title=@
endif=

generate_main=TRUE
raw=</div><!--stop links dancing about floating div-->
raw=<div class=info>
subheading=Information
text="@=*title=@"
txt=@=*descr=@
generate_info=TRUE

rf=*minilogo
raw=</div><!-- info -->

if=@=*no_comment=@==FALSE
raw=<div id=comments>
generate_comments=  TRUE
raw=</div><!-- comments -->
endif=

raw=</div><!-- main -->

    END_PAGE_BODY

//----------------------------------------------------------------------------------------
page_nav_init<<END_PNI

nav_list_start=     <div class=navsec><ul>
nav_list_end=       </ul></div><!-- navsec -->
list_link_start=    <li>
list_link_end=      </li>
nav_clump_start=    <div class=navsec><p>
nav_clump_end=      </p></div class=navsec>

    END_PNI

//----------------------------------------------------------------------------------------
page_nav<<END_PAGE_NAV

navhead<<END_NH
<div id=navbox>
<div class=navhead>Navigation</div>
  END_NH

generate_tree=      LIST

ilink=home
ilink=journal ! ! {(*parent==journal)?j=*q(p):!;}
ilink=painting
ilink=drawing
ilink=photography
ilink=audio
ilink=code
ilink=misc
ilink=statement
ilink=about
ilink=contact ! ! context=*this
ilink=keywords@!
ilink=links
ilink=themes ! ! ret=*this

generate_home=      LIST
generate_related=   LIST
generate_keywords=  CLUMP


navfoot<<END_NF
<div class=navfoot>Navigation</div>
</div><!-- navbox -->
  END_NF

    END_PAGE_NAV

page_gfx_bar<<END_GFX_BAR
raw=<div id=iconbar>
icon_img_inc=@=*style_prefix=@_icon_inc.gif
icon_img_def=@=*style_prefix=@_icon_def.gif
icon_img_dec=@=*style_prefix=@_icon_dec.gif
raw=</div><!-- iconbar -->

END_GFX_BAR

    

Which is not pretty, but once set up, it's unlikely to require additional editing (handy that I set it up as I coded, so I knew exactly what was happening). One thing I was pleased with is the way it accesses 'variables' defined in the page data files themselves, such as keywords, title, and description tags. It allows pages to tell it not to display the default page heading, or to not allow comment posting for a page. Any web designer would expect this of a CMS, but it was something of a revelation to have the control of such things specified in the layout file instead hard-coded within the PHP code like it had been.

If in the web browser you are using to view this page you look at the page source (ie the HTML generated by my PHP code) you will see how it correlates with the layout file.

Below is the contents of the file which specifies the contents of the 'home' page for this site.

    head<<END_HEAD
title   = Home
keywords= james-morris,painting,acrylic,canvas,paper,drawing,audio,code,abstract,surreal,expression,artist,fractal,spade
descr<<END_DESCR
jwm-art.net is the personal website of James W. Morris for visual art,
audio, code, and other constructions.
  END_DESCR
parent  = 
    END_HEAD

options=no_page_heading=TRUE
options=no_comment=TRUE

    meta<<END_META
netinsert=0.0.1.1.7.1
author=James W. Morris
hover=@=*descr=@
    END_META

    main<<END_MAIN
heading=jwm-art.net
image=*logo
cheading=Welcome to jwm-art.net
csubheading=Art Made By James W. Morris.
ctext=See the @=ilink=journal=@ for news about recent activity.
    END_MAIN

Again, if you use your browser and visit the 'home' page and then view the page source, you will see how this correlates with the HTML output by my PHP code.

In the near future I am planning on releasing the source code - the PHP scripts which do all this stuff for people to inspect and use if they find it suitable for their purpose. Maybe some might improve upon it or find bugs which I have overlooked, though I think this is unlikely. My content management system has plenty of shortcomings and there are other systems providing more efficient ways of creating pages, more user-friendly ways of creating pages, and more powerful ways to create web pages. This system suits me however, I am who I have designed it for, I have enjoyed doing so at times and of course it was a learning experience which is more important to me than the finished product - if there ever is such a thing.

Information

"Journal"

A page detailing new stuff and other random noise.

The journal is a general place for writing about what I am doing, or for making more official announcements concerning the things I do. It's also a place where I can write freely about my ideas, or just play with words and language.

DISCLAIMER: The opinions and attitudes of James W. Morris as expressed here in the past may or may not accurately reflect the opinions and attitudes of James W. Morris at present, moreover, they may never have.

this page last updated:29th April 2013 jwm-art.net (C) 2003 - 2017 James W. Morris

script time:0.0622