summaryrefslogtreecommitdiffstats
path: root/app/views/blobs/show.html.erb
blob: 1da6fcae4306e2e29d1b060861b56effbeeca52f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<%
#--
#   Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
#   Copyright (C) 2008 Johan Sørensen <johan@johansorensen.com>
#   Copyright (C) 2008 Tor Arne Vestbø <tavestbo@trolltech.com>
#   Copyright (C) 2009 Fabio Akita <fabio.akita@gmail.com>
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Affero General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#++
%>

<% @page_title = t("views.blobs.page_title", :path => current_path.join("/"), :repo => @repository.name, :title => @project.title) -%>
<%= breadcrumbs_from(@root) -%>

<% content_for :extra_head do -%>
  <% if highlightable?(@blob) -%>
    <%= stylesheet_link_tag("prettify/prettify.css") -%>
    <%= javascript_include_tag("prettify/prettify.js") -%>
    <% if hl = language_of_file(current_path.last) -%>
      <%= javascript_include_tag("prettify/lang-#{hl}.js", :cache => false) -%>
    <% end -%>
    <script type="text/javascript" charset="utf-8">
      $(document).ready(function(){
          if (parseInt($("#codeblob tr td.line-numbers:last").text()) < 3500) {
              prettyPrint();
          } else {
              $("#long-file").show().find("a#highlight-anyway").click(function(e){
                  prettyPrint();
                  e.preventDefault();
              });
          }
      });
    </script>
  <% end -%>
<% end -%>

<% if false -%>
<ul class="mode_selector">
  <li class="list_header">
    <%= t("views.blobs.wrap") %>:
  </li>
  <li>
    <%= link_to_function t("views.common.toggle"), "Gitorious.Wordwrapper.toggle($$('table#codeblob td.code'))" -%>
  </li>
</ul>
<% end -%>

<!-- mime: <%= @blob.mime_type -%> -->

<% if textual?(@blob) && !too_big_to_render?(@blob.size) -%>
  <% cache([:blob_render, @commit.id, @blob.id]) do -%>
     <% help_box(:center, :error, :style => "display:none", :id => "long-file") do -%>
        <p>
          This file looks large and may slow your browser down if we attempt
          to syntax highlight it, so we're showing it without any
          pretty colors.
          <a href="#highlight-anyway" id="highlight-anyway">Highlight
          it anyway</a>.
        </p>
     <% end -%>
    <%= render_highlighted(@blob.data, current_path.last || "") -%>
  <% end -%>
<% elsif textual?(@blob) && too_big_to_render?(@blob.size) -%>
  <p>
	<%= t("views.blobs.too_big").call(self, raw_blob_path(@commit.id, current_path)) %>
  </p>
<% elsif image?(@blob) -%>
  <% cache(blob_path(@commit.id, @blob.id)) do -%>
    <%= image_tag raw_blob_path(@commit.id, current_path) -%>
  <% end -%>
<% else -%>
  <p>
	<%= t("views.blobs.message").call(self, raw_blob_path(@commit.id, current_path)) %>
  </p>
<% end -%>

<%= render "menu" -%>