From 2f6dcf6a064bc14dcc1ddfebe944be6cfa26c542 Mon Sep 17 00:00:00 2001 From: Will Budicm Date: Thu, 17 Sep 2020 10:16:53 +1000 Subject: [PATCH] markdown dev. cont. --- htdocs/cgi-bin/docs/About.md | 5 +++++ htdocs/cgi-bin/docs/LogTagsHelp.md | 34 ++++++++++++++++++++++++++++++ htdocs/cgi-bin/markdown.cgi | 29 ++++++++++++++++++++----- 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 htdocs/cgi-bin/docs/About.md create mode 100644 htdocs/cgi-bin/docs/LogTagsHelp.md diff --git a/htdocs/cgi-bin/docs/About.md b/htdocs/cgi-bin/docs/About.md new file mode 100644 index 0000000..dfa8ede --- /dev/null +++ b/htdocs/cgi-bin/docs/About.md @@ -0,0 +1,5 @@ +# About Life Log + +* Life Log is an full database implementation, web journal of categorised logs and events in time. +* It is meant to be limitless, fully searchable and viewed as mostly desired. +* Can be used and expanded, as it is also fully configurable. diff --git a/htdocs/cgi-bin/docs/LogTagsHelp.md b/htdocs/cgi-bin/docs/LogTagsHelp.md new file mode 100644 index 0000000..2bfc654 --- /dev/null +++ b/htdocs/cgi-bin/docs/LogTagsHelp.md @@ -0,0 +1,34 @@ +# L-Tags +```HTML + <> + +<> + +<> + +< + +<> + +<> +```HTML + +*_frm.png images file pairs are located in the ./images folder of the cgi-bin directory. +These are manually resized by the user. Next to the original. Otherwise considered as stand alone icons. *_frm.png Image resized to -> width="210" height="120" +Example: +``` + + ../cgi-bin/images/ + my_cat_simon_frm.png + my_cat_simon.jpg + + For log entry, place: + + <my_cat_simon_frm.png> <> + This is my pet, can you hold him for a week while I am on holiday? +``` + +```HTML +<> +```HTML +Explicitly tag an URL in the log entry. Required if using in log IMG or FRM tags. Otherwise link appears as plain text. \ No newline at end of file diff --git a/htdocs/cgi-bin/markdown.cgi b/htdocs/cgi-bin/markdown.cgi index 88f542f..d53b945 100755 --- a/htdocs/cgi-bin/markdown.cgi +++ b/htdocs/cgi-bin/markdown.cgi @@ -11,15 +11,34 @@ use CGI; use Text::Markdown 'markdown'; my $cgi = CGI->new; +my $dir = $cgi->param('dir'); + #$dir = './htdocs/cgi-bin/docs' if(!$dir); + $dir = './docs' if(!$dir); my $file = $cgi->param('file'); - $file = qq(../../Current Development Check List.md) if(!$file); + #$file = qq(../../Current Development Check List.md) if(!$file); try{ - -open my $fh, '<', $file or die "Can't open file $!"; -read $fh, my $file_content, -s $fh; -my $html = markdown($file_content); +if($file && -f "$dir/$file"){ + open my $fh, '<', "$dir/$file" or die "Can't open file $!"; + read $fh, my $file_content, -s $fh; + my $html = markdown($file_content); print $cgi->header, "
\n$html\n
", $cgi->end_html; +} +elsif(-d "$dir"){ #List and return markup files found in dir, comma separated. + opendir(DIR, $dir) or die $!; + my @lst = (); + while ($file = readdir(DIR)) { + next if ($file =~ m/^\./) || ($file =~ m/!\.md$/); + next if (-d "$dir/$file"); + push @lst, $file; + } + closedir(DIR); + print $cgi->header, join (',', map { chomp; qq("$_") } sort @lst); +}else{ + die "Directory [$dir] not valid!" +} + + exit; } catch{ -- 2.34.1