gitprep / templates / submodule.html.ep /
7233306 10 years ago
1 contributor
71 lines | 1.851kb
<%
  use File::Basename ();
  
  # 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($user, $project, $rev_file);
  my $file_base = File::Basename::basename $file;

  # Blob lines
  my $lines = $git->blob($user, $project, $rev, '.gitmodules');

  my $submodule_rep_url;
  my $match;
  my $file_q = quotemeta $file;
  for my $line (@$lines) {
    $line =~ s/\r//;
    $line =~ s/\n//;
    
    if ($match) {
      if ($line =~ /url += +(.+)/) {
        $submodule_rep_url = $1;
        last;
      }
    }
    elsif ($line =~ /path += +$file_q( +|$)/) {
      $match = 1;
    };
  }

  # 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';

  <div class="container">
    %= include '/include/project_header';
    %= include '/include/code_menu', display => 'files';
    %= include '/include/page_path', type => 'blob', Path => $file;
        
    <div class="border-gray bk-gray-light" style="padding:5px; border-bottom:none">
      <div class="row">
        <div class="span7" style="padding-top:5px">
          <%= $file_base %> (Sub Module)
        </div>
      </div>
    </div>
    <div class="border-gray" style="font-size:16px;padding:15px;margin-bottom:30px">
      % if ($submodule_rep_url) {
        % if ($submodule_rep_url =~ /^http/) {
          <a href="<%= $submodule_rep_url %>"><%= $submodule_rep_url %></a>
        % } else {
          <%= $submodule_rep_url %>
        % }
      % }
    </div>
  </div>
  
  %= include '/include/footer';