New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smart tags discussion thread #262

Open
mobitar opened this Issue Jul 24, 2018 · 20 comments

Comments

Projects
None yet
6 participants
@mobitar
Member

mobitar commented Jul 24, 2018

Creating a dedicated thread for any questions related to Smart Tags. Feel free to share any tags you've created, or ask for help on how to construct a custom query.

@onlinemumie

This comment has been minimized.

onlinemumie commented Jul 28, 2018

I found some JavaScripts references on w3schools and modified one of the code examples on the Smart Tag help page.

Now I've got a working Smart Tag for finding dates in titles. I always write dates within parenthesis, and this one will find any note that has (20 in the title, for example (2018-07-28) or (2020-10-01).

!["Date", "title", "includes", "(20"]

The string reference "includes" can be used to find text strings in the note text as well. Just replace "title" with "text". For example

!["Buy", "text", "includes", "=Buy"]

to find any note with =Buy in the text.

@mobitar

This comment has been minimized.

Member

mobitar commented Jul 29, 2018

Looks good! More advanced, but you can use Regex too to do more detailed date finding (because your solution won't work once we enter the year 3000 ;)

@onlinemumie

This comment has been minimized.

onlinemumie commented Jul 30, 2018

Sounds interesting, Unfortunately, I'm not a coder and know nothing of Javascript syntax. Care to give an example?

I also wonder if it's possible to combine "search terms" in a smart tag, for example to find all notes that contains "=Buy" and "+Garage", or all notes that contains "=Buy" and have the tag "Home".

@mobitar

This comment has been minimized.

Member

mobitar commented Jul 30, 2018

It's not currently possible to combine terms, but that may be an interesting addition.

Ah I forgot to include a regex example in the help post. Will add this later:

Regex is also supported. But be sure to escape your / and \ as necessary.

!["Only Letters", "title", "matches", "^[a-zA-Z]+$"]
@onlinemumie

This comment has been minimized.

onlinemumie commented Aug 5, 2018

As I said, I'm not a coder. I understand that your example returns all notes with only letters, but I have a hard time figuring out how to modify the code for date formats and such. Can you recommend some good links on how to write the specific syntax for these kind of queries? What I've found so far on the web doesen't work and looks very different from your example.

@mobitar

This comment has been minimized.

Member

mobitar commented Aug 6, 2018

Your best bet for regex is an online builder:

https://regex101.com/
http://rubular.com/

It's definitely not easy, but very powerful.

@onlinemumie

This comment has been minimized.

onlinemumie commented Aug 6, 2018

Perhaps not rocket science, but after some research I found (and tweaked) some regex code that will recognize the yyyy-mm-dd date format in titles. It won't check for valid dates though.

!["Date", "title", "matches", "\\d{4}-\\d{2}-\\d{2}"]

@mobitar

This comment has been minimized.

Member

mobitar commented Aug 6, 2018

Nice!

@onlinemumie

This comment has been minimized.

onlinemumie commented Aug 7, 2018

I found some code for making negative searches at stackoverflow.com. Perhaps someone will find it useful.

!["Not in text", "text", "matches", "^(?!.*(word1|word2|word3))"]

This tag will search for notes NOT containing word1, word2, or word3.

It will only work for words on the first line of text, but that can probably be changed if .* is replaced or combined with some other token such as \s (whitespace character). For a list of tokens, check out the links provided by mobitar above. I can also recommend Regular-Expressions.info.

It is also possible to use symbols such as + and * as part of words, but \\ must be included before the symbol to escape its function.

Personally, I use _* or _+ on the first line of text to identify notes as part of themes or projects, so the smart tag I use (which will look for notes NOT marked as _+projects or _*themes) looks like this:

!["Unmarked", "text", "matches", "^(?!.*(_\\*|_\\+))"]

@ionisingTuna

This comment has been minimized.

ionisingTuna commented Sep 24, 2018

Nice one guys, please consider this one, which will check for numbered lists:
^\d\. You can find it here.
I have tried to convert it into the Standard Notes format unsuccessfully so far:
!["Numbered List", "text", "includes", "^\\d(\.)"]

Could one of you please show me the way? Cheers.

@onlinemumie

This comment has been minimized.

onlinemumie commented Sep 24, 2018

Hello, ionisingTuna. I tried the following for your particular problem:
!["Numbered List", "text", "matches", "\\d\\.\\s"]
And it found any note with a digit followed by a dot and a whitespace character. Not very useful for numbered lists.
After some testing, I ended up with the following code. It found all my numbered lists, because all my numbered lists start with a 1 followed by a dot and a whitespace character:
!["Numbered List", "text", "matches", "1\\.\\s"]
Perhaps not perfect, but hey, it works!

@ionisingTuna

This comment has been minimized.

ionisingTuna commented Sep 24, 2018

Thanks a million. This works perfectly.

@mobitar

This comment has been minimized.

Member

mobitar commented Nov 20, 2018

From a user email interaction:

I have a tag called "Journal" that I'd like to create a view for.

I've tried these 3 options with no success.

- !["Journal", "tags", "=", "Journal"]
- !["Journal", "tags.title", "=", "Journal"]
- !["Journal", "title", "=", "Journal"]

I just want my 'Journal' tag to show up on the top under a "View".

Solution:

!["Journal", "tags", "includes", ["title", "=", "Journal"]]
@jacolind

This comment has been minimized.

jacolind commented Nov 27, 2018

Can I do text includes "todo" or "TODO" and tag includes "project1"?

@mobitar

This comment has been minimized.

Member

mobitar commented Nov 27, 2018

Try

!["Todo", "text", "includes", "todo"]

As for a single predicate that satisfies all 3 conditions, I'm not sure. I'd have to review the code to see if that's possible.

@neaxi

This comment has been minimized.

neaxi commented Dec 28, 2018

Is there any way to use Smart Tags in the Android app to display untagged notes? In similar way web app utilizes tags.length = 0?

@mobitar

This comment has been minimized.

Member

mobitar commented Dec 28, 2018

No, smart tags aren't currently supported on mobile.

@nickAtWybar

This comment has been minimized.

nickAtWybar commented Jan 15, 2019

I've found the default 'last day, last week' very useful views. Extending that, I'm trying to figure out what the comparison operator would be for 'last hour'.

['Last Hour','updated_at',comparison operator. updated_at is less than hours time delta,2]

Anybody have thoughts on how to do this?

Thanks.

@mobitar

This comment has been minimized.

Member

mobitar commented Jan 15, 2019

It should just be

!["Last Hour", "updated_at", ">", "1.hours.ago"]
@mobitar

This comment has been minimized.

Member

mobitar commented Jan 15, 2019

Also, smart tags are now supported in the mobile 3.0 beta: https://twitter.com/StandardNotes/status/1085185273116483584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment