Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
osp
tools.gitlabculture
Commits
4764bbd3
Commit
4764bbd3
authored
Mar 27, 2020
by
svilayphiou
Browse files
Download raw file.
parent
27370198
Changes
1
Hide whitespace changes
Inline
Side-by-side
generator/templates/project.html
View file @
4764bbd3
...
...
@@ -47,7 +47,7 @@
</a>
</li>
</ul>
<div
id=
"blob"
v-html=
"blo
up
"
>
<div
id=
"blob"
v-html=
"blo
bItem
"
>
</div>
</section>
<section
id=
"commits"
class=
"repo-views"
>
...
...
@@ -75,7 +75,7 @@
{% block script %}
<script
type=
"text/javascript"
charset=
"utf-8"
>
var
gitlab
_url
=
"
http://gitlab.constantvzw.org
"
;
var
gitlab
URL
=
"
http://gitlab.constantvzw.org
"
;
var
user_name
=
"
osp
"
;
var
repoID
=
{{
project
.
id
}};
...
...
@@ -114,7 +114,7 @@
data
:
{
fileList
,
upPath
:
"
/
"
,
blo
up
:
"
?
"
,
blo
bItem
:
""
,
},
delimiters
:
[
'
[[
'
,
'
]]
'
],
methods
:
{
...
...
@@ -147,19 +147,30 @@
let
blobURL
=
"
https://gitlab.constantvzw.org/api/v4/projects/
"
+
repoID
+
"
/repository/blobs/
"
+
blobID
+
"
/raw
"
;
fetch
(
blobURL
).
then
((
resp
)
=>
resp
.
blob
())
.
then
(
function
(
data
){
// FILENAME
h4
=
"
<h4>
"
+
path
+
"
</h4>
"
// DOWNLOAD RAW FILE
project_path
=
[
gitlabURL
,
user_name
,
'
{{ project.name }}
'
].
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
"
)
{
vm
.
blo
up
=
"
<img src='
"
+
blobURL
+
"
'>
"
vm
.
blo
bItem
=
h4
+
a
+
"
<img src='
"
+
blobURL
+
"
'>
"
;
}
// if TXT, SVG, code...
else
if
(
mime
==
"
text/plain
"
|
mime
==
"
image/svg+xml
"
)
{
var
reader
=
new
FileReader
();
reader
.
readAsText
(
data
);
reader
.
onloadend
=
function
(){
vm
.
blo
up
=
reader
.
result
;
vm
.
blo
bItem
=
h4
+
a
+
reader
.
result
;
};
}
else
{
vm
.
blobItem
=
h4
+
a
;
}
})
}
},
...
...
@@ -194,7 +205,7 @@
return
data
.
map
(
function
(
image
)
{
item
=
{};
item
.
name
=
image
.
name
;
project_path
=
[
gitlab
_url
,
user_name
,
"
{{ project.name }}
"
].
join
(
'
/
'
);
project_path
=
[
gitlab
URL
,
user_name
,
"
{{ project.name }}
"
].
join
(
'
/
'
);
item
.
src
=
project_path
+
"
/raw/{{ project.default_branch }}/
"
+
image
.
path
;
imageList
.
push
(
item
);
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment