Listfilder for backlinks for two titles?

224 views
Skip to first unread message

David Gifford

unread,
Jul 2, 2016, 9:55:35 AM7/2/16
to TiddlyWiki
Hi all

Is there a way to do a list filter that returns only the tiddlers that have both a link to one tiddler AND a link to another tiddler?

I tried

<$list filter="[backlinks[Spain]backlinks[Modern]] +[sort[title]]"><$transclude mode="block"/></$list>

and

<$list filter="[backlinks[Spain]] +[backlinks[Modern]] +[sort[title]]"><$transclude mode="block"/></$list>

Both return more than what I am looking for. I also tried the same with links instead of backlinks.

Dave

Jed Carty

unread,
Jul 2, 2016, 2:01:05 PM7/2/16
to TiddlyWiki
It is horribly inefficient but this may work if you don't have too many tiddlers:

<$list filter='[[Spain]backlinks[]]' variable=LinksSpain>
<$list filter='[[Modern]backlinks[]field:title<LinksSpain>]'>

<$transclude mode="block"/>
</$list>
</$list>

David Gifford

unread,
Jul 2, 2016, 2:04:27 PM7/2/16
to tiddl...@googlegroups.com
how many tiddlers is too many?

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/iLswKCGcSCM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/6ee9da00-9d84-40e5-b95d-975ce2bd8ea9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
David Gifford
Christian Reformed World Missions, Mexico City

Jed Carty

unread,
Jul 2, 2016, 4:46:11 PM7/2/16
to TiddlyWiki
I have no idea how many is too many. It may not be a problem but the inside second is going to be evaluated once for everything returned by the first. If the first returns 100 results than adding the inner loop could mean that it takes 100 times the time to evaluate. Filters are done pretty well so even with that you may not have any trouble, but if the tiddlers being transcluded are complex or other things are going on it could cause things to slow down.

David Gifford

unread,
Jul 2, 2016, 10:48:44 PM7/2/16
to TiddlyWiki
Yeah I think I would need something a little more efficient, then.

Dave

Mark S.

unread,
Jul 3, 2016, 12:53:05 AM7/3/16
to TiddlyWiki
How many tiddlers are we talking about here? Have you tried Jed's code to see how long it takes?

There must be an internal JS function that turns filters into arrays of titles. With that bit of knowledge, it should be possible to make a javascript macro that takes two filters and returns the intersection without inefficiently running a loop inside of another. That is, the processing factor will be n+m rather than n*m.

Anyone have pointers to such a function?

If not, there might be another way that's a little more convoluted to set up.

Mark



Jed Carty

unread,
Jul 3, 2016, 3:32:05 AM7/3/16
to TiddlyWiki
Mark, 

It wouldn't be hard to make something that does that and me and Jeremy (and others) have discussed adding something like that. The last I heard the problem was getting consistent syntax and then everyone got busy with other work, I am going to add some discussion ideas to the meetup later this month about extending filtering to include all logical operations, which would greatly simplify things like this. . 

Jeremy Ruston

unread,
Jul 3, 2016, 4:06:23 AM7/3/16
to tiddl...@googlegroups.com
The backlinks filter operator is inherently slow because every tiddler needs to be parsed to find all the outgoing links, and then filtered to choose the links to the target tiddler. Parsing is a slowish process because it involves analysing the tiddler text character by character to find the syntactic constructions.

However, the results of parsing are cached for each tiddler until the results are invalidated by changes. Thus, the construction that Jed showed with two nested usages of the backlinks filter operator won't be much slower than a single usage.

Generally, I'd strongly recommend careful measurements to avoid premature optimisation.

Best wishes


On 3 Jul 2016, at 08:32, Jed Carty <inmy...@gmail.com> wrote:

Mark, 

It wouldn't be hard to make something that does that and me and Jeremy (and others) have discussed adding something like that. The last I heard the problem was getting consistent syntax and then everyone got busy with other work, I am going to add some discussion ideas to the meetup later this month about extending filtering to include all logical operations, which would greatly simplify things like this. . 

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.

To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

David Gifford

unread,
Jul 3, 2016, 10:07:57 AM7/3/16
to tiddl...@googlegroups.com
So would you guys say that using list filters for backlinks is LESS inefficient than using list filters for tagging? I would have assumed the opposite, since tags involve tag pills and dropdowns. That is what gave me the idea of using backlinks, to avoid the slow down that eventually occurs with using list filters with tags...now I am bummed...

