diff --git a/app/dada/DADA/App.pm b/app/dada/DADA/App.pm index 3e4304367..3d12788fc 100755 --- a/app/dada/DADA/App.pm +++ b/app/dada/DADA/App.pm @@ -10226,8 +10226,9 @@ sub edit_template { my $header_content_tag_found_in_url_template = 0; my $header_content_tag_found_in_default_template = 0; - my $content_tag = quotemeta(''); - my $header_content_tag = quotemeta(''); + my $content_tag = quotemeta(''); + my $header_content_tag = quotemeta(''); + my $header_content_include_tag = quotemeta(''); if ( $DADA::Config::TEMPLATE_OPTIONS->{user}->{enabled} == 1 && $DADA::Config::TEMPLATE_OPTIONS->{user}->{mode} eq 'magic' ) @@ -10252,7 +10253,10 @@ sub edit_template { if ( $raw_template =~ m/$content_tag/ ) { $content_tag_found_in_default_template = 1; } - if ( $raw_template =~ m/$header_content_tag/ ) { + if ( + $raw_template =~ m/$header_content_tag/ + || $raw_template =~ m/$header_content_include_tag/ + ) { $header_content_tag_found_in_default_template = 1; } } @@ -10267,7 +10271,10 @@ sub edit_template { $content_tag_found_in_template = 1; } - if ( $edit_this_template =~ m/$header_content_tag/ ) { + if ( + $edit_this_template =~ m/$header_content_tag/ + || $edit_this_template =~ m/$header_content_include_tag/ + ) { $header_content_tag_found_in_template = 1; } @@ -10309,19 +10316,19 @@ sub edit_template { $content_tag_found_in_url_template = 1; } - if ( $tmp_tmpl =~ m/$header_content_tag/ ) { + if ( + $tmp_tmpl =~ m/$header_content_tag/ + || $tmp_tmpl =~ m/$header_content_include_tag/ + ) { $header_content_tag_found_in_url_template = 1; } } else { - $template_url_check = 0; - } } } - my $scrn = DADA::Template::Widgets::wrap_screen( { -screen => 'edit_template_screen.tmpl', @@ -10350,6 +10357,7 @@ sub edit_template { $content_tag_found_in_url_template, content_tag_found_in_default_template => $content_tag_found_in_default_template, + header_content_tag_found_in_default_template => $header_content_tag_found_in_default_template, header_content_tag_found_in_template => $header_content_tag_found_in_template, header_content_tag_found_in_url_template => $header_content_tag_found_in_url_template, @@ -16451,14 +16459,13 @@ sub transform_to_pro { open my $config, '>>', $config_file or die $!; print $config $config_chunk or die $!; close $config or die; - } - catch { + } catch { $status = 0; $error = $_; warn $_; }; + if ( $status == 1 ) { - $c->flush; $self->header_type('redirect'); $self->header_props( -url => $DADA::Config::S_PROGRAM_URL diff --git a/app/dada/DADA/Config.pm b/app/dada/DADA/Config.pm index 1064e6cfd..6dc3193cd 100644 --- a/app/dada/DADA/Config.pm +++ b/app/dada/DADA/Config.pm @@ -554,6 +554,7 @@ $DEBUG_TRACE //= { DADA_App_HTMLtoMIMEMessage => 0, DADA_App_Subscriptions => 0, DADA_App_WebServices => 0, + DADA_Template_HTML => 0, DADA_Logging_Clickthrough => 0, DADA_Mail_MailOut => 0, DADA_Mail_Send => 0, diff --git a/app/dada/DADA/Template/HTML.pm b/app/dada/DADA/Template/HTML.pm index 5b9df0a05..2a75abba3 100644 --- a/app/dada/DADA/Template/HTML.pm +++ b/app/dada/DADA/Template/HTML.pm @@ -1,6 +1,11 @@ package DADA::Template::HTML; -use lib qw(../../../ ../../../DADA/perllib); +use lib "../../"; +use lib "../../DADA/perllib"; +use lib "../../DADA/App/Support"; +use lib './'; +use lib './DADA/perllib'; +use lib './DADA/App/Support'; use DADA::Config qw(!:DEFAULT); use DADA::App::Guts; @@ -8,6 +13,7 @@ use Try::Tiny; use Carp qw(croak carp); +my $t = $DADA::Config::DEBUG_TRACE->{DADA_Template_HTML}; BEGIN { if($] > 5.008){ @@ -16,7 +22,6 @@ BEGIN { } } - my $q; lame_init(); @@ -414,6 +419,27 @@ sub default_template { warn 'Unknown user template type: "' . $DADA::Config::TEMPLATE_OPTIONS->{user}->{mode} . '"'; } } + + + # I'm guessing this is what gets hit, when there's no reasonable template to use: + # + my $content_tag = quotemeta(''); + # my $header_content_tag = quotemeta(''); + # my $header_content_include_tag = quotemeta(''); + + + unless($tmpl =~ m/$content_tag/){ + warn 'cannot find content_tag in template, using default'; + undef($tmpl); + } + #unless( + # $tmpl =~ m/$header_content_tag/ + # || $tmpl =~ m/$header_content_include_tag/ + #){ + # warn 'cannot find header_content_tag in template, using default'; + # undef($tmpl); + #} + if ( !defined($tmpl) ) { require DADA::Template::Widgets; $tmpl = DADA::Template::Widgets::_raw_screen( @@ -422,7 +448,47 @@ sub default_template { -encoding => 1, } ); + + # warn '$tmpl: ' . $tmpl; + + #Utter sanity check: + unless($tmpl =~ m/$content_tag/){ + warn 'cannot find content_tag in default template - using bare bones'; + undef($tmpl); + } + #unless( + # $tmpl =~ m/$header_content_tag/ + # || $tmpl =~ m/$header_content_include_tag/ + #){ + # warn 'cannot find header_content_tag in default template, using bare bones'; + # undef($tmpl); + #} + + if ( !defined($tmpl) ) { + + $tmpl = < + + + --> + + + + + + + +EOF +; + + } + + } + + + + return $tmpl; } @@ -738,26 +804,29 @@ sub open_template { sub list_template { require DADA::Template::Widgets; + # DEV: Weird. I know. if ( $DADA::Config::PROGRAM_URL eq 'https://www.changetoyoursite.com/cgi-bin/dada/mail.cgi' ) { $DADA::Config::PROGRAM_URL = $ENV{SCRIPT_URI} || $q->url(); } + my %args = ( -List => undef, -Part => undef, - -Use_Custom => 1, + -Use_Custom => 1, # Use Custom is set to, "0" for screens like, "admin" -Title => undef, #-HTML_Header => 1, -header_params => {}, # this is used only when you delete a list. - -data => undef, # used in previewing a template. + -data => undef, # (only?) used in previewing a template. -vars => {}, -prof_sess_obj => undef, @_, ); + my $list = undef; - if ( $args{ -List } ) { + if ( defined($args{ -List }) ) { $list = $args{ -List }; } @@ -767,58 +836,118 @@ sub list_template { $ls = DADA::MailingList::Settings->new( { -list => $list } ); } - my $list_template = undef; + my $list_template = undef; + + # are we using a custom or just the default template? my $using_default_template = 1; if ( defined( $args{ -data } ) ) { - $list_template = ${ $args{ -data } }; + + warn 'passing data' if $t; + + $list_template = ${ $args{ -data } }; + # No, because the template is being passed in, -data. $using_default_template = 0; } - elsif ($list) { - if ( $ls->param('get_template_data') eq "from_url" - && DADA::App::Guts::isa_url( $ls->param('url_template') ) == 1 ) - { - # this is pretty bad, as there's no feedback of if the URL returned any data that's useful: - $list_template = open_template_from_url( -URL => $ls->param('url_template'), ); + else { + if ($list) { + warn 'passed list' if $t; + + if ( + $ls->param('get_template_data') eq "from_url" + && DADA::App::Guts::isa_url( $ls->param('url_template') ) == 1 + ) { + + warn 'getting template drom url' if $t; + + # this is pretty bad, as there's no feedback of if the URL returned any data that's useful: + $list_template = open_template_from_url( -URL => $ls->param('url_template'), ); - # We can just go with, "is it defined, or not?" - if(!defined($list_template)){ - $using_default_template = 1; - } - else { - $using_default_template = 0; - } - } - elsif ( $ls->param('get_template_data') eq 'from_default_template' ) { - - $list_template = default_template(); - - } - elsif ( - -e make_safer( - $DADA::Config::TEMPLATES . '/' . $list . '.template' ) ) - { - - $list_template = DADA::Template::Widgets::_slurp( - make_safer( - $DADA::Config::TEMPLATES . '/' . $list . '.template' - ) - ); - $using_default_template = 0; - - } # meaning, there's no list template - # This also means that none of the above methods were successful: - - - - if($using_default_template == 1){ - $list_template = default_template(); - } - - } # meaning, no list was passed: - else { - $list_template = default_template({-Use_Custom => $args{-Use_Custom}}); - } + # We can just go with, "is it defined, or not?" + if(!defined($list_template)){ + # yes, because the URL returned nothing of interest + $using_default_template = 1; + } + else { + # This could be a good place to make sure the template is valid (has the tags we need). + + # no, because the template we have is valid: + $using_default_template = 0; + } + } + elsif ( $ls->param('get_template_data') eq 'from_default_template' ) { + + warn 'from_default_template' if $t; + + $using_default_template = 1; + } + elsif($ls->param('get_template_data') eq 'from_template_file'){ + + warn 'from_template_file' if $t; + + if( + -e make_safer($DADA::Config::TEMPLATES . '/' . $list . '.template' ) + ){ + + warn 'custom template file exists, so we\'ll usd that' if $t; + + # no custom template, so we're not going to use nothing, right? + $using_default_template = 0; + + $list_template = DADA::Template::Widgets::_slurp( + make_safer( + $DADA::Config::TEMPLATES . '/' . $list . '.template' + ) + ); + + if(defined($list_template)){ + + warn 'defined($list_template)' if $t; + $using_default_template = 0; + } + else { + $using_default_template = 1; + } + + } + else { + warn '! defined($list_template)' if $t; + $using_default_template = 1; + } + } + + if($using_default_template == 1){ + warn '$using_default_template == 1' if $t; + $list_template = default_template(); + } + + if(! $list_template) { + warn '! $list_template' if $t; + $list_template = default_template(); + } + + } + else { + $list_template = default_template({-Use_Custom => $args{-Use_Custom}}); + } + } + + # let's check! + my $content_tag = quotemeta(''); + # my $header_content_tag = quotemeta(''); + # my $header_content_include_tag = quotemeta(''); + + unless($list_template =~ m/$content_tag/){ + warn 'cannot find content_tag in list template - using bare bones'; + $list_template = default_template(); + } + #unless( + # $list_template =~ m/$header_content_tag/ + # || $list_template =~ m/$header_content_include_tag/ + #){ + # warn 'cannot find header_content_tag in list template, using bare bones'; + # $list_template = default_template(); + #} my $prof_email = ''; my $is_logged_in = 0; @@ -826,7 +955,6 @@ sub list_template { my $prof_sess = undef; my $profile_widget = undef; - my $header_options = { include_jquery_lib => 1, include_app_user_js => 1, @@ -839,7 +967,7 @@ sub list_template { # warn q{$using_default_template} . $using_default_template; if( - $args{-Use_Custom} == 1 + $args{-Use_Custom} == 1 && $DADA::Config::TEMPLATE_OPTIONS->{user}->{enabled} == 1 && $DADA::Config::TEMPLATE_OPTIONS->{user}->{mode} eq 'magic' && $using_default_template == 1 @@ -876,14 +1004,8 @@ sub list_template { carp "CAUGHT Error with Sessioning: $_"; }; - my $content_tag = quotemeta(''); - if ( $list_template !~ m/$content_tag/ ) { - # warn 'can\'t find content tag in list template'; - } - - - + my $header_content = DADA::Template::Widgets::screen({ -screen => 'list_template_header_code_block.tmpl', -vars => { diff --git a/app/dada/installer-disabled/lib/DadaMailInstaller.pm b/app/dada/installer-disabled/lib/DadaMailInstaller.pm index 61d9827a0..f45b82bf6 100755 --- a/app/dada/installer-disabled/lib/DadaMailInstaller.pm +++ b/app/dada/installer-disabled/lib/DadaMailInstaller.pm @@ -239,6 +239,7 @@ my @Debug_Option_Names = qw( DADA_Profile DADA_Profile_Fields DADA_Profile_Session + DADA_Template_HTML DBI HTML_TEMPLATE NET_POP3 @@ -1516,7 +1517,7 @@ sub grab_former_config_vals { = $BootstrapConfig::RECAPTCHA_PARAMS->{v3}->{score_threshold}; } if ( defined( $BootstrapConfig::RECAPTCHA_PARAMS->{v3}->{hide_badge} ) ) { - $opt->{'g-recaptcha-response'} + $opt->{'captcha_params_v3_hide_badge'} = $BootstrapConfig::RECAPTCHA_PARAMS->{v3}->{hide_badge}; } } @@ -1967,7 +1968,7 @@ sub query_params_to_install_params { captcha_params_v3_public_key captcha_params_v3_private_key captcha_params_v3_score_threshold - g-recaptcha-response + captcha_params_v3_hide_badge configure_google_maps google_maps_api_key @@ -2891,12 +2892,12 @@ sub create_dada_config_file { } my $debugging_options_params = {}; - warn '`here.`'; + # warn '`here.`'; if ( $ip->{-configure_debugging} == 1 ) { - warn 'here.1'; + # warn 'here.1'; $debugging_options_params->{configure_debugging} = 1; for my $debug_option (@Debug_Option_Names) { - warn '$debug_option: ' . $debug_option; + # warn '$debug_option: ' . $debug_option; $debugging_options_params->{ 'debugging_options_' . $debug_option } = clean_up_var( $ip->{ '-debugging_options_' . $debug_option } ) || 0; } @@ -2984,7 +2985,7 @@ sub create_dada_config_file { $captcha_params->{captcha_params_v3_public_key} = clean_up_var( $ip->{-captcha_params_v3_public_key} ); $captcha_params->{captcha_params_v3_private_key} = clean_up_var( $ip->{-captcha_params_v3_private_key} ); $captcha_params->{captcha_params_v3_score_threshold} = clean_up_var( $ip->{-captcha_params_v3_score_threshold} ); - $captcha_params->{g-recaptcha-response} = clean_up_var( $ip->{-g-recaptcha-response} ); + $captcha_params->{captcha_params_v3_hide_badge} = clean_up_var( $ip->{-hide_bage} ); } diff --git a/app/dada/installer-disabled/templates/dada_config.tmpl b/app/dada/installer-disabled/templates/dada_config.tmpl index d59c11cc6..88891be37 100644 --- a/app/dada/installer-disabled/templates/dada_config.tmpl +++ b/app/dada/installer-disabled/templates/dada_config.tmpl @@ -199,6 +199,7 @@ $DEBUG_TRACE = { DADA_Profile => , DADA_Profile_Fields => , DADA_Profile_Session => , + DADA_Template_HTML => , }; %CPAN_DEBUG_SETTINGS = ( diff --git a/app/dada/installer-disabled/templates/installer_configure_dada_mail_scrn.tmpl b/app/dada/installer-disabled/templates/installer_configure_dada_mail_scrn.tmpl index 880dc8f61..eec15a527 100644 --- a/app/dada/installer-disabled/templates/installer_configure_dada_mail_scrn.tmpl +++ b/app/dada/installer-disabled/templates/installer_configure_dada_mail_scrn.tmpl @@ -1809,8 +1809,6 @@ DADA::App::WebServices - - + +