diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2020-12-06 23:00:38 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2020-12-06 23:00:38 +0300 |
commit | 2282ef61b60c1ce90ce7ac056781bfba0d7bdfec (patch) | |
tree | 13ec3bce878111cae8e65c33884299ea9e930a18 | |
parent | 217fc658ff15c7dc00e61d90b13cd84b0adc63b1 (diff) | |
download | vsvs-2282ef61b60c1ce90ce7ac056781bfba0d7bdfec.tar vsvs-2282ef61b60c1ce90ce7ac056781bfba0d7bdfec.tar.xz vsvs-2282ef61b60c1ce90ce7ac056781bfba0d7bdfec.zip |
.
-rw-r--r-- | articles.vs | 5 | ||||
-rw-r--r-- | articles/funweb.vs | 9 | ||||
-rw-r--r-- | articles/someweb.vs | 10 | ||||
-rwxr-xr-x | default.do | 5 | ||||
-rw-r--r-- | site/data/some | 8 | ||||
-rwxr-xr-x | vsvs | 44 | ||||
-rw-r--r-- | vsvs-extract | 43 | ||||
-rw-r--r-- | vsvs-locate | 2 | ||||
-rw-r--r-- | vsvs-parse | 4 |
9 files changed, 54 insertions, 76 deletions
diff --git a/articles.vs b/articles.vs deleted file mode 100644 index 902c495..0000000 --- a/articles.vs +++ /dev/null @@ -1,5 +0,0 @@ -template - <html> - <head><title>$title</title></head> - <body>$content</body> - </html> diff --git a/articles/funweb.vs b/articles/funweb.vs deleted file mode 100644 index a7770e1..0000000 --- a/articles/funweb.vs +++ /dev/null @@ -1,9 +0,0 @@ -title Web must be fun! -content - This operator can be used on a quotation or a dictionary:<br /> - If a quotation quot is passed, it returns a new quotation - obtained by evaluating each element of quot in a separate stack.<br /> - If a dictionary dict (with values and keys) is passed, - it returns a new dictionary obtained by evaluating each value - in the dict that is a symbol in a separate stack - (values that aren’t symbols stay as they are). diff --git a/articles/someweb.vs b/articles/someweb.vs deleted file mode 100644 index 4ef95a1..0000000 --- a/articles/someweb.vs +++ /dev/null @@ -1,10 +0,0 @@ -title Web must be! -content - Yeap! - This operator can be used on a quotation or a dictionary:<br /> - If a quotation quot is passed, it returns a new quotation - obtained by evaluating each element of quot in a separate stack.<br /> - If a dictionary dict (with values and keys) is passed, - it returns a new dictionary obtained by evaluating each value - in the dict that is a symbol in a separate stack - (values that aren’t symbols stay as they are). diff --git a/default.do b/default.do deleted file mode 100755 index 617cc1c..0000000 --- a/default.do +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -export title="$(vsvs-get title < $1.vs)" -export content="$(vsvs-get content < $1.vs)" -echo -n "$(vsvs-get template < articles.vs)" | shelter >$3; -redo-ifchange $1.vs articles.vs diff --git a/site/data/some b/site/data/some new file mode 100644 index 0000000..f9eae4a --- /dev/null +++ b/site/data/some @@ -0,0 +1,8 @@ +model + title string + content multiline +data + title Web must be fun! + content blah-blah + blah-blah + blah-blah @@ -1,44 +0,0 @@ -#!/bin/bash - -# This is a parser of the Very Simple Values Storage. -# It has two arguments: an action and an object. -# Action is a string to be evaluated with key and its value provided. -action=$1 -# Object is like a path in filesystem (which pretty much it is), -# this is a string describing piece of data in storage. -object=$2 - -# Utility functions: -after () { test -z "${2##*$1*}" && echo -n "${2#*$1}" } - -# File processor: -pfile () { - # First of all, we need to lock the file. - lockfile="$base/proc/$proc/lock/$object" - mkdir -p -- "${lockfile%/*}" - echo $proc > $lockfile - lockpath="$path.lock" - if ln $lockfile $lockpath - then - # PARSER - rm $lockpath - fi - rm $lockfile -} - -# First of all, we need to locate object in filesystem. -# To do so, we will get parts of the path from the beginning of object, -# until we will run out of object or meet the file in filesystem. -test "${object::1}" == "/" && path=$base || path="." -lastpath=$object -until test -n "$lastpath" -do - # Tear another part of $lastpath until slash into $path: - path="$path/${lastpath%%/*}" - lastpath=$(after / "$lastpath") - # If $path does not exist, the object does not exist too, - test -e "$path" || exit 1 - # otherwise it can be file, then we need to parse it and exit, - # or it can be a directory, then we need to repeat the process. - test -f "$path" && pfile "$action" "$object" "$path" "$lastpath"; exit 0 -done diff --git a/vsvs-extract b/vsvs-extract new file mode 100644 index 0000000..a45d231 --- /dev/null +++ b/vsvs-extract @@ -0,0 +1,43 @@ +#!/bin/bash +after () { test -z "${2##*$1*}" && echo -n "${2#*$1}" } +vsvs-locate "$2" | { read path; read vsvspath; } || exit 1 +if test -f "$path" +then + lockfile="$base/proc/$proc/lock/" + if test "${path::1}" == "." + then lockfile="$lockfile$base$path" + else lockfile="$lockfile$path" + fi + mkdir -p -- "${lockfile%/*}" + echo $proc > $lockfile + lockpath="$path.lock" + ln $lockfile $lockpath || exit 1 # Error, cannot lock + data="$(cat $path)" + rm $lockpath + rm $lockfile + until test -z "$vsvspath" + do + data="$(echo -n "$data" | vsvs-parse " + if test \"\$key\" == \"${vsvspath%%/*}\" + then + echo \"\$value\" + exit 0 + fi")" + vsvspath=$(after / "$vsvspath") + done + echo -n "$data" | vsvs-parse "$1" +else + for key in `ls -a $path` + do + test "$key" == "." || test "$key" == ".." && continue + if test -f "$key" + then value=$(cat "$path/$key") + else + savedpath=$(pwd) + cd "$path/$key" + value=$(vsvs-archive) + cd "$savedpath" + fi + eval "$1" + done +fi diff --git a/vsvs-locate b/vsvs-locate index 5015529..21df2ac 100644 --- a/vsvs-locate +++ b/vsvs-locate @@ -1,5 +1,5 @@ #!/bin/bash -# Tear $1 into path to file (or directory) and in file, +# Tear $1 into path to file (or directory) and path in file, # if no such file exit with error. after () { test -z "${2##*$1*}" && echo -n "${2#*$1}"; } test "${1::1}" == "/" && path=$base || path="." @@ -9,9 +9,9 @@ do if test -z "${line%% *}" then value="${value}"$'\n'"$(after " " "$line")" else - eval $1 + test -z "$key" && eval $1 key="${line%% *}" value="$(after " " "$line")" fi done -eval $1 +test -z "$key" && eval $1 |