From: Will Budic Date: Sun, 7 May 2023 04:05:49 +0000 (+1000) Subject: Started work on Index Page full PerlCNF implementation. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=bfecce5a9a10c36d2838f660d76e602dac504001;p=LifeLog.git Started work on Index Page full PerlCNF implementation. --- diff --git a/htdocs/cgi-bin/docs/About.md b/htdocs/cgi-bin/docs/About.md index dfa8ede..b58945b 100644 --- a/htdocs/cgi-bin/docs/About.md +++ b/htdocs/cgi-bin/docs/About.md @@ -1,5 +1,7 @@ # About Life Log -* Life Log is an full database implementation, web journal of categorised logs and events in time. +* Life Log is an full database implementation, web journal of categorized 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. + +![](images/VS-on-METABOX-42.png) diff --git a/htdocs/cgi-bin/docs/LogTagsHelp.md b/htdocs/cgi-bin/docs/LogTagsHelp.md index 2bfc654..e1ee4d7 100644 --- a/htdocs/cgi-bin/docs/LogTagsHelp.md +++ b/htdocs/cgi-bin/docs/LogTagsHelp.md @@ -1,34 +1,43 @@ -# L-Tags -```HTML - <> +# LifeLog Post 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: ``` +* 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 is resized to -> width="210" height="120" + +Examples: +```html + ../cgi-bin/images/ my_cat_simon_frm.png my_cat_simon.jpg - For log entry, place: + For log entry, place: +  < <> + This is my pet, can you hold him for a week while I am on holiday? + + Explicitly tag an URL in the log entry. Required if using in log IMG or FRM tags. + Otherwise link appears as plain text: +  <> - <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 +* YuoTube embed script is automatically parsed. + +Example: + +```pre + + + +``` diff --git a/htdocs/cgi-bin/docs/PerlCNF/README.md b/htdocs/cgi-bin/docs/PerlCNF/README.md new file mode 100644 index 0000000..b987e2e --- /dev/null +++ b/htdocs/cgi-bin/docs/PerlCNF/README.md @@ -0,0 +1,100 @@ +# PerlCNF + +Perl based Configuration Network File Format Parser and Specifications. +CNF file format supports used format extraction from any text file. +Useful for templates and providing initial properties and values for an application settings. +Has own textual data format. Therefore can also be useful for database data batch processing. + +This version doesn't parse the actual __DATA__ section of an perl file yet. Contact me if this is needed, and for any other possible, useful requests. +It is at current v.2.6, and specification implemented. + +### [You can find the specification here](./Specifications_For_CNF_ReadMe.md). + +--- + +NEWS (2022-11-18) - PerlCNF now provides custom test manager and test cases. +That will in future be used for all projects as an copy from this project. +This is all available in the ./test directory and is not a Perl module. + +--- + +## Installation Of This Perl GitHub Project + +* Installation is standard. + +```sh + mkdir ~/dev; cd ~/dev + git clone https://github.com/wbudic/PerlCNF.git + cd PerlCNF +``` + +* To install required modules locally to home, do not run following with sudo in front. + * cd ~/dev/PerlCNF; #Perl tests and project directory is required to be the starting location. +```sh + ./install_cpan_modules_required.pl +``` + + +## Usage + +* Copy the system/modules/CNFParser.pm module into your project. +* From your project you can modify and adopt, access it. +* You can also make an perl bash script. + +```perl +use lib "system/modules"; +use lib $ENV{'PWD'}.'/htdocs/cgi-bin/system/modules'; +require CNFParser; + + my $cnf1 = new CNFParser('sample.cnf'); + #Load config with enabled evaluation on the fly, of perl code embedded in config file. + my $cnf2 = new CNFParser('sample.cnf',{DO_enabled=>1, duplicates_overwrite=0}); + + ``` +## Sample CNF File + +```CNF +<<>> +<<$APP_DESCRIPTION +This application presents just +a nice multi-line template. +>> + +<<@<@LIST_OF_COUNTRIES> +Australia, USA, "Great Britain", 'Ireland', "Germany", Austria +Spain, Serbia +Russia +Thailand, Greece +>>> + +Note this text here, is like an comment, not affecting and simply ignored. +

Other tags like this paragraph better put into a CNF property to be captured.

