From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: John 'Warthog9' Hawley <warthog9@eaglescrag.net>,
Kevin Cernekee <cernekee@gmail.com>,
Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH/RFC 11/11] gitweb: Make JavaScript ability to adjust timezones configurable
Date: Sun, 10 Apr 2011 00:49:26 +0200 [thread overview]
Message-ID: <1302389366-21515-12-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <1302389366-21515-1-git-send-email-jnareb@gmail.com>
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>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Original patch by J.H. had strictly speaking only $jslocaltime
(default timezone) configurable, though cookie name was stored in
global variable (set in gitweb/static/js/common-defs.js).
But do we really need full flexibility...?
gitweb/gitweb.perl | 37 ++++++++++++++++++++++++++++++-------
1 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 6651946..b80f2e0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -480,6 +480,18 @@ our %feature = (
'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,
@@ -3733,13 +3745,18 @@ sub git_footer_html {
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! onloadTZSetup('local', 'gitweb_tz', '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! onloadTZSetup('$jstimezone', '$tz_cookie', '$datetime_class');\n!;
+ }
+ print qq!};\n!.
qq!</script>\n!;
}
@@ -3945,7 +3962,13 @@ sub git_print_section {
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">$strtime</span>!;
+ }
my $localtime_format = '(%02d:%02d %s)';
if ($date->{'hour_local'} < 6) {
--
1.7.3
next prev parent reply other threads:[~2011-04-09 22:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-09 22:49 [PATCH 00/11] gitweb: Change timezone Jakub Narebski
2011-04-09 22:49 ` [PATCH 01/11] gitweb: Split JavaScript for maintability, combining on build Jakub Narebski
2011-04-09 22:49 ` [PATCH 02/11] gitweb.js: Update and improve comments in JavaScript files Jakub Narebski
2011-04-09 22:49 ` [PATCH/RFC 03/11] gitweb.js: Provide default values for padding in padLeftStr and padLeft Jakub Narebski
2011-04-09 22:49 ` [PATCH 04/11] gitweb.js: Extract and improve datetime handling Jakub Narebski
2011-04-09 22:49 ` [PATCH 05/11] gitweb.js: Introduce gitweb/static/js/lib/cookies.js Jakub Narebski
2011-04-09 22:49 ` [PATCH 06/11] gitweb.js: Provide getElementsByClassName method (if it not exists) Jakub Narebski
2011-04-09 22:49 ` [PATCH 07/11] gitweb: Refactor generating of long dates into format_timestamp_html Jakub Narebski
2011-04-09 22:49 ` [RFC/PATCH 08/11] gitweb: Unify the way long timestamp is displayed Jakub Narebski
2011-04-09 22:49 ` [PATCH 09/11] gitweb: JavaScript ability to adjust time based on timezone Jakub Narebski
2011-04-09 22:49 ` [PATCH/RFC 10/11] gitweb.js: Add UI for selecting common timezone to display dates Jakub Narebski
2011-04-10 9:36 ` Jakub Narebski
2011-04-10 14:39 ` Jakub Narebski
2011-04-10 15:10 ` Jakub Narebski
2011-04-09 22:49 ` Jakub Narebski [this message]
2011-04-12 1:19 ` [PATCH 00/11] gitweb: Change timezone Kevin Cernekee
2011-04-12 12:44 ` Jakub Narebski
2011-04-12 13:24 ` [PATCHv2 10/11] gitweb.js: Add UI for selecting common timezone to display dates Jakub Narebski
2011-04-12 13:25 ` [PATCHv2 11/11] gitweb: Make JavaScript ability to adjust timezones configurable Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1302389366-21515-12-git-send-email-jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=cernekee@gmail.com \
--cc=git@vger.kernel.org \
--cc=warthog9@eaglescrag.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).