From: John 'Warthog9' Hawley Date: Thu, 09 Dec 2010 21:57:21 GMT Subject: [PATCH 15/18] gitweb: Add show_warning() to display an immediate warning, with refresh Message-ID: <1291931844-28454-16-git-send-email-warthog9@eaglescrag.net> In-Reply-To: <1291931844-28454-1-git-send-email-warthog9@eaglescrag.net> die_error() is an immediate and abrupt action. show_warning() more or less functions identically, except that the page generated doesn't use the gitweb header or footer (in case they are broken) and has an auto-refresh (10 seconds) built into it. This makes use of print_transient_header() which is also used in the 'Generating...' page. Currently the only warning it throws is about the cache needing to be created. If that fails it's a fatal error and we call die_error() Signed-off-by: John 'Warthog9' Hawley --- gitweb/lib/cache.pl | 36 +++++++++++++++++++++++++++++++++--- 1 files changed, 33 insertions(+), 3 deletions(-) diff --git a/gitweb/lib/cache.pl b/gitweb/lib/cache.pl index 723ae9b..28e4240 100644 --- a/gitweb/lib/cache.pl +++ b/gitweb/lib/cache.pl @@ -25,9 +25,13 @@ sub cache_fetch { my $cacheTime = 0; if(! -d $cachedir){ - print "*** Warning ***: Caching enabled but cache directory does not exsist. ($cachedir)\n"; - mkdir ("cache", 0755) || die "Cannot create cache dir - you will need to manually create"; - print "Cache directory created successfully\n"; + mkdir ("cache", 0755) || die_error(500, "Internal Server Error", "Cannot create cache dir () - you will need to manually create"); + show_warning( + "

". + "*** Warning ***: Caching enabled but cache directory did not exsist. ($cachedir)
/\n". + "Cache directory created successfully\n". + "

" + ); } $full_url = "$my_url?". $ENV{'QUERY_STRING'}; @@ -119,6 +123,32 @@ sub print_transient_header { return; } +sub show_warning { + $| = 1; + + my $warning = esc_html(shift) || "Unknown Warning"; + + print_transient_header(); + + print < + + + + + + + +$title + + +$warning + + +EOF + exit(0); +} + sub isBinaryAction { my ($action) = @_; -- 1.7.2.3