Commit a13c43b5 authored by svilayphiou's avatar svilayphiou
Browse files

Added file history for bitmap files

parent 6fe2e668
......@@ -49,6 +49,12 @@
</ul>
<div id="blob" v-html="blobItem">
</div>
<div id="blobHistory">
<h4 v-if="blobHistory.length > 1">File History</h4>
<div v-for="b64 in blobHistory">
<img v-bind:src="b64">
</div>
</div>
</section>
<section id="commits" class="repo-views">
......@@ -102,6 +108,7 @@
const hiddenFile = /^\./;
var fileList = [];
var formerTree = [];
var blobHistory = [];
var treeURL = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/tree?per_page=100";
fetch(treeURL).then(function(resp){ return resp.json(); })
.then(function(data){
......@@ -118,6 +125,7 @@
fileList,
upPath: "/",
blobItem: "",
blobHistory
},
delimiters: ['[[',']]'],
methods: {
......@@ -163,10 +171,33 @@
href = project_path + "/raw/master/" + path;
a = '<p><a download href="' + href + '">Download file</a></p>';
var mime = data["type"];
// if PNG, JPG, or GIF
if(mime == "image/png" | mime == "image/jpeg" | mime == "image/jpg" | mime == "image/gif") {
vm.blobItem = h4 + a + "<img src='" + blobURL+ "'>";
// DIFF: SHOWS ALL VERSIONS OF ONE PICTURE ////////////////////////////////////
const file_commits_url = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/commits?path=" + path;
fetch(file_commits_url)
.then((resp) => resp.json())
.then(function(data){
return data.map(function(file) {
blob_id = file.id;
const commit_url = "https://gitlab.constantvzw.org/api/v4/projects/" + repoID + "/repository/files/" + path.replace(/\//g, "%2F") + "?ref=" + blob_id;
fetch(commit_url)
.then((resp) => resp.json())
.then(function(data){
img = 'data:image/jpeg;base64,' + data['content'];
blobHistory.push(img);
});
console.log(blobHistory)
});
});
vm.blobItem = h4 + a + "<img src='" + blobURL+ "'i>";
}
// if TXT, SVG, code...
else if (mime == "text/plain" | mime == "image/svg+xml") {
......
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