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
Boxiang Sun
gitlab-ce
Commits
7b2b281d
Commit
7b2b281d
authored
Jul 29, 2017
by
Jacob Schatz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds support for SVG because that's why. Does binary right.
parent
6f88402f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
23 deletions
+64
-23
app/assets/javascripts/repo/repo_binary_viewer.vue
app/assets/javascripts/repo/repo_binary_viewer.vue
+25
-15
app/assets/javascripts/repo/repo_file_buttons.vue
app/assets/javascripts/repo/repo_file_buttons.vue
+1
-1
app/assets/javascripts/repo/repo_helper.js
app/assets/javascripts/repo/repo_helper.js
+11
-2
app/assets/javascripts/repo/repo_store.js
app/assets/javascripts/repo/repo_store.js
+12
-2
app/assets/stylesheets/pages/repo.scss
app/assets/stylesheets/pages/repo.scss
+15
-3
No files found.
app/assets/javascripts/repo/repo_binary_viewer.vue
View file @
7b2b281d
...
...
@@ -7,7 +7,18 @@ const RepoBinaryViewer = {
computed
:
{
pngBlobWithDataURI
()
{
return
`data:image/png;base64,
${
this
.
blobRaw
}
`
;
if
(
this
.
binaryTypes
.
png
){
return
`data:image/png;base64,
${
this
.
blobRaw
}
`
;
}
return
''
;
},
svgBlobWithDataURI
()
{
if
(
this
.
binaryTypes
.
svg
){
return
`data:image/svg+xml;utf8,
${
this
.
blobRaw
}
`
;
}
return
''
;
},
},
...
...
@@ -20,29 +31,24 @@ const RepoBinaryViewer = {
Store
.
binaryLoaded
=
true
;
},
isMarkdown
()
{
return
this
.
activeFile
.
extension
===
'
md
'
;
},
getBinaryType
()
{
if
(
this
.
binaryTypes
.
hasOwnProperty
(
this
.
activeFile
.
extension
))
{
return
this
.
activeFile
.
extension
;
}
return
'
unknown
'
;
}
},
watch
:
{
blobRaw
()
{
if
(
this
.
isMarkdown
())
{
this
.
binaryTypes
.
markdown
=
true
;
Store
.
resetBinaryTypes
();
if
(
RepoHelper
.
isKindaBinary
())
{
this
.
activeFile
.
raw
=
false
;
// counts as binaryish so we use the binary viewer in this case.
this
.
binary
=
true
;
return
;
}
if
(
!
this
.
binary
)
return
;
switch
(
this
.
binaryMimeType
)
{
case
'
image/png
'
:
this
.
binaryTypes
.
png
=
true
;
break
;
default
:
RepoHelper
.
loadingError
();
break
;
}
this
.
binaryTypes
[
this
.
getBinaryType
()]
=
true
;
},
},
};
...
...
@@ -53,6 +59,10 @@ export default RepoBinaryViewer;
<
template
>
<div
id=
"binary-viewer"
v-if=
"binary && !activeFile.raw"
>
<img
v-show=
"binaryTypes.png && binaryLoaded"
@
error=
"errored"
@
load=
"loaded"
:src=
"pngBlobWithDataURI"
:alt=
"activeFile.name"
/>
<img
v-show=
"binaryTypes.svg"
@
error=
"errored"
@
load=
"loaded"
:src=
"svgBlobWithDataURI"
:alt=
"activeFile.name"
/>
<div
v-if=
"binaryTypes.markdown"
v-html=
"activeFile.html"
></div>
<div
class=
"binary-unknown"
v-if=
"binaryTypes.unknown"
>
<span>
Binary Unloadable
</span>
</div>
</div>
</
template
>
app/assets/javascripts/repo/repo_file_buttons.vue
View file @
7b2b281d
...
...
@@ -19,7 +19,7 @@ const RepoFileButtons = {
},
canPreview
()
{
return
this
.
activeFile
.
extension
===
'
md
'
;
return
Helper
.
isKindaBinary
()
;
},
rawFileURL
()
{
...
...
app/assets/javascripts/repo/repo_helper.js
View file @
7b2b281d
...
...
@@ -58,7 +58,7 @@ const RepoHelper = {
file
.
opened
=
true
;
file
.
icon
=
'
fa-folder-open
'
;
RepoHelper
.
toURL
(
file
.
url
)
RepoHelper
.
toURL
(
file
.
url
,
file
.
name
)
return
file
;
},
...
...
@@ -66,6 +66,11 @@ const RepoHelper = {
return
url
.
replace
(
'
blob
'
,
'
raw
'
);
},
isKindaBinary
()
{
const
okExts
=
[
'
md
'
,
'
svg
'
];
return
okExts
.
indexOf
(
Store
.
activeFile
.
extension
)
>
-
1
;
},
getBlameURLFromBlobURL
(
url
)
{
return
url
.
replace
(
'
blob
'
,
'
blame
'
);
},
...
...
@@ -269,12 +274,16 @@ const RepoHelper = {
RepoHelper
.
key
=
key
;
},
toURL
(
url
)
{
toURL
(
url
,
title
)
{
const
history
=
window
.
history
;
RepoHelper
.
key
=
RepoHelper
.
genKey
();
history
.
pushState
({
key
:
RepoHelper
.
key
},
''
,
url
);
if
(
title
)
{
document
.
title
=
`
${
title
}
· GitLab`
;
}
},
loadingError
()
{
...
...
app/assets/javascripts/repo/repo_store.js
View file @
7b2b281d
...
...
@@ -48,7 +48,9 @@ const RepoStore = {
scrollWidth
:
0
,
binaryTypes
:
{
png
:
false
,
markdown
:
false
,
md
:
false
,
svg
:
false
,
unknown
:
false
,
},
loading
:
{
tree
:
false
,
...
...
@@ -56,6 +58,13 @@ const RepoStore = {
},
readOnly
:
true
,
resetBinaryTypes
()
{
let
s
=
''
;
for
(
s
in
RepoStore
.
binaryTypes
){
RepoStore
.
binaryTypes
[
s
]
=
false
;
}
},
// mutations
checkIsCommitable
()
{
RepoStore
.
service
.
checkCurrentBranchIsCommitable
()
...
...
@@ -86,11 +95,12 @@ const RepoStore = {
if
(
file
.
binary
)
{
RepoStore
.
blobRaw
=
file
.
base64
;
RepoStore
.
binaryMimeType
=
file
.
mime_type
;
}
else
{
RepoStore
.
blobRaw
=
file
.
plain
;
}
if
(
!
file
.
loading
)
RepoHelper
.
toURL
(
file
.
url
);
if
(
!
file
.
loading
)
RepoHelper
.
toURL
(
file
.
url
,
file
.
name
);
RepoStore
.
binary
=
file
.
binary
;
},
...
...
app/assets/stylesheets/pages/repo.scss
View file @
7b2b281d
...
...
@@ -140,15 +140,27 @@
}
#binary-viewer
{
height
:
7
0vh
;
height
:
8
0vh
;
overflow
:
auto
;
margin-top
:
5px
;
margin-left
:
10px
;
margin
:
0
;
.blob-viewer
{
padding-top
:
20px
;
padding-left
:
20px
;
}
.binary-unknown
{
text-align
:
center
;
padding-top
:
100px
;
background
:
#FAFAFA
;
height
:
100%
;
text-shadow
:
0px
7px
#DDDDDD
,
0
9px
#CCCCCC
,
0
11px
#FFF
,
0
13px
#000
;
font-size
:
17px
;
font-weight
:
900
;
span
{
display
:
block
;
}
}
}
}
...
...
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