Skip to content

Commit

Permalink
set bundleid and add CHANGELOG.md
Browse files Browse the repository at this point in the history
- set bundleid for proper updates
- add CHANGELOG.md
- misc cleanup
- provide error information
  • Loading branch information
skeletonkey committed Oct 31, 2023
1 parent 156d2fa commit aa007e5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/create_alfredworkflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
uses: thedoctor0/zip-release@main
with:
type: 'zip'
filename: 'link-opener.alfredworkflow'
filename: 'joplin.alfredworkflow'
exclusions: '*.git*'
- uses: actions/upload-artifact@main
with:
name: link-opener.alfredworkflow
path: link-opener.alfredworkflow
name: joplin.alfredworkflow
path: joplin.alfredworkflow


12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## 0.0.1

- add `js` search

## 0.0.2

- set bundleid; this should allow for upgrading the workflow properly
- add CHANGELOG.md
- some error handling to provide feedback to user
- misc code clean up to standardize naming
11 changes: 11 additions & 0 deletions Joplin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,15 @@ sub get_data {
return decode_json($resp);
}

sub parse_error {
my $data = shift || warn("parse_error called without data\n");

warn("no error element found in data\n") unless exists $data->{error};

my @lines = split(/\n/, $data->{error});
$lines[0] =~ s/"/'/g;

return $lines[0];
}

1;
4 changes: 2 additions & 2 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>bundleid</key>
<string></string>
<string>com.github/skeletonkey/joplin_alfred_workflow</string>
<key>category</key>
<string>Productivity</string>
<key>connections</key>
Expand Down Expand Up @@ -142,7 +142,7 @@ Report issues here: https://github.com/skeletonkey/joplin_alfred_workflow/issues
<string>JOPLIN_TOKEN</string>
</array>
<key>version</key>
<string>0.0.1</string>
<string>0.0.2</string>
<key>webaddress</key>
<string>https://github.com/skeletonkey/joplin_alfred_workflow</string>
</dict>
Expand Down
27 changes: 14 additions & 13 deletions search_notes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@

use Joplin;

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

sub find_link {
my $find = join(' ', @ARGV);
my $tmpl = '"title":"%s","subtitle":"%s","arg":"%s"';

my $tmpl = '"title":"%s","subtitle":"%s","arg":"%s"';
my $data = Joplin::get_data(["search"], { "query" => $find });

my $data = Joplin::get_data(["search"], { "query" => $find });

if (@{$data->{items}}) {
my @items = @{$data->{items}};
print '{"items":[{' . join('},{', map({ sprintf($tmpl, $_->{"title"},$_->{"title"},$_->{"id"}) } @items)) . '}]}';
}
else {
print '{"items":[{"title":"No links found","subtitle":"Please try a different search"}]}';
}
if (exists $data->{items} && @{$data->{items}}) {
my @items = @{$data->{items}};
print '{"items":[{' . join('},{', map({ sprintf($tmpl, $_->{"title"},$_->{"title"},$_->{"id"}) } @items)) . '}]}';
}
elsif (exists $data->{error}) {
my @lines = split(/\n/, $data->{error});
$lines[0] =~ s/"/'/g;
print '{"items":[{' . sprintf($tmpl, 'Error', Joplin::parse_error($data), 0) . '}]}';
}
else {
print '{"items":[{"title":"No notes found","subtitle":"Please try a different search"}]}';
}

0 comments on commit aa007e5

Please sign in to comment.