Skip to content

Commit

Permalink
jt - search titles
Browse files Browse the repository at this point in the history
* jt - search titles
  • Loading branch information
skeletonkey committed Nov 27, 2023
1 parent 79b8329 commit d376c1d
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 26 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Find the latest release on the right-hand side of the main [README](https://gith
In Alfred, select the Joplin Workflow and open the Configuration Build (top right, it looks like '(x)').
![Configuration Build](https://github.com/skeletonkey/joplin_alfred_workflow/assets/1487600/650cb170-dd02-4f2b-ad9a-144d17e9e131)

On the Environment Variables tab, provide your token for JOPLIN_TOKEN and ensure that JOPLIN_URL has the correct port.
On the Environment Variables tab, provide your token for JOPLIN_TOKEN and ensure that JOPLIN_URL has the correct Port.
![Env Vars](https://github.com/skeletonkey/joplin_alfred_workflow/assets/1487600/924a089c-492c-4f09-b207-bdba0ae89984)

### Joplin Web Clipper

To use Joplin's API, the Web Clipper needs to be enabled.

This is done by going to Joplin Preferences (Options) -> Web Clipper and enabling the web clipper.
Web Clipper can be enabled by going to Joplin Preferences (Options) -> Web Clipper and enabling the web clipper.
![Joplin Clipper](https://github.com/skeletonkey/joplin_alfred_workflow/assets/1487600/59880df4-e59d-43d9-a27f-ecd1039e72ef)

Note the Port that it is running on and copy your Authorization Token.
Expand All @@ -41,7 +41,7 @@ brew install curl

### Perl

Perl should be installed on your Mac device.
Perl should already be installed on your Mac device.

```bash
brew install perl
Expand All @@ -63,10 +63,18 @@ cpan install JSON

Create a new note and open it in the specified folder.

Currently only an empty note (no title, no body) is created. [Issue #9](https://github.com/skeletonkey/joplin_alfred_workflow/issues/9) has been created to address this shortcoming.
Only an empty note (no title, no body) is created. [Issue #9](https://github.com/skeletonkey/joplin_alfred_workflow/issues/9) has been created to address this shortcoming.

#### js _search words_

Search all of Joplin for the string entered.

*NOTE:* Joplin search operates on 'Words'; therefore, partial strings may not return what you expect.

*BUG* currently, words separated with a space are treated as two tokens with an AND operation instead of one string.

#### jt _search words_

Search Joplin Note Titles for the string entered.

*NOTE:* Joplin search operates on 'Words'; therefore, partial strings may not return what you expect.
114 changes: 94 additions & 20 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
<false/>
</dict>
</array>
<key>37A8BF91-10EC-4879-88A2-976F4EE28959</key>
<array>
<dict>
<key>destinationuid</key>
<string>7ECD89F0-69D5-4743-AAF9-E0C2751C5A6E</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>49E47331-FA4F-4C25-BB08-BB344B51A6D7</key>
<array>
<dict>
Expand Down Expand Up @@ -109,6 +122,31 @@ perl search_notes.pl $query 2&gt;&amp;1</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>query=$1
perl create_note.pl $query</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>11</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>305C4FC4-16E8-40CA-9742-E7CD7C269C37</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand All @@ -133,45 +171,71 @@ perl search_notes.pl $query 2&gt;&amp;1</string>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>alfredfiltersresults</key>
<true/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<true/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>1</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>jn</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string>query=$1
perl create_note.pl $query</string>
perl find_folder.pl $query 2&gt;&amp;1</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>&lt;folder name&gt; Titel of note</string>
<key>title</key>
<string>Create a new note</string>
<key>type</key>
<integer>11</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>305C4FC4-16E8-40CA-9742-E7CD7C269C37</string>
<string>D7C5E8DE-9100-473F-86E2-CF04F3D99F60</string>
<key>version</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<true/>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<true/>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
<integer>1</integer>
<integer>0</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>jn</string>
<string>jt</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
Expand All @@ -181,28 +245,28 @@ perl create_note.pl $query</string>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string></string>
<string>Loading results...</string>
<key>script</key>
<string>query=$1
<string>query=$*
perl find_folder.pl $query 2&gt;&amp;1</string>
perl search_notes.pl -t $query</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>&lt;folder name&gt; Titel of note</string>
<string></string>
<key>title</key>
<string>Create a new note</string>
<string>Joplin: Search Note Titles</string>
<key>type</key>
<integer>11</integer>
<integer>0</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>D7C5E8DE-9100-473F-86E2-CF04F3D99F60</string>
<string>37A8BF91-10EC-4879-88A2-976F4EE28959</string>
<key>version</key>
<integer>3</integer>
</dict>
Expand All @@ -216,10 +280,20 @@ Report issues here: https://github.com/skeletonkey/joplin_alfred_workflow/issues
<key>305C4FC4-16E8-40CA-9742-E7CD7C269C37</key>
<dict>
<key>xpos</key>
<real>285</real>
<real>200</real>
<key>ypos</key>
<real>255</real>
</dict>
<key>37A8BF91-10EC-4879-88A2-976F4EE28959</key>
<dict>
<key>note</key>
<string>Search Note Titles
This is an exact search on what Joplin considers words.</string>
<key>xpos</key>
<real>30</real>
<key>ypos</key>
<real>435</real>
</dict>
<key>49E47331-FA4F-4C25-BB08-BB344B51A6D7</key>
<dict>
<key>note</key>
Expand All @@ -232,9 +306,9 @@ Report issues here: https://github.com/skeletonkey/joplin_alfred_workflow/issues
<key>7ECD89F0-69D5-4743-AAF9-E0C2751C5A6E</key>
<dict>
<key>xpos</key>
<real>535</real>
<real>625</real>
<key>ypos</key>
<real>15</real>
<real>255</real>
</dict>
<key>D7C5E8DE-9100-473F-86E2-CF04F3D99F60</key>
<dict>
Expand Down
10 changes: 8 additions & 2 deletions search_notes.pl
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#!/usr/bin/perl -I .
#!/usr/bin/perl -I . -s

use strict;
use warnings;
use vars qw($t);

use Joplin;
use Jundy::AlfredWorkflow::Filter;

$t ||= 0; # search titles only

my $find = join(' ', @ARGV);

my $data = Joplin::get_data(
["search"],
{ fields => 'id,title', limit => 9, order_by => "updated_time", query => $find, }
{ fields => 'id,title', order_by => "updated_time", query => $find, }
);

my %display_data = (
Expand All @@ -19,6 +22,9 @@
);
if (exists $data->{items} && @{$data->{items}}) {
my @items = @{$data->{items}};
if ($t) { # search only titles
@items = grep { $_->{title} =~ /$find/i } @items;
}
map { push(@{$display_data{data}}, { title => $_->{title}, subtitle => $_{title}, arg => $_->{id} }) } @items;
}
elsif (exists $data->{error}) {
Expand Down

0 comments on commit d376c1d

Please sign in to comment.