Jump to content

Quick Ref - Quickly reference files (e.g. cheat sheets) using quick look


Recommended Posts

Hi,

 

After updating the workflow, I had to go back and change the directory in the script. So, I added to your workflow to save the directory list in a file in the data area for Alfred. I also added "qr:dir"; when you start typing a directory name, it will hunt it for you. Executing it multiple times appends new directories to the list.

 

Loving it and the cheatsheet web site you gave above. Thanks!

 

Download:  https://db.tt/YnXYTkea

Edited by raguay.customct
Link to comment

Thanks for the input regarding the config. I've done some updates and come up with what I think is quite a neat solution.

 

I've also added the ability for it to load web sites links (.webloc) so you can quickly open up and reference material from the internet, which will also mean it's always up to date!

 

Let me know your thoughts on the setup and configuration of it!

Link to comment

Great workflow, but the QL app did not work (perhaps it only works for 10.8 ?), so I replaced it by qlmanage -p '{query}‘, and since the quick-look window is sometimes small, I added a script with a cmd trigger that uses "open" instead of quick-look

Link to comment

That's strange, I did build the QL app for 10.6+, but haven't been able to test it.

 

Are you able to build and run the Xcode project and see what errors it's throwing?

 

The reason I moved away from qlmanage is because it didn't handle previewing web links, which is something I wanted.

Link to comment
  • 3 months later...

How do I get past the "Invalid Configuration.  Press Return to configure quick ref?

 

You should press return and configure the workflow. If you keep getting the error that means either the path you entered is invalid or the changes you made to it have made it no longer valid JSON.

Link to comment
  • 2 months later...

I love this workflow! Currently, I got it working as sort of a library, where I have Delicious Library files inside a folder and have this workflow searching inside that folder.

 

However, I have three feature requestsIs:

 

1. Is there any way to get Swedish letters working? å, ä and ö.

2. I'd love the ability to get the icon of the files to show in Alfred, instead of the QR logo.

3. I don't get the indicator and the scroll to browse through more than the standard 9 results. How come?

 

Cheers!

Edited by sound214
Link to comment

I love this workflow! Currently, I got it working as sort of a library, where I have Delicious Library files inside a folder and have this workflow searching inside that folder.

 

However, I have three feature requestsIs:

 

1. Is there any way to get Swedish letters working? å, ä and ö.

2. I'd love the ability to get the icon of the files to show in Alfred, instead of the QR logo.

3. I don't get the indicator and the scroll to browse through more than the standard 9 results. How come?

 

Cheers!

I'm a bit too drunk to come up with a guaranteed solution, but the reason for (1) is that the workflow is naively mashing ASCII text together with (correct) Unicode data from alfred.py. This is causing Python to try to decode the Unicode text as ASCII and blowing up when it hits å, ä or ö.

 

I know from experience that the alfred.py library handles Unicode properly, so the problem is in mwaterfall's code.

A possible (and very simple) fix is to add:

from __future__ import unicode_literals
to the very top of the files alfred_script_workflow.py and process.py.

 

If that doesn't work, let me know and I can have a closer look tomorrow when I'm sober enough to properly follow code.

WRT (2), change line 81 of process.py from 

icon='icon.png',
to: 

icon=(result, {'type': 'fileicon'}),
That should show the icon of the actual file. (If it doesn't, once again, ask me tomorrow when I'm sober).
Link to comment

Thank you for your suggestions! Sadly, the first one did not work - it's still not letting me search å, ä, and ö. The second one did sort of work, but shows me the icon for the filetype ".delicious3medium". In Finder, however, I see a preview of the cover art of the file. See images for clarification.

 

EDIT: This can be fixed clicking cmd + i and dragging album art to each file, but it's a little tedious to say the least.

 

bild2-1.png

bild1-1.png

 

bild3.png

Edited by sound214
Link to comment

I've had a closer look at the code, and it is a Unicode problem.

Turns out this workflow uses a really old verison of alfred.py. Downloading a newer version from here to replace the buggy one should fix the problem.

Alternatively, you can add the missing normalisation yourself:

At the top of process.py, add import unicodedata alongside the other import statements.

Then in line 51/52, change if query_str: to:

 

if query_str:
   query_str = unicodedata.normalize('NFD', query_str)
With regard to the icons, filetype icons is all you're going to get. Alfred doesn't know how to show file thumbnails/cover art etc. Edited by deanishe
Link to comment

I've had a closer look at the code, and it is a Unicode problem.

Turns out this workflow uses are really old verison of alfred.py. Downloading a newer version from here to replace the buggy one should fix the problem.

Alternatively, you can add the missing normalisation yourself:

At the top of process.py, add import unicodedata alongside the other import statements.

Then in line 51/52, change if query_str: to:

 

if query_str:
   query_str = unicodedata.normalize('NFD', query_str)
With regard to the icons, filetype icons is all you're going to get. Alfred doesn't know how to show file thumbnails/cover art etc.

 

 

 

Changing the alfred.py to the newer one worked out perfectly! Thank you very much!

 

