Commit a4f7367c authored by svilayphiou's avatar svilayphiou
Browse files

download raw file with proper filename

parent 438f3a83
......@@ -35,6 +35,10 @@
<script type="text/javascript" charset="utf-8">
var gitlab_url = "http://gitlab.constantvzw.org";
var user_name = "osp";
var project_name = "work.contour";
var this_url = new URL(window.location.href);
// BEGIN DIFF
......@@ -59,6 +63,8 @@
// BLOB
var blob = this_url.searchParams.get("blob");
var path = this_url.searchParams.get("path");
if (blob){
var blob_url = "https://gitlab.constantvzw.org/api/v4/projects/456/repository/blobs/" + blob + "/raw";
console.log(blob_url);
......@@ -80,6 +86,14 @@ console.log(data);
};
reader.readAsText(data);
}
let raw = document.createElement('a');
project_path = [gitlab_url, user_name, project_name].join('/');
raw.href = project_path + "/raw/master/" + path;
raw.innerHTML = 'Download raw file.';
raw.download = name;
raw.target = '_blank';
blob_elt.appendChild(raw);
})
}
......@@ -102,7 +116,7 @@ console.log(data);
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>";
li.innerHTML = "<a href='?path=" + file.path + "&blob=" + file.id + "' >" + file.name + "</a>";
}
tree_elt.appendChild(li);
......
Supports Markdown
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