sf-gdrive 0.1.12 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bea772569dca67a5b5866ac45b026b36ba311db4ed71ef32f0e9c9c9eb5bf70c
4
- data.tar.gz: cf7375758c11b092499ccc115702540f5e3cdcb6b77c94c839fba3c763d5f731
3
+ metadata.gz: fb178b930ad9073cfaab265f1f5a4ec88888d527cdfd5ddaeba0aeafc0a94228
4
+ data.tar.gz: 37f90c7fe20e8c8bfd39673a1d44c455016853fe2730f0f811699251245bcd08
5
5
  SHA512:
6
- metadata.gz: 1046fdcfbdeb38aed95321e534b1db655cd58b39e21d164f0448f6381c56faefd12daf93ba2eb5c6418f3c3f207f13ec25af481244f34c6a3584617e47de3588
7
- data.tar.gz: 8228caf3e1213690f96c9b93370e6f5284d0d1edce830c180551664de054c50ea72bf6b67f362586f4b4331e6792e6a5b54a5fbaea648adc6a895308cb8fd35d
6
+ metadata.gz: 8471d5da6288c218fbed80daab32d9cb633488f25440027c9a3b14dbffae2c70f23763763b913d95ca14fd8fe617e79935cf2e35e8f41f4e58bdc8e1df1798ca
7
+ data.tar.gz: c5220ce96f4c27b7736c90dad1982111863ab6b3aacfe22dbea0c5d82d8b7afc208918566f6912237d4cb4d1b6f6fbe9a5a360e2753cfaf97731412a8e7a48ce
@@ -24,7 +24,7 @@ module Gdrive
24
24
  auth_client.fetch_access_token!
25
25
  secret_hash = auth_client.as_json.slice("expiry", "refresh_token", "access_token")
26
26
  if secret_hash["refresh_token"] == nil
27
- @error = 'You have already authorized this application. In order to re-configure, go to <a href="https://myaccount.google.com/permissions">https://myaccount.google.com/permissions</a> and revoke access to "Standard File".'
27
+ @error = 'You have already authorized this application. In order to re-configure, go to <a href="https://myaccount.google.com/permissions">https://myaccount.google.com/permissions</a> and revoke access to "Standard Notes".'
28
28
  else
29
29
  secret_hash[:expires_at] = auth_client.expires_at
30
30
  secret = Base64.encode64(secret_hash.to_json)
@@ -36,119 +36,5 @@ module Gdrive
36
36
  end
37
37
  end
38
38
  end
39
-
40
- def decrypt_temp_file
41
- require 'open-uri'
42
- content = open('https://raw.githubusercontent.com/standardfile/decrypt-html-page/master/decrypt.html').read
43
- tmp = Tempfile.new("decrypt")
44
- tmp.write(content)
45
- tmp.rewind
46
- return tmp
47
- end
48
-
49
- def sync_decrypt_file(drive, folder)
50
- file_name = "decrypt.html"
51
- existing = drive.list_files(q: "name = '#{file_name}'", fields: "files(id, name, created_time)")
52
- if existing.files.length > 0
53
- file = existing.files[0]
54
- days_old = DateTime.now - file.created_time
55
- if days_old < 14
56
- return
57
- end
58
- drive.update_file(file.id, upload_source: decrypt_temp_file().path)
59
- else
60
- drive.create_file({:name => file_name, :parents => [folder.id]}, upload_source: decrypt_temp_file().path, content_type: "text/html")
61
- end
62
- end
63
-
64
- def find_or_create_folder(drive, folder_name, parent_folder)
65
- folder_mime = "application/vnd.google-apps.folder"
66
- folder_search = nil
67
- begin
68
- if parent_folder
69
- folder_search = drive.list_files(q: "mimeType='#{folder_mime}' and name='#{folder_name}' and parents in '#{parent_folder.id}'")
70
- else
71
- folder_search = drive.list_files(q: "mimeType='#{folder_mime}' and name='#{folder_name}'")
72
- end
73
- rescue Exception => e
74
- puts "\n\n find_or_create_folder exception: #{e}\n\n"
75
- return
76
- end
77
-
78
- if folder_search.files.length > 0
79
- folder = folder_search.files[0]
80
- else
81
- folder_data = {
82
- name: folder_name,
83
- mime_type: folder_mime
84
- }
85
- if parent_folder
86
- folder_data[:parents] = [parent_folder.id]
87
- end
88
- folder = drive.create_file(folder_data, fields: 'id')
89
- end
90
-
91
- return folder
92
- end
93
-
94
- def sync
95
- client_secrets = Google::APIClient::ClientSecrets.load
96
- client_params = client_secrets.to_authorization.as_json
97
- secret_hash = JSON.parse(Base64.decode64(params[:key]))
98
- client_params.merge!(secret_hash)
99
- auth_client = Signet::OAuth2::Client.new(client_params)
100
- drive = Google::Apis::DriveV3::DriveService.new
101
- drive.authorization = auth_client
102
-
103
- parent = nil
104
- folders = ["Standard Notes", "#{Time.current.year}", "#{DateTime.now.strftime("%B")}"]
105
- resolved_folders = []
106
- folders.each do |current_folder_name|
107
- result = find_or_create_folder(drive, current_folder_name, parent)
108
- resolved_folders.push(result)
109
- parent = result
110
- end
111
-
112
- folder = resolved_folders.last
113
-
114
- self.sync_decrypt_file(drive, resolved_folders.first)
115
-
116
- auth_params = params[:auth_params]
117
- items = params[:items]
118
- if items && items.length > 0
119
- tmp = Tempfile.new(SecureRandom.hex)
120
- payload = { "items" => items}
121
- payload["auth_params"] = auth_params if auth_params != nil
122
- tmp.write("#{JSON.pretty_generate(payload.as_json)}")
123
- tmp.rewind
124
-
125
- file_name = "#{DateTime.now.strftime("%B %-d, %Y").sub(',', '')}.txt"
126
- existing = drive.list_files(q: "name = '#{file_name}'")
127
- if existing.files.length > 0
128
- file = existing.files[0]
129
- drive.update_file(file.id, upload_source: tmp.path)
130
- else
131
- file = drive.create_file({:name => file_name, :parents => [folder.id]}, upload_source: tmp.path, content_type: "text/plain")
132
- end
133
- end
134
- rescue Signet::AuthorizationError => _e
135
- render(
136
- json: {
137
- error: {
138
- message: 'Could not authorize with Google Drive. Please verify your integration.'
139
- }
140
- },
141
- status: :bad_request
142
- )
143
- rescue Google::Apis::Error => _e
144
- render(
145
- json: {
146
- error: {
147
- message: 'Could not sync with Google Drive. Please verify your integration.'
148
- }
149
- },
150
- status: :bad_request
151
- )
152
- end
153
39
  end