Do you have a solution for my last problem, about not getting an indicator bar and thus not being able to browse more than 9 items?

Edited by sound214
Link to comment

I love this workflow! Currently, I got it working as sort of a library, where I have Delicious Library files inside a folder and have this workflow searching inside that folder.

 

However, I have three feature requestsIs:

 

1. Is there any way to get Swedish letters working? å, ä and ö.

2. I'd love the ability to get the icon of the files to show in Alfred, instead of the QR logo.

3. I don't get the indicator and the scroll to browse through more than the standard 9 results. How come?

 

Cheers!

 

 

I'd be interested in setting this up a folder of ebooks I have - could you let me know how you did it? I changed the directory to my ebooks folder, but I'm getting an error that says the file is an invalid json file so apparently I did something wrong to it :)

Link to comment

Changing the alfred.py to the newer one worked out perfectly! Thank you very much!

 

Do you have a solution for my last problem, about not getting an indicator bar and thus not being able to browse more than 9 items?

The default number of results is limited to 9 in alfred.py. You either need to change _MAX_RESULTS_DEFAULT in that file to a larger number, or xml = alfred.xml(results) to xml = alfred.xml(results, maxresults=50) on line 83 of alfred_script_workflow.py.

Link to comment

I'd be interested in setting this up a folder of ebooks I have - could you let me know how you did it? I changed the directory to my ebooks folder, but I'm getting an error that says the file is an invalid json file so apparently I did something wrong to it :)

No, the configuration setup is broken in the workflow.

If I were you, I'd use a File Filter instead. This workflow is a bit of a mess code-wise, and apparently unmaintained.

Link to comment

No, the configuration setup is broken in the workflow.

If I were you, I'd use a File Filter instead. This workflow is a bit of a mess code-wise, and apparently unmaintained.

 

Okay, thanks for the advice. I'll check out that option :)

Link to comment

Hi Guys, thanks for all the feedback.

 

I'll take a look into the issues and see if I can get them all sorted for you as soon as I can :-)

 

Also, deanishe, the code is certainly not a mess, so I'm not quite sure what's giving you that impression. And as for it being unmaintained, I can assure you it's not. My delay in responding is simply because I have a job and thought it might be nice to go away for the weekend ;-) Hope that's okay. The code is also open source on GitHub, so any contributions or pull requests are most welcome.

Link to comment

Hi Guys, thanks for all the feedback.

 

I'll take a look into the issues and see if I can get them all sorted for you as soon as I can :-)

 

Also, deanishe, the code is certainly not a mess, so I'm not quite sure what's giving you that impression. And as for it being unmaintained, I can assure you it's not. My delay in responding is simply because I have a job and thought it might be nice to go away for the weekend ;-) Hope that's okay. The code is also open source on GitHub, so any contributions or pull requests are most welcome.

Yeah, sorry. "Mess" is too harsh. I just had a hard time making head or tail of it at first. A little sparsely commented for unfamiliar eyes.

My comment regarding maintenance was based on there not having been a commit in ~6 months despite the configuration being broken since at least January.

Again, that was too harsh: It was completely broken for me due to the keyword mix-up, but this is presumably a regression introduced since other users installed it, so not obvious to you/them.

FWIW, a likely reason for the broken configuration files (where they are being correctly created) is that TextEdit will use Smart Quotes by default, thus creating invalid JSON.

I've submitted a pull request on GitHub that fixes the mismatched !config/run_config and !setup/run_setup keywords, updates alfred.py to fix the non-ASCII text matching bug, replaces a lot of the code duplicating functions already in alfred.py, and removes TextEdit as the editor.

I've set it to use the user's default editor for JSON files. This is not ideal, as I'm unsure how that will behave on a system with no proper code editor installed, but using TextEdit is basically guaranteed to mess up the JSON on account of Smart Quotes, and it's not obvious to most users what's going wrong.

I think a better solution would be a plain text file with one directory per line, but that would require significant changes in order to migrate existing users' JSON config files.

Edited by deanishe
Link to comment

I've set it to use the user's default editor for JSON files. This is not ideal, as I'm unsure how that will behave on a system with no proper code editor installed, but using TextEdit is basically guaranteed to mess up the JSON on account of Smart Quotes, and it's not obvious to most users what's going wrong.

I think a better solution would be a plain text file with one directory per line, but that would require significant changes in order to migrate existing users' JSON config files.

 

Nice fixes! The smart quotes problem with JSON will plague users who use textedit by default.

 

There are a couple of ways around this. I'm not sure how/why textedit defaults to rich text (and thus creates the smart quotes). You might be able to search around and see if it's an extended attribute set on the file (or one is set when you change to plain text). If so, you could throw a command into the script to use the xattr command to flag it as plain text.

 

Alternatively, it's not that difficult to use Alfred to generate the JSON with a few config aspect. You could use some applescript dialogs to catch the information (with a config script), or you could just build them in as a series of keywords to grab the values that you need and then write the JSON via a script. That would ensure good JSON.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...