Commit 46527353 authored by svilayphiou's avatar svilayphiou
Browse files

SVG and plain text are showing.

parent da89f926
...@@ -46,8 +46,7 @@ ...@@ -46,8 +46,7 @@
</a> </a>
</li> </li>
</ul> </ul>
<div id="blob" :key="bloup"> <div id="blob" v-html="bloup">
[[ bloup ]]
</div> </div>
</section> </section>
<section id="commits" class="repo-views"> <section id="commits" class="repo-views">
...@@ -131,11 +130,22 @@ ...@@ -131,11 +130,22 @@
let blobURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/blobs/" + blobID + "/raw"; let blobURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/blobs/" + blobID + "/raw";
fetch(blobURL).then((resp) => resp.blob()) fetch(blobURL).then((resp) => resp.blob())
.then(function(data){ .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(); var reader = new FileReader();
reader.readAsText(data); reader.readAsText(data);
reader.onloadend=function(){ reader.onloadend=function(){
vm.bloup = reader.result; 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