Dave

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/iLswKCGcSCM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

For more options, visit https://groups.google.com/d/optout.

Jeremy Ruston

unread,
Jul 3, 2016, 10:13:08 AM7/3/16
to tiddl...@googlegroups.com
Hi Dave

So would you guys say that using list filters for backlinks is LESS inefficient than using list filters for tagging?

By “using list filters for backlinks” do you mean using a list widget to generate a list of backlinks?

If you’re asking about the relative efficiency of rendering links as plain links or as tag pills, I wouldn’t expect there to be a significant difference.

Best wishes

Jeremy.

Mark S.

unread,
Jul 3, 2016, 12:20:11 PM7/3/16
to TiddlyWiki
Hi Jed,

I was thinking about this particular use-case. If I knew which call to make a filter into an array, it would be fairly easy to write a javascript macro that would return the intersection of the two sets without the cross-multiplying of the nested <$list> approach.

I'm guessing that the benefit comes when n*m > 400 or so. Since Dave apparently has some data already, I was curious whether the nested <$list> approach was creating any difficulty, and with how much data.

Mark

Jeremy Ruston

unread,
Jul 3, 2016, 2:31:24 PM7/3/16
to tiddl...@googlegroups.com
Hi Mark

I'd emphasise again the importance of measuring the performance characteristics of the existing implementation before thinking about optimising it.

The speed of the backlinks operator is much more sensitive to the overall number of tiddlers than to the number of tiddlers whose backlinks are being retrieved. That's because regardless of the number of tiddlers whose backlinks are being retrieved we have to parse *all* tiddlers to find their outgoing links. That's a much more costly operation than the final part, pulling off the backlinks to particular tiddlers.

Best wishes
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

David Gifford

unread,
Jul 3, 2016, 3:00:33 PM7/3/16
to TiddlyWiki
Hi everyone,

Don't want you guys to sweat too much over this one...

My use case is simply a file where I collect photos from around the world, store them locally, image link to them from my TW, and either tag them or (use backlinks as tags) by country and by topic (e.g. modern architecture, nature, etc).

I want to display the photos in galleries by tag. Any given gallery might conceivably get to 50-100 photos? But a lot of the galleries would combine two tags (photos tagged both Spain and Modern). So a conditional viewtemplate would not work for those galleries. I would need to have image galleries based on list filters in at least some of the tiddlers themselves.

I remember trying something similar when TW5 was still younger (5.0.10), and found the file getting slower and slower, even though the photos were not in the file but embedded. To be fair, I admit that the image gallery code was in almost every tiddler on that file, so that made the file larger.

So I don't have data all ready to test out. I just don't want to waste my time creating a big database of photos only to find that this one slows down like the other one did. I thought maybe doing it as backlinks would be more efficient than by tags, but I am getting the sense from what you all are saying, that if anything it could be slower.

Maybe I should experiment with it again as tagging, and see if I can get it to stay lean and fast this time around. Any advice would be appreciated. Blessings,

Dave

Mark S.

unread,
Jul 3, 2016, 5:02:05 PM7/3/16
to TiddlyWiki
Hi Dave,

Making a photo gallery has been something in the back of my mind for awhile. Unfortunately, I seem to lack much of an aesthetic sense. I bet you would come up with something really cool.

Can you explain what you mean by this:


But a lot of the galleries would combine two tags (photos tagged both Spain and Modern). So a conditional viewtemplate would not work for those galleries. I would need to have image galleries based on list filters in at least some of the tiddlers themselves.

I don't understand why having two tags would preclude a conditional viewtemplate based on those two tags. I'm also wondering if you're thinking of different viewtemplates for all sorts of combinations (e.g. "Modern" and "Spain", "Medieval" and "Spain","Medieval" and "England", etc.)

Thanks,
Mark

David Gifford

unread,
Jul 3, 2016, 5:50:25 PM7/3/16
to tiddl...@googlegroups.com
Hi Mark

see my responses in bold below

On Sun, Jul 3, 2016 at 4:02 PM, 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
Hi Dave,

Making a photo gallery has been something in the back of my mind for awhile. Unfortunately, I seem to lack much of an aesthetic sense. I bet you would come up with something really cool.

​<div class="imggal"><$list filter="[is[current]tagging[]sort[title]]"><div class="imggal-item"><$link to={{!!title}}><$transclude/></$link></div></$list></div>​
 


With CSS being

/*IMGGAL*/

