Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gpt
large_projects
gitlabhq1
Commits
49adde69
Commit
49adde69
authored
7 years ago
by
Robert Speicher
Browse files
Options
Download
Email Patches
Plain Diff
Add a CSV blob view handler
parent
5b880f0d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
app/models/blob.rb
app/models/blob.rb
+1
-0
app/models/blob_viewer/csv.rb
app/models/blob_viewer/csv.rb
+21
-0
app/views/projects/blob/viewers/_csv.html.haml
app/views/projects/blob/viewers/_csv.html.haml
+8
-0
No files found.
app/models/blob.rb
View file @
49adde69
...
...
@@ -20,6 +20,7 @@ class Blob < SimpleDelegator
# type. LFS pointers to `.stl` files are assumed to always be the binary kind,
# and use the `BinarySTL` viewer.
RICH_VIEWERS
=
[
BlobViewer
::
CSV
,
BlobViewer
::
Markup
,
BlobViewer
::
Notebook
,
BlobViewer
::
SVG
,
...
...
This diff is collapsed.
Click to expand it.
app/models/blob_viewer/csv.rb
0 → 100644
View file @
49adde69
require
'csv'
module
BlobViewer
class
CSV
<
Base
include
ServerSide
self
.
binary
=
false
self
.
extensions
=
%w(csv)
self
.
partial_name
=
'csv'
self
.
switcher_icon
=
'file-excel-o'
self
.
type
=
:rich
def
parse
(
&
block
)
begin
::
CSV
.
parse
(
blob
.
data
).
each_with_index
(
&
block
)
rescue
::
CSV
::
MalformedCSVError
=>
ex
# TODO (rspeicher): How do we want to handle this?
end
end
end
end
This diff is collapsed.
Click to expand it.
app/views/projects/blob/viewers/_csv.html.haml
0 → 100644
View file @
49adde69
%table
.table-striped.table-bordered
-
viewer
.
parse
do
|
row
,
index
|
%tr
-
row
.
each
do
|
column
|
-
if
index
==
0
%th
=
column
-
else
%td
=
column
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment