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
1
Merge Requests
1
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
nexedi
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
Show 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 = {
...
@@ -7,7 +7,18 @@ const RepoBinaryViewer = {
computed
:
{
computed
:
{
pngBlobWithDataURI
()
{
pngBlobWithDataURI
()
{
if
(
this
.
binaryTypes
.
png
){
return
`data:image/png;base64,
${
this
.
blobRaw
}
`
;
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 = {
...
@@ -20,29 +31,24 @@ const RepoBinaryViewer = {
Store
.
binaryLoaded
=
true
;
Store
.
binaryLoaded
=
true
;
},
},
isMarkdown
()
{
getBinaryType
()
{
return
this
.
activeFile
.
extension
===
'
md
'
;
if
(
this
.
binaryTypes
.
hasOwnProperty
(
this
.
activeFile
.
extension
))
{
},
return
this
.
activeFile
.
extension
;
}
return
'
unknown
'
;
}
},
},
watch
:
{
watch
:
{
blobRaw
()
{
blobRaw
()
{
if
(
this
.
isMarkdown
())
{
Store
.
resetBinaryTypes
();
this
.
binaryTypes
.
markdown
=
true
;
if
(
RepoHelper
.
isKindaBinary
())
{
this
.
activeFile
.
raw
=
false
;
this
.
activeFile
.
raw
=
false
;
// counts as binaryish so we use the binary viewer in this case.
// counts as binaryish so we use the binary viewer in this case.
this
.
binary
=
true
;
this
.
binary
=
true
;
return
;
}
}
if
(
!
this
.
binary
)
return
;
if
(
!
this
.
binary
)
return
;
switch
(
this
.
binaryMimeType
)
{
this
.
binaryTypes
[
this
.
getBinaryType
()]
=
true
;
case
'
image/png
'
:
this
.
binaryTypes
.
png
=
true
;
break
;
default
:
RepoHelper
.
loadingError
();
break
;
}
},
},
},
},
};
};
...
@@ -53,6 +59,10 @@ export default RepoBinaryViewer;
...
@@ -53,6 +59,10 @@ export default RepoBinaryViewer;
<
template
>
<
template
>
<div
id=
"binary-viewer"
v-if=
"binary && !activeFile.raw"
>
<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.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
v-if=
"binaryTypes.markdown"
v-html=
"activeFile.html"
></div>
<div
class=
"binary-unknown"
v-if=
"binaryTypes.unknown"
>
<span>
Binary Unloadable
</span>
</div>
</div>
</div>
</
template
>
</
template
>
app/assets/javascripts/repo/repo_file_buttons.vue
View file @
7b2b281d
...
@@ -19,7 +19,7 @@ const RepoFileButtons = {
...
@@ -19,7 +19,7 @@ const RepoFileButtons = {
},
},
canPreview
()
{
canPreview
()
{
return
this
.
activeFile
.
extension
===
'
md
'
;
return
Helper
.
isKindaBinary
()
;
},
},
rawFileURL
()
{
rawFileURL
()
{
...
...
app/assets/javascripts/repo/repo_helper.js
View file @
7b2b281d
...
@@ -58,7 +58,7 @@ const RepoHelper = {
...
@@ -58,7 +58,7 @@ const RepoHelper = {
file
.
opened
=
true
;
file
.
opened
=
true
;
file
.
icon
=
'
fa-folder-open
'
;
file
.
icon
=
'
fa-folder-open
'
;
RepoHelper
.
toURL
(
file
.
url
)
RepoHelper
.
toURL
(
file
.
url
,
file
.
name
)
return
file
;
return
file
;
},
},
...
@@ -66,6 +66,11 @@ const RepoHelper = {
...
@@ -66,6 +66,11 @@ const RepoHelper = {
return
url
.
replace
(
'
blob
'
,
'
raw
'
);
return
url
.
replace
(
'
blob
'
,
'
raw
'
);
},
},
isKindaBinary
()
{
const
okExts
=
[
'
md
'
,
'
svg
'
];
return
okExts
.
indexOf
(
Store
.
activeFile
.
extension
)
>
-
1
;
},
getBlameURLFromBlobURL
(
url
)
{
getBlameURLFromBlobURL
(
url
)
{
return
url
.
replace
(
'
blob
'
,
'
blame
'
);
return
url
.
replace
(
'
blob
'
,
'
blame
'
);
},
},
...
@@ -269,12 +274,16 @@ const RepoHelper = {
...
@@ -269,12 +274,16 @@ const RepoHelper = {
RepoHelper
.
key
=
key
;
RepoHelper
.
key
=
key
;
},
},
toURL
(
url
)
{
toURL
(
url
,
title
)
{
const
history
=
window
.
history
;
const
history
=
window
.
history
;
RepoHelper
.
key
=
RepoHelper
.
genKey
();
RepoHelper
.
key
=
RepoHelper
.
genKey
();
history
.
pushState
({
key
:
RepoHelper
.
key
},
''
,
url
);
history
.
pushState
({
key
:
RepoHelper
.
key
},
''
,
url
);
if
(
title
)
{
document
.
title
=
`
${
title
}
· GitLab`
;
}
},
},
loadingError
()
{
loadingError
()
{
...
...
app/assets/javascripts/repo/repo_store.js
View file @
7b2b281d
...
@@ -48,7 +48,9 @@ const RepoStore = {
...
@@ -48,7 +48,9 @@ const RepoStore = {
scrollWidth
:
0
,
scrollWidth
:
0
,
binaryTypes
:
{
binaryTypes
:
{
png
:
false
,
png
:
false
,
markdown
:
false
,
md
:
false
,
svg
:
false
,
unknown
:
false
,
},
},
loading
:
{
loading
:
{
tree
:
false
,
tree
:
false
,
...
@@ -56,6 +58,13 @@ const RepoStore = {
...
@@ -56,6 +58,13 @@ const RepoStore = {
},
},
readOnly
:
true
,
readOnly
:
true
,
resetBinaryTypes
()
{
let
s
=
''
;
for
(
s
in
RepoStore
.
binaryTypes
){
RepoStore
.
binaryTypes
[
s
]
=
false
;
}
},
// mutations
// mutations
checkIsCommitable
()
{
checkIsCommitable
()
{
RepoStore
.
service
.
checkCurrentBranchIsCommitable
()
RepoStore
.
service
.
checkCurrentBranchIsCommitable
()
...
@@ -86,11 +95,12 @@ const RepoStore = {
...
@@ -86,11 +95,12 @@ const RepoStore = {
if
(
file
.
binary
)
{
if
(
file
.
binary
)
{
RepoStore
.
blobRaw
=
file
.
base64
;
RepoStore
.
blobRaw
=
file
.
base64
;
RepoStore
.
binaryMimeType
=
file
.
mime_type
;
}
else
{
}
else
{
RepoStore
.
blobRaw
=
file
.
plain
;
RepoStore
.
blobRaw
=
file
.
plain
;
}
}
if
(
!
file
.
loading
)
RepoHelper
.
toURL
(
file
.
url
);
if
(
!
file
.
loading
)
RepoHelper
.
toURL
(
file
.
url
,
file
.
name
);
RepoStore
.
binary
=
file
.
binary
;
RepoStore
.
binary
=
file
.
binary
;
},
},
...
...
app/assets/stylesheets/pages/repo.scss
View file @
7b2b281d
...
@@ -140,15 +140,27 @@
...
@@ -140,15 +140,27 @@
}
}
#binary-viewer
{
#binary-viewer
{
height
:
7
0vh
;
height
:
8
0vh
;
overflow
:
auto
;
overflow
:
auto
;
margin-top
:
5px
;
margin
:
0
;
margin-left
:
10px
;
.blob-viewer
{
.blob-viewer
{
padding-top
:
20px
;
padding-top
:
20px
;
padding-left
:
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