summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-09-04 09:00:33 +0100
committerKatolaZ <katolaz@freaknet.org>2018-09-04 09:00:33 +0100
commitb4c015b23c34870243b75ca75fa824cf3452b471 (patch)
treee97b0e9a3cd9cd414af4561dd0772c4269b1472a
parent4d152e47955641f954b9b038b969c94c087a0146 (diff)
added value continuation
-rw-r--r--parse.awk16
-rw-r--r--render.awk40
2 files changed, 39 insertions, 17 deletions
diff --git a/parse.awk b/parse.awk
index fd6e3e7..e725532 100644
--- a/parse.awk
+++ b/parse.awk
@@ -2,6 +2,7 @@ BEGIN{
lnum=0;
cnum=0;
type="";
+ last_field="";
FS=":";
# category is an array of category data
delete category;
@@ -60,21 +61,27 @@ function get_cur(cur){
}
-/^[A-Z][-a-zA-Z]+:/{
+/^[A-Z][-a-zA-Z]+:/{## New field
#print "Field:",$1,"-","Value:",$2
gsub(/^ +/,"",$2);
gsub(/ *$/,"",$2);
cur[$1]=$2;
+ last_field=$1
}
-/^[[:blank:]]*$/{
+/^[[:blank:]]*$/{ ## End of stanza
if (!is_empty(cur)){
get_cur(cur);
delete cur;
+ last_field="";
}
- else{
- print "cur is empty" > /dev/stderr
+}
+
+/^[[:blank:]]+[^[:blank:]]+/{## Multi-line value
+ if (!is_empty(cur) && last_field!=""){
+ gsub(/^[[:blank:]]+/, "", $0);
+ cur[last_field]=cur[last_field] "\n" $0;
}
}
@@ -93,5 +100,4 @@ END{
#for (k in cnames)
# print k, cnames[k];
-
}
diff --git a/render.awk b/render.awk
index db97f47..c528188 100644
--- a/render.awk
+++ b/render.awk
@@ -9,7 +9,10 @@ function show_link(l, i, dst){
print "Uncategorised link:", l[i,"Selector"] > /dev/stderr;
else{
printf("[1|%s|%s|%s|%s]\r\n", l[i,"LinkName"], l[i,"Selector"], l[i,"Host"], l[i,"Port"] ) > dst;
- info_line(l[i,"Description"],"Err", HOST, PORT, dst);
+ split(l[i,"Description"], descr, "\n");
+ for (d in descr){
+ info_line(descr[d],"Err", HOST, PORT, dst);
+ }
info_line("", "Err", HOST, PORT, dst);
}
@@ -38,9 +41,14 @@ function category_in_parents(category, i){
for (p in pars){
#printf("pars[%d]: %s\n", p, pars[p]);
if (pars[p]!="none"){### this is the root page
- f = pars[p];
+ dst=cfiles[pars[p]];
+ if (has_categories[pars[p]] == ""){
+ info_line("", "Err", HOST, PORT, dst);
+ info_line("Sub-categories:", "Err", HOST, PORT, dst) ;
+ }
+ has_categories[pars[p]]=1;
##print "cfiles[pars[p]]:", cfiles[f];
- show_category_link(category, i, cfiles[f]);
+ show_category_link(category, i, dst);
}
}
}
@@ -48,7 +56,10 @@ function category_in_parents(category, i){
function category_header(category, i, dst){
info_line(category[i,"Title"], "Err", HOST, PORT, dst);
info_line("", "Err", HOST, PORT, dst);
- info_line("Categories:", "Err", HOST, PORT, dst);
+ split(category[i,"Description"], descr, "\n");
+ for (d in descr){
+ info_line(descr[d], "Err", HOST, PORT, dst);
+ }
}
function get_link_categories(a){
@@ -72,6 +83,10 @@ function render_categories(category, cnum, link, lnum){
cname=category[i,"Name"];
#print "'" cname "'";
cfiles[cname]=BASEDIR category[i,"Selector"];
+ "dirname " cfiles[cname] | getline bdir;
+ if (system("ls -d " bdir " >/dev/null") >0){
+ system("mkdir " bdir);
+ }
#print cname ":" cfiles[cname];
cmd=sprintf("rm -f %s", cfiles[cname]);
system(cmd);
@@ -82,10 +97,6 @@ function render_categories(category, cnum, link, lnum){
function render_post_categories(category, cnum){
- for(i=1;i<=cnum; i++){
- info_line("_______________", "Err", HOST, PORT, cfiles[category[i,"Name"]]);
- info_line("Links:", "Err", HOST, PORT, cfiles[category[i,"Name"]]);
- }
}
@@ -96,7 +107,15 @@ function render_links(category, cnum, link, lnum){
get_link_categories(link[i,"Category"]);
for (c in cats){
if (cfiles[cats[c]]!=""){
- show_link(link, i, cfiles[cats[c]]);
+ dst=cfiles[cats[c]];
+ if (has_links[cats[c]] == ""){
+ info_line("_______________", "Err", \
+ HOST, PORT, dst);
+ info_line("Links:", "Err", HOST, PORT,\
+ dst);
+ }
+ has_links[cats[c]]=1;
+ show_link(link, i, dst);
}
}
}
@@ -108,8 +127,5 @@ function render_finalise(category, cnum, link, lnum){
for(i=1;i<=cnum; i++){
info_line("_______________", "Err", HOST, PORT, cfiles[category[i,"Name"]]);
printf("[1|%s|%s|%s|%s]\r\n", "Back to the lawn", ROOTSEL, HOST, PORT ) > cfiles[category[i,"Name"]];
- info_line("Links:", "Err", HOST, PORT, cfiles[category[i,"Name"]]);
}
-
-
}