Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
8ef7220c
Commit
8ef7220c
authored
Oct 04, 2014
by
Sullivan SENECHAL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve file icons rendering on tree
parent
db948ff3
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
171 additions
and
8 deletions
+171
-8
CHANGELOG
CHANGELOG
+1
-0
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+8
-0
app/helpers/icons_helper.rb
app/helpers/icons_helper.rb
+44
-0
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+5
-4
app/views/projects/blob/_blob.html.haml
app/views/projects/blob/_blob.html.haml
+1
-1
app/views/projects/tree/_blob_item.html.haml
app/views/projects/tree/_blob_item.html.haml
+1
-1
app/views/projects/tree/_submodule_item.html.haml
app/views/projects/tree/_submodule_item.html.haml
+1
-1
app/views/projects/tree/_tree_item.html.haml
app/views/projects/tree/_tree_item.html.haml
+1
-1
spec/helpers/icons_helper_spec.rb
spec/helpers/icons_helper_spec.rb
+109
-0
No files found.
CHANGELOG
View file @
8ef7220c
...
@@ -47,6 +47,7 @@ v 7.10.0 (unreleased)
...
@@ -47,6 +47,7 @@ v 7.10.0 (unreleased)
- AJAX selectbox for issue assignee and author filters
- AJAX selectbox for issue assignee and author filters
- Fix issue with missing options in issue filtering dropdown if selected one
- Fix issue with missing options in issue filtering dropdown if selected one
- Prevent holding Control-Enter or Command-Enter from posting comment multiple times.
- Prevent holding Control-Enter or Command-Enter from posting comment multiple times.
- Improve file icons rendering on tree (Sullivan Sénéchal)
v 7.9.0
v 7.9.0
- Send EmailsOnPush email when branch or tag is created or deleted.
- Send EmailsOnPush email when branch or tag is created or deleted.
...
...
app/helpers/blob_helper.rb
View file @
8ef7220c
...
@@ -61,4 +61,12 @@ module BlobHelper
...
@@ -61,4 +61,12 @@ module BlobHelper
'Preview changes'
'Preview changes'
end
end
end
end
# Return an image icon depending on the file mode and extension
#
# mode - File unix mode
# mode - File name
def
blob_icon
(
mode
,
name
)
icon
(
"
#{
file_type_icon_class
(
'file'
,
mode
,
name
)
}
fw"
)
end
end
end
app/helpers/icons_helper.rb
View file @
8ef7220c
...
@@ -36,4 +36,48 @@ module IconsHelper
...
@@ -36,4 +36,48 @@ module IconsHelper
def
private_icon
def
private_icon
icon
(
'lock'
)
icon
(
'lock'
)
end
end
def
file_type_icon_class
(
type
,
mode
,
name
)
if
type
==
'folder'
icon_class
=
'folder'
elsif
mode
==
0120000
icon_class
=
'share'
else
# Guess which icon to choose based on file extension.
# If you think a file extension is missing, feel free to add it on PR
case
File
.
extname
(
name
).
downcase
when
'.pdf'
icon_class
=
'file-pdf-o'
when
'.jpg'
,
'.jpeg'
,
'.jif'
,
'.jfif'
,
'.jp2'
,
'.jpx'
,
'.j2k'
,
'.j2c'
,
'.png'
,
'.gif'
,
'.tif'
,
'.tiff'
,
'.svg'
,
'.ico'
,
'.bmp'
icon_class
=
'file-image-o'
when
'.zip'
,
'.zipx'
,
'.tar'
,
'.gz'
,
'.bz'
,
'.bzip'
,
'.xz'
,
'.rar'
,
'.7z'
icon_class
=
'file-archive-o'
when
'.mp3'
,
'.wma'
,
'.ogg'
,
'.oga'
,
'.wav'
,
'.flac'
,
'.aac'
icon_class
=
'file-audio-o'
when
'.mp4'
,
'.m4p'
,
'.m4v'
,
'.mpg'
,
'.mp2'
,
'.mpeg'
,
'.mpe'
,
'.mpv'
,
'.mpg'
,
'.mpeg'
,
'.m2v'
,
'.avi'
,
'.mkv'
,
'.flv'
,
'.ogv'
,
'.mov'
,
'.3gp'
,
'.3g2'
icon_class
=
'file-video-o'
when
'.doc'
,
'.dot'
,
'.docx'
,
'.docm'
,
'.dotx'
,
'.dotm'
,
'.docb'
icon_class
=
'file-word-o'
when
'.xls'
,
'.xlt'
,
'.xlm'
,
'.xlsx'
,
'.xlsm'
,
'.xltx'
,
'.xltm'
,
'.xlsb'
,
'.xla'
,
'.xlam'
,
'.xll'
,
'.xlw'
icon_class
=
'file-excel-o'
when
'.ppt'
,
'.pot'
,
'.pps'
,
'.pptx'
,
'.pptm'
,
'.potx'
,
'.potm'
,
'.ppam'
,
'.ppsx'
,
'.ppsm'
,
'.sldx'
,
'.sldm'
icon_class
=
'file-powerpoint-o'
else
icon_class
=
'file-text-o'
end
end
icon_class
end
end
end
app/helpers/tree_helper.rb
View file @
8ef7220c
...
@@ -34,12 +34,13 @@ module TreeHelper
...
@@ -34,12 +34,13 @@ module TreeHelper
end
end
end
end
# Return an image icon depending on the file type
# Return an image icon depending on the file type
and mode
#
#
# type - String type of the tree item; either 'folder' or 'file'
# type - String type of the tree item; either 'folder' or 'file'
def
tree_icon
(
type
)
# mode - File unix mode
icon_class
=
type
==
'folder'
?
'folder'
:
'file-o'
# name - File name
icon
(
icon_class
)
def
tree_icon
(
type
,
mode
,
name
)
icon
(
"
#{
file_type_icon_class
(
type
,
mode
,
name
)
}
fw"
)
end
end
def
tree_hex_class
(
content
)
def
tree_hex_class
(
content
)
...
...
app/views/projects/blob/_blob.html.haml
View file @
8ef7220c
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
%div
#tree-content-holder
.tree-content-holder
%div
#tree-content-holder
.tree-content-holder
%article
.file-holder
%article
.file-holder
.file-title
.file-title
%i
.fa.fa-fil
e
=
blob_icon
blob
.
mode
,
blob
.
nam
e
%strong
%strong
=
blob
.
name
=
blob
.
name
%small
%small
...
...
app/views/projects/tree/_blob_item.html.haml
View file @
8ef7220c
%tr
{
class:
"tree-item #{tree_hex_class(blob_item)}"
}
%tr
{
class:
"tree-item #{tree_hex_class(blob_item)}"
}
%td
.tree-item-file-name
%td
.tree-item-file-name
=
tree_icon
(
type
)
=
tree_icon
(
type
,
blob_item
.
mode
,
blob_item
.
name
)
%span
.str-truncated
%span
.str-truncated
=
link_to
blob_item
.
name
,
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@id
||
@commit
.
id
,
blob_item
.
name
))
=
link_to
blob_item
.
name
,
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
tree_join
(
@id
||
@commit
.
id
,
blob_item
.
name
))
%td
.tree_time_ago.cgray
%td
.tree_time_ago.cgray
...
...
app/views/projects/tree/_submodule_item.html.haml
View file @
8ef7220c
%tr
{
class:
"tree-item"
}
%tr
{
class:
"tree-item"
}
%td
.tree-item-file-name
%td
.tree-item-file-name
%i
.fa.fa-archive
%i
.fa.fa-archive
.fa-fw
=
submodule_link
(
submodule_item
,
@ref
)
=
submodule_link
(
submodule_item
,
@ref
)
%td
%td
%td
.hidden-xs
%td
.hidden-xs
app/views/projects/tree/_tree_item.html.haml
View file @
8ef7220c
%tr
{
class:
"tree-item #{tree_hex_class(tree_item)}"
}
%tr
{
class:
"tree-item #{tree_hex_class(tree_item)}"
}
%td
.tree-item-file-name
%td
.tree-item-file-name
=
tree_icon
(
type
)
=
tree_icon
(
type
,
tree_item
.
mode
,
tree_item
.
name
)
%span
.str-truncated
%span
.str-truncated
-
path
=
flatten_tree
(
tree_item
)
-
path
=
flatten_tree
(
tree_item
)
=
link_to
path
,
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
tree_join
(
@id
||
@commit
.
id
,
path
))
=
link_to
path
,
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
tree_join
(
@id
||
@commit
.
id
,
path
))
...
...
spec/helpers/icons_helper_spec.rb
0 → 100644
View file @
8ef7220c
require
'spec_helper'
describe
IconsHelper
do
describe
'file_type_icon_class'
do
it
'returns folder class'
do
expect
(
file_type_icon_class
(
'folder'
,
0
,
'folder_name'
)).
to
eq
'folder'
end
it
'returns share class'
do
expect
(
file_type_icon_class
(
'file'
,
0120000
,
'link'
)).
to
eq
'share'
end
it
'returns file-pdf-o class with .pdf'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.pdf'
)).
to
eq
'file-pdf-o'
end
it
'returns file-image-o class with .jpg'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.jpg'
)).
to
eq
'file-image-o'
end
it
'returns file-image-o class with .JPG'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.JPG'
)).
to
eq
'file-image-o'
end
it
'returns file-image-o class with .png'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.png'
)).
to
eq
'file-image-o'
end
it
'returns file-archive-o class with .tar'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.tar'
)).
to
eq
'file-archive-o'
end
it
'returns file-archive-o class with .TAR'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.TAR'
)).
to
eq
'file-archive-o'
end
it
'returns file-archive-o class with .tar.gz'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.tar.gz'
)).
to
eq
'file-archive-o'
end
it
'returns file-audio-o class with .mp3'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.mp3'
)).
to
eq
'file-audio-o'
end
it
'returns file-audio-o class with .MP3'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.MP3'
)).
to
eq
'file-audio-o'
end
it
'returns file-audio-o class with .wav'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.wav'
)).
to
eq
'file-audio-o'
end
it
'returns file-video-o class with .avi'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.avi'
)).
to
eq
'file-video-o'
end
it
'returns file-video-o class with .AVI'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.AVI'
)).
to
eq
'file-video-o'
end
it
'returns file-video-o class with .mp4'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.mp4'
)).
to
eq
'file-video-o'
end
it
'returns file-word-o class with .doc'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.doc'
)).
to
eq
'file-word-o'
end
it
'returns file-word-o class with .DOC'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.DOC'
)).
to
eq
'file-word-o'
end
it
'returns file-word-o class with .docx'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.docx'
)).
to
eq
'file-word-o'
end
it
'returns file-excel-o class with .xls'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.xls'
)).
to
eq
'file-excel-o'
end
it
'returns file-excel-o class with .XLS'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.XLS'
)).
to
eq
'file-excel-o'
end
it
'returns file-excel-o class with .xlsx'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.xlsx'
)).
to
eq
'file-excel-o'
end
it
'returns file-excel-o class with .ppt'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.ppt'
)).
to
eq
'file-powerpoint-o'
end
it
'returns file-excel-o class with .PPT'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.PPT'
)).
to
eq
'file-powerpoint-o'
end
it
'returns file-excel-o class with .pptx'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.pptx'
)).
to
eq
'file-powerpoint-o'
end
it
'returns file-text-o class with .unknow'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'filename.unknow'
)).
to
eq
'file-text-o'
end
it
'returns file-text-o class with no extension'
do
expect
(
file_type_icon_class
(
'file'
,
0
,
'CHANGELOG'
)).
to
eq
'file-text-o'
end
end
end
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