summaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <zegerjan@gitlab.com>2016-04-14 12:44:35 +0200
committerZeger-Jan van de Weg <zegerjan@gitlab.com>2016-04-28 21:28:39 +0200
commitad99404d2588e182a115d89b0b457d957e8ca7b6 (patch)
tree527619b709363e1515c41c0d8f861995389a58d4 /app/views
parent3fd0f5374447f0763c60d5b10b35d4a6f6981497 (diff)
downloadgitlab-ce-ad99404d2588e182a115d89b0b457d957e8ca7b6.tar.gz
Properly handle bigger files
Diffstat (limited to 'app/views')
-rw-r--r--app/views/projects/blob/_text.html.haml25
-rw-r--r--app/views/shared/_file_highlight.html.haml5
2 files changed, 20 insertions, 10 deletions
diff --git a/app/views/projects/blob/_text.html.haml b/app/views/projects/blob/_text.html.haml
index d09cd73558c..b1769759dce 100644
--- a/app/views/projects/blob/_text.html.haml
+++ b/app/views/projects/blob/_text.html.haml
@@ -1,10 +1,19 @@
-- blob.load_all_data!(@repository)
-- if markup?(blob.name)
- .file-content.wiki
- = render_markup(blob.name, blob.data)
+- if blob.only_display_raw?
+ .file-content.code
+ .nothing-here-block
+ File too large, you can
+ = succeed '.' do
+ = link_to 'view the raw file', namespace_project_raw_path(@project.namespace, @project, @id), target: '_blank'
+
- else
- - unless blob.empty?
- = render 'shared/file_highlight', blob: blob
+ - blob.load_all_data!(@repository)
+
+ - if markup?(blob.name)
+ .file-content.wiki
+ = render_markup(blob.name, blob.data)
- else
- .file-content.code
- .nothing-here-block Empty file
+ - if blob.empty?
+ .file-content.code
+ .nothing-here-block Empty file
+ - else
+ = render 'shared/file_highlight', blob: blob
diff --git a/app/views/shared/_file_highlight.html.haml b/app/views/shared/_file_highlight.html.haml
index 57856031d6e..37dcf39c062 100644
--- a/app/views/shared/_file_highlight.html.haml
+++ b/app/views/shared/_file_highlight.html.haml
@@ -1,12 +1,13 @@
.file-content.code.js-syntax-highlight
.line-numbers
- if blob.data.present?
+ - link_icon = icon('link')
- blob.data.each_line.each_with_index do |_, index|
- offset = defined?(first_line_number) ? first_line_number : 1
- i = index + offset
-# We're not using `link_to` because it is too slow once we get to thousands of lines.
%a.diff-line-num{href: "#L#{i}", id: "L#{i}", 'data-line-number' => i}
- %i.fa.fa-link
+ = link_icon
= i
.blob-content{data: {blob_id: blob.id}}
- = highlight(blob.name, blob.data)
+ = highlight(blob.name, blob.data, plain: blob.no_highlighting?)