X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9836938f40f4738dd4e1fabd585e24be5b2bffba..f217d072d76183bc07723dcc29503b732bd2022d:/SL/Layout/Base.pm
diff --git a/SL/Layout/Base.pm b/SL/Layout/Base.pm
index a1df9ebef..a9f08356a 100644
--- a/SL/Layout/Base.pm
+++ b/SL/Layout/Base.pm
@@ -3,6 +3,8 @@ package SL::Layout::Base;
use strict;
use parent qw(Rose::Object);
+use SL::Version;
+
use File::Slurp qw(read_file);
use List::MoreUtils qw(uniq);
use Time::HiRes qw();
@@ -38,33 +40,50 @@ sub init_sublayouts_by_name {
{}
}
+sub webpages_path {
+ "templates/webpages";
+}
+
+sub webpages_fallback_path {
+}
+
+sub html_dialect {
+ 'transitional'
+}
+
+sub allow_stylesheet_fallback {
+ 1
+}
+
sub get {
$_[0]->sub_layouts;
return grep { $_ } ($_[0]->sub_layouts_by_name->{$_[1]});
}
-sub init_auto_reload_resources_param {
- if ($::lx_office_conf{debug}->{auto_reload_resources}) {
- return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000));
- }
+sub _current_git_ref {
+ my $git_dir = SL::System::Process::exe_dir() . '/.git';
- if ($::lx_office_conf{debug}{git_commit_reload_resources}) {
- my $git_dir = SL::System::Process::exe_dir() . '/.git';
+ return unless -d $git_dir;
- return '' unless -d $git_dir;
+ my $content = eval { scalar(read_file($git_dir . '/HEAD')) };
- my $content = eval { scalar(read_file($git_dir . '/HEAD')) };
+ return unless ($content // '') =~ m{\Aref: ([^\r\n]+)};
- return '' unless ($content // '') =~ m{\Aref: ([^\r\n]+)};
+ $content = eval { scalar(read_file($git_dir . '/' . $1)) };
- $content = eval { scalar(read_file($git_dir . '/' . $1)) };
+ return unless ($content // '') =~ m{\A([0-9a-fA-F]+)};
- return '' unless ($content // '') =~ m{\A([0-9a-fA-F]+)};
+ return $1;
+}
- return '?rand=' . $1;
- }
+sub init_auto_reload_resources_param {
+ my $value;
+
+ $value = sprintf('%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000)) if $::lx_office_conf{debug}->{auto_reload_resources};
+ $value ||= _current_git_ref();
+ $value ||= SL::Version->get_version;
- return '';
+ return $value ? "?rand=${value}" : '';
}
##########################################
@@ -131,7 +150,7 @@ sub _find_stylesheet {
my ($self, $stylesheet, $css_path) = @_;
return "$css_path/$stylesheet" if -f "$css_path/$stylesheet";
- return "css/$stylesheet" if -f "css/$stylesheet";
+ return "css/$stylesheet" if -f "css/$stylesheet" && $self->allow_stylesheet_fallback;
return $stylesheet if -f $stylesheet;
return $stylesheet if $stylesheet =~ /^http/; # external
}
@@ -322,6 +341,58 @@ stylesheets. Javascripts are resolved relative to the C basedir.
Setting directly with C and C is eprecated.
+=head1 BEHAVIOUR SWITCHES FOR SUB LAYOUTS
+
+Certain methods have been added to adjust behaviour in sub layouts. Most of these are single case uses.
+
+=over 4
+
+=item * sublayouts_by_name
+
+Contains a map that holds named sublayouts. If a sublayout needs to targeted
+directly, the compositing layout needs to add it here. Initially introduced for
+the ActionPlan.
+
+=item * webpages_path
+
+Overrides the default webpages path "templates/webpages". Used for mobile and design40 styles.
+
+Note that this does not have fallback behaviour by default. It is intended for
+stylesheets where the templates are so incompatible that a complete fork of the
+templates dir is sensible.
+
+=item * webpages_fallback_path
+
+Allows partial template sets to fallback to other paths in case a template
+wasn't found. Intended to be used in conjunction with L.
+
+Note: in case a template can't be found at all, generic/error.html will be
+rendered, and the fallback doesn't work in this case.
+
+
+=item * allow_stylesheet_fallback
+
+Defaults to true. The default behaviour is that stylesheets not found in the
+stylesheet path of the user will fallback to files found in css/. This is
+usually desirable for shared stuff like common.css, which contains behaviour
+styling. If a stylesheet comes from a separate generator, this can be used to
+turn falllback off. Files can still be included with the complete path though.
+A request for "common.css" would not find "css/common.css", but a request for
+"css/common.css" would be found.
+
+Also see the next section L
+
+=item * html_dialect
+
+Default 'transitional'. Controls the html dialect that the header will
+generate. Used in combination with template overriding for html5.
+
+See also L
+
+=back
+
+
+
=head1 GORY DETAILS ABOUT JAVASCRIPT AND STYLESHEET OVERLOADING
The original code used to store one stylesheet in C<< $form->{stylesheet} >> and