Skip to content

Commit

Permalink
support page history
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki-kimoto committed May 23, 2017
1 parent d25899c commit 9c8039d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 44 deletions.
71 changes: 42 additions & 29 deletions public/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,35 @@
color:#767676
*/

.btn, .btn:visited {
display: inline-block;
padding: 4px 12px 3px 12px;
font-size: 11px;
color:#395582;
text-align: center;
cursor: pointer;
border: 1px solid #cccccc;
border-radius: 4px;
background: -moz-linear-gradient(top,#FFF 0%,#EEE);
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), to(#EEE));
height:26px;
}

.btn:hover,
.btn:focus,
.btn:active,
.btn.active,
.btn.disabled,
.btn[disabled] {
background:#eff2f4;
text-decoration:none;
}

.btn.disabled,
.btn[disabled] {
cursor: default;
}

body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
Expand Down Expand Up @@ -61,6 +90,19 @@ a:hover {
box-sizing: border-box;
}

a.wiki-btn-history {
display:block;
font-size:14px;
padding:5px 8px;
height:28px;
background:#fff;
border:1px solid white;
width:100%;
}
a.wiki-btn-history:hover {
background:white;
}

.wiki-count {
margin:0;
border: 1px solid #ddd;
Expand Down Expand Up @@ -2180,35 +2222,6 @@ button.close {
-webkit-appearance: none;
}

.btn, .btn:visited {
display: inline-block;
padding: 4px 12px 3px 12px;
font-size: 11px;
color:#395582;
text-align: center;
cursor: pointer;
border: 1px solid #cccccc;
border-radius: 4px;
background: -moz-linear-gradient(top,#FFF 0%,#EEE);
background: -webkit-gradient(linear, left top, left bottom, from(#FFF), to(#EEE));
height:26px;
}

.btn:hover,
.btn:focus,
.btn:active,
.btn.active,
.btn.disabled,
.btn[disabled] {
background:#eff2f4;
text-decoration:none;
}

.btn.disabled,
.btn[disabled] {
cursor: default;
}

.btn-fork, .btn-new, .btn-delete {
font-size:13px;
padding:5px 20px;
Expand Down
38 changes: 23 additions & 15 deletions templates/blame.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,37 @@
my $git = $self->app->git;

# Parameters
my $user = param('user');
my $project = param('project');
my $user_id = param('user');
my $project_id = param('project');
my $rev_file = param('rev_file');
my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file);

my $is_wiki = (stash('tab') // '') eq 'wiki';
my $user_project_path = "/$user_id/$project_id";
if ($is_wiki) {
$user_project_path .= '/wiki';
}
my $rep_info = $is_wiki ? app->wiki_rep_info($user_id, $project_id) : app->rep_info($user_id, $project_id);

my ($rev, $file) = $git->parse_rev_path($rep_info, $rev_file);

# Commit
my $commit = $git->last_change_commit(app->rep_info($user, $project), $rev, $file);
my $commit = $git->last_change_commit($rep_info, $rev, $file);

# Authors
my $authors = $git->authors(app->rep_info($user, $project), $rev, $file);
my $authors = $git->authors($rep_info, $rev, $file);

# File size
my $file_size = $git->blob_size(app->rep_info($user, $project), $rev, $file);
my $file_size = $git->blob_size($rep_info, $rev, $file);

# File mode
my $mode = $git->blob_mode(app->rep_info($user, $project), $rev, $file);
my $mode = $git->blob_mode($rep_info, $rev, $file);
my $file_type = $git->file_type_long($mode);

# MIME type
my $mime_type = $git->blob_mime_type(app->rep_info($user, $project), $rev, $file);
my $mime_type = $git->blob_mime_type($rep_info, $rev, $file);

# Blame
my $blame = $git->blame(app->rep_info($user, $project), $rev, $file);
my $blame = $git->blame($rep_info, $rev, $file);
my $blame_lines = $blame->{lines};
my $blame_min_author_time = $blame->{min_author_time};
my $blame_max_author_time = $blame->{max_author_time};
Expand All @@ -48,10 +56,10 @@
];

# Variables for included template
stash(id => $rev, project => $project, rev => $rev);
stash(id => $rev, project => $project_id, rev => $rev);
%>

% layout 'common' , title => "$user/$project at $rev";
% layout 'common' , title => "$user_id/$project_id at $rev";

%= include '/include/header';

Expand All @@ -77,13 +85,13 @@
<div class="file-header-right">
<ul>
<li>
<a class="btn btn-small" href="<%= url_for("/$user/$project/raw/$rev/$file") %>">Raw</a>
<a class="btn btn-small" href="<%= url_for("$user_project_path/raw/$rev/$file") %>">Raw</a>
</li>
<li>
<a class="btn btn-small" href="<%= url_for("/$user/$project/blob/$rev/$file") %>">Normal View</a>
<a class="btn btn-small" href="<%= url_for("$user_project_path/blob/$rev/$file") %>">Normal View</a>
</li>
<li>
<a class="btn btn-small" href="<%= url_for("/$user/$project/commits/$rev/$file") %>">History</a>
<a class="btn btn-small" href="<%= url_for("$user_project_path/commits/$rev/$file") %>">History</a>
</li>
</ul>
</div>
Expand Down Expand Up @@ -112,7 +120,7 @@
<%= $summary_short %>
</div>
<div class="blame-commit-id">
<a href="<%= url_for("/$user/$project/commit/$blame_commit") %>" ><%= substr($blame_commit, 0, 7) %></a>
<a href="<%= url_for("$user_project_path/commit/$blame_commit") %>" ><%= substr($blame_commit, 0, 7) %></a>
</div>
</div>
<div class="blame-author">
Expand Down
5 changes: 5 additions & 0 deletions templates/wiki.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@
<div class="wiki-top-buttons-box">
<ul class="wiki-top-buttons">
% if ($display eq 'page') {
<li>
<a class="wiki-btn-history" href="<%= url_for("/$user_id/$project_id/wiki/commits/master/$title.md") %>" >
History
</a>
</li>
<li>
<a href="<%= url_for("/$user_id/$project_id/wiki/$title/_edit") %>">
<button class="btn btn-new">Edit</button>
Expand Down

0 comments on commit 9c8039d

Please sign in to comment.