154
40
  end
@@ -1,23 +1,9 @@
1
1
  <h1> Google Drive Data Backup </h1>
2
2
 
3
- <p> This Standard File sync adapter creates real-time backups of your data to your Google Drive.</p>
3
+ <p> This extension creates real-time backups of your data to your Google Drive.</p>
4
4
 
5
5
  <% if @secret_url %>
6
6
  <p> Your secret URL is: <strong><%= @secret_url %></strong></p>
7
-
8
- <p>
9
- <strong>To register this sync adapter using your secret URL:</strong>
10
- </p>
11
-
12
- <ol>
13
- <li>In the Standard Notes app, find and click "Account" in the lower left corner.</li>
14
- <li>Click "Standard File Dashboard".</li>
15
- <li>After logging in, click "Sync Adapters" in the left panel.</li>
16
- <li>In the add new section, paste in the secret URL, and submit.</li>
17
- </ol>
18
-
19
- <p>That's it! Now, whenever you make changes to a note or tag, it will automatically be synced to your Drive.<p>
20
-
21
7
  <% elsif @error %>
22
8
  <strong style="color: red;">Error:</strong> <%= @error.html_safe %>
23
9
  <% else %>
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Standard File Google Drive Extension</title>
4
+ <title>Standard Notes Google Drive Extension</title>
5
5
  <%= stylesheet_link_tag "gdrive/application", media: "all" %>
6
6
  <%= javascript_include_tag "gdrive/application" %>
7
7
  <%= csrf_meta_tags %>
data/config/routes.rb CHANGED
@@ -1,6 +1,3 @@
1
1
  Gdrive::Engine.routes.draw do
2
-
3
- post "sync" => "drive#sync"
4
-
5
2
  root "drive#index"
6
3
  end
@@ -1,3 +1,3 @@
1
1
  module Gdrive
2
- VERSION = '0.1.12'
2
+ VERSION = '0.1.16'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sf-gdrive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@StandardNotes"
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-12 00:00:00.000000000 Z
11
+ date: 2022-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,31 +16,31 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.1
19
+ version: '5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.1
26
+ version: '5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: google-api-client
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.25.0
33
+ version: 0.53.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.25.0
41
- description: Google Drive Extension for Standard File/Standard Notes.
40
+ version: 0.53.0
41
+ description: Google Drive Extension for Standard Notes.
42
42
  email:
43
- - mo@standardnotes.org
43
+ - help@standardnotes.com
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
@@ -67,11 +67,11 @@ files:
67
67
  - lib/gdrive/engine.rb
68
68
  - lib/gdrive/version.rb
69
69
  - lib/tasks/gdrive_tasks.rake
70
- homepage: https://standardnotes.org
70
+ homepage: https://standardnotes.com
71
71
  licenses:
72
72
  - GPL-3.0
73
73
  metadata: {}
74
- post_install_message:
74
+ post_install_message:
75
75
  rdoc_options: []
76
76
  require_paths:
77
77
  - lib
@@ -86,8 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubygems_version: 3.0.3
90
- signing_key:
89
+ rubygems_version: 3.0.6
90
+ signing_key:
91
91
  specification_version: 4
92
- summary: Google Drive Extension for Standard File/Standard Notes.
92
+ summary: Google Drive Extension for Standard Notes.
93
93
  test_files: []