3 |
3 |
use strict;
|
4 |
4 |
use parent qw(Rose::Object);
|
5 |
5 |
|
|
6 |
use SL::Version;
|
|
7 |
|
6 |
8 |
use File::Slurp qw(read_file);
|
7 |
9 |
use List::MoreUtils qw(uniq);
|
8 |
10 |
use Time::HiRes qw();
|
... | ... | |
47 |
49 |
return grep { $_ } ($_[0]->sub_layouts_by_name->{$_[1]});
|
48 |
50 |
}
|
49 |
51 |
|
50 |
|
sub init_auto_reload_resources_param {
|
51 |
|
if ($::lx_office_conf{debug}->{auto_reload_resources}) {
|
52 |
|
return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000));
|
53 |
|
}
|
|
52 |
sub _current_git_ref {
|
|
53 |
my $git_dir = SL::System::Process::exe_dir() . '/.git';
|
54 |
54 |
|
55 |
|
if ($::lx_office_conf{debug}{git_commit_reload_resources}) {
|
56 |
|
my $git_dir = SL::System::Process::exe_dir() . '/.git';
|
|
55 |
return unless -d $git_dir;
|
57 |
56 |
|
58 |
|
return '' unless -d $git_dir;
|
|
57 |
my $content = eval { scalar(read_file($git_dir . '/HEAD')) };
|
59 |
58 |
|
60 |
|
my $content = eval { scalar(read_file($git_dir . '/HEAD')) };
|
|
59 |
return unless ($content // '') =~ m{\Aref: ([^\r\n]+)};
|
61 |
60 |
|
62 |
|
return '' unless ($content // '') =~ m{\Aref: ([^\r\n]+)};
|
|
61 |
$content = eval { scalar(read_file($git_dir . '/' . $1)) };
|
63 |
62 |
|
64 |
|
$content = eval { scalar(read_file($git_dir . '/' . $1)) };
|
|
63 |
return unless ($content // '') =~ m{\A([0-9a-fA-F]+)};
|
65 |
64 |
|
66 |
|
return '' unless ($content // '') =~ m{\A([0-9a-fA-F]+)};
|
|
65 |
return $1;
|
|
66 |
}
|
67 |
67 |
|
68 |
|
return '?rand=' . $1;
|
69 |
|
}
|
|
68 |
sub init_auto_reload_resources_param {
|
|
69 |
my $value;
|
|
70 |
|
|
71 |
$value = sprintf('%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000)) if $::lx_office_conf{debug}->{auto_reload_resources};
|
|
72 |
$value ||= _current_git_ref();
|
|
73 |
$value ||= SL::Version->get_version;
|
70 |
74 |
|
71 |
|
return '';
|
|
75 |
return $value ? "?rand=${value}" : '';
|
72 |
76 |
}
|
73 |
77 |
|
74 |
78 |
##########################################
|
CSS/JS-Caching: immer neuladen durch Verwendung von Git-Revision oder kivitendo-Version
Ist [debug] → »auto_reload_resources« gesetzt, so wird weiterhin in
jedem Request neu geladen (für Entwicklerinstallationen).
Ist der Parameter aber nicht gesetzt, so wird nun immer versucht, die
aktuelle git-Revision in Erfahrung zu bringen (den Parameter
»git_reload_resources« gibt es nicht mehr).
Schlägt dies fehl, wird die kivitendo-Version genommen.