From 55ba7d2d916927209c140f3fa6ed5a32e44dd46b Mon Sep 17 00:00:00 2001 From: Alex Zai Date: Sat, 23 Apr 2016 10:45:41 -0700 Subject: [PATCH 1/5] (feat) can create docs, sheets, slides, forms --- src/config.py | 37 ++++++++++++++++++++- src/drive_api.py | 48 ++++++++++++++++++++++++++-- src/drive_launcher.py | 8 +++++ src/icons/{docs.png => doc.png} | Bin src/icons/form.png | Bin 0 -> 12659 bytes src/icons/{sheets.png => sheet.png} | Bin src/icons/{slides.png => slide.png} | Bin src/util.py | 8 +++-- 8 files changed, 94 insertions(+), 7 deletions(-) rename src/icons/{docs.png => doc.png} (100%) create mode 100644 src/icons/form.png rename src/icons/{sheets.png => sheet.png} (100%) rename src/icons/{slides.png => slide.png} (100%) diff --git a/src/config.py b/src/config.py index eabb04e..1ea3c05 100644 --- a/src/config.py +++ b/src/config.py @@ -3,16 +3,24 @@ CLIENT_ID = '978117856621-tvpnqtr02b8u0bgnh75sqb1loq1f5527.apps.googleusercontent.com' CLIENT_SECRET = 'rty2NIATZfWFWSDX-XPs2usX' -SCOPE = 'https://www.googleapis.com/auth/drive.readonly' +SCOPE = 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.appdata https://www.googleapis.com/auth/drive.file' REDIRECT_URI = 'http://127.0.0.1:1337' AUTH_URL = 'https://accounts.google.com/o/oauth2/auth?scope=%(scope)s&redirect_uri=%(redirect_uri)s&response_type=code&client_id=%(client_id)s&access_type=offline&approval_prompt=force' % {'scope' : SCOPE, 'redirect_uri' : REDIRECT_URI, 'client_id' : CLIENT_ID} TOKEN_URL = 'https://www.googleapis.com/oauth2/v3/token' FILES_URL = 'https://www.googleapis.com/drive/v2/files?maxResults=1000&q=mimeType%3D%22application%2Fvnd.google-apps.document%22+or+mimeType%3D%22application%2Fvnd.google-apps.spreadsheet%22+or+mimeType%3D%22application%2Fvnd.google-apps.presentation%22&fields=items,nextPageToken' +CREATE_URL = 'https://www.googleapis.com/drive/v3/files?fields=webViewLink' CACHE_MAX_AGE = 60*60*24*30 # cache set to 1 month +MIMETYPES = { + 'DOC' : 'application/vnd.google-apps.document', + 'SHEET' : 'application/vnd.google-apps.spreadsheet', + 'SLIDE' : 'application/vnd.google-apps.presentation', + 'FORM' : 'application/vnd.google-apps.form' +} + SETTINGS = { 'LOGIN' : { 'title' : 'Login', @@ -40,6 +48,33 @@ } } +CREATE_SETTINGS = { + 'DOC' : { + 'title' : 'Create Google Doc', + 'autocomplete' : '> Create Google Doc', + 'arg' : 'create_doc', + 'icon' : './icons/doc.png' + }, + 'SHEET' : { + 'title' : 'Create Google Sheet', + 'autocomplete' : '> Create Google Sheet', + 'arg' : 'create_sheet', + 'icon' : './icons/sheet.png' + }, + 'SLIDE' : { + 'title' : 'Create Google Slide', + 'autocomplete' : '> Create Google Slide', + 'arg' : 'create_slide', + 'icon' : './icons/slide.png' + }, + 'FORM' : { + 'title' : 'Create Google Form', + 'autocomplete' : '> Create Google Form', + 'arg' : 'create_form', + 'icon' : './icons/form.png' + } +} + OPTIONS = [ { 'title' : 'Search Google Drive', diff --git a/src/drive_api.py b/src/drive_api.py index b4d1f66..5c6cf66 100644 --- a/src/drive_api.py +++ b/src/drive_api.py @@ -1,10 +1,10 @@ import json import subprocess -from config import CLIENT_ID, CLIENT_SECRET, SCOPE, REDIRECT_URI, FILES_URL, AUTH_URL, TOKEN_URL, TOKEN_URL, CACHE_MAX_AGE, ERRORS, OPTIONS, SETTINGS +from config import * import requests import util from time import sleep -from workflow import Workflow, ICON_EJECT, ICON_ACCOUNT, ICON_BURN, ICON_CLOCK, ICON_WARNING, PasswordNotFound +from workflow import * from workflow.background import is_running, run_in_background UPDATE_SETTINGS = {'github_slug' : 'azai91/alfred-drive-workflow'} HELP_URL = 'https://github.com/azai91/alfred-drive-workflow/issues' @@ -29,7 +29,6 @@ def exchange_tokens(cls, code): Store tokens in workflow """ - response = requests.post(TOKEN_URL, { 'code': code, 'client_id' : CLIENT_ID, @@ -137,6 +136,7 @@ def show_options(cls): for option in OPTIONS: wf.add_item(title=option['title'], autocomplete=option['autocomplete']) + wf.send_feedback() @classmethod @@ -157,6 +157,17 @@ def show_settings(cls, user_input): if 'set cache length'.startswith(user_input[:16].lower()): cls.show_set_cache_length(user_input[17:]) + # if account is already set + if wf.get_password('drive_access_token'): + if 'create google doc'.startswith(user_input.lower()): + cls.show_create_setting('DOC') + if 'create google sheet'.startswith(user_input.lower()): + cls.show_create_setting('SHEET') + if 'create google slide'.startswith(user_input.lower()): + cls.show_create_setting('SLIDE') + if 'create google form'.startswith(user_input.lower()): + cls.show_create_setting('FORM') + if len(wf._items) == 0: cls.show_error('InvalidOption') @@ -172,6 +183,17 @@ def show_setting(cls, setting): autocomplete=SETTINGS[setting]['autocomplete'], valid=True) + @classmethod + def show_create_setting(cls, setting): + """Show settings""" + + wf.add_item(title=CREATE_SETTINGS[setting]['title'], + arg=CREATE_SETTINGS[setting]['arg'], + icon=CREATE_SETTINGS[setting]['icon'], + autocomplete=CREATE_SETTINGS[setting]['autocomplete'], + valid=True) + + @classmethod def show_set_cache_length(cls, length): """Show set cache length setting""" @@ -228,3 +250,23 @@ def add_items(cls, links): icon=icon, valid=True) + @classmethod + def create_file(cls, type): + """ + Returns: + a list of all spreadsheets and documents from Google Drive + """ + + access_token = wf.get_password('drive_access_token') + headers = { + 'Authorization' : 'Bearer %s' % access_token, + 'Content-Type': 'application/json' + } + response = requests.post(CREATE_URL, headers=headers, data=json.dumps({ + 'mimeType' : MIMETYPES[type] + })).json() + + return response['webViewLink'] + + + diff --git a/src/drive_launcher.py b/src/drive_launcher.py index e67cf7a..401e109 100644 --- a/src/drive_launcher.py +++ b/src/drive_launcher.py @@ -18,6 +18,14 @@ def main(wf): elif url == 'clear': Drive.clear_cache() return sys.stdout.write('cache cleared') + elif url == 'create_doc': + url = Drive.create_file('DOC') + elif url == 'create_sheet': + url = Drive.create_file('SHEET') + elif url == 'create_slide': + url = Drive.create_file('SLIDE') + elif url == 'create_form': + url = Drive.create_file('FORM') elif url.startswith('set'): length = int(url[3:]) Drive.set_cache_length(length) diff --git a/src/icons/docs.png b/src/icons/doc.png similarity index 100% rename from src/icons/docs.png rename to src/icons/doc.png diff --git a/src/icons/form.png b/src/icons/form.png new file mode 100644 index 0000000000000000000000000000000000000000..11b56128eacfc289e30bacbd4be6a24bcf030f28 GIT binary patch literal 12659 zcma*Nc|25K{6BtXY$Mx@B_bJ1krGmtEHko3QBf)}w5f=MD9eoOduUN;q(#V5_QZ@O zM3RIg#x7f9H^Z3wz0>>i`#rwj?_XbkjC0RDukHDIzFz0dy%TfX#zJU|^cDbs&=E`1 zlK>#$Arhc?;eX2kKh^=zJaoj=*ggO;TZa&WClMO!k9!)}eDLu9?a$eFc7W@?(h>2d z1^TI#zYLFl^LdZ{@&c-6K>3aSa(Yks+`wu1Jv5bKbN}w6y~}Hkg2>S?#M;6)#@9PL z)RPJ`_t(AE)6wy=Q;*iZ<>Yo*W?FT`D)o)T-iR_wp;IcNE@~H)k!DtB+%Y<*PAFxS z8{cvmte7+ed!tphX6I%3GR7ZjmTmHO3?7R&Y?Ahg)cqT&l6*KBWp@3|>!DHGzFw3z`W_VjD{=C}_-`CNj_WiGs8bAsR6n`$?)3E2M zZDLJ8zF4&fH(C??DXboPd*Y9u{aBRk-k|Rez_=4Dxc8__|Fd6~&-0469?#FLJmc=? z)ziHLJpCd`%seLjZfVf{`NMM?O|Fw3-kx_bc++k6+wcA@XY&=LsMTJRbyM>`UmE*1 zJ56YKT#-A3yKGB#q3t^j?~Ib#yY3J4M&jG|UE-Mj5MHrk`-i3<{C)oC>p~M}z?J}> zFxE$ONF83{p)L1uo)amGTY5)6K0*OS(i>l4Rit5X8`S(oO2_Ng%!CN|lu@@F!}BHM zeE4IX<2)E0C_-T9KXVT#rdonP)iVJ`q* z2{KM6H{@rpPhhMIxuul6UgCp%b1zz#A3L3gpr%4^5UK1`!Sb~@-mWIep$$y5Wm_z% zh$h9p^{LR^R1g?V;AX3}7PPl^xHd|sRDQoXQ=9j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|6-Rs*YSCY;0WU1=JeYUBRpZ`;3-Pd z9sT#;p)L5q%|@>zVWXRiUZUv{E=MnLH3glRH5-a`kL!k57-`Ol1uRw`@QW*4-$nvR)hn24_`RDyx1@y z;S|y{41MD0nsP6l{omK>$rDqlCc2J-q2lpU3QM-34ibK*5wzXiQ`evOwCV{$t~YFh z4;3Sx2z;JF?w6a5jaLc)LYeA)Ih7VTmrSxX1A35&&U__J-~05qBp-T9F~_OBr0if_k}m9%yIG75EN zB^rudOu4j1zes8!d0)TTvwmnAFCG#VJNlQ=C+F@r-A5o3{Aj%&YsY5YR(uL|JL#ZB z;P1u@{V_9Q*yQ|CYg36J>~u_a5ko!3ZHo~3htS<1uC3;152v!d4sW5j(c-QWF58FPjHA%s^Bq6CwQ;b$`s}kYk+od|A3Sdti0;zK z8jt+B{NYDwA-8!Y&n2_s>96ohrYD$%Sf6dbKR(^~aiMQ$r|c;iec$&(QFQ+V*+jnm zZDD_Kh}h`p=<>#{Uj`|K>{Pm WYH#D>Zce~Dz!5VW)560p_x=~fXd2uA literal 0 HcmV?d00001 diff --git a/src/icons/sheets.png b/src/icons/sheet.png similarity index 100% rename from src/icons/sheets.png rename to src/icons/sheet.png diff --git a/src/icons/slides.png b/src/icons/slide.png similarity index 100% rename from src/icons/slides.png rename to src/icons/slide.png diff --git a/src/util.py b/src/util.py index f38fb26..132dbef 100644 --- a/src/util.py +++ b/src/util.py @@ -16,9 +16,11 @@ def internet_on(): def find_icon(link): if link['mimeType'] == 'application/vnd.google-apps.document': - icon = './icons/docs.png' + icon = './icons/doc.png' elif link['mimeType'] == 'application/vnd.google-apps.spreadsheet': - icon = './icons/sheets.png' + icon = './icons/sheet.png' elif link['mimeType'] == 'application/vnd.google-apps.presentation': - icon = './icons/slides.png' + icon = './icons/slide.png' + elif link['mimeType'] == 'application/vnd.google-apps.form': + icon = './icons/slide.png' return icon From 57d5313c3f5ce3c5d488414c8f86e7cc8fc70e56 Mon Sep 17 00:00:00 2001 From: Alex Zai Date: Sat, 23 Apr 2016 11:10:44 -0700 Subject: [PATCH 2/5] (feat) can load pdfs --- src/config.py | 7 ++++--- src/icons/pdf.png | Bin 0 -> 21640 bytes src/util.py | 6 +++++- src/version | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 src/icons/pdf.png diff --git a/src/config.py b/src/config.py index 1ea3c05..ead3f8d 100644 --- a/src/config.py +++ b/src/config.py @@ -1,16 +1,17 @@ - +import urllib from workflow import ICON_ACCOUNT, ICON_EJECT, ICON_WARNING, ICON_SYNC, ICON_CLOCK CLIENT_ID = '978117856621-tvpnqtr02b8u0bgnh75sqb1loq1f5527.apps.googleusercontent.com' CLIENT_SECRET = 'rty2NIATZfWFWSDX-XPs2usX' SCOPE = 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.appdata https://www.googleapis.com/auth/drive.file' +FILTER = urllib.quote("mimeType='application/vnd.google-apps.document' or mimeType='application/vnd.google-apps.spreadsheet' or mimeType='application/vnd.google-apps.presentation' or mimeType='application/vnd.google-apps.form' or mimeType='application/pdf'") REDIRECT_URI = 'http://127.0.0.1:1337' AUTH_URL = 'https://accounts.google.com/o/oauth2/auth?scope=%(scope)s&redirect_uri=%(redirect_uri)s&response_type=code&client_id=%(client_id)s&access_type=offline&approval_prompt=force' % {'scope' : SCOPE, 'redirect_uri' : REDIRECT_URI, 'client_id' : CLIENT_ID} TOKEN_URL = 'https://www.googleapis.com/oauth2/v3/token' -FILES_URL = 'https://www.googleapis.com/drive/v2/files?maxResults=1000&q=mimeType%3D%22application%2Fvnd.google-apps.document%22+or+mimeType%3D%22application%2Fvnd.google-apps.spreadsheet%22+or+mimeType%3D%22application%2Fvnd.google-apps.presentation%22&fields=items,nextPageToken' -CREATE_URL = 'https://www.googleapis.com/drive/v3/files?fields=webViewLink' +FILES_URL = 'https://www.googleapis.com/drive/v2/files?maxResults=1000&q=%(filter)s&fields=items,nextPageToken' % {'filter' : FILTER} +CREATE_URL = 'https://www.googleapis.com/drive/v3/files?fields=webViewLink' CACHE_MAX_AGE = 60*60*24*30 # cache set to 1 month diff --git a/src/icons/pdf.png b/src/icons/pdf.png new file mode 100644 index 0000000000000000000000000000000000000000..8fd2d287766672be8ffef5f02cb93fc8974ec67f GIT binary patch literal 21640 zcmbT8V|OLZ*T!SpwlT47OzdQ0PHa0lnP6hu&Pj46oY=N)I}mpF zLf5|bZ||z^NEIa+WCQ{PFfcG=Iax_HFfeeY|4ulVuRGrUvF=|NC|7Yg4Y;qv56(OS z42%p+PEt(6EBm6uw}E;^m-Jz+ZL;O@;i7Y6jzb958clY1u`eP4Tr8vxhp~rIcMzjz zn=C5@8*)ZAI+|;4BQZt>2*hKdfW|*0r%ePY?mqpoOA5n)V@HWhA;W?4j*sV*o!gi_ z7GiOKylZ>i^qs885vlZ82)J_8Uhtl8xj%D%$yN8gx_Yftx-jzJY9@unV>Rv$0*8b_ z`hOLG9LsgcI#jvspR|{oXoR(Wcw30VFSo`_94tX}pEyIVVC}r$ToO^p0TD~`lA9gF z2oPv=Q!&n>cvtwRzadZtEl&ogzvZZP?K~r#nWfs>3%ysOe(dGh(l~Wj?ueo-w!D5; z!LAfklY;jVHt{saPLh#90SVW|0lrXBP!PBY6k7{A>5l3DI;qq!cm~fRZhTm!lE5G( z42j79$v}+6S4F+VdBcw*8W|!M5MwM0dq6CCJ_8C$TJJ5QOAF}ca=MEN$5^^RJpXM1ftn!4R_D_HTB zW(z%7ZGL{J!;8ZL@t*3Cj|r>-Plp2IH=JL))|S`3_9l+<`X*`vpzCe5gZ*Hf4AHO| z+lCnC?kkrUGl-F){v3`jM2JAL?jmIw)8+*{wgvwAGY$TINDqB6BhP0H^)_cMAWe~$ zwkB5~bY+2&Ukq8t7VyS~5+r6EY9;a+=Gk$kjcYL%^6R0q z&!Z)n7I}gR<_kiebdInRaeXkjdbz@}TMSCoLF`=(SZNmGp1e)F5`MKyD6896IN|Qy zF1sh4o#RioxO(obP$$)C5`sKF7Bb24T?>3J5|8+Nd*LvGWxs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GR-^Un1wX;6=Cx5Q5c0)g}_TT;I)VJ8DFgj&prY)Y6 zI}Eq6h&S8N%_e24R@WxxI4y;R=A&ntLvy>CmfFV)H5<8n6sn@Q_Fj9{zve6Vwg>oI zL!ME)i&itCAyilOF)Ke^lM~F`ggXmdr`%b&6gFsIEzV!L^yH{Yb2r>ejdc46LeVbSLZ0TjxUhO~E zzOq3I+6Y?ty9Dw@PzqVVHY6k#69Zh$3r<% l+5a1}`9C Date: Sat, 23 Apr 2016 11:13:33 -0700 Subject: [PATCH 3/5] (feat) render page when loaded authentication works --- src/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.py b/src/server.py index c9afcfc..59b03b1 100644 --- a/src/server.py +++ b/src/server.py @@ -18,7 +18,7 @@ def do_GET(s): subprocess.call(['python','./drive_refresh.py']) sys.stdout.write('Account Saved') logging.info('Account Saved') - # s.wfile.write('Your code has been saved in Alfred') + s.wfile.write('Your code has been saved in Alfred') except: s.wfile.write('Error with setting code') From c5f7c7dd024eb0762e38f444075cdb5e29bc6aad Mon Sep 17 00:00:00 2001 From: Alex Zai Date: Sat, 23 Apr 2016 11:13:56 -0700 Subject: [PATCH 4/5] (feat) dynamically loads create options if signed in --- src/drive_api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/drive_api.py b/src/drive_api.py index 5c6cf66..4f83b62 100644 --- a/src/drive_api.py +++ b/src/drive_api.py @@ -158,7 +158,8 @@ def show_settings(cls, user_input): cls.show_set_cache_length(user_input[17:]) # if account is already set - if wf.get_password('drive_access_token'): + try: + wf.get_password('drive_access_token') if 'create google doc'.startswith(user_input.lower()): cls.show_create_setting('DOC') if 'create google sheet'.startswith(user_input.lower()): @@ -167,6 +168,7 @@ def show_settings(cls, user_input): cls.show_create_setting('SLIDE') if 'create google form'.startswith(user_input.lower()): cls.show_create_setting('FORM') + except: pass if len(wf._items) == 0: cls.show_error('InvalidOption') From f3cf7818c146d7fd687487408c541299822458f1 Mon Sep 17 00:00:00 2001 From: Alex Zai Date: Sat, 23 Apr 2016 11:17:26 -0700 Subject: [PATCH 5/5] (feat) add create files and supported files types --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 726d1c3..c21a160 100644 --- a/README.md +++ b/README.md @@ -31,4 +31,24 @@ Responses from Google Drive API are cached to increase the speed. Use this optio - ```d > set cache [seconds]``` Sets the length of the duration for how long responses are held in cache before a fresh request is made. Default is 3600 seconds (1 hour) +- ```d > Create Google Doc``` +Create Google Doc and opens in default browser + +- ```d > Create Google Sheet``` +Create Google Sheet and opens in default browser + +- ```d > Create Google Slide``` +Create Google Slide and opens in default browser + +- ```d > Create Google Form``` +Create Google Form and opens in default browser + +##Supported files types + +- Google Docs +- Google Sheets +- Google Slides +- Google Forms +- PDFs + ###Please leave issues if you encounter any problems or star this repo if you found it useful :)