<% # API my $api = gitprep_api; # Git my $git = $self->app->git; # Parameters my $user = param('user'); my $project = param('project'); my $rev_file = param('rev_file'); my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file); # Commit my $commit = $git->last_change_commit(app->rep_info($user, $project), $rev, $file); my $commit_author_email = $commit->{author_email}; my $commit_author_id = app->dbi->model('user')->select( 'id', where => {email => $commit_author_email} )->value; # Authors my $authors = $git->authors(app->rep_info($user, $project), $rev, $file); # File size my $file_size = $git->blob_size(app->rep_info($user, $project), $rev, $file); # File mode my $mode = $git->blob_mode(app->rep_info($user, $project), $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); # Blob lines(only text) my $lines; $lines = $git->blob(app->rep_info($user, $project), $rev, $file) if $mime_type =~ /^text/; # Variables for included template stash(id => $rev, project => $project, rev => $rev); %> <% layout 'common' , title => "$project/$file at $rev \x{30fb} $user/$project", stylesheets => ['/js/google-code-prettify/prettify.css']; %> % %= include '/include/header';
%= include '/include/branch_select', display => 'blob', Path => $file;
% if (defined $commit_author_id) { "><%= $commit_author_id %> % } else { <%= $commit->{author_name} %> % } "> <%= $commit->{title} %>
<%= @$authors %> contributor
% if ($lines) { <%= @$lines %> lines | % } <%= $file_size %>kb
% if ($mime_type =~ m#^image/#) {
" title="<%= $file %>" % } src="<%= url_for("/$user/$project/raw/$rev/$file") %>" />
% } elsif ($mime_type =~ m#^text/#) { % if ($file =~ /\.md$/) { <% my $readme = join "\n", @$lines; $readme =~ s#^(\[.*\]:)(?!\s*https?://)\s*(\S*)#{"$1 " . url_for("/$user/$project/raw/$rev/$2")}#mge; $readme =~ s#^(!\[.*\]\()(?!https?://)(\S*)#{$1 . url_for("/$user/$project/raw/$rev/$2")}#mge; my $readme_e = $api->markdown($readme); %>
<%== $readme_e %>
% } else {
<% for my $line (@$lines) { %><%= "$line\n" %><% } %>
% } % } else {
">View raw
% }
%= javascript '/js/google-code-prettify/prettify.js'; %= javascript begin // Google prety print prettyPrint(); % end %= include '/include/footer';