robhor Posted January 26, 2013 Posted January 26, 2013 Hey, I was experimenting with workflows that allowed "drilling down" into an result to provide more options, and here's what I came up with. Firstly, a workflow that uses omdbapi.com to search for movies, actioning a result shows you more information and actions. Download: here or via AlfPT As a second workflow using this I built an alternative client workflow to Tom Hunt's Alfred Workflow repository. It has some performance improvements over the "official" AlfPT workflow, and a few extras like updating all workflows, uninstalling and opening workflow folder from within the workflow. Download: here or via AlfPT thec13, phyllisstein, epogue and 7 others 10
phyllisstein Posted January 26, 2013 Posted January 26, 2013 This is absolutely brilliant. I've been trying to accomplish much the same thing in Python but have only run up against difficulties. Ruby, though, is a totally foreign language to me—would I be a huge wang if I asked you to explain how it works?
palobo Posted January 26, 2013 Posted January 26, 2013 Totallly...bloody...awesome. I've often thought about something similar (not the workflows but the functionality), just never had time to really dig in, so I'm with phyllistein on this one... Please enlighten the masses.
MrClaye Posted January 26, 2013 Posted January 26, 2013 This is AWEMAZING ! However there's something wrong with the "workflow manager" : it doesn't recognize all my workflows. I need to reinstall them with the manager for being able to see them in the Installed Workflows list.
alfredo Posted January 26, 2013 Posted January 26, 2013 Awesome, I was also experimenting with something similar. I would really like to see this functionality supported in the workflow editor.
robhor Posted January 26, 2013 Author Posted January 26, 2013 … I've been trying to accomplish much the same thing in Python but have only run up against difficulties. Ruby, though, is a totally foreign language to me—would I be a huge wang if I asked you to explain how it works? … I'm with phyllistein on this one... Please enlighten the masses. Sure, I'll explain it kind of conceptually what's going on and how it's implemented. The three key factors here: * Building paths using a separator character (➣) in the query * Autocompletion to help build those paths * Using ids in the path Based on the current "path" in the query i decide what results to show. So if nothing has been entered yet, in the case of the workflow repository one, i show the 4 main menu entries, each of which autocompletes to a defined Tag + the separator. The next invocation of the script might be with the query "Browse ➣ ". In that case I present all workflows, each of which autocompletes to "Browse ➣ (bundle id of workflow) ➣ " I use the bundle id in the path because the next menu needs to know what you chose. For the movie workflow I use the IMDb-ID. It would be prettier if I could use "Shutter Island ➣ " in the path, but sadly that isn't unique enough. It would also allow deleting the separator character with backspace and thereby going back to the previous menu and still get sensible results back (as the query would then be "Shutter Island" and not "tt1130884", the IMDb-ID). But the query string is the only transfer mechanism we have to determine what item has been chosen. For more information on how do the autocompletion check this out (basically, set valid="no" and autocomplete="your path" on an item) So far for the concept. On the implementation side i have the helper module AlfredFeedback. In there I have helper functions "get_path" and "get_query". get_query returns the very last part of the actual query-string given to the script get_path returns the current path as an array So for example "Installed ➣ com.linuslundahl.alfred.phpfunctionsapi ➣ open" would result in get_path: ["Installed", "com.linuslundahl.alfred.phpfunctionsapi"] get_query "open" These help in deciding what items to present. (In that example, I check if path is two segments long, which would mean I'm in the submenu for a workflow. The last segment is the bundle id of the chosen workflow and I show the "back", "update", "uninstall" and "open workflow folder" items. I apply get_query as a filter so that only the "open workflow folder" item remains) Next I have a simple class called Item that just holds all the information for an feedback result item (title, subtitle, icon, arg, …) Extending that I have a class called Menu. These are the items that bring you to a submenu. They have their autocomplete-attribute automatically set to the current path + the argument of that item + separator, and valid to "no". Lastly I have the class Feedback, which gathers Items (and Menus) with add_item and add_menu methods. (I also have .fixed_order in there, which automatically gives the items an uid of timestamp + index in item list, thereby the items are always presented in the order they are specified) (And .autofilter, which takes the query to filter the items before printing them out if set) After that just print out the feedback.to_xml As for allowing different kinds of action on an item: I use argument-strings in the form of "(action):(parameter)". In the movie workflow I have a whole bunch of actions for showing an image, opening URLs, showing large text, .. This argument-string is passed to an output-script and appropriate action is taken. phyllisstein, Weaselboy and thec13 3
CarlosNZ Posted January 27, 2013 Posted January 27, 2013 Wow. Can I also just chime in to say that that Alfred repo workflow is awesome. Finally, the repo is useable to me now. Great job! Weaselboy 1
phyllisstein Posted January 27, 2013 Posted January 27, 2013 Sure, I'll explain it kind of conceptually what's going on and how it's implemented. Totally awesome. Thanks for the explanation! I'm going to read through it a couple of times tomorrow and see if something doesn't spark. Terrific work.
CarlosNZ Posted January 27, 2013 Posted January 27, 2013 (edited) One suggestion for the Repo workflow, if I may: It would be good for the "Install" list to have an "hide" option (maybe be "option-click" on the selection) for items we don't want to see any more. Might be a way to keep the list from blossoming to unwieldy levels. (Alfred 2's still in beta, and it's already impressively large! ) Edit: Sorry, just one more quick thing - is there anyway to specify the time before the workflow attempts to acquire new data rather than just relying on the cache? Personally, I don't see a need for a fresh check any more often than 2-3 hours. Edited January 27, 2013 by CarlosNZ
robhor Posted January 27, 2013 Author Posted January 27, 2013 One suggestion for the Repo workflow, if I may: It would be good for the "Install" list to have an "hide" option (maybe be "option-click" on the selection) for items we don't want to see any more. Might be a way to keep the list from blossoming to unwieldy levels. (Alfred 2's still in beta, and it's already impressively large! ) Good suggestion! Option-click doesn't work very well with this type of menu, as I can only set one modifier subtext for every item in the whole workflow, including the menus (eg. "Browse"). I could set it to "Alternative action", which I find too non-descriptive, and isn't even true for items that don't provide an alternative action. Instead, the "hide" option is now available when drilling down into a workflow in "Browse" and "Installed". I want to keep installing and updating quick, so I won't drill down on pressing enter when in those menus, but I found something new: You can now press Tab to drill down into a workflow, even in the "Install" menu. Hidden workflows can still be found in "Browse > Hidden" Edit: Sorry, just one more quick thing - is there anyway to specify the time before the workflow attempts to acquire new data rather than just relying on the cache? Personally, I don't see a need for a fresh check any more often than 2-3 hours. Yep, you can set the timeout in the config file here: ~/Library/Application Support/Alfred 2/Workflow Data/at.robhor.alfred.alfredrepo/config In there, you'll find max_cache_age, set it to how many seconds you'd like, eg. 7200 for 2 hours Updated workflow found in the usual places… AlfPT or in itself or via updated link in the original post ---- Based on a request I've added some rotten tomatoes data to the movies workflow: Weaselboy 1
Weaselboy Posted January 27, 2013 Posted January 27, 2013 Thanks for the update. The Rotten Tomato info is a nice addition.
hankydysplasia Posted January 28, 2013 Posted January 28, 2013 Based on a request I've added some rotten tomatoes data to the movies workflow: Thanks!
ClintonStrong Posted January 29, 2013 Posted January 29, 2013 Great job on the Alfred Repo workflow. I just had one problem. When I ran it, following error occurred: ./lib.rb:91:in `installed_workflows': undefined method `[]' for nil:NilClass (NoMethodError) from ./lib.rb:90:in `each' from ./lib.rb:90:in `installed_workflows' from ./lib.rb:127 from repo.rb:3:in `require' from repo.rb:3 Turns out one of my installed workflows' info.plist files was empty (0 KB). No idea how that happened (I doubt it's typical), just thought I'd let you know.
phyllisstein Posted January 29, 2013 Posted January 29, 2013 Great job on the Alfred Repo workflow. I just had one problem. When I ran it, following error occurred: ./lib.rb:91:in `installed_workflows': undefined method `[]' for nil:NilClass (NoMethodError) from ./lib.rb:90:in `each' from ./lib.rb:90:in `installed_workflows' from ./lib.rb:127 from repo.rb:3:in `require' from repo.rb:3 Turns out one of my installed workflows' info.plist files was empty (0 KB). No idea how that happened (I doubt it's typical), just thought I'd let you know. I wouldn't be so sure it's atypical—turned out that's why it wasn't working for me, too. It broke after I updated a YouTube workflow and the folder filled with corrupted data. Deleting the offending folder solved the problem.
CarlosNZ Posted January 29, 2013 Posted January 29, 2013 Is it just me or has the latest Alfred beta messed this up somewhat? When I hit "Tab" on a workflow name, it used to drill down to provide options ("hide" etc.). Now the existing Alfred field (ie. "repo Install ➣" is just highlighted and nothing happens.
robhor Posted January 29, 2013 Author Posted January 29, 2013 Great job on the Alfred Repo workflow. I just had one problem. When I ran it, following error occurred: ./lib.rb:91:in `installed_workflows': undefined method `[]' for nil:NilClass (NoMethodError) from ./lib.rb:90:in `each' from ./lib.rb:90:in `installed_workflows' from ./lib.rb:127 from repo.rb:3:in `require' from repo.rb:3 Turns out one of my installed workflows' info.plist files was empty (0 KB). No idea how that happened (I doubt it's typical), just thought I'd let you know. I wouldn't be so sure it's atypical—turned out that's why it wasn't working for me, too. It broke after I updated a YouTube workflow and the folder filled with corrupted data. Deleting the offending folder solved the problem. Thanks, I updated the workflow to protect against that! Is it just me or has the latest Alfred beta messed this up somewhat? When I hit "Tab" on a workflow name, it used to drill down to provide options ("hide" etc.). Now the existing Alfred field (ie. "repo Install ➣" is just highlighted and nothing happens. Still works for me (on b94)
CarlosNZ Posted January 29, 2013 Posted January 29, 2013 Still works for me (on b94) Okay, that's interesting. I have "tab" as my key for actioning items in Alfred, rather than the default right-arrow. And so "tab" was now highlighting the text instead of drilling down in this workflow. However, if I change it to the default key, it works fine with tab. Still seems odd though; might mention it to Andrew and see what the intention of this changed "tab" behaviour is.
Juuro Posted February 6, 2013 Posted February 6, 2013 When I try to use the movie workflow I get the following error in the console: [ERROR] Script XML Parse Error occured Error Domain=NSXMLParserErrorDomain Code=42 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 42.)" The workflow isn't working at all. It feels like if I'm typing something with a result it falls back to the standard Alfred Google search: I'm using b112.
robhor Posted February 6, 2013 Author Posted February 6, 2013 When I try to use the movie workflow I get the following error in the console: [ERROR] Script XML Parse Error occured Error Domain=NSXMLParserErrorDomain Code=42 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 42.)" The workflow isn't working at all. It feels like if I'm typing something with a result it falls back to the standard Alfred Google search: Thanks, I've updated the workflow, should be fixed now! CarlosNZ 1
Martin Posted February 12, 2013 Posted February 12, 2013 Thanks a lot for this! I can't seem to the past the "updating cache" today? Is the repo still working?
Juuro Posted February 12, 2013 Posted February 12, 2013 Thanks, I've updated the workflow, should be fixed now! Thanks! It works now! Great workflow(s), by the way! ;-)
Carlos-Sz Posted February 25, 2013 Posted February 25, 2013 The drill-down is a great concept. I’m playing with recent Finder items and I used the concept: Selecting “Applications”, for example, will load a list of recent apps: At this point you can search the app by typing something. However if you hit delete (backspace) once, removing the space after the arrow symbol, the workflow will go back to its initial list (first screenshot). Initially I thought that I could only use “search” Alfred 2 script command. However, right now the search command will only highlight the text in an existing Alfred 2 window. I was expecting that I could use this command to overwrite the current Alfred 2 text. Anyway, I still use the search command. However, after it the workflow pastes the keyword and the list is back to its initial state. All that using AppleScript. It would be smoother (code cleaner) if Alfred 2 “search” command would work the same way with or without its window showing. Anyway, this workaround does the job in a smooth way, without flickering. Note: this workflow is still a work in progress, not ready for a public release.
Jono Posted February 25, 2013 Posted February 25, 2013 The drill-down is a great concept. I’m playing with recent Finder items and I used the concept: Selecting “Applications”, for example, will load a list of recent apps: At this point you can search the app by typing something. However if you hit delete (backspace) once, removing the space after the arrow symbol, the workflow will go back to its initial list (first screenshot). Initially I thought that I could only use “search” Alfred 2 script command. However, right now the search command will only highlight the text in an existing Alfred 2 window. I was expecting that I could use this command to overwrite the current Alfred 2 text. Anyway, I still use the search command. However, after it the workflow pastes the keyword and the list is back to its initial state. All that using AppleScript. It would be smoother (code cleaner) if Alfred 2 “search” command would work the same way with or without its window showing. Anyway, this workaround does the job in a smooth way, without flickering. Note: this workflow is still a work in progress, not ready for a public release. Looks good, looking forward to it
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now