+ +``` + +```perl + +my $cnf = new CNFParser('sample.cnf'); +my @LIST_OF_COUNTRIES = @{$cnf -> collection('@LIST_OF_COUNTRIES')}; +print "[".join(',', sort @LIST_OF_COUNTRIES )."]"; +#prints -> [Australia,Austria,Germany,Great Britain,Greece,Ireland,Russia,Serbia,Spain,Thailand,USA] +print "App Name: ".$cnf->constant('$APP_NAME')."]"; +#prints -> App Name: Test Application + +``` + +## Run Test Cases + +* Tests are located in the projects **./test directory. +* Example how to run them: + + ```sh + perl ./tests/testAll.pl + ``` + +* Check also the latest Perl CNF [example.cnf](./tests/example.cnf) scripted also as an tutorial. + * Yes! That is an actual valid configuration file. + * To only just run it or check use ``` perl ./tests/testExample.pl ``` diff --git a/htdocs/cgi-bin/index.cgi b/htdocs/cgi-bin/index.cgi new file mode 100755 index 0000000..a03a8c8 --- /dev/null +++ b/htdocs/cgi-bin/index.cgi @@ -0,0 +1,111 @@ +#!/usr/bin/env perl +# A delegated CNFParser processed rendering of the Document Index Web page, a Model-View-Controller Pattern approuch. +# The index.cnf script contains the structure and page skeleton, +# all configuration as well as the HTMLIndexProcessorPlugin converting the CNF to final HTML. +# It is very convienient, as both style and script for the page is separated and developed in the index.cnf. +# Which then can be moved to a respective include file over there. +# This controller binds and provides to the parser to do its magic thing. +# +# Programed by: Will Budic +# Open Source License -> https://choosealicense.com/licenses/isc/ +# +use v5.30; +use strict; +use warnings; +use Exception::Class ('LifeLogException'); +use Syntax::Keyword::Try; +use DateTime; +## +# We is dynamic perl compilations. The following ONLY HERE required to carp to browser on +# system requirments or/and unexpected perl compiler errors. +## +use CGI::Carp qw(fatalsToBrowser set_message); +BEGIN { + sub handle_errors { + my $err = shift; + say "

Server Error

Error: $err
"; + } + set_message(\&handle_errors); +} + +#debug -> +use lib "/home/will/dev/LifeLog/htdocs/cgi-bin/system/modules"; +use lib "system/modules"; +require CNFParser; +require CNFNode; + +our $GLOB_HTML_SERVE = "{}/*.cgi {}/*.htm {}/*.html {}/*.md {}/*.txt"; +our $script_path = $0; +$script_path =~ s/\w+.cgi$//; +exit main(); + +sub main { + my $html = obtainDirListingHTML('docs'); + my $cnf = CNFParser->new( + $script_path."index.cnf",{ + DO_enabled => 1, + ANONS_ARE_PUBLIC => 1, + PAGE_HEAD => "

Index Page of Docs

", + PAGE_CONTENT => $html, + PAGE_FOOT => "" + } + ); + my $ptr = $cnf->data(); + $ptr = $ptr->{'PAGE'}; + say $$ptr if $ptr; + return 0 +} + +sub obtainDirListingHTML { + my ($dir, $ret) = (shift,""); + $ret .="$dir →
    \n"; + $ret .= listFiles($dir,$script_path); + my $handle; + opendir ($handle, $script_path.$dir) or die "Couldn't open directory, $!"; + while (my $node = readdir $handle) { + my $file_full_path = "$script_path$dir/$node"; + if($node !~ /^\./ && -d $file_full_path){ + $ret .= obtainDirListingHTML($dir.'/'.$node); + } + } + closedir $handle; + + $ret .= "
"; + return $ret; +} +sub listFiles ($){ + my ($dir, $script_path, $ret) = @_; + my $path = $script_path.$dir; + my $spec = $GLOB_HTML_SERVE; $spec =~ s/{}/$path/gp; + my @files = glob ($spec); + foreach my $file(@files){ + if($file =~ /\.md$/){ + my @title = getDocTitle($file); + $ret .= qq(\t\t\t
  • $title[1]
  • \n); + }else{ + ($file =~ m/(\w+\.\w*)$/g); + $ret .= qq(\t\t\t
  • $1
  • \n); + } + } + return $ret; +} + +sub getDocTitle($){ + my ($file,$ret) = shift; + open(my $fh, '<', $file) or LifeLogException->throw("Can't open $file: $!"); + while (my $line = <$fh>) { + if($line =~ /^#+\s*(.*)/){ + $ret = $1; + last; + } + } + close $fh; + ($file =~ m/(\w+\.\w*)$/g); + return ($1,$ret) +} + + + + + + diff --git a/htdocs/cgi-bin/index.cnf b/htdocs/cgi-bin/index.cnf new file mode 100644 index 0000000..808b8fc --- /dev/null +++ b/htdocs/cgi-bin/index.cnf @@ -0,0 +1,226 @@ +!CNF2.8 + +<<@<%HTTP_HEADER> +-charset = UTF8 +-expires = +5s +>> + +< _HAS_PROCESSING_PRIORITY_ + +[JS[ + [@@[wsrc/main.js]@@] + [@@[wsrc/jquery.js]@@] + [@@[wsrc/jquery-ui.js]@@] +]JS] +[CSS[ + [@@[wsrc/main.css]@@] + [@@[wsrc/jquery-ui.css]@@] + [@@[wsrc/jquery-ui.theme.css]@@] + [@@[wsrc/jquery-ui.theme.css]@@] +]CSS] + +STYLE> + +SCRIPT> +>> + +### +# We in plugin mainly access this PAGE property, <*
    *> is linked in for clarity, +# and/or if want to change from keeping the original \<\...\>\> above. +# +< + + <*
    *> + + Title: Index Page + OnLoad : onIndexBodyLoad() + + *> + a> + >div> + #> + >span> + *> + >div> + *> + >div> + >div> + *> + span> + #> + >a> + span> + >div> + >div> + !> +>> + +< + package : HTMLIndexProcessorPlugin + subroutine : convert + property : PAGE +>> + +<>> + +< _HAS_PROCESSING_PRIORITY_ + package : MarkdownPlugin + subroutine : convert + property : INFO_MD +>> + + + + + +