Fields - what are they?

32 просмотра
Перейти к первому непрочитанному сообщению

Yakov

не прочитано,
18 нояб. 2010 г., 11:55:4118.11.2010
– TiddlyWiki
The question arised after considering tag-based CSS and some other
aspects. How should I think of fields (or, what are they actually)?

1.1 Are they a part of the object model of TW only? Or they must have
some DOM "representation"?

1.2 Is there a field generated for references? If not, why? Is it a
part of another table in the relational database?

1.3 Is it true that TW has core mechanisms (simple API) for search
based on fields?

Some answers can be found in [1], but I'm looking for the concepts,
more general answers than "yes" and "no".



Also, I have some questions about Filters that were extended in TW
2.6.2 [2].

2.1. The first one is about set algebra. We can make a filter that
sets a set of tiddlers with tag1 or tag2:
<<list filter "[tag[transcluded]] [tag[examples]]">> (in TW v2.6.1)
but is there a syntax for defining an intersection of sets (tiddler
with tag1 and tag2)?

2.2. Do the filters implement regular expressions search? If so, what
syntax do the use?

[1] http://tiddlywiki.org/wiki/Tiddler_Fields
[2] http://trac.tiddlywiki.org/ticket/1261

Thanks in advance, Yakov.

Eric Shulman

не прочитано,
18 нояб. 2010 г., 12:26:0918.11.2010
– TiddlyWiki
> 2.1. The first one is about set algebra. We can make a filter that
> sets a set of tiddlers with tag1 or tag2:
> <<list filter "[tag[transcluded]] [tag[examples]]">> (in TW v2.6.1)
> but is there a syntax for defining an intersection of sets (tiddler
> with tag1 and tag2)?

For full Boolean logic (and/or/not plus parens as needed), you can
use:
http://www.TiddlyTools.com/#MatchTagsPlugin

It extends the core's syntax so that instead of using a single tag
value:
[tag[tagvalue]]
you can use a Boolean tag 'expression':
[tag[tag1 OR tag2 OR (tag3 AND NOT tag4)]]

The plugin also provides a public API:
store.getMatchingTiddlers(expr,sort,tids)
where:
"expr" is a text string containing the boolean tag expression
"sort" is a tiddler fieldname to sort by (default="title")
"tids" is an array of tiddlers to search (default=search ALL)

note: both "sort" and "tids" are OPTIONAL arguments. Most of the
time, these are omitted, and you can simply write:
var result=store.getMatchingTiddlers(expr)
as in:
var result=store.getMatchingTiddlers("tag1 or tag2 and not tag3")

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

PMario

не прочитано,
18 нояб. 2010 г., 14:58:4118.11.2010
– TiddlyWiki
Hi Yakov,
You are busy tweaking :)

On Nov 18, 5:55 pm, Yakov <yakov.litvin.publi...@gmail.com> wrote:
> 1.1 Are they a part of the object model of TW only? Or they must have
> some DOM "representation"?
It is part of the TW meta data model.
You can open a vanilla tw at http://tiddlywiki.com and __view the
source__.
Then search for "<div title=" and you will see a tiddler source.
There are some fields: modified, modifier ... These are standard tw
fields. Programmers are able to create so called "custom fields" which
look exactly like the standard fields.

> 1.2 Is there a field generated for references? If not, why? Is it a
> part of another table in the relational database?
If you click the button "references" the list is dynamically created.
There is no database model involved, in plain/vanilla tiddlywiki.
There is a database for TiddlyWeb/TiddlySpace. But it is used as a
storage only. You have no direct access to this database. TiddlyWiki
client side is allways the same.

> 1.3 Is it true that TW has core mechanisms (simple API) for search
> based on fields?
if you look at list macro it is simple
<<list filter [tag[myTag]] [sort[modified]]>>

> Some answers can be found in [1], but I'm looking for the concepts,
> more general answers than "yes" and "no".
> Also, I have some questions about Filters that were extended in TW
> 2.6.2 [2].

As described above.
<<list filter [tag[myTag]]>> was possible because there was core code
for it.

but eg:
<<list filter [tag[myTag]] [template[myListTemplate]]>>

wasn't very easy to create. The new extension to the core, makes it
much easier now, _for developers_ to add functions like the
[template[]] which may be used to have custom list output formats.

> 2.1. The first one is about set algebra. We can make a filter that
> sets a set of tiddlers with tag1 or tag2:
> <<list filter "[tag[transcluded]] [tag[examples]]">> (in TW v2.6.1)
> but is there a syntax for defining an intersection of sets (tiddler
> with tag1 and tag2)?
see Erics post.

