... | ... |
@@ -1,3 +1,7 @@ |
1 |
+1.9 |
|
2 |
+ - add ssh_rep_url_base to cnahge or hide ssh URL user directory |
|
3 |
+ - add atom feed of commits page |
|
4 |
+ for example, http://somehost.com/kimoto/gitprep_t/commits/master.atom |
|
1 | 5 |
1.8 |
2 | 6 |
- support publick key authentication |
3 | 7 |
1.7 |
... | ... |
@@ -426,7 +426,7 @@ OK. GitPrep suport time zone. You can set time_zone option in conig file. |
426 | 426 |
|
427 | 427 |
### How to hide user home directory in ssh repository URL? |
428 | 428 |
|
429 |
-**1. Use symbolic link and ssh_rep_url_base option |
|
429 |
+**1. Use symbolic link and ssh_rep_url_base option** |
|
430 | 430 |
|
431 | 431 |
At first, set [basic]ssh_rep_url_base option to /git |
432 | 432 |
|
... | ... |
@@ -441,7 +441,7 @@ And you create symbolic link to /home/gitprep/gitprep/data/rep |
441 | 441 |
ln -s /home/gitprep/gitprep/data/rep /git |
442 | 442 |
chown gitprep:gitprep /git |
443 | 443 |
|
444 |
-**2. Use only public key authentication and set [basic]ssh_rep_url_base to empty |
|
444 |
+**2. Use only public key authentication and set [basic]ssh_rep_url_base to empty** |
|
445 | 445 |
|
446 | 446 |
If you use only public key authentication, you can access ssh repository |
447 | 447 |
using the following url. |
... | ... |
@@ -455,6 +455,12 @@ If you set [basic]ssh_rep_url_base to empty string, this URL is shown on Browser |
455 | 455 |
; ssh://kimoto@59.106.185.196/git/kimoto/gitprep.git |
456 | 456 |
ssh_rep_url_base= |
457 | 457 |
|
458 |
+### How to get atom feed of commits page |
|
459 |
+ |
|
460 |
+You can get atom feed of commits page by the following URL |
|
461 |
+ |
|
462 |
+ http://somehost.com/kimoto/gitprep/commits/master.atom |
|
463 |
+ |
|
458 | 464 |
## Web Site |
459 | 465 |
|
460 | 466 |
[GitPrep Web Site](http://perlcodesample.sakura.ne.jp/gitprep-site/) |
... | ... |
@@ -17,7 +17,7 @@ use Mojolicious::Plugin::AutoRoute::Util 'template'; |
17 | 17 |
eval {require Digest::SHA; import Digest::SHA qw(sha1 sha1_hex)}; |
18 | 18 |
} |
19 | 19 |
|
20 |
-our $VERSION = 'v1.7'; |
|
20 |
+our $VERSION = 'v1.9_dev'; |
|
21 | 21 |
|
22 | 22 |
has 'dbi'; |
23 | 23 |
has 'git'; |
... | ... |
@@ -1270,8 +1270,7 @@ sub parse_commit_text { |
1270 | 1270 |
|
1271 | 1271 |
# GMT |
1272 | 1272 |
{ |
1273 |
- my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) |
|
1274 |
- = gmtime($commit{committer_epoch}); |
|
1273 |
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($commit{committer_epoch}); |
|
1275 | 1274 |
$commit{age_string_date} = sprintf '%4d-%02d-%02d', 1900 + $year, $mon + 1, $mday; |
1276 | 1275 |
$commit{age_string_datetime} = sprintf '%4d-%02d-%02d %02d:%02d:%02d', |
1277 | 1276 |
1900 + $year, $mon + 1, $mday, $hour, $min, $sec; |
... | ... |
@@ -1280,19 +1279,14 @@ sub parse_commit_text { |
1280 | 1279 |
# Local Time |
1281 | 1280 |
{ |
1282 | 1281 |
my $time_zone_second = $self->time_zone_second || 0; |
1283 |
- my $time_zone_hour = int($time_zone_second / 60); |
|
1284 |
- my $time_zone_min = $time_zone_second % 60; |
|
1285 |
- my $time_zone = $time_zone_second >= 0 ? '+' : '-'; |
|
1286 |
- $time_zone .= sprintf("%02d:%02d", $time_zone_hour, $time_zone_min); |
|
1287 | 1282 |
|
1288 |
- my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) |
|
1289 |
- = gmtime($commit{committer_epoch} + $time_zone_second); |
|
1283 |
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($commit{committer_epoch} + $time_zone_second); |
|
1290 | 1284 |
$commit{age_string_date_local} |
1291 | 1285 |
= sprintf '%4d-%02d-%02d', 1900 + $year, $mon + 1, $mday; |
1292 |
- $commit{age_string_datetime_local} = sprintf "%4d-%02d-%02d %02d:%02d:%02d GMT$time_zone", |
|
1286 |
+ $commit{age_string_datetime_local} = sprintf '%4d-%02d-%02d %02d:%02d:%02d', |
|
1293 | 1287 |
1900 + $year, $mon + 1, $mday, $hour, $min, $sec; |
1294 | 1288 |
} |
1295 |
- |
|
1289 |
+ |
|
1296 | 1290 |
return \%commit; |
1297 | 1291 |
} |
1298 | 1292 |
|
... | ... |
@@ -10,7 +10,7 @@ |
10 | 10 |
my $project = param('project'); |
11 | 11 |
my $rev_file = param('rev_file'); |
12 | 12 |
|
13 |
- my $return_atom = $rev_file =~ s/\.atom$// ? 1 : 0; |
|
13 |
+ my $render_atom_feed = $rev_file =~ s/\.atom$// ? 1 : 0; |
|
14 | 14 |
|
15 | 15 |
my ($rev, $file) = $git->parse_rev_path($user, $project, $rev_file); |
16 | 16 |
my $page = param('page') || 0; |
... | ... |
@@ -46,27 +46,68 @@ |
46 | 46 |
stash(user => $user, project => $project, rev => $rev); |
47 | 47 |
|
48 | 48 |
# Render atom xml feed |
49 |
- if ($return_atom) { |
|
49 |
+ if ($render_atom_feed) { |
|
50 | 50 |
my $url = url_with->to_abs; |
51 | 51 |
|
52 |
- my $updated = $commits->[0]; |
|
53 |
- |
|
54 |
- warn dumper $commits->[0]; |
|
52 |
+ # Add updated date time |
|
53 |
+ for my $commit (@$commits) { |
|
54 |
+ my $committer_epoch = $commit->{committer_epoch}; |
|
55 |
+ my $committer_tz = $commit->{committer_tz}; |
|
56 |
+ |
|
57 |
+ my $time_zone_second; |
|
58 |
+ my $time_zone; |
|
59 |
+ if ($committer_tz =~ /^(\+|\-)([0-9]{2})([0-9]{2})$/) { |
|
60 |
+ my $time_zone_sign = $1; |
|
61 |
+ my $time_zone_hour = $2; |
|
62 |
+ my $time_zone_min = $3; |
|
63 |
+ $time_zone_second = $time_zone_sign . ($time_zone_hour * (60 * 60) + $time_zone_min * 60); |
|
64 |
+ $time_zone = sprintf("$time_zone_sign%02d:%02d", $time_zone_hour, $time_zone_min); |
|
65 |
+ } |
|
66 |
+ |
|
67 |
+ # updated datetime |
|
68 |
+ my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($committer_epoch + $time_zone_second); |
|
69 |
+ my $updated = sprintf('%4d-%02d-%02dT%02d:%02d:%02d', 1900 + $year, $mon + 1, $mday, $hour, $min, $sec); |
|
70 |
+ $updated .= $time_zone; |
|
71 |
+ |
|
72 |
+ $commit->{updated} = $updated; |
|
73 |
+ } |
|
55 | 74 |
|
56 | 75 |
my $xml = <<"EOS"; |
57 | 76 |
<?xml version="1.0" encoding="UTF-8"?> |
58 | 77 |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US"> |
59 | 78 |
<id>tag:gitprep,2008:/$user/$project/commits/$rev_file</id> |
79 |
+ <link type="text/html" rel="alternate" href="$url"/> |
|
60 | 80 |
<link type="application/atom+xml" rel="self" href="$url"/> |
61 | 81 |
<title>Recent Commits to $project:$rev</title> |
62 |
- <updated>2013-03-29T22:16:25+09:00</updated> |
|
82 |
+ <updated>$commits->[0]->{updated}</updated> |
|
83 |
+ |
|
63 | 84 |
EOS |
64 | 85 |
|
86 |
+ for my $commit (reverse @$commits) { |
|
87 |
+ my $author_uri = url_for->base->to_abs . "/$user"; |
|
88 |
+ $xml .= <<"EOS"; |
|
89 |
+ <entry> |
|
90 |
+ <id>tag:gitprep,2008:Grit::Commit/$commit->{id}</id> |
|
91 |
+ <link type="text/html" rel="alternate" href="https://github.com/kraih/mojo/commit/9efcd268fd08c8e0f2418278aec31c44906e1be3"/> |
|
92 |
+ <title> |
|
93 |
+ $commit->{title} |
|
94 |
+ </title> |
|
95 |
+ <updated>$commit->{updated}</updated> |
|
96 |
+ <author> |
|
97 |
+ <name>$commit->{author_name}</name> |
|
98 |
+ <uri>$author_uri</uri> |
|
99 |
+ </author> |
|
100 |
+ <content type="html"> |
|
101 |
+ <pre style='white-space:pre-wrap;width:81ex'>$commit->{title}</pre> |
|
102 |
+ </content> |
|
103 |
+ </entry> |
|
104 |
+EOS |
|
105 |
+ } |
|
106 |
+ |
|
65 | 107 |
$xml .= <<"EOS"; |
66 | 108 |
</feed> |
67 | 109 |
EOS |
68 | 110 |
|
69 |
- |
|
70 | 111 |
$self->res->headers->content_type('application/atom+xml'); |
71 | 112 |
$self->render(text => $xml); |
72 | 113 |
return; |
... | ... |
@@ -188,6 +188,14 @@ note 'Commits page'; |
188 | 188 |
$t->get_ok("/$user/$project/commits/refs/heads/master"); |
189 | 189 |
$t->content_like(qr#refs/heads/master#); |
190 | 190 |
} |
191 |
+ |
|
192 |
+ # Commits page - atom feed |
|
193 |
+ { |
|
194 |
+ # Page access(branch name long) |
|
195 |
+ $t->get_ok("/$user/$project/commits/master.atom"); |
|
196 |
+ $t->content_like(qr/\Q<?xml version="1.0" encoding="UTF-8"?>/); |
|
197 |
+ $t->content_like(qr/<entry>/); |
|
198 |
+ } |
|
191 | 199 |
} |
192 | 200 |
|
193 | 201 |
note 'History page'; |