@media (min-width: 600px) {

	.imggal {
		-moz-column-count: 4;
		-moz-column-gap: 10px;
		-webkit-column-count: 4;
		-webkit-column-gap: 10px;
		column-count: 4;
		column-gap: 10px;
	}

	.imggal-item {
		width: 100%;
	}

}

.imggal-item {
	display: inline-block;
	border: 0px solid <<colour muted-foreground>>;
	padding: none;
	margin-bottom: 0px;
	background: #fff;
	font-size: 0em;
	line-height: 0;
}

.imggal-item h1 {
	font-weight: 500;
	font-size: 16px;	
}


This is what I was using. Pretty sure Jeremy did this up back then in 2014.


Can you explain what you mean by this:

But a lot of the galleries would combine two tags (photos tagged both Spain and Modern). So a conditional viewtemplate would not work for those galleries. I would need to have image galleries based on list filters in at least some of the tiddlers themselves.

I don't understand why having two tags would preclude a conditional viewtemplate based on those two tags.

I am not sure how having a conditional viewtemplate for each two-tag combination would be better than just having a tiddler for each combination with a list filter in the tiddler. I don't understand what you mean.
 
I'm also wondering if you're thinking of different viewtemplates for all sorts of combinations (e.g. "Modern" and "Spain", "Medieval" and "Spain","Medieval" and "England", etc.)

I
​ am thinking of galleries​ for all sorts of combinations. Perhaps if I had a conditional viewtemplate for all tiddlers tagged combomodern, I could apply that tag to all tiddlers that combine the tag modern with a country tag. Hadn't thought of that. Perhaps that is what you were imagining when you asked your first question above? But that would still make ten or so conditional view templates...

Thanks,

​No, thank you.​
 
Mark


On Sunday, July 3, 2016 at 12:00:33 PM UTC-7, David Gifford wrote:
Hi everyone,

Don't want you guys to sweat too much over this one...

My use case is simply a file where I collect photos from around the world, store them locally, image link to them from my TW, and either tag them or (use backlinks as tags) by country and by topic (e.g. modern architecture, nature, etc).

I want to display the photos in galleries by tag. Any given gallery might conceivably get to 50-100 photos? But a lot of the galleries would combine two tags (photos tagged both Spain and Modern). So a conditional viewtemplate would not work for those galleries. I would need to have image galleries based on list filters in at least some of the tiddlers themselves.

I remember trying something similar when TW5 was still younger (5.0.10), and found the file getting slower and slower, even though the photos were not in the file but embedded. To be fair, I admit that the image gallery code was in almost every tiddler on that file, so that made the file larger.

So I don't have data all ready to test out. I just don't want to waste my time creating a big database of photos only to find that this one slows down like the other one did. I thought maybe doing it as backlinks would be more efficient than by tags, but I am getting the sense from what you all are saying, that if anything it could be slower.

Maybe I should experiment with it again as tagging, and see if I can get it to stay lean and fast this time around. Any advice would be appreciated. Blessings,

Dave

On Sunday, July 3, 2016 at 11:20:11 AM UTC-5, Mark S. wrote:
Hi Jed,

I was thinking about this particular use-case. If I knew which call to make a filter into an array, it would be fairly easy to write a javascript macro that would return the intersection of the two sets without the cross-multiplying of the nested <$list> approach.

I'm guessing that the benefit comes when n*m > 400 or so. Since Dave apparently has some data already, I was curious whether the nested <$list> approach was creating any difficulty, and with how much data.

Mark

On Sunday, July 3, 2016 at 12:32:05 AM UTC-7, Jed Carty wrote:
Mark, 

It wouldn't be hard to make something that does that and me and Jeremy (and others) have discussed adding something like that. The last I heard the problem was getting consistent syntax and then everyone got busy with other work, I am going to add some discussion ideas to the meetup later this month about extending filtering to include all logical operations, which would greatly simplify things like this. . 

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/iLswKCGcSCM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

For more options, visit https://groups.google.com/d/optout.

Birthe C

unread,
Jul 3, 2016, 7:39:40 PM7/3/16
to TiddlyWiki
Hi Dave,

I remember you created a huge gallery as early as 2013. https://groups.google.com/forum/#!searchin/tiddlywiki/TW5$20image$20gallery/tiddlywiki/PpJsdJr99n8/nY-9eAXGB6YJ.
It took quite some time for my old computer to read the file, but I was so amazed that it was possible, I had never even imagined a tiddlywiki this size.


Birthe

David Gifford

