]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Upd. to v.2.2
authorwbudic <redacted>
Tue, 9 Feb 2021 00:07:53 +0000 (11:07 +1100)
committerwbudic <redacted>
Tue, 9 Feb 2021 00:07:53 +0000 (11:07 +1100)
dbLifeLog/main.cnf
htdocs/cgi-bin/system/modules/Settings.pm

index 36f3b513e76e78b68ac83a507cc8e9c4ba78f035..8d7830b5ef173c687360c5c2c180e1fac38b12d4 100644 (file)
@@ -41,36 +41,15 @@ America/Texas=America/Chicago
 >>
 
 
-# Setting to modify the page view to exclude older log entries by a list of categories from today minus days back.
-# This is to avoid and page only list relevant logs on logon. Searching by category will list them and still make visible.
-# value: {days=}{category id},.. days default to zero, if you don't want from yesterday to the past category entries listed.
-<<!PAGE_VIEW_EXCLUDES<0=88,6,69> <- (Diary,System Log,Poetry) category id's only, does set in the config page also work.
-
-/*
-   Global view overrides. These get generated in the db if set on logon. And used instead of the normal data view.
-   Overrides must always show todays log entries, regardless of criteria.
-   Overrides don't affect category and keywords desired searches and views. They are mainly useful to filter out 
-   the not required to see on the main pages.
-   NOTE - These settings AND on VW_LOG_WITH_EXCLUDES if they are set. VW_ prefix signifies, database view, 
-   meaning this will be created. Based on the settings bellow you make. An interesting concept, don't you think?
-*/
+# @See help at bottom of config for all the following.
 
-#######################
-# VIEW_OVERRIDE_SYSLOGS overrides not to show system logs older than today.
-# Default for 0, disabled.
+<<!PAGE_VIEW_EXCLUDES<0=88,6,69> <- (Diary,System Log,Poetry) category id's only, does set in the config page also work.
 <<VIEW_OVERRIDE_SYSLOGS<0>>>
-
-#######################
-# VIEW_OVERRIDE_WHERE overrides what to, or not to select.
-# Default is not being used. OLDER_THAN keyword translates to appropriate SQL. 
-# By either months, days, hours. From current time.
-# i.e VIEW_OVERRIDE_WHERE<ID_CAT!=6 OR OLDER_THAN=2months>, this instructs skip older then to months logs and all sys logs.
-# i.e VIEW_OVERRIDE_WHERE<ID_CAT>=6>, this instructs skip all categories bellow and including sys logs..
-<<VIEW_OVERRIDE_WHERE<"">>>
+<<VIEW_OVERRIDE_WHERE<ID_CAT>=6 AND >>>
 
 
 <<CONFIG<4>
-00|$RELEASE_VER = 2.1`LifeLog Application Version.
+00|$RELEASE_VER = 2.2`LifeLog Application Version.
 01|$REC_LIMIT   = 25`Records shown per page.
 03|$TIME_ZONE   = Australia/Sydney`Time zone of your country and city.
 05|$PRC_WIDTH   = 80`Default presentation width for pages.
@@ -111,51 +90,54 @@ America/Texas=America/Chicago
 NOTES|DROP TABLE NOTES;' ver. 1.5 fts4 virtual tables have been scratched as they require special SQLite compilation.
 LOG<5>|Run Query ' ver. 1.5
 
-## Following are historical migration changes.
+## HELP SECTION ON OPTIONS
 
-//ALTER TABLE LOG RENAME AMOUNT TO AMOUNT;
 
-CREATE TABLE life_log_temp_table AS SELECT * FROM LOG;
-DROP TABLE LOG;
-//CREATE TABLE LOG ( ID_CAT TINY NOT NULL, DATE   DATETIME    NOT NULL, LOG    VCHAR (128) NOT NULL,  AMOUNT INTEGER,  AFLAG TINY DEFAULT 0, RTF BOOL DEFAULT 0);
-CREATE TABLE LOG (
-    ID_CAT TINY        NOT NULL,
-    DATE   DATETIME    NOT NULL,
-    LOG    VCHAR (128) NOT NULL,
-    AMOUNT INTEGER,
-    AFLAG TINY DEFAULT 0,
-    RTF BOOL DEFAULT 0
-);
+   Global view overrides. These get generated in the db if set on logon. And used instead of the normal data view.
+   Overrides must always show todays log entries, regardless of criteria.
+   Overrides don't affect category and keywords desired searches and views. They are mainly useful to filter out 
+   the not required to see on the main pages.
+   NOTE - These settings AND on VW_LOG_WITH_EXCLUDES if they are set. VW_ prefix signifies, database view, 
+   meaning this will be created. Based on the settings bellow you make. An interesting concept, don't you think?
+
+### PAGE_VIEW_EXCLUDES
+
+ Setting to modify the page view to exclude older log entries by a list of categories from today minus days back.
+ This is to avoid and page only list relevant logs on logon. Searching by category will list them and still make visible.
+ value: {days=}{category id},.. days default to zero, if you don't want from yesterday to the past category entries listed.
+
+<<!PAGE_VIEW_EXCLUDES<0=88,6,69> <- (Diary,System Log,Poetry) category id's only, does set in the config page also work.
 
-INSERT INTO LOG (
-                    ID_CAT,
-                    DATE,
-                    LOG,
-                    AMOUNT
-                )
-                SELECT ID_CAT,
-                       DATE,
-                       LOG,
-                       AMOUNT
-                  FROM life_log_temp_table;
 
-DROP TABLE life_log_temp_table;
-PRAGMA foreign_keys = 1;
+### VIEW_OVERRIDE_SYSLOGS overrides not to show system logs that are older than today. Same to CAT!=6 by default,
+# Default is 0, disabled.
 
-%INCOME_ID% = SELECT ID FROM CAT WHERE CAT.NAME LIKE 'Income';
-%EXPENSE_ID% = SELECT ID FROM CAT WHERE CAT.NAME LIKE 'Income';
+### VIEW_OVERRIDE_WHERE 
 
+ This option overrides what log entries to filter out from the page view, in more detail.
+ It translated via keywords to appropriate required SQL. This filter by default is
+ not active on 24 hours old entries. PAGE_VIEW_EXCLUDES option entries are included.
 
+#### CAT is the ID_CAT column, keyword.
+* i.e VIEW_OVERRIDE_WHERE<CAT >= 6>, selects all categories from and category id 6. 
+PAGE_VIEW_EXCLUDES and VIEW_OVERRIDE_SYSLOGS don't have to be set. But preside if set.
 
-UPDATE LOG SET AFLAG=1 WHERE ID_CAT=%INCOME_ID%;
-UPDATE LOG SET AFLAG=2 WHERE ID_CAT=%EXPENSE_ID%;
+#### AND/OR keyword, logically joins the instructions.
+* i.e VIEW_OVERRIDE_WHERE< CAT > 6 AND CAT != 'Personal' >, selects all categories from 
+category id 6, excluding resolved category entries.
 
-LOG<6>|Run Query ' ver. 1.6
-ALTER TABLE LOG ADD STICKY BOOL DEFAULT 0;
+#### OLDER_THAN keyword translates to date column older than from today up to an specified date in the past.
+* This is assigned by either months, days, hours. 
+** i.e VIEW_OVERRIDE_WHERE<CAT !=6 AND OLDER_THAN=2 months>, this instructs skip older then to months logs and all sys logs.
 
-LOG<6>|Run Query ' ver. 1.8
+#### FROM/TO in either months, days, hours.
+* Selects only FROM or TO an specified date only log entries.
+** i.e VIEW_OVERRIDE_WHERE<FROM=12 hours AND NOT OLDER_THAN=1 year>
 
-CREATE TABLE notes_temp_table (LID INTEGER PRIMARY KEY NOT NULL, DOC TEXT);
-INSERT INTO notes_temp_table SELECT `LID`,`DOC` FROM `NOTES`;
-DROP TABLE `NOTES`;
-ALTER TABLE `notes_temp_table` RENAME TO `NOTES`;
+#### NOT keyword, logically negates.
+** i.e VIEW_OVERRIDE_WHERE<RTF>, select only log entries that contain attached RTF documents, if they
+are older than 24 hours. Remember, the default filtering is on 24 hour and older log entries.
+** i.e VIEW_OVERRIDE_WHERE<NOT RTF>, don't select log entries that contain attached RTF documents.
+** i.e VIEW_OVERRIDE_WHERE<CAT NOT 'Diary' AND CAT NOT 'System Log' AND DATE FROM=24 days AND NOT OLDER_THAN=1 year>, 
+category is not (!=), resolved category id by name. And also exclude all logs older than an year. 
+All is FROM to OLDER_THAN, affected. So from today (now) to FROM 'will' be paged, visible.
\ No newline at end of file
index 4f8dba99db6e469ac104a420899f22702881e694..62ea71a7a04dfdffd29a335c8246da7de1e5a01f 100644 (file)
@@ -1,11 +1,13 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+#
+# Web interaction, reusable tri state of configuration concerns, set of utilities. 
 #
 # Programed by: Will Budic
 # Open Source License -> https://choosealicense.com/licenses/isc/
 #
 package Settings;
 
-use v5.10;
+use v5.14;
 use strict;
 use warnings;
 use Exception::Class ('SettingsException','LifeLogException','SettingsLimitSizeException');
@@ -18,7 +20,7 @@ use DateTime::Format::SQLite;
 use DateTime::Duration;
 
 use DBI;
-use experimental qw( switch );
+use experimental 'switch';
 
 # This is the default developer release key, replace on istallation. As it is not secure.
 use constant CIPHER_KEY             => '95d7a85ba891da';
@@ -40,7 +42,7 @@ use constant VW_LOG_WITH_EXCLUDES   => 'VW_LOG_WITH_EXCLUDES';
 use constant VW_LOG_OVERRIDE_WHERE  => 'VW_LOG_OVR_WHERE';
 
 #DEFAULT SETTINGS HERE!
-our $RELEASE_VER  = '2.1';
+our $RELEASE_VER  = '2.2';
 our $TIME_ZONE    = 'Australia/Sydney';
 our $LANGUAGE     = 'English';
 our $PRC_WIDTH    = '60';
@@ -666,23 +668,34 @@ sub connectDB {
        LifeLogException->throw(error=>"<p>Error->$@</p><br><p>$DSN</p>",  show_trace=>1);
     }
 }
-my $reg_autonom = qr/(^<<)(.+?<)(.+)(>{3,})/mp;
-
-sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line.
 
-    my $t = shift;
+my @F = ('', '""', 'false', 'off', 'no', 0);# Placed 0 last, as never will be checked for in toPropertyValue.
+my @T  = (1, 'true', 'on', 'yes');
+my $reg_autonom = qr/(<<)(.+?)(<)(\n*.+\s*)(>{3,})/mp;
 
-    if($t =~ /$reg_autonom/g){
-        my ($tag,$val) = ($2,$3);
-        $tag =~ s/<$//g; 
+sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line.
+    my $tag  = shift;
+    my $line = shift;
+    if($line =~ /$reg_autonom/g){
+        my ($t,$val) = ($2,$4);       
         $val =~ s/""$//g; #empty is like not set
         $val =~ s/^"|"$//g;
-        if($tag&&$val){
-            return $val;
+        if($t eq $tag&&$val){           
+           return toPropertyValue( $val );
         }        
     }
 
     return;
 }
 
+sub toPropertyValue {
+    my $prm = shift;
+    if($prm){
+       my $p = lc $prm; 
+       foreach(@T){return 1 if $_ eq $p;}
+       foreach(@F){return 0 if $_ eq $p;}       
+    }
+    return $prm;
+}
+
 1;
\ No newline at end of file