Search in resources plugin

Here's a very basic plugin that can search in attachments.
At this point it only supports PDF attachments with text, i.e. it does not have OCR capabilities.

In its current state it's not intended for production use as it has some serious flaws. It won't mess with your data but:

  • it will re-index all attachments at startup
  • there's no guarantee it'd extract all text from PDFs
  • it may slow Joplin down
  • and as you can see the UI is horrendous: I could not figure out how to resize the window with results to fit the content, and I also wanted to have clickable links to open a note containing the resource, but I'm not sure if it's possible at the moment.

Putting it out there so that maybe someone can get an inspiration from it.
I'll probably take a break from Joplin plugins for some time, although I may eventually update this plugin.

4 Likes

That's interesting, thanks for sharing. The part to extract text from the pdf seems a bit crazy but makes sense, and I assume there's no other way since pdfs don't keep the plain text. Perhaps some of it could be reused if we ever implement the ocr plugin.

If you don't want to scan all the resources on startup, perhaps you can rely on the updated_time property? Once you've finished processing you store the highest updated_time, and next time you don't need to process anything below it. Just an idea if you or someone wants to improve this part.

1 Like

Just published the 1st usable version of the plugin. Here's a video showing its use

Known issues:

  • due to limitations of the API search dialog has to be closed manually, so I had to keep the OK button; ideally the dialog should close after clicking on a search result;
  • still supports only PDF attachments with text (i.e. no OCR);
2 Likes

Just testing this, looks good - with a few issues.

In my dark theme Joplin, this shows up as white text on a white background. I've tried to adjust this using the devtools + userchrome.css but it doesn't seem to work:

.resource-name-cell {
    font-family: helvetica;
    color: rgb(248, 248, 242);
    padding: 3px;
}

.referencing-notes-cell {
    font-family: helvetica;
    color: rgb(248, 248, 242);
    padding: 3px;
}

#search-results {
    background: rgb(40, 42, 54);
}

Any chance of adding something to the user options, or some help with the CSS here?

userchrome.css is not available to plugins, only some variables are visible. Therefore, this plugin has its own stylesheet which can reference these variables.
I'll see what I can do for the background colour.

Ok, I see that for the search results I have hardcoded the colors in the plugin's stylesheet. The reason is that I am using different color to indicate the line that is currently selected with up/down arrows and another color to highlight the line under the mouse pointer.

Now, while I have access to CSS variables defining colors used by Joplin, I am not sure how I can derive these 2 other colors at runtime.

I'll see what I can do here.

Great cheers - I guess it'll show up in a lighter theme where the fonts are dark then. Is there a way to use the theme colour for this - e.g. same as the note selection colours?

I don't know what yours looks like but I'd suggest that a bit of padding around the fonts and a sans-serif family would improve the visual appearance.

I am open for suggestions - UI design is not my strong side as anyone can see.

The CSS file is here: joplin-plugin-resource-search/src/webview/resource-search-view.css at master · roman-r-m/joplin-plugin-resource-search · GitHub

Does the plugin still need to index on every Joplin restart? I can't tell if it's indexing, how long the indexing will take, etc. In other words, it would be good to know when starting the search: can I expect all the results to be ready yet?

BTW thanks for this plugin. It fills a much-needed gap in Joplin's feature set, in my opinion.

I think I've fixed it but not sure if I've ever released it. Will do later today.

EDIT
yes, I have, should be fixed in the latest version 0.1.1

I already had 0.1.1. How can I tell what's going on with indexing? I have many PDFs.

You can check the size of the index on disk to see if it's increasing, which would indicate indexing is in progress, but there's no way to see currently when it finishes.

Normally it should not take more than a couple minutes to index.

It appears this no longer works?

To be honest, I didn't think anyone was using it and had no plans to maintain it. But I can at least keep it working. Will try to check on the weekend.

There was a version of Joplin that broke certain plugins, but that's fixed now, at least in pre release. Which version are you using?

Jopin 2.9.17

@mzguy I've just published a new version, please give it a try and see if it works for you.

To be fair, there are no functional changes there. For some reason I was unable to build it after not touching for a while, so all I've done there was update some dependencies so that I can at least run it.

Looks like it's working. Thanks.