documentation
The main goal of these scripts is to have, simply launching them, a full functional site.For the auto generated part of site, it should be html 5 compliant. Simplicity is not
married with complexity, and, in this case, I think is impossible to have all effects and
features possible in a site. If you need them, you can either heavily modify these scripts,
or use a more complete technology like php, javascript libraries, etc etc.
Don't think to these script as a professional way of writing complex web sites, but only
to a way of reducing works and as a base to extend with your work. When I was a Windows
user, I was using Adobe Dreamwaver to mantain a site, but it was a bit annoying the process
of adjusting the pages with the same look. So, under Linux, I've do this small work due
other similar applications did not do exactly what I want.
Most of preconfigured values for using scripts, are in sg_module. I keep the explaination
of them directly on this file. sg_module has not to be called, it is merged into scripts by
row source $(dirname $0)/"sg__module".
Ah, scripts (and my documentation) are still incompletes, so all work is in progress.
How it (should) works
The main thing to know is that you've to put a text file (with .txt extension) into the
right directory, and it will be processed when scripts are launched. In my ideas, you will
put the txt file there, scripts process the file, and results - in html files - are copied
in another directory, where they can be synchronized with an ftp o webdav server, linked
to your website structure.
The simple way is to run 'sg_go', while it contains the calls for other scripts:
#! /bin/bash
source $(dirname $0)/"sg__module"
export PATH=$PATH:$(dirname $0)
sg_checkstart
sg_postscreate
sg_createdocs
sg_creategalleries
sg_singlefile filename.txt
sg_createmap
sg_replaceparm
sg_finalmove
The first row is the shebang, and it is necessary to use bash shell. Second row is to include
'sg__module' file, that contains some declarations of variables used in the other scripts.
Third row set the path to $PATH and scripts directory (it is necessary due the path couldn't
include the directory, and generally when runned with cron path is different for security).
Then the scripts.
sg_checkstart
This script is intended to check some conditions required for using script, for example the
presence of template files. In the example provided, css rules are defined into this (if it
needs to be created, but obviously you can define an external css file, the simple way is
to put a link rel and the name of an online css.
sg_createdocs
Procedure for the articles. First time, you need to create the 'documents' directory. Then, make
a child directory with the name on range of your arguments: for example, if you want to make some
pages talking about platypuses, you could have a /documents/platypuses directory. You'll have to
put here the txt files that will be the pages. The main file, like in your settings, will be
created overwriting the existing file, so don't name a file like this.
The name for 'documents' directory is set into the variable $confdocsdirectory. The value is set
into the sg_module file, but if you set the value again in the launching script sg_go, you can
process multiple directories trees.
sg_creategalleries
You need to create an 'images' directory, and children directory on arguments, that you will fill
with the jpg files. Pay attention that script automatically resizes the images, depending on
the settings in sg__module file, and creates the thumbnails. Images are definetively resized,
so if you need an original copy, save it in another place. The used file type is jpeg, and if
you put .gif or png. images they will be converted.
Script has dependencies, and without installing imagemagick it doesn't work. Checking for the
installation of imagemagick will ask 'which' to find indentify, but if you set a research for
'mogrify' against the variable dep_exifremove, at the first found of an image will run a command
like mogrify -strip imagename, causing the deletion of the exif tags.
sg_singlefile filename.txt
To process a single file, it simply add the header and footer part of the html document.
sg_createmap
This create a map, under yoursitedirectory, called 'map', with the default html file name.
It looks for directories that contains this default html file name, and add them, with files
*.html, under them.
sg_formatpage
This script should not be called directly. It does a simple formatting of the page, if the first
row of the file doesn't contain a > symbol. Formatting applies the > symbol, obviously, so
is not a trauma the applying of more processing options in the script, due every file is processed
only one time.
sg_postscreate
This creates the posts. First of all, you have to make a 'posts' directory under your site dir.
You will put the .txt file (and, if you want, a .jpg file with the same name). Use a descriptive
name (ie talking_about_soccer.txt, underscores will be removed). Files will move to a subdir,
like /posts/year/month/day: for example, /posts/2011/10/12/talking_about_soccer.txt. If there is
the jpg file with the same name, it will be resized according to setting in 'sg__module'. The
list of all post will be showed in the default file of posts directory, and consecutives linked
with it.
sg_replaceparm
Purpose of this file is to put your substitions in here. This is only a skeleton for your work.
For example, you can put a string %FOO% that will be replaced with a string in all html files,
or the result of a command.
sg_finalmove
At the end of all, files are copied in another directory (depending on extensions found in
'sg__module'): files are copied only if there is not the same file in the destination dir or
if checksum of that file is different. This is why md5sum is required for this. Conditional
copy is necessary to not create the same file when intention is not to synchronize files
depending on date with the the host server, for example when using ftpsync.pl.