Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
osp
tools.gitlabculture
Commits
08d3c006
Commit
08d3c006
authored
May 23, 2019
by
svilayphiou
Browse files
read image blob
parent
42605541
Changes
1
Hide whitespace changes
Inline
Side-by-side
contour.html
View file @
08d3c006
...
...
@@ -24,8 +24,8 @@
<h2>
Tree
</h2>
<ul
id=
"tree"
></ul>
<h2>
README
</h2>
<div
id=
"
readme
"
></div>
<h2>
BLOB
</h2>
<div
id=
"
blob
"
></div>
<h2>
ICEBERG
</h2>
<div
id=
"iceberg"
></div>
...
...
@@ -35,6 +35,8 @@
<script
type=
"text/javascript"
charset=
"utf-8"
>
var
this_url
=
new
URL
(
window
.
location
.
href
);
// BEGIN DIFF
const
file_elt
=
document
.
querySelector
(
'
#file_history
'
);
const
file_path
=
'
communication%2Fbanners%2Fbanner-eflux.png
'
;
...
...
@@ -55,17 +57,35 @@
});
});
// BLOB
var
blob
=
this_url
.
searchParams
.
get
(
"
blob
"
);
if
(
blob
){
var
blob_url
=
"
https://gitlab.constantvzw.org/api/v4/projects/456/repository/blobs/
"
+
blob
+
"
/raw
"
;
console
.
log
(
blob_url
);
//README = file.id;
const
blob_elt
=
document
.
querySelector
(
'
#blob
'
);
fetch
(
blob_url
)
.
then
((
resp
)
=>
resp
.
blob
())
.
then
(
function
(
data
){
var
mime
=
data
[
"
type
"
];
if
(
mime
==
"
image/png
"
|
mime
==
"
image/jpg
"
|
mime
==
"
image/gif
"
)
{
let
img
=
document
.
createElement
(
'
img
'
);
img
.
src
=
blob_url
;
blob_elt
.
appendChild
(
img
);
}
else
{
blob_elt
.
innerHTML
=
'
data
'
;
}
})
}
// BEGIN TREE
var
this_url
=
new
URL
(
window
.
location
.
href
);
var
path
=
this_url
.
searchParams
.
get
(
"
path
"
);
const
tree_elt
=
document
.
querySelector
(
'
#tree
'
);
if
(
path
==
null
)
{
var
tree_url
=
"
https://gitlab.constantvzw.org/api/v4/projects/456/repository/tree
"
;
}
else
{
if
(
path
)
{
var
tree_url
=
"
https://gitlab.constantvzw.org/api/v4/projects/456/repository/tree?path=
"
+
path
;
}
else
{
var
tree_url
=
"
https://gitlab.constantvzw.org/api/v4/projects/456/repository/tree
"
;
}
var
README
=
""
;
fetch
(
tree_url
)
.
then
((
resp
)
=>
resp
.
json
())
...
...
@@ -73,24 +93,18 @@
return
data
.
map
(
function
(
file
)
{
let
li
=
document
.
createElement
(
'
li
'
);
li
.
classList
.
add
(
file
.
type
);
li
.
innerHTML
=
"
<a href='?path=
"
+
file
.
path
+
"
' >
"
+
file
.
name
+
"
</a>
"
;
if
(
file
.
type
==
'
tree
'
)
{
li
.
innerHTML
=
"
<a href='?path=
"
+
file
.
path
+
"
' >
"
+
file
.
name
+
"
</a>
"
;
}
else
{
console
.
log
(
file
.
path
);
li
.
innerHTML
=
"
<a href='?blob=
"
+
file
.
id
+
"
' >
"
+
file
.
name
+
"
</a>
"
;
}
tree_elt
.
appendChild
(
li
);
// README
if
(
file
.
name
==
"
README.md
"
){
README
=
file
.
id
;
const
readme_elt
=
document
.
querySelector
(
'
#readme
'
);
const
readme_url
=
"
https://gitlab.constantvzw.org/api/v4/projects/456/repository/blobs/
"
+
README
+
"
/raw
"
;
fetch
(
readme_url
)
.
then
((
resp
)
=>
resp
.
text
())
.
then
(
function
(
data
){
readme_elt
.
innerHTML
=
data
;
})
}
// ICEBERG
if
(
file
.
name
==
"
iceberg
"
){
iceberg
=
fil
e
.
id
;
iceberg
=
fil
4
.
id
;
const
iceberg_elt
=
document
.
querySelector
(
'
#iceberg
'
);
const
iceberg_url
=
"
https://gitlab.constantvzw.org/api/v4/projects/456/repository/tree/?path=iceberg
"
;
fetch
(
iceberg_url
)
...
...
Write
Preview
Supports
Markdown
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