Code Monkey home page Code Monkey logo

Comments (9)

skysgh avatar skysgh commented on June 12, 2024

My other question is ...is there a way to format a string with some of the variables?
eg: create a tmp variable and output something like the "Refer to :r for further info."

Again...Great plugin. Really really helping me get organized...

Cheers.

from dokuwiki-strata.

bwanders avatar bwanders commented on June 12, 2024

Glad to hear that you find the plugin useful!

As to the first question "How do I combine search clauses to search by Foo or Bar?"

In the search UI displayed with tables one can only do simple searches, so things like "Foo" or "Bar" are not possible there. In the query format, you can combine search patterns through the use of the union construct:

?s is a: example
union {
  {
    ?s Foo: 10
  }
  {
    ?s Bar: 20
  }
}

Any variables that match inside the union get carried out, so you could have an additional ?s Description: ?desc statement with the Foo and the ?desc would be available to show in the resulting table.

As to the second question "Is there a way to format a string with some of the variables?"

The query system does not allow the construction of temporary variables. That being said, you can do complex formatting by using the bwanders/dokuwiki-plugin-templatery and bwanders/dokuwiki-plugin-stratatemplatery plugins.

The Templatery plugin offers generic templating, and the second combines the data handling of Strata with the templating from Templatery. Their README's should get you going with that.

from dokuwiki-strata.

bwanders avatar bwanders commented on June 12, 2024

(Blegh; hit Close and Comment.)

Do these answers help you out?

from dokuwiki-strata.

skysgh avatar skysgh commented on June 12, 2024

Hi,
First off, apologies for the tardy thanks -- end of year madness at work...

Unfortunately, no :-(

Still can't get union to work.

I've tried

union {
{
?tg: [Usability]
}
{
?tg: [UI]
}

And

union {
{
?tg ~ [Usability]
}
{
?tg ~ [UI]
}

And

union {
{
?tg: [Usability]
}
{
?tg: [UI]
}

And without reusing the var I already created

union {
{
?r Tags ~ [Usability]
}
{
?r Tags ~ [UI]
}

...but keep on getting the following.

Unknown triple pattern or filter pattern '?r Tags ~ [Usability]'.

What's the obvious part that I am missing?

As for the templates, can't say I've wrapped my mind around them yet.

Thanks!

from dokuwiki-strata.

bwanders avatar bwanders commented on June 12, 2024

Let's focus on the query first, before getting to the whole template thing.

You are nearly there with the last attempt:

<table ?r>
union {
  {
    ?r Tags: [Usability]
  }
  {
    ?r Tags: [UI]
  }
}
</table>

That nets you all ?r that are tagged with [Usability] or [UI]. The trick is that a Union most contain actual triple patterns, and not only filters:

  • A triple pattern is a pattern of ?subject ?predicate: ?object, where you are free to replace any number of the variables with constants... ?r Tags: ?tag is a good pattern, and so is ?r Tags: Usability, or ?r ?relation: UI.
  • A filter is anything like ?var1 <operation> ?var2 or ?var1 <operation> Constant. With <operation> replaced with one of the Comparison Operators section from the manual.

(This additional information is possibly overkill, but wanted to clarify the difference to be sure.)

Hope that helps!

from dokuwiki-strata.

skysgh avatar skysgh commented on June 12, 2024

from dokuwiki-strata.

bwanders avatar bwanders commented on June 12, 2024

You can't place a pattern and a filter on a single line, but you can add both a pattern and a filter:

<list ?r "Id" ?re [wiki] "Requirement">
  ?r is a: requirement
  optional {
    ?r Tags : ?tg
  }
  optional {
    ?r Requirement [wiki] : ?re
  }
  union {
    {
      ?r Tags : ?temp1
      ?temp1 ~ [UI]
    }
    {
      ?r Tags : ?temp2
      ?temp2 ~ [Usability]
    }
  }
  sort {
    ?r (asc)
  }
</list>

I admit that this isn't the nicest way to express a "match this or that" kind of filter, but there's currently not better way to do it.

You could also ask yourself if it really is the best plan to do "tags contains some string" matching on sets of tags. Maybe we can find a way that better represents the data you are trying to model. Can you give an example of a data block that adds this data?

from dokuwiki-strata.

skysgh avatar skysgh commented on June 12, 2024

from dokuwiki-strata.

bwanders avatar bwanders commented on June 12, 2024

(First a short note: If you put your code examples between hedges of ``` they will be set in monospace font, and overall look a tad nicer.)

Ahhh... Now I get it! You want to AND the conditions, instead of having them ORed. Right.

Well, that's brutality simple then. Simply filter on both terms:

<list ?r "Id" ?re [wiki] "Requirement">
  ?r is a: requirement
  ?r Tags : ?tg
  ?tg ~ [UI]
  ?tg ~ [Usability]
  optional {
    ?r Requirement [wiki] : ?re
  }
  sort {
    ?r (asc)
  }
</list>

I dropped the optional from the ?r Tags: ?tg pattern, since any requirements that have a [UI] and [Usability] tag by necessity have data for the Tags field. Then it's a simple matter of declaring that the matched tags should contain both the tags you want.

The best way to understand these queries is by not thinking of them as database queries (in the relational sense), but as describing the pattern you want to match. In this case you want to match all ?r that have some Tags that match two different filters.

Hope this helps!

PS. I'm interested in what you think is a less bizarre syntax for describing the pattern you want to match -- I don't have time to implement it right now, but feel free to open another issue so we can discuss! (I modeled this syntax roughly after SPARQL which is a query language for RDF, which is a very good fit for the data model of Strata)

from dokuwiki-strata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.