unread,
Jul 3, 2016, 9:20:58 PM7/3/16
to tiddl...@googlegroups.com
Yeah Birthe, that was an early attempt, with the images right in the TW. Later came the one I mentioned in this thread, where the images were embedded via links.

Dave

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/iLswKCGcSCM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

For more options, visit https://groups.google.com/d/optout.

Mark S.

unread,
Jul 4, 2016, 1:17:46 AM7/4/16
to TiddlyWiki
Hi Dave,

So it looks like the way your code and/or template worked before (not sure which way you were using it) was to have a "gallery" tiddlers, with a title that would match the tags of images you would want to display.

It seems likes now, if you want to have gallery tiddlers composed of images matching 2 or more tags, that you might need to take a different approach.

I'm thinking that your gallery tiddlers could have a special field, "galleryfilter", containing a filter selecting the tags (or other other criteria -- maybe not always tags) that you want. Like ...

title: Images of Modern Spain
galleryfilter
: [tag[Modern]tag[Spain]sort[]]
text
: Many architectural features of modern Spain follow classic Spanish design, as you will notice in the following assemblage of images.

 Then the modified (untested - sorry) version of Jeremy's code would live in a template tiddler ($:/tags/ViewTemplate):

<$list filter="[all[current]has[galleryfilter]]" >
<div class="imggal"><$list filter={{!!galleryfilter}}><div class="imggal-item"><$link to={{!!title}}><$transclude/></$link></div></$list></div>
</$list>​


HTH
Mark

P.S. I guess the field/feature I would want in a photo gallery (and I'm thinking more of personal use) is the ability to annotate. Sort of an alternative to Adobe photo management or AC/DC.

David Gifford

unread,
Jul 4, 2016, 7:21:00 AM7/4/16
to tiddl...@googlegroups.com
Oh wow, that is nice, Mark! I will give that a try. That opens up all sorts of new ideas in my head.

Dave

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/iLswKCGcSCM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

For more options, visit https://groups.google.com/d/optout.

David Gifford

unread,
Jul 4, 2016, 8:52:13 AM7/4/16
to TiddlyWiki


On Monday, July 4, 2016 at 12:17:46 AM UTC-5, Mark S. wrote:


P.S. I guess the field/feature I would want in a photo gallery (and I'm thinking more of personal use) is the ability to annotate. Sort of an alternative to Adobe photo management or AC/DC.

Mark: don't know if this is what you mean, but if you do it as

<$link to={{!!title}} tooltip={{!!notes}}><$transclude/></$link>

you can add a notes field, and the note will show up as a tooltip on hover in the img gallery.

Jed Carty

unread,
Jul 4, 2016, 1:05:47 PM7/4/16
to TiddlyWiki
I did make a photo gallery at one point, but I am not sure I ever packaged it as a plugin by itself. You can see it here. Adding some ability to add notes to images is a good idea. Adding a caption like the ones in my other gallery here wouldn't be difficult. Would you want something where you put in a caption and then don't edit it again or a text area where you could always edit it when you can see it or something in between?

Mark S.

unread,
Jul 4, 2016, 2:42:22 PM7/4/16
to TiddlyWiki
Probably something in between. Like a button or section that will drop down to let you change. You would want a caption field, and a key word field so that images could be searched. But you wouldn't want the edit box to be open all the time, because it would be too easy to accidentally change text.

The galleries would probably need, in a real application, to be two-tiered or even three tiered. One tier to show thumbnails, the  other to show individual images.

Dave said he had problems with his gallery slowing down, and I'm guessing that it was the actual size of the images being displayed. If you have too many high-resolution images displayed at once, it's going to soak up a lot of memory. Unfortunately, the only way around this is to actually generate smaller medium-scale and small-scale images. You can't use <img> scaling, because even though the image you see is only 10k pixels, the image the browser had to pull in could be 10s of megabytes. So the system needs to be smart enough to deal with at least two file paths -- one for the small image, and the other for the large image.

There are various apps around that can do batch scaling, so making multiple directories with the images at various sizes should not be too difficult.

Most people take high resolution images, but are content in web browsers looking at medium resolution images. For rapidly viewing lots of images, thumb-nail resolutions are useful.  So that's why you might even want 3 types of gallery viewers.

To take it to another level, there might need to be some device/path management, to bring online images that are stored on an external drive or disk. But I digress.

Something to think about, anyways.

Thanks!
Mark
Reply all
Reply to author
Forward
0 new messages