From bae050e9f3e3aaeab94bbbbed96949edca155346 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 27 Feb 2013 09:38:29 +0100 Subject: [PATCH] Entwickleroption "debug.auto_reload_resources" implementiert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fügt einen zufälligen GET-Parameter an jeden JavaScript-/CSS-Link hinzu, der via $layout->use_javascript()/use_stylesheet() ausgegeben wird. Sorgt dafür, dass der Browser Resourcen jedes Mal neu lädt. Hilfreich, wenn man gerade CSS oder JavaScript bastelt und nicht dauernd F5 drücken möchte. --- SL/Form.pm | 6 ++++-- SL/Layout/Base.pm | 8 +++++++- config/kivitendo.conf.default | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index f406817f6..e7d142599 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -490,10 +490,12 @@ sub header { push @header, ""; } - push @header, map { qq|| } $layout->stylesheets; + my $auto_reload_resources_param = $layout->auto_reload_resources_param; + + push @header, map { qq|| } $layout->stylesheets; push @header, " " if $self->{landscape}; push @header, "" if -f $self->{favicon}; - push @header, map { qq|| } $layout->javascripts; + push @header, map { qq|| } $layout->javascripts; push @header, $self->{javascript} if $self->{javascript}; push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] }; diff --git a/SL/Layout/Base.pm b/SL/Layout/Base.pm index cd5ace939..de94ee054 100644 --- a/SL/Layout/Base.pm +++ b/SL/Layout/Base.pm @@ -4,9 +4,10 @@ use strict; use parent qw(SL::Controller::Base); use List::MoreUtils qw(uniq); +use Time::HiRes qw(); use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => qw(menu), + 'scalar --get_set_init' => [ qw(menu auto_reload_resources_param) ], 'scalar' => qw(focus), 'array' => [ 'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' }, @@ -30,6 +31,11 @@ sub init_menu { Menu->new('menu.ini'); } +sub init_auto_reload_resources_param { + return '' unless $::lx_office_conf{debug}->{auto_reload_resources}; + return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000)); +} + ########################################## # inheritable/overridable ########################################## diff --git a/config/kivitendo.conf.default b/config/kivitendo.conf.default index 2f4c88a6b..875cfe0c3 100644 --- a/config/kivitendo.conf.default +++ b/config/kivitendo.conf.default @@ -293,3 +293,9 @@ file_name = /tmp/kivitendo-debug.log # If set to 1 then the installation will be kept unlocked even if a # database upgrade fails. keep_installation_unlocked = 0 + +# If set to 1 then all resource links (JavaScript, CSS files) output +# via $::request->{layout}->use_stylesheet() / use_javascript() will +# be made unique by appending a random GET parameter. This will cause +# the web browser to always reload the resources. +auto_reload_resources = 0 -- 2.20.1