]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Added link parsing within the log, requires Regexp::Common
authorwbudic <redacted>
Fri, 18 Jan 2019 05:44:52 +0000 (16:44 +1100)
committerwbudic <redacted>
Fri, 18 Jan 2019 05:44:52 +0000 (16:44 +1100)
htdocs/cgi-bin/main.cgi

index 872519f8d7bd44871b827ddb152b227f3084187d..dba5d35542384f5cd4a71a28564517a300117cb0 100755 (executable)
@@ -10,6 +10,7 @@ use DBI;
 use DateTime;
 use DateTime::Format::SQLite;
 use DateTime::Duration;
+use Regexp::Common qw /URI/;
 
 my $driver   = "SQLite"; 
 my $database = "../../dbLifeLog/data_log.db";
@@ -126,6 +127,7 @@ if($rv < 0) {
 my $tfId = 0;
 my $id = 0;
 my $tbl_start = index $stmt, "<=";
+my $re_a_tag = qr/<a\s+.*?>.*<\/a>/si ;
 
 if($tbl_start>0){
        #check if we are at the beggining of the LOG table?
@@ -139,6 +141,7 @@ if($tbl_start>0){
        $stc->finish();
 }
 
+
  while(my @row = $st->fetchrow_array()) {
 
         $id = $row[0];
@@ -162,6 +165,13 @@ if($tbl_start>0){
         }else{
                 $tfId = 1;
         }
+        my @chunks = split(/($re_a_tag)/si , $log) ;
+  
+        foreach my $chunks_i ( @chunks ) {
+            next if $chunks_i =~ /$re_a_tag/ ;
+               $chunks_i =~ s/($RE{URI}{HTTP})/<a href="$1" target=_blank>$1<\/a>/gsi;
+        }      
+        $log = join('' , @chunks) ;
 
          $tbl = $tbl . '<tr class="r'.$tfId.'"><td id="y'.$id.'">'. $dt->ymd . '</td>'. 
                          '<td id="t'.$id.'">' . $dt->hms . "</td>" .
@@ -281,6 +291,7 @@ exit;
 ### CGI END
 
 
+
 sub buildNavigationButtons{
 
        my $is_end_of_rs = shift;