theodi/git-data-viewer

View on GitHub
app/views/repositories/show.html.erb

Summary

Maintainability
Test Coverage
<h1><%= @repo.data_title %></h1>

<div class='row-fluid'>  
  
  <div class='span9'>
    <p>
      <%= @repo.description %>
    </p>

    <dl class='dl-horizontal'>

      <% unless @repo.licenses.empty? %>
        <dt><%= 'License'.pluralize(@repo.licenses.length) %></dt>
        <dd>
          <% @repo.licenses.each do |l| %>
            <% if l.uri %>
              <%= link_to license_name(l), l.uri %>
            <% else %>
              <%= license_name(l) %>
            <% end %>
          <% end %>
        </dd>
      <% end %>

      <% unless @repo.publishers.empty? %>
        <dt><%= 'Publisher'.pluralize(@repo.publishers.length) %></dt>
        <dd>
          <% @repo.publishers.each do |agent| %>
            <%= agent_link(agent) %>
          <% end %>
        </dd>
      <% end %>

      <% unless @repo.maintainers.empty? %>
        <dt><%= 'Maintainer'.pluralize(@repo.maintainers.length) %></dt>
        <dd>
          <% @repo.maintainers.each do |agent| %>
            <%= agent_link(agent) %>
          <% end %>
        </dd>
      <% end %>
      
      <% unless @repo.contributors.empty? %>
        <dt><%= 'Contributor'.pluralize(@repo.contributors.length) %></dt>
        <dd>
          <% @repo.contributors.each do |agent| %>
            <%= agent_link(agent) %>
          <% end %>
        </dd>
      <% end %>

      <% if @repo.keywords %>
        <dt>Keywords</dt>
        <dd>
          <ul class='inline'>
            <% @repo.keywords.each do |keyword| %>
              <li><span class='label'><%= keyword%></span></li>
            <% end %>
          </ul>
        </dd>
      <% end %>
      
    </dl>
    
    <% unless @repo.sources.empty? %>
      <h4>Sources</h4>
      <ul>
        <% @repo.sources.each do |source| %>
          <li>
            <% if source.web %>
              <%= link_to source.name, source.web%>
            <% else %>
              <%= source.name %>
            <% end %>            
          </li>
        <% end %>
      </ul>
    <% end %>
    

    <% if @repo.distributions.count > 1 %>
      <h3><%= @repo.distributions.count %> resources</h3>
      <ul>
        <% @repo.distributions.each_with_index do |file, index| %>
          <li><a href='#distribution-<%= index %>'><%= file.title %></a></li>
        <% end %>
      </ul>
    <% end %>
    
    <% @repo.distributions.each_with_index do |file, index| %>
      <a name='distribution-<%= index %>'></a>
      <%= render partial: 'preview', locals: {file: file} %>
    <% end %>
    
  </div>

  <div class='span3'>
    <% if @repo.host == :github %>
      <div class='well'>
        <div class='actionbutton'>
          <a href='<%= @repo.github_path %>' class='btn btn-warning btn-block'>
            <i class='icon-code-fork'></i>
            Fork on GitHub
          </a>
        </div>
        <div class='actionbutton'>
          <a href='<%= @repo.github_path("archive/master.zip") %>' class='btn btn-primary btn-block'>
            <i class='icon-cloud-download'></i>
            Download Latest
          </a>
        </div>
        <div class='actionbutton'>
          <% feed = @repo.github_path("commits/master.atom") %>
          <%= auto_discovery_link_tag :rss, feed %>
          <a href='<%= feed %>' class='btn btn-primary btn-block'>
            <i class='icon-rss'></i>
            Subscribe to updates
          </a>
        </div>
      </div>
    <% end %>

    <% if @repo.host == :bitbucket %>
      <div class='well'>
        <div class='actionbutton'>
          <a href='<%= @repo.bitbucket_path %>' class='btn btn-warning btn-block'>
            <i class='icon-code-fork'></i>
            Fork on Bitbucket
          </a>
        </div>
        <div class='actionbutton'>
          <a href='<%= @repo.bitbucket_path("get/master.zip") %>' class='btn btn-primary btn-block'>
            <i class='icon-cloud-download'></i>
            Download Latest
          </a>
        </div>
        <div class='actionbutton'>
          <% feed = @repo.bitbucket_path("rss") %>
          <%= auto_discovery_link_tag :rss, feed %>
          <a href='<%= feed %>' class='btn btn-primary btn-block'>
            <i class='icon-rss'></i>
            Subscribe to updates
          </a>
        </div>
      </div>
    <% end %>

    <% if @repo.host == :gist %>
      <div class='well'>
        <div class='actionbutton'>
          <a href='<%= @repo.gist_path %>' class='btn btn-warning btn-block'>
            <i class='icon-code-fork'></i>
            Fork on Gist
          </a>
        </div>
        <div class='actionbutton'>
          <a href='<%= @repo.gist_path("download") %>' class='btn btn-primary btn-block'>
            <i class='icon-cloud-download'></i>
            Download Latest
          </a>
        </div>
      </div>
    <% end %>

    <% unless @repo.change_history.empty? %>
      <h3>Changes</h3>
      <ul class='unstyled' id='commits'>
        <% @repo.change_history.each do |commit| %>
          <li>
            <% if @repo.host == :github %>
              <%= link_to commit.message, @repo.github_path("commit/#{commit.sha}") %>
            <% elsif @repo.host == :bitbucket %>
              <%= link_to commit.message, @repo.bitbucket_path("commits/#{commit.sha}") %>
            <% elsif @repo.host == :gist %>
              <%= commit.sha.first(10) %>
            <% else %>
              <%= commit.message %>
            <% end %>
            <br/><small class='pull-right'><%= commit.committer.name %>, <%= commit.committer.date.to_s(:long) %></small>
          </li>
        <% end %>
      </ul>
    <% end %>

  </div>
  
</div>