> 2.2. Do the filters implement regular expressions search? If so, what
> syntax do the use?
The core doesn't.

I made some plugins, that implement regular expression filtering.

I don't know, how much JavaScript you know. But you can have a look at
my Plugin sources at [1]

Start with:
NoCaseListPlugin .. its the easiest.
NumberedTextListPlugin .. next
XCaseListPlugin .. many possibilities but more complicated.

all these plugins extend the core <<list>> macro.

instead of <<list filter ....>>
you can use
<<list numberedText -title>>

so "filter" is replaced by "numberedText" + parameters.

=======

Since at the time I wrote the macros, I didn't fully understand how to
extend the [tag[]] core mechanism, and I didn't want to totally
"hijack" the <<list>> macro, I created my own parameter syntax, which
is different to the core.

Now I am thinking about to rewrite these macros and use the new core
extension mechanism.
eg:
<<list filter [regExp[]]>> would be much easyer now.

=======

If you need information, how the core builds its functions use Erics
insideTW [2], which helped me a lot.

You wrote:

> Some answers can be found in (http://tiddlywiki.org/wiki/Tiddler_Fields), but I'm looking for the concepts,
> more general answers than "yes" and "no".
All of the above is heavily dev related. So depending on your
scripting skills it may be sometimes frustrating to get the overview.
Be carefull :) If this information was too specific tell me, and I'll
move back one step.

-mario

[1] http://apm-plugins.tiddlyspot.com/#XCaseListPlugin%20NumberedTextListPlugin%20NoCaseListPlugin
[2] http://www.tiddlytools.com/insideTW/

PMario

не прочитано,
18 нояб. 2010 г., 15:09:5018.11.2010
– TiddlyWiki
There is a FieldsEditorPlugin [1], which may be of interest.
Guessing, one of you next questions would be, who to tweak them :)

[1] http://visualtw.ouvaton.org/VisualTW.html#FieldsEditorPlugin

-m

Yakov

не прочитано,
21 нояб. 2010 г., 13:50:3021.11.2010
– TiddlyWiki
Eric, thanks for the plugin, it will be quite useful.

@PMario

> part of the TW meta data model

Terms) Is it described somewhere?

So, all the fields (including extended ones) are "represented" as
element attributes?

> If you click the button "references" the list is dynamically created.

Really? This seems strage.. (seems that such a mechanism would be slow
compared to creating an "object" which is changed after each change of
tiddlers, isn't it?)

> plain/vanilla

More terms?

> I don't know, how much JavaScript you know.

I studied it by myself and many things are simple after C++ and shell
script; but I did so little practice that this would take me some time
to understand things and get able to write what I want. This is very
kind of you to list some plugins with increasing level of complicity.
As for now I mostly describe TW's possibilities and pointing what I
want aside the core ones (and they tend to be aggregation [*] tools).
But when I concentrate on the development possibilities, this will be
very useful (as this also connects with some desires).

As for now, my question would be - how the fields are represented in
the object model? Are they just properties of tiddler objects with
respective names (say, "modifier" property for "modifier" field) or
there's more complicated structure?

> [1] http://visualtw.ouvaton.org/VisualTW.html#FieldsEditorPlugin

Wow, the repository looks particularly useful!

Thanks once again.

[*] https://groups.google.com/group/tiddlywiki/browse_thread/thread/3298c096d1e89eeb/bc173dfb903230d4

FND

не прочитано,
22 нояб. 2010 г., 03:05:5222.11.2010
– tiddl...@googlegroups.com
> As for now, my question would be - how the fields are represented in
> the object model?

There are two types of Tiddler attributes, standard and custom fields:
http://trac.tiddlywiki.org/browser/Trunk/core/js/TiddlerFields.js?rev=11290#L46
http://tiddlywiki.org/wiki/Dev:Custom_Fields

Custom fields are represented as members of the "fields" object, e.g.:
{
title: "Foo",
modifier: "FND",
...
tags: ["bar", "baz"],
text: "lorem ipsum dolor sit amet",
fields: {
alpha: "hello",
bravo: "world"
}
}

You might want to inspect a Tiddler instance using Firebug:
var tiddler = store.getTiddler("MyTiddler");
console.dir(tiddler);

Please note that such technical details are better discussed on the dev
group, as you're more likely to get competent help there:
http://groups.google.com/group/TiddlyWikiDev/


-- F.

Ответить всем
Отправить сообщение автору
Переслать
0 новых сообщений