]> lifelog.hopto.org Git - LifeLog.git/commitdiff
markdown dev. cont.
authorWill Budicm <redacted>
Thu, 17 Sep 2020 00:16:53 +0000 (10:16 +1000)
committerWill Budicm <redacted>
Thu, 17 Sep 2020 00:16:53 +0000 (10:16 +1000)
htdocs/cgi-bin/docs/About.md [new file with mode: 0644]
htdocs/cgi-bin/docs/LogTagsHelp.md [new file with mode: 0644]
htdocs/cgi-bin/markdown.cgi

diff --git a/htdocs/cgi-bin/docs/About.md b/htdocs/cgi-bin/docs/About.md
new file mode 100644 (file)
index 0000000..dfa8ede
--- /dev/null
@@ -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 (file)
index 0000000..2bfc654
--- /dev/null
@@ -0,0 +1,34 @@
+# L-Tags
+```HTML
+ <<B<{Text To Bold}>>
+
+<<I<{Text To Italic}>>
+
+<<TITLE<{Title Text}>>
+
+<<LIST<{List of items delimited by new line to terminate item or with '~' otherwise.}>
+
+<<IMG<{url to image}>>
+
+<<FRM<{file name}_frm.png}>>
+```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:
+
+         <<FRM>my_cat_simon_frm.png> <<TITLE<Simon The Cat>>
+         This is my pet, can you hold him for a week while I am on holiday?
+```
+
+```HTML
+<<LNK<{url to image}>>
+```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
index 88f542f0fd95ff42b7b26f1808355e9337c41d9a..d53b945c8e56f12795e66152213cff3a3e0dc1c0 100755 (executable)
@@ -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, "<DIV style='padding:10px'>\n$html\n</DIV>", $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{