Yet Another Static Site (Generator) Documentation

Extending Program

Table of Contents

General informations

YASS can be extended with any script or other program which can be run on your machine. This mean, for example Bash, Perl, Python scripts or any compiled program, anything what can be run from terminal. Second requirement is that extension (called module) must have ability to read environment variables, read standard input and write to standard output, because in that ways YASS and module communicate. Modules are per site not assigned to the program, thus every site can have own set of modules to run.

^ Top

Adding modules to the site project

After creating a site project, you will have directory _modules (with default setting) inside site project directory. This directory have structure:

[ProjectName]
  |-_modules
     |-end
     |-post
     |-pre
     |-start

Subdirectories inside _modules directory are places where all modules should be put. They names are that same like the program hooks for running modules thus you should not change names for this subdirectories.

Thus, if you have module test.sh and you want to run it every time when the program finish manipulating file, you must put it in path modules/post:

[ProjectName]
  |-_modules
     |-end
     |-post
        |-test.sh
     |-pre
     |-start

YASS checking for modules only this four subdirectories, don't go recursively deeper. Thus, modules can be not only one executable file, but even whole directories. In that situation, you will need to provide any "entry point": one executable to run that complicated module.

^ Top

Communication between YASS and modules

There are two ways for communication between the program and modules.

^ Top

API informations

^ Top

Example module

This is very small example of module, which show name of currently processed file, then show value of tag "Name", then set second value of tag "news" and at the end show all values of the tag "news".

#!/bin/sh

echo "Now processing: $YASSFILE"
# get value for tag "Name"
echo "gettag Name"
# read value of the tag "Name"
read name
# print value of the tag
echo "$name"
# set value of tag "Name" to "NewName"
echo "edittag Name NewName"
# read result of the operation
read result
echo "Result:$result"
# set second value of tag "news" to "NewSite2"
echo "edittag news 2 NewSite2"
# get result of operation and print it
read result
echo "Result:$result"
# get all values for composite tag "news"
echo "gettag news"
# read how many values this tag have
read amount
# read and print values of the tag
for (( i=1; i<=$amount; i++ ))
do
  read newvalue
  echo "$newvalue"
done

Save it as showname.sh file, give it permissions to run chmod 744 showname.sh and put it in modules/pre directory in selected site project. Additionally, you been need to add or to site.cfg or to markdown file the composite tag news with at least 2 values. For example in site.cfg:

news = []
news = first news
news = second news
news = last news

^ Top

<< Page Config
Index