Commit 0c3d0ebf authored by svilayphiou's avatar svilayphiou
Browse files

File history for all files.

If not a bitmap image, there is only the info about the commit and a
link to download the file.
parent d18958f7
......@@ -27,6 +27,7 @@ const hiddenFile = /^\./;
var fileList = [];
var formerTree = [];
var blobHistory = [];
const project_path = [gitlabURL, user_name, projectName].join('/');
// GET ROOT TREE
var treeURL = gitlabApiURL + repoID + "/repository/tree?per_page=100";
......@@ -80,22 +81,18 @@ var treeApp = new Vue({
let blobURL = gitlabApiURL + repoID + "/repository/blobs/" + blobID + "/raw";
fetch(blobURL).then((resp) => resp.blob())
.then(function(data){
var mime = data["type"];
// FILENAME
h4 = "<h4>" + path + "</h4>"
// DOWNLOAD RAW FILE
project_path = [gitlabURL, user_name, projectName].join('/');
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") {
// DIFF: SHOWS ALL VERSIONS OF ONE PICTURE ////////////////////////////////////
vm.blobHistory.splice(0);
const file_commits_url = gitlabApiURL + repoID + "/repository/commits?path=" + path;
fetch(file_commits_url)
.then((resp) => resp.json())
......@@ -103,27 +100,30 @@ var treeApp = new Vue({
return data.map(function(file) {
let f = {};
blob_id = file.id;
path = path.replace(/\//g, "%2F");
console.log(file);
f.date = file.created_at;
f.msg = file.message;
f.author = file.author_name;
const commit_url = gitlabApiURL + repoID + "/repository/files/" + path + "?ref=" + blob_id;
fetch(commit_url)
.then((resp) => resp.json())
.then(function(data){
console.log(data);
f.b64 = 'data:image/jpeg;base64,' + data['content'];
f.href = project_path + "/-/raw/" + blob_id + "/" + path ;
path = path.replace(/\//g, "%2F");
if(mime == "image/png" | mime == "image/jpeg" | mime == "image/jpg" | mime == "image/gif") {
const commit_url = gitlabApiURL + repoID + "/repository/files/" + path + "?ref=" + blob_id;
fetch(commit_url)
.then((resp) => resp.json())
.then(function(data){
f.b64 = 'data:image/jpeg;base64,' + data['content'];
blobHistory.push(f);
});
} else {
blobHistory.push(f);
});
}
});
});
// 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+ "'i>";
}
// if TXT, SVG, code...
......@@ -176,7 +176,6 @@ function getImages(repoID, apiURL, imageList){
return data.map(function(image) {
item = {};
item.name = image.name;
project_path = [gitlabURL, user_name, projectName].join('/');
item.src = project_path + "/raw/" + projectBranch + "/" + image.path;
imageList.push(item);
})
......
......@@ -55,7 +55,8 @@
<h5>[[ file.date ]]</h5>
<p>[[ file.msg ]]</p>
<p>[[ file.author ]]</p>
<img v-bind:src="file.b64">
<img v-if="file.b64" v-bind:src="file.b64">
<a v-bind:href="file.href" download target="_blank">Download that file.</a>
</div>
</div>
</section>
......
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