summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2ae8da2)
raw | patch | inline | side by side (parent: 2ae8da2)
author | Jakub Narebski <jnareb@gmail.com> | |
Thu, 28 Apr 2011 19:04:11 +0000 (21:04 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 24 May 2011 18:22:45 +0000 (11:22 -0700) |
Configure JavaScript-based ability to select common timezone for git
dates via %feature mechanism, namely 'javascript-timezone' feature.
The following settings are configurable:
* default timezone (defaults to 'local' i.e. browser timezone);
this also can function as a way to disable this ability,
by setting it to false-ish value (undef or '')
* name of cookie to store user's choice of timezone
* class name to mark dates
NOTE: This is a bit of abuse of %feature system, which can store only
sequence of values, rather than dictionary (hash); usually but not
always only a single value is used.
Based-on-code-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Helped-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dates via %feature mechanism, namely 'javascript-timezone' feature.
The following settings are configurable:
* default timezone (defaults to 'local' i.e. browser timezone);
this also can function as a way to disable this ability,
by setting it to false-ish value (undef or '')
* name of cookie to store user's choice of timezone
* class name to mark dates
NOTE: This is a bit of abuse of %feature system, which can store only
sequence of values, rather than dictionary (hash); usually but not
always only a single value is used.
Based-on-code-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net>
Helped-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl | patch | blob | history |
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b1e80ef87bb18912479180e8d4f596e052f5bf1a..ac335b6deada78d8096e028db27a1bfc6bcebe3b 100755 (executable)
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
'override' => 0,
'default' => [0]},
+ # Enable and configure ability to change common timezone for dates
+ # in gitweb output via JavaScript. Enabled by default.
+ # Project specific override is not supported.
+ 'javascript-timezone' => {
+ 'override' => 0,
+ 'default' => [
+ 'local', # default timezone: 'utc', 'local', or '(-|+)HHMM' format,
+ # or undef to turn off this feature
+ 'gitweb_tz', # name of cookie where to store selected timezone
+ 'datetime', # CSS class used to mark up dates for manipulation
+ ]},
+
# Syntax highlighting support. This is based on Daniel Svensson's
# and Sham Chukoury's work in gitweb-xmms2.git.
# It requires the 'highlight' program present in $PATH,
qq! "!. href() .qq!");\n!.
qq!</script>\n!;
} else {
+ my ($jstimezone, $tz_cookie, $datetime_class) =
+ gitweb_get_feature('javascript-timezone');
+
print qq!<script type="text/javascript">\n!.
- qq!window.onload = function () {\n!.
- (gitweb_check_feature('javascript-actions') ?
- qq! fixLinks();\n! : '').
- # last parameter to onloadTZSetup must be CSS class used by format_timestamp_html
- qq! var tz_cookie = { name: 'gitweb_tz', expires: 14, path: '/' };\n!. # in days
- qq! onloadTZSetup('local', tz_cookie, 'datetime');\n!.
- qq!};\n!.
+ qq!window.onload = function () {\n!;
+ if (gitweb_check_feature('javascript-actions')) {
+ print qq! fixLinks();\n!;
+ }
+ if ($jstimezone && $tz_cookie && $datetime_class) {
+ print qq! var tz_cookie = { name: '$tz_cookie', expires: 14, path: '/' };\n!. # in days
+ qq! onloadTZSetup('$jstimezone', tz_cookie, '$datetime_class');\n!;
+ }
+ print qq!};\n!.
qq!</script>\n!;
}
sub format_timestamp_html {
my $date = shift;
- my $strtime = '<span class="datetime">'.$date->{'rfc2822'}.'</span>';
+ my $strtime = $date->{'rfc2822'};
+
+ my (undef, undef, $datetime_class) =
+ gitweb_get_feature('javascript-timezone');
+ if ($datetime_class) {
+ $strtime = qq!<span class="$datetime_class">$strtime</span>!;
+ }
my $localtime_format = '(%02d:%02d %s)';
if ($date->{'hour_local'} < 6) {