Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vereign Client Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
Vereign Client Library
Commits
00970c5f
Commit
00970c5f
authored
6 years ago
by
Markin Igor
Browse files
Options
Downloads
Patches
Plain Diff
Rework host.
parent
9145a129
No related branches found
No related tags found
1 merge request
!4
Use webpack for bundling JS libs and move Golang code related to Iframe generation there
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
javascript/src/wopiapi-iframe.js
+3
-1
3 additions, 1 deletion
javascript/src/wopiapi-iframe.js
main.go
+12
-21
12 additions, 21 deletions
main.go
with
15 additions
and
22 deletions
javascript/src/wopiapi-iframe.js
+
3
−
1
View file @
00970c5f
...
@@ -10,7 +10,9 @@ WopiAPI.prototype.getPassports = function(publicKey, uuid, token, fileID) {
...
@@ -10,7 +10,9 @@ WopiAPI.prototype.getPassports = function(publicKey, uuid, token, fileID) {
}
}
};
};
return
axios
.
post
(
'
{{host}}:{{port}}/getPassports
'
,
{},
requestConfig
);
const
urlParts
=
window
.
API_HOST
.
split
(
'
:
'
);
return
axios
.
post
(
urlParts
[
0
]
+
urlParts
[
1
]
+
'
:8787/getPassports
'
,
{},
requestConfig
);
};
};
wopiAPI
=
new
WopiAPI
();
wopiAPI
=
new
WopiAPI
();
This diff is collapsed.
Click to expand it.
main.go
+
12
−
21
View file @
00970c5f
...
@@ -32,6 +32,7 @@ func GetClientJsLibrary(iframeUrl string) string {
...
@@ -32,6 +32,7 @@ func GetClientJsLibrary(iframeUrl string) string {
func
GetIframeJsLibrary
(
host
string
,
func
GetIframeJsLibrary
(
host
string
,
endPoints
map
[
string
]
*
types
.
EndPoint
)
string
{
endPoints
map
[
string
]
*
types
.
EndPoint
)
string
{
result
:=
"<script>
\n\n
"
result
:=
"<script>
\n\n
"
result
+=
"window.API_HOST = '"
+
host
+
"';
\n\n
"
var
keys
[]
string
var
keys
[]
string
for
k
:=
range
endPoints
{
for
k
:=
range
endPoints
{
...
@@ -48,7 +49,7 @@ func GetIframeJsLibrary(host string,
...
@@ -48,7 +49,7 @@ func GetIframeJsLibrary(host string,
fmt
.
Println
(
err
.
Error
())
fmt
.
Println
(
err
.
Error
())
}
}
methods
:=
generatePenpalRemoteMethods
(
host
,
endPoints
)
methods
:=
generatePenpalRemoteMethods
(
endPoints
)
methods
+=
getWopiAPIPenpalMethods
()
methods
+=
getWopiAPIPenpalMethods
()
viamApi
:=
strings
.
Replace
(
string
(
dat
),
"placeholderForExternalMethods:1"
,
methods
,
1
)
viamApi
:=
strings
.
Replace
(
string
(
dat
),
"placeholderForExternalMethods:1"
,
methods
,
1
)
...
@@ -59,7 +60,13 @@ func GetIframeJsLibrary(host string,
...
@@ -59,7 +60,13 @@ func GetIframeJsLibrary(host string,
result
+=
viamApi
+
"
\n\n
"
result
+=
viamApi
+
"
\n\n
"
result
+=
getWopiAPI
(
host
)
dat
,
err
=
ioutil
.
ReadFile
(
"../vcl/javascript/dist/wopiapi-iframe.js"
)
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
}
result
+=
string
(
dat
)
+
"
\n\n
"
result
+=
"
\n\n
function ViamAPI() {
\n
"
+
result
+=
"
\n\n
function ViamAPI() {
\n
"
+
" this.config = {
\n
"
+
" this.config = {
\n
"
+
...
@@ -118,7 +125,7 @@ func GetIframeJsLibrary(host string,
...
@@ -118,7 +125,7 @@ func GetIframeJsLibrary(host string,
}
}
result
+=
"ViamAPI.prototype."
+
packageStr
+
strings
.
Title
(
methodStr
)
+
" = function("
+
args
+
") {
\n
"
+
result
+=
"ViamAPI.prototype."
+
packageStr
+
strings
.
Title
(
methodStr
)
+
" = function("
+
args
+
") {
\n
"
+
" return axios.post(
'"
+
host
+
packageStr
+
"/"
+
methodStr
+
"', {
\n
"
" return axios.post(
window.API_HOST + '"
+
packageStr
+
"/"
+
methodStr
+
"', {
\n
"
for
i
:=
0
;
i
<
lenFields
;
i
++
{
for
i
:=
0
;
i
<
lenFields
;
i
++
{
result
+=
" "
+
fields
[
i
]
.
name
+
": "
+
fields
[
i
]
.
name
+
"Arg"
result
+=
" "
+
fields
[
i
]
.
name
+
": "
+
fields
[
i
]
.
name
+
"Arg"
...
@@ -143,7 +150,7 @@ func GetIframeJsLibrary(host string,
...
@@ -143,7 +150,7 @@ func GetIframeJsLibrary(host string,
methodStr
:=
splits
[
len
(
splits
)
-
1
]
methodStr
:=
splits
[
len
(
splits
)
-
1
]
result
+=
"ViamAPI.prototype."
+
packageStr
+
strings
.
Title
(
methodStr
)
+
" = function() {
\n
"
+
result
+=
"ViamAPI.prototype."
+
packageStr
+
strings
.
Title
(
methodStr
)
+
" = function() {
\n
"
+
" return axios.post(
'"
+
host
+
"/
"
+
packageStr
+
"/"
+
methodStr
+
"', {}, this.config);
\n
"
+
" return axios.post(
window.API_HOST
+
'
"
+
packageStr
+
"/"
+
methodStr
+
"', {}, this.config);
\n
"
+
"}
\n\n
"
"}
\n\n
"
}
}
}
}
...
@@ -563,8 +570,7 @@ func dominantField(fields []field) (field, bool) {
...
@@ -563,8 +570,7 @@ func dominantField(fields []field) (field, bool) {
return
fields
[
0
],
true
return
fields
[
0
],
true
}
}
func
generatePenpalRemoteMethods
(
host
string
,
func
generatePenpalRemoteMethods
(
endPoints
map
[
string
]
*
types
.
EndPoint
)
string
{
endPoints
map
[
string
]
*
types
.
EndPoint
)
string
{
var
keys
[]
string
var
keys
[]
string
for
k
:=
range
endPoints
{
for
k
:=
range
endPoints
{
keys
=
append
(
keys
,
k
)
keys
=
append
(
keys
,
k
)
...
@@ -780,18 +786,3 @@ func getWopiAPIPenpalMethods() string {
...
@@ -780,18 +786,3 @@ func getWopiAPIPenpalMethods() string {
});
});
}`
}`
}
}
func
getWopiAPI
(
url
string
)
string
{
dat
,
err
:=
ioutil
.
ReadFile
(
"../vcl/javascript/dist/wopiapi-iframe.js"
)
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
}
urlParts
:=
strings
.
Split
(
url
,
":"
)
wopiAPI
:=
strings
.
Replace
(
string
(
dat
),
"{{host}}"
,
urlParts
[
0
]
+
":"
+
urlParts
[
1
],
-
1
)
wopiAPI
=
strings
.
Replace
(
wopiAPI
,
"{{port}}"
,
"8787"
,
-
1
)
wopiAPI
+=
"
\n\n
"
return
wopiAPI
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment