From 38b74693ddb2fff75ae045268a7c8a88bb26327b Mon Sep 17 00:00:00 2001 From: wbudic Date: Sun, 15 Aug 2021 16:27:28 +1000 Subject: [PATCH] Lot of CSS updates, new RTF handling implemented. --- Current Development Check List.md | 2 + htdocs/cgi-bin/config.cgi | 41 +++-- htdocs/cgi-bin/data.cgi | 14 +- htdocs/cgi-bin/main.cgi | 23 ++- htdocs/cgi-bin/stats.cgi | 73 +++++---- htdocs/cgi-bin/system/modules/Settings.pm | 5 +- htdocs/cgi-bin/wsrc/main.css | 47 +++--- htdocs/cgi-bin/wsrc/main.js | 48 ++++-- htdocs/cgi-bin/wsrc/main_earth.css | 7 + htdocs/cgi-bin/wsrc/main_moon.css | 73 ++++++--- htdocs/cgi-bin/wsrc/main_sun.css | 183 +++++++++++++++++----- 11 files changed, 350 insertions(+), 166 deletions(-) diff --git a/Current Development Check List.md b/Current Development Check List.md index 3546613..b73d4e4 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -6,6 +6,8 @@ ### New Development +* Configuration needs to be updated, to use CNF 2.2, for system reset, etc. +* Fix themes. Themes don't display and set consistently the pages throughout. * ✔ RTF load of the zero document if present. When RTF attaching to a new log, you can save the rtf, it is called a zero document (not assigned), as the log hasn't been saved yet. This reload can be useful, as it is always stored... * ✔ Implement backup/restore on Pg based data. Restore only partially works from older backup. diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index 5254902..f07206c 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -309,8 +309,6 @@ my $frmVars = qq(
); - - $tbl = qq( ); @@ -488,8 +486,7 @@ sub getHeader { print $cgi->header(-expires=>"+6s", -charset=>"UTF-8"); print $cgi->start_html(-title => "Personal Log", -BGCOLOR=>&Settings::bgcol, -onload => "onBodyLoadGeneric();", - -style => [ - { -type => 'text/css', -src => "wsrc/".&Settings::css }, + -style => [ { -type => 'text/css', -src => 'wsrc/jquery-ui.css' }, { -type => 'text/css', -src => 'wsrc/jquery-ui.theme.css' }, { @@ -501,6 +498,7 @@ print $cgi->start_html(-title => "Personal Log", -BGCOLOR=>&Settings::bgcol, -type => 'text/css', -src => 'wsrc/tip-yellowsimple/tip-yellowsimple.css' }, + { -type => 'text/css', -src => "wsrc/".&Settings::css }, ], -script => [ { -type => 'text/javascript', -src => 'wsrc/main.js' }, @@ -778,9 +776,8 @@ try{ my @row; getHeader() if(&Settings::debug); - print "

Database Records Fix Result

\n
" if(&Settings::debug); - print "
Started transaction!\n" if(&Settings::debug);
-
+        print "

Database Records Fix Result

\n
" if &Settings::debug; + print "
Started transaction!\n" if &Settings::debug;
         $db->do('BEGIN TRANSACTION;');
         # Check for duplicates, which are possible during imports or migration as internal rowid is not primary in log.
         # @TODO This should be selecting an cross SQL compatibe view.
@@ -809,12 +806,12 @@ try{
             my $st_del = $db->prepare($sql);
             $st_del->execute();
         }
-        print "Doing renumerate next...\n" if(&Settings::debug);
+        print "Doing renumerate next...\n" if &Settings::debug;
         &renumerate;
-        print "done!\n";
-        print "Doing removeOldSessions next..." if(&Settings::debug);
+        print "done!\n" if &Settings::debug;
+        print "Doing removeOldSessions next..." if &Settings::debug;
         &Settings::removeOldSessions;
-        print "done!\n " if(&Settings::debug);
+        print "done!\n " if &Settings::debug;
         &resetCategories if $rs_cats;
         &resetSystemConfiguration($db) if $rs_syst;
         &wipeSystemConfiguration if $wipe_ss;
@@ -858,7 +855,7 @@ sub renumerate {
 
     ### RENUMERATE LOG
     $db->do("CREATE TABLE life_log_temp_table AS SELECT * FROM LOG;");
-    if(Settings::isProgressDB()){
+    if(&Settings::isProgressDB){
         $db->do('DROP TABLE LOG CASCADE;');
     }
     else{
@@ -876,7 +873,7 @@ sub renumerate {
         my $old = $notes{$date};
         #my $sql_date = DateTime::Format::SQLite->parse_datetime($date);
         
-        if(Settings::isProgressDB()){
+        if(&Settings::isProgressDB){
             $sql = "SELECT ID FROM LOG WHERE RTF > 0 AND DATE = '".$date."';";
         }else{
             $sql = "SELECT rowid FROM LOG WHERE RTF > 0 AND DATE = '".$date."';";
@@ -928,7 +925,7 @@ sub wipeSystemConfiguration {
 
 sub resetSystemConfiguration {
 
-        open(my $fh, '<', &Settings::logPath.'main.cnf' ) or die "Can't open main.cnf: $!";
+        open(my $fh, '<', &Settings::logPath.'main.cnf') or die "Can't open ".&Settings::logPath."main.cnf! $!";
         my $db = shift;
         my ($id,$name, $value, $desc);
         my $inData = 0;
@@ -963,7 +960,7 @@ try{
                                                                     my @row = $dbs->fetchrow_array();
                                                                     if(scalar @row == 0){
                                                                        #The id in config file has precedence to the one in the db,
-                                                                       #from a ppossible previous version.
+                                                                       #from a possible previous version.
                                                                        $dbs = Settings::selectRecords($db, "SELECT ID FROM CONFIG WHERE ID = $id;");
                                                                        @row = $dbs->fetchrow_array();
                                                                        if(scalar @row == 0){
@@ -997,9 +994,9 @@ try{
                         }
                     }
         }
-        #die "Configuration script './main.cnf' [$fh] contains errors." if $err;
+        die "Configuration script './main.cnf' [$fh] contains errors." if $err;
         close $fh;
-       Settings::getConfiguration($db);
+        Settings::getConfiguration($db);
  } catch{
       close $fh;
       print $cgi->header;
@@ -1060,7 +1057,7 @@ sub backup {
    my @dr = split(':', Settings::dbSrc());
    my $ball = 'bck_'.$today->strftime('%Y%m%d%H%M%S_').$dr[1]."_$dbname.osz";   
 
-   my $file = Settings::logPath().'data_'.$dr[1].'_'."$dbname"."_log.db";
+   my $file = &Settings::logPath.'data_'.$dr[1].'_'."$dbname"."_log.db";
    my $dsn= "DBI:SQLite:dbname=$file";
    my $weProgress = Settings::isProgressDB();
    if($weProgress){
@@ -1096,10 +1093,10 @@ sub backup {
    }
 
     print $cgi->header(-charset=>"UTF-8", -type=>"application/octet-stream", -attachment=>$ball);
-    my $pipe = "tar czf - ".Settings::logPath().'main.cnf' ." ".$file." | openssl enc -e -des-ede3-cfb -salt -S ".
-                            Settings->CIPHER_KEY." -pass pass:$pass-$alias -out ".Settings::logPath().$ball." 2>/dev/null";
+    my $pipe = "tar czf - ".&Settings::logPath.'main.cnf' ." ".$file." | openssl enc -e -des-ede3-cfb -salt -S ".
+                            Settings->CIPHER_KEY." -pass pass:$pass-$alias -out ".&Settings::logPath.$ball." 2>/dev/null";
     my $rez = `$pipe`;       
-       open (my $TAR, "<", Settings::logPath().$ball) or die "Failed creating backup -> $ball";
+       open (my $TAR, "<", &Settings::logPath.$ball) or die "Failed creating backup -> $ball";
             while(<$TAR>){print $_;}
        close $TAR;
     unlink $file if $weProgress;  
@@ -1296,7 +1293,7 @@ my $stdout = capture_stdout {
         print "Restore ended: ".Settings::today(), "\n";
 };      print $stdout;
 
-my $fh; open( $fh, ">>", Settings::logPath()."backup_restore.log");
+my $fh; open( $fh, ">>", &Settings::logPath."backup_restore.log");
         print $fh $stdout;
         close $fh;
 
diff --git a/htdocs/cgi-bin/data.cgi b/htdocs/cgi-bin/data.cgi
index dd75069..a23d0c5 100755
--- a/htdocs/cgi-bin/data.cgi
+++ b/htdocs/cgi-bin/data.cgi
@@ -130,7 +130,7 @@ try{
    print $cgi->redirect('main.cgi');  
 
 }catch{
-    print $cgi->p("ERROR  " . $@);
+    print $cgi->p("ERROR$!  " . $@);
 }
 }
 
@@ -138,13 +138,17 @@ sub printHeader {
 my $title = shift;
 print $cgi->header(-expires=>"+6os");
 print $cgi->start_html(-title => $title, -BGCOLOR => &Settings::bgcol,                
-            -script=> [{-type => 'text/javascript', -src => 'wsrc/main.js'},
-                        {-type => 'text/javascript', -src => 'wsrc/jquery.js'},
-                        {-type => 'text/javascript', -src => 'wsrc/jquery-ui.js'}],                
+            -script=> [ {-type => 'text/javascript', -src => 'wsrc/jquery.js'},
+                        {-type => 'text/javascript', -src => 'wsrc/jquery-ui.js'},
+                        {-type => 'text/javascript', -src => 'wsrc/main.js'}
+                        ],                
             -style => [{-type => 'text/css', -src => "wsrc/".&Settings::css}, {-type => 'text/css', -src => "wsrc/print.css"},
                         {-type => 'text/css', -src => 'wsrc/jquery-ui.css'},
                         {-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'},
-                        {-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'}],
+                        {-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'},
+                        { -type => 'text/css', -src => "wsrc/".&Settings::css }
+                        ],
+                        
             -onload => "onBodyLoadGeneric()");
 }
 
diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi
index 6edf73a..6c0fa7d 100755
--- a/htdocs/cgi-bin/main.cgi
+++ b/htdocs/cgi-bin/main.cgi
@@ -608,7 +608,7 @@ sub buildLog {
         $log =~ s/(^\*)(.*)(\*)(\\n)/$2<\/b>
/oi; #Decode escaped \\n $log =~ s/\r\n/
/gs; - $log =~ s/\\n/
/gs; + $log =~ s/\\n/
\n/gs; @@ -632,6 +632,14 @@ sub buildLog { $log_orig =~ s/\"/"/g; $log_orig =~ s/\'/'/g; $tags .= qq(\n); + }elsif(not &Settings::displayAll){ + my $h; + if($log =~ m/(.*\s*.*?)
/){$h=$1} + elsif($log =~ m/(\s*.*\n)/) {$h=$1} + if($h){ + $log = $h.qq(); + } } my ( $dty, $dtf ) = $dt->ymd; @@ -675,12 +683,12 @@ sub buildLog { )}; - if ( $rtf > 0 ) { + if ( $rtf > 0 ) {#max-width:1000px; + # style="max-height:480px; box-sizing: border-box; padding: 5px; background:#fffafa; overflow-x:scroll;scrollbar-width:none;" $log_output .= qq(
); } @@ -1525,8 +1533,7 @@ sub outputPage { -title => "Personal Log", -BGCOLOR => $BGCOL, -onload => "onBodyLoad('$toggle','".&Settings::language."','".&Settings::timezone."','$today','".&Settings::sessionExprs."','$rs_cur',".&Settings::dbVLSZ.");", - -style => [ - { -type => 'text/css', -src => "wsrc/$TH_CSS" }, + -style => [ { -type => 'text/css', -src => 'wsrc/jquery-ui.css' }, { -type => 'text/css', -src => 'wsrc/jquery-ui.theme.css' }, { @@ -1542,7 +1549,7 @@ sub outputPage { { -type => 'text/css', -src => 'wsrc/quill/monokai-sublime.min.css' }, { -type => 'text/css', -src => 'wsrc/quill/quill.snow.css' }, { -type => 'text/css', -src => 'wsrc/jquery.sweet-dropdown.css' }, - + { -type => 'text/css', -src => "wsrc/$TH_CSS" }, ], -script => [ { -type => 'text/javascript', -src => 'wsrc/main.js' }, diff --git a/htdocs/cgi-bin/stats.cgi b/htdocs/cgi-bin/stats.cgi index 39ed1ba..f2cc0e3 100755 --- a/htdocs/cgi-bin/stats.cgi +++ b/htdocs/cgi-bin/stats.cgi @@ -27,18 +27,11 @@ my $sss = Settings::session(); my $sid = Settings::sid(); my $dbname = Settings::dbFile(); my $alias = Settings::alias(); -my $passw = Settings::pass(); + if(!$alias||!$dbname){ - # if (Settings::debug()){ - # $alias ="admin"; - # $dbname = "data_admin_log.db"; - # $passw = "admin"; - # } - # else{ print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid"); exit; - # } } try{ @@ -46,36 +39,36 @@ my $today = Settings->today(); $ENV{'HOME'} = "~/"; -my $CSS=<header(-expires=>"+6os", -charset=>"UTF-8"); print $cgi->start_html(-title => "Log Data Stats", -BGCOLOR=>Settings::bgcol(), -script=> [{-type => 'text/javascript', -src => 'wsrc/main.js'}, {-type => 'text/javascript', -src => 'wsrc/jquery.js'}, {-type => 'text/javascript', -src => 'wsrc/jquery-ui.js'}], - -style => [{-type => 'text/css', -src => "wsrc/".&Settings::css}, - {-type => 'text/css', -src => 'wsrc/jquery-ui.css'}, + -style => [{-type => 'text/css', -src => 'wsrc/jquery-ui.css'}, {-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'}, {-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'}, + {-type => 'text/css', -src => "wsrc/".Settings::css()}, {-script=>$CSS} ], -head => style({-type => 'text/css'}, $CSS), @@ -140,7 +133,7 @@ my $year =$today->year(); my $IPPublic = `curl -s https://www.ifconfig.me`; my $IPPrivate = `hostname -I`; $IPPrivate =~ s/\s/
/g; -my $tbl = qq(
* DATA FIX *
+my $tbl = qq(
* Personal Log Data Statistics *
@@ -154,24 +147,38 @@ my $tbl = qq(
* Personal Log Data Statistics *
LifeLog App. Version:).Settings::release().qq(
Number of Records:$log_rc
No. of Records This Year:$log_this_year_rc
); -print qq(