appscms-tools-theme 0.9.0 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/head/index.html +0 -1
- data/_includes/share/socialshare.html +4 -3
- data/assets/js/googledrive.js +79 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 036b7a24001add163d19a0503ef4de9c2bd71339762b9e393d93897b11b82d2a
|
4
|
+
data.tar.gz: 7914a96bb2f2ed3d4f432e407246fd43e6b9916a8fc828baacd3c91038443939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b06d6ff126097a8bd827fc5a6f142b0af8d10a0f7a2dbd4ca10f9170b5fbe4a0e426b45c94ec10abf45b40d1bf7243b6cdb6a362cb39a81a8472e3afeab20555
|
7
|
+
data.tar.gz: 69359ae79aeaeeb0c6d769a9b3901c4800bfb7c4fdebd107943dfef9aa8f3768bfebc212d7be665d0c4da5e79569bf83433006c28c679cbb7db19615b5414349
|
data/_includes/head/index.html
CHANGED
data/assets/js/googledrive.js
CHANGED
@@ -1,7 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const
|
1
|
+
---
|
2
|
+
---
|
3
|
+
|
4
|
+
const addScripts=()=>{
|
5
|
+
const scripts=document.getElementsByTagName('script')
|
6
|
+
const check= Array.from(scripts).find(item=>item.src==='https://www.dropbox.com/static/api/2/dropins.js')
|
7
|
+
if(!check){
|
8
|
+
const dropboxscript = document.createElement('script')
|
9
|
+
dropboxscript.src = 'https://www.dropbox.com/static/api/2/dropins.js'
|
10
|
+
dropboxscript.dataset.appKey = '{{site.dropboxapikey}}'
|
11
|
+
dropboxscript.id='dropboxjs'
|
12
|
+
document.head.append(dropboxscript)
|
13
|
+
}
|
14
|
+
const checkgooglescript= Array.from(scripts).find(item=>item.src==='https://apis.google.com/js/api.js')
|
15
|
+
if(!checkgooglescript){
|
16
|
+
const googlescript = document.createElement('script')
|
17
|
+
googlescript.src = '{{site.googleapisrc}}'
|
18
|
+
document.head.append(googlescript)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
const developerKey = '{{site.developerKey}}'
|
22
|
+
const clientId ='{{site.clientId}}'
|
23
|
+
const appId = '{{site.appId}}'
|
5
24
|
const scope = [
|
6
25
|
'https://www.googleapis.com/auth/drive.file',
|
7
26
|
'https://www.googleapis.com/auth/drive.appdata',
|
@@ -35,7 +54,7 @@ const handleAuthResult = (authResult) => {
|
|
35
54
|
const createPicker = () => {
|
36
55
|
if (pickerApiLoaded && oauthToken) {
|
37
56
|
const view = new google.picker.View(google.picker.ViewId.DOCS)
|
38
|
-
view.setMimeTypes(
|
57
|
+
view.setMimeTypes(mimeTypes)
|
39
58
|
const picker = new google.picker.PickerBuilder()
|
40
59
|
.enableFeature(google.picker.Feature.NAV_HIDDEN)
|
41
60
|
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
|
@@ -51,6 +70,7 @@ const createPicker = () => {
|
|
51
70
|
}
|
52
71
|
const pickerCallback = async (data) => {
|
53
72
|
if (data.action == google.picker.Action.PICKED) {
|
73
|
+
showLoader()
|
54
74
|
const res = await fetch(
|
55
75
|
`https://www.googleapis.com/drive/v3/files/${data.docs[0].id}?alt=media`,
|
56
76
|
{
|
@@ -63,23 +83,70 @@ const pickerCallback = async (data) => {
|
|
63
83
|
type: data.docs[0].mimeType,
|
64
84
|
}
|
65
85
|
let file = new File([res], data.docs[0].name, metadata)
|
86
|
+
closeLoader()
|
66
87
|
getFile(file)
|
67
88
|
}
|
68
89
|
}
|
69
90
|
function chooseFromDropbox() {
|
70
91
|
Dropbox.choose({
|
71
|
-
success:
|
92
|
+
success: async (files) => {
|
72
93
|
if (files.length < 0) {
|
73
94
|
return
|
74
95
|
}
|
75
96
|
var file = files[0]
|
76
|
-
|
77
|
-
|
97
|
+
const url = new URL(file.link)
|
98
|
+
const response = await fetch(url).then((res) => res.blob())
|
99
|
+
let metadata = {
|
100
|
+
type: response.type,
|
101
|
+
}
|
102
|
+
let newFile = new File([response], file.name, metadata)
|
103
|
+
getDropBoxFile(newFile)
|
78
104
|
},
|
79
105
|
cancel: function () {},
|
80
|
-
linkType: 'direct',
|
81
|
-
multiselect: false,
|
82
|
-
extensions: ['.jpg'],
|
83
|
-
folderselect: false,
|
106
|
+
linkType: 'direct',
|
107
|
+
multiselect: false,
|
108
|
+
extensions: ['.jpg'],
|
109
|
+
folderselect: false,
|
84
110
|
})
|
85
111
|
}
|
112
|
+
|
113
|
+
const fileupload=(file)=>{
|
114
|
+
gapi.load('auth', {'callback': onAuthLoad});
|
115
|
+
}
|
116
|
+
const onAuthLoad=()=> {
|
117
|
+
window.gapi.auth.authorize(
|
118
|
+
{
|
119
|
+
'client_id': clientId,
|
120
|
+
'scope': scope,
|
121
|
+
'immediate': false
|
122
|
+
},
|
123
|
+
handleAuth);
|
124
|
+
}
|
125
|
+
const handleAuth=(authResult)=> {
|
126
|
+
if (authResult && !authResult.error) {
|
127
|
+
showuploadloading()
|
128
|
+
var formData = new FormData();
|
129
|
+
const fileToUpload = file
|
130
|
+
var metadata = {
|
131
|
+
name: fileToUpload.name,
|
132
|
+
mimeType: fileToUpload.type
|
133
|
+
};
|
134
|
+
formData.append( "metadata", new Blob( [JSON.stringify( metadata )], {type: "application/json"} ));
|
135
|
+
formData.append( "file", fileToUpload );
|
136
|
+
fetch( "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", {
|
137
|
+
method: "POST",
|
138
|
+
headers: new Headers({ "Authorization": "Bearer " + gapi.auth.getToken().access_token }),
|
139
|
+
body: formData
|
140
|
+
}).then( function( response ){
|
141
|
+
stopuploadloading()
|
142
|
+
return response.json();
|
143
|
+
|
144
|
+
}).then( function( value ){
|
145
|
+
stopuploadloading()
|
146
|
+
showmessage()
|
147
|
+
});
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appscms-tools-theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vivek-appscms
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|