Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Add support for cloud tabs on High Sierra closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Oct 22, 2018
1 parent 9bafcbb commit 5aaef43
Show file tree
Hide file tree
Showing 15 changed files with 639 additions and 240 deletions.
1 change: 1 addition & 0 deletions E7C9EB62-33E3-497F-83AF-47702D848406.png
107 changes: 76 additions & 31 deletions README.html

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
Safari Assistant for Alfred 3
=============================

Search and open/activate your Safari bookmark(let)s and tabs from Alfred 3.
Search and open/activate your Safari bookmark(let)s and (iCloud) tabs from Alfred 3.

Includes several actions for tabs/bookmarks and allows you to add your own via scripts. Assign your favourite actions (and bookmarklets) to hotkeys.

<!-- MarkdownTOC autolink="true" bracket="round" depth="3" autoanchor="true" -->
<!-- MarkdownTOC autolink="true" bracket="round" levels="2,3,4" autoanchor="true" -->

- [Download & installation](#download--installation)
- [macOS Mojave](#macos-mojave)
- [Usage](#usage)
- [Configuration](#configuration)
- [Blacklist](#blacklist)
Expand All @@ -29,13 +30,21 @@ Includes several actions for tabs/bookmarks and allows you to add your own via s


<a name="download--installation"></a>
<a id="download--installation"></a>
Download & installation
-----------------------

Grab the workflow from [GitHub releases][download]. Download the `Safari-Assistant-X.X.alfredworkflow` file and double-click it to install.


<a id="macos-mojave"></a>
### macOS Mojave ###

If you're running macOS 10.14 (Mojave), you must [grant Alfred "Full Disk Access"][mojave-tips].


<a name="usage"></a>
<a id="usage"></a>
Usage
-----

Expand Down Expand Up @@ -64,6 +73,9 @@ Usage
- `tab [<query>]` — Search and activate/action Safari tabs.
- `` — Activate the selected tab.
- `⌘↩`, `⌥↩`, `^↩`, `fn↩`, `⇧↩` — As above.
- `itab [<query>]` — Search and open Cloud Tabs from other machines.
- `` — Open the selected tab (URL).
- `⌘↩`, `⌥↩`, `^↩`, `fn↩`, `⇧↩` — As above.
- `safass` — Show help and configuration options.
- `View Help File` — Open the workflow help file.
- `Edit Action Blacklist` — Add/remove actions to blacklist.
Expand All @@ -72,6 +84,7 @@ Usage
- `Visit Forum Thread` — Open the [workflow's thread][forum-thread] on [alfredforum.com](https://www.alfredforum.com/).

<a name="configuration"></a>
<a id="configuration"></a>
Configuration
-------------

Expand Down Expand Up @@ -102,6 +115,7 @@ In either case, press `⌘C` on an action or bookmarklet in Alfred's UI to copy


<a name="blacklist"></a>
<a id="blacklist"></a>
### Blacklist ###

As some of the built-in actions may not be of any interest to some users (e.g. you don't have/use Firefox), they can be blacklisted so they are no longer shown in the list of actions.
Expand All @@ -114,6 +128,7 @@ If you add any actions to the blacklist manually, add one action (file)name per


<a name="action-scripts"></a>
<a id="action-scripts"></a>
Action scripts
--------------

Expand All @@ -135,24 +150,28 @@ If you create a script with the same name (minus extension) as one of the built-


<a name="supported-languages"></a>
<a id="supported-languages"></a>
### Supported languages

The workflow knows to run `.scpt`, `.js`, `.applescript` and `.scptd` scripts via `/usr/bin/osascript`. It can also run any script/program with its executable bit set (it will call these directly).


<a name="script-icons"></a>
<a id="script-icons"></a>
### Script icons

By default, tab scripts get a tab icon and URL scripts a URL one. You can supply a custom icon for any script by saving the icon alongside the script with the same basename (i.e. the same name as the script, only with a different file extension). Supported icon extensions are `.png`, `.icns`, `.jpg`, `.jpeg` and `.gif`.


<a name="built-in-actions"></a>
<a id="built-in-actions"></a>
### Built-in actions

The following actions are built into the workflow, either hard-coded or as bundled scripts (in the `scripts` subdirectory of the workflow).


<a name="tab-actions"></a>
<a id="tab-actions"></a>
#### Tab actions

These actions are available for tabs only.
Expand All @@ -164,6 +183,7 @@ These actions are available for tabs only.


<a name="url-actions"></a>
<a id="url-actions"></a>
#### URL actions

These actions are available for bookmarks and tabs (that have URLs).
Expand All @@ -175,6 +195,7 @@ These actions are available for bookmarks and tabs (that have URLs).


<a name="history"></a>
<a id="history"></a>
History
-------

Expand All @@ -190,6 +211,7 @@ Depending on the speed of your Mac and your own tolerance for slowness, you may


<a name="licensing--thanks"></a>
<a id="licensing--thanks"></a>
Licensing & thanks
------------------

Expand All @@ -211,3 +233,5 @@ The icons are from [Elusive Icons][elusive], [Font Awesome][awesome], [Material
[octicons]: https://octicons.github.com/
[icongen]: http://icons.deanishe.net
[forum-thread]: https://www.alfredforum.com/topic/10921-safari-assistant/
[mojave-tips]: https://www.alfredapp.com/help/getting-started/macos-mojave/

2 changes: 1 addition & 1 deletion actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func Register(action Actionable) error {
urlActions[a.Title()] = a
return nil
}
return fmt.Errorf("Unknown action type : %+v", action)
return fmt.Errorf("unknown action type : %+v", action)
}

// URLActions returns registered URLActions
Expand Down
2 changes: 2 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env zsh

set -e

# Path to this script's directory (i.e. workflow root)
here="$( cd "$( dirname "$0" )"; pwd )"
root="$( cd "$here/../"; pwd )"
Expand Down
47 changes: 47 additions & 0 deletions cloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2018 Dean Jackson <deanishe@deanishe.net>
// MIT Licence applies http://opensource.org/licenses/MIT

package main

import (
"log"

aw "github.com/deanishe/awgo"
"github.com/deanishe/go-safari/cloud"
)

func doFilterCloudTabs() error {

showUpdateStatus()

if err := LoadScripts(scriptDirs...); err != nil {
return err
}

tabs, err := cloud.Tabs()
if err != nil {
return err
}

log.Printf("%d cloud tab(s)", len(tabs))

for _, t := range tabs {
URLerItem(&cloudTabURLer{t})
}

wf.WarnEmpty("No matching tabs found", "Try a different query?")
wf.SendFeedback()

return nil
}

type cloudTabURLer struct {
tab *cloud.Tab
}

func (u *cloudTabURLer) Title() string { return u.tab.Title }
func (u *cloudTabURLer) URL() string { return u.tab.URL }
func (u *cloudTabURLer) UID() string { return u.tab.URL }
func (u *cloudTabURLer) Copytext() string { return u.tab.URL }
func (u *cloudTabURLer) Largetype() string { return u.tab.URL }
func (u *cloudTabURLer) Icon() *aw.Icon { return IconCloud }
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ require (
github.com/DHowett/go-plist v0.0.0-20180609054337-500bd5b9081b // indirect
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deanishe/awgo v0.0.0-20180708154148-fda4e59dbe69
github.com/deanishe/go-safari v0.0.0-20181020143051-15f91b5d844c
github.com/deanishe/go-safari v0.3.1
github.com/juju/deputy v0.0.0-20161007041147-5e10e7deaf1c
github.com/mattn/go-sqlite3 v1.9.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2 // indirect
golang.org/x/text v0.3.0 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
howett.net/plist v0.0.0-20180609054337-500bd5b9081b // indirect
npf.io/deputy v0.0.0-20161007041147-5e10e7deaf1c // indirect
)
16 changes: 14 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5Vpd
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deanishe/awgo v0.0.0-20180708154148-fda4e59dbe69 h1:Kmt/ire64P+C3szOGa7DJ+NaF1fR9bOIZrOQ4kFgjTI=
github.com/deanishe/awgo v0.0.0-20180708154148-fda4e59dbe69/go.mod h1:iS04UkOlaot9B69n8pPeXb804n4vxgDGl3QjXybu4nM=
github.com/deanishe/go-safari v0.0.0-20181020143051-15f91b5d844c h1:/p8hmXqvjROrSoyd1p9kQTpsx0umG7qFoZbwHBNFMno=
github.com/deanishe/go-safari v0.0.0-20181020143051-15f91b5d844c/go.mod h1:EKPpW10YX70yPv6pCvxUH2xHxbkd+EXR010J943NicE=
github.com/deanishe/go-safari v0.0.0-20181022171711-b11c3bee9322 h1:Zbp4ftrMJMx5NqOWcWaH6Fs0V7AqbsQdlUGguTbdiJU=
github.com/deanishe/go-safari v0.0.0-20181022171711-b11c3bee9322/go.mod h1:EKPpW10YX70yPv6pCvxUH2xHxbkd+EXR010J943NicE=
github.com/deanishe/go-safari v0.3.1 h1:2ASV07uLgTtBwLBMEP43Joff+QfgdNy3BYm2H35x+5Q=
github.com/deanishe/go-safari v0.3.1/go.mod h1:EKPpW10YX70yPv6pCvxUH2xHxbkd+EXR010J943NicE=
github.com/juju/deputy v0.0.0-20161007041147-5e10e7deaf1c h1:P2DJ4J0PCWYIiNLjNY/Iq6sk1m/HcvAgVWGyVYRxLns=
github.com/juju/deputy v0.0.0-20161007041147-5e10e7deaf1c/go.mod h1:0CRTVyTLGPTjnUC6o3jNmzJiWmMv+tfKW8saKZ7ihzc=
github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
howett.net/plist v0.0.0-20180609054337-500bd5b9081b h1:r4LwkXZhdblHVSgAvfRjsFpQBorl6S9pAH+AOHVs+28=
howett.net/plist v0.0.0-20180609054337-500bd5b9081b/go.mod h1:jInWmjR7JRkkon4jlLXDZGVEeY/wo3kOOJEWYhNE+9Y=
npf.io/deputy v0.0.0-20161007041147-5e10e7deaf1c h1:UKtgtbhsuzggbLgzwBaVEyGN88lH0JNe9hcprCTzw+I=
npf.io/deputy v0.0.0-20161007041147-5e10e7deaf1c/go.mod h1:RN2eTWdyCHOoSwvZtuTIpRpRoI1tp2RE2PBIYcAEKac=
Binary file added icons/cloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/icons.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bookmark fontawesome 00A1DE bookmark
history fontawesome 00E756 history
folder fontawesome 00A1DE folder
bookmarklet fontawesome 00E756 asterisk
cloud material 00A1DE cloud
url fontawesome 00A1DE globe
tab octicons 00A1DE browser
tab-active octicons F8AC30 browser
Expand Down
Loading

0 comments on commit 5aaef43

Please sign in to comment.