From: Will Budicm Date: Sun, 13 Sep 2020 09:51:50 +0000 (+1000) Subject: Started work on markdown implementation. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=b90de47678af5caf03368f92e5df544dc55f98af;p=LifeLog.git Started work on markdown implementation. --- diff --git a/Current Development Check List.md b/Current Development Check List.md index 764a7f6..032f09e 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -10,6 +10,8 @@ * Earth stage requires same SQL related code to work on at least one more DBMS type other than SQLight. * PostgreSQL is most likelly candidate as MySQL is not easy to install for the average user. * Developing and adopting to MySQL or any other system is not prerogative, as it works well as it is with inbuild simplicity. +* Provide markdown text functionality to html pages. For quick vanila plain documentation. +* ✔ Implement title bolding on logs using markdown, so tags can be avoided, for multiline logs. ### v.2.0 SUN RC2 Encountered diff --git a/Installation.txt b/Installation.txt index 21c3972..530dbf1 100644 --- a/Installation.txt +++ b/Installation.txt @@ -132,6 +132,7 @@ sudo cpan JSON; sudo cpan Switch; sudo cpan IPC::Run sudo cpan Syntax::Keyword::Try; +sudo cpan Text::Markdown #Install DBI module sudo cpan DBI; diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 182590b..66825be 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -605,10 +605,13 @@ sub buildLog { $log =~ s/<+?)/$sub/o; $tagged = 1; } - + #bold on start markup + $log =~ s/(^\*)(.*)(\*)(\\n)/\2<\/b>
/oi; #Decode escaped \\n $log =~ s/\r\n/
/gs; $log =~ s/\\n/
/gs; + + if ( $CID_EVENT == $row[1] ) { $log = "$log"; diff --git a/htdocs/cgi-bin/markdown.cgi b/htdocs/cgi-bin/markdown.cgi new file mode 100755 index 0000000..88f542f --- /dev/null +++ b/htdocs/cgi-bin/markdown.cgi @@ -0,0 +1,30 @@ +#!/usr/bin/perl +# Programed by: Will Budic +# Open Source License -> https://choosealicense.com/licenses/isc/ +# +use strict; +use warnings; + +use Syntax::Keyword::Try; +use DateTime; +use CGI; +use Text::Markdown 'markdown'; + +my $cgi = CGI->new; +my $file = $cgi->param('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); + print $cgi->header, "
\n$html\n
", $cgi->end_html; +exit; +} +catch{ + my $err = $@; + print $cgi->header, + "SERVER ERROR on ".DateTime->now."
 $err\n$file
"; + print $cgi->end_html; +} \ No newline at end of file diff --git a/htdocs/cgi-bin/stats.cgi b/htdocs/cgi-bin/stats.cgi index 8c041b5..094a659 100755 --- a/htdocs/cgi-bin/stats.cgi +++ b/htdocs/cgi-bin/stats.cgi @@ -7,7 +7,7 @@ use warnings; #no warnings 'uninitialized'; use Switch; -use CGI::Pretty ":standard"; +#use CGI::Pretty ":standard"; use CGI::Session '-ip_match'; use DBI; use DateTime;