Commit 46527353 authored by svilayphiou's avatar svilayphiou
Browse files

SVG and plain text are showing.

parent da89f926
......@@ -46,8 +46,7 @@
</a>
</li>
</ul>
<div id="blob" :key="bloup">
[[ bloup ]]
<div id="blob" v-html="bloup">
</div>
</section>
<section id="commits" class="repo-views">
......@@ -131,11 +130,22 @@
let blobURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/blobs/" + blobID + "/raw";
fetch(blobURL).then((resp) => resp.blob())
.then(function(data){
var mime = data["type"];
console.log(mime);
// if PNG, JPG, or GIF
if(mime == "image/png" | mime == "image/jpg" | mime == "image/gif") {
let img = document.createElement('img');
img.src = blob_url;
blob_elt.appendChild(img);
}
// if TXT, SVG, code...
else if (mime == "text/plain" | mime == "image/svg+xml") {
var reader = new FileReader();
reader.readAsText(data);
reader.onloadend=function(){
vm.bloup = reader.result;
};
}
})
}
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment