I've managed to get my tw5ikifier[1] code (mostly) correctly handing
dependencies so I'd now like to add TiddlySpaceLinkPlugin[2] into the
mix.
It looks relatively straightforward, but before I tuck in I thought
I'd ask.
Thanks.
[1] https://github.com/cdent/tw5ikifier
[2]
https://github.com/TiddlySpace/tiddlyspace/blob/master/src/plugins/TiddlySpaceLinkPlugin.js
--
Chris Dent http://burningchrome.com/
[...]
> Is there yet a cookbook or rules of thumb for porting a plugin that
> adds to the formatter of tw2 to one that adds rules to the tw5
> wikitextrules?
No, not yet. I'm still expecting to do a fairly substantial
refactoring of the wikifier to make it properly re-entrant, which will
have an impact on how formatters are coded. Worse, I have yet to
properly document the new renderer architecture.
The easiest way to cope with the uncertainty might be to maintain the
new formatters as part of the core TW5 code base, and then I can
refactor them easily alongside the others. I plan to re-use the @space
syntax in standalone tiddlywiki, so I think it would make sense.
I think there are two jobs:
1) make the <<link>> macro understand how to make inter-space links
2) add/modify a new formatter to detect the @space link syntax and
emit the required <<link>> macro
> I've managed to get my tw5ikifier[1] code (mostly) correctly handing
> dependencies so I'd now like to add TiddlySpaceLinkPlugin[2] into the
> mix.
Great stuff, let me know if I can do anything to help.
Cheers
Jeremy
> It looks relatively straightforward, but before I tuck in I thought
> I'd ask.
>
> Thanks.
>
> [1] https://github.com/cdent/tw5ikifier
> [2]
> https://github.com/TiddlySpace/tiddlyspace/blob/master/src/plugins/TiddlySpaceLinkPlugin.js
>
> --
> Chris Dent http://burningchrome.com/
> [...]
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWikiDev" group.
> To post to this group, send email to tiddly...@googlegroups.com.
> To unsubscribe from this group, send email to
> tiddlywikide...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/tiddlywikidev?hl=en.
>
--
Jeremy Ruston
mailto:jeremy...@gmail.com
http://www.tiddlywiki.com
1) make the <<link>> macro understand how to make inter-space links
2) add/modify a new formatter to detect the @space link syntax and
emit the required <<link>> macro
I'm interested in generalising the link notation so that it can be
used as a general purpose mechanism to reference tiddlers from a
different source than the current document.
One simple way of doing it would be for a reference like 'alpha@gamma'
to be interpreted as a reference to the tiddler called 'alpha' coming
from the space defined by the tiddler called 'gamma'. Then the content
of the tiddler 'gamma' would define the origin space, perhaps with a
type field and a base URL. The type field would allow for tiddlers to
be retrieved from instances of TiddlyWeb/TiddlySpace, but could also
be used to access other types of data.
For instance, with the appropriate definitions, we might have:
- 02747527426@twitter to identify a particular tweet
- Lettuces@wikipedia to identify a Wikipedia article
- Agenda@work to identify a tiddler in a separate TiddlyWiki document
I've also been researching oembed, a protocol designed to simplify
embedding content from one website in another, but I note that it is
actually a pretty good implementation of what we'd need for a general
purpose import mechanism.
Best wishes
Jeremy
>
> Tobias.
I'm away from a proper computer until next week, but this is great stuff, and I'll look forward to picking it up on my return,
I'm tending towards the idea of being able to register a link
generator function with the store object. The function would be passed
the parameters of the link macro and return a Renderer.ElementNode
representing the generated <a> tag. It might be less brittle if the
function were passed a default <a> element which it could modify,
rather than generating one from scratch. Does that sound reasonable?
Best wishes
Jeremy
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWikiDev" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/tiddlywikidev/-/_cWUg749cgMJ.
> I'm tending towards the idea of being able to register a link
> generator function with the store object. The function would be passed
> the parameters of the link macro and return a Renderer.ElementNode
> representing the generated <a> tag. It might be less brittle if the
> function were passed a default <a> element which it could modify,
> rather than generating one from scratch. Does that sound reasonable?
Are you thinking that there would be a mapping of link types to
various functions (which return the ElementNode) or something within a
single function that handles different types of links?
The former seems in keeping with the usual patterns.
So a "formatter" would result in a link macro of type X. Macro
processing would say "oh yeah, that's X, funcX deals with that".
Can you clarify what sort of link types you'd expect to see?
Links in TW5 are parsed as a simple link target string. The link
target may be a URI or a tiddler reference, and in the latter case
we're talking about adding an optional space component to the link.
Currently, heuristics are applied at macro execution time to determine
if the link target is an external link or a tiddler link.
I don't think it makes sense to have separate callbacks for massaging
external links, tiddler links, intraspace vs. interspace links because
one of the things we want to be able to override is those heuristics
that are used to classify and render links.
Therefore, I see this mechanism more as a way for the link macro to
delegate some of its work to an external callback, and would be
inclined structure it in those terms, as a single callback.
Cheers
Jeremy
>> Are you thinking that there would be a mapping of link types to
>> various functions (which return the ElementNode) or something within a
>> single function that handles different types of links?
>>
>> The former seems in keeping with the usual patterns.
>>
>> So a "formatter" would result in a link macro of type X. Macro
>> processing would say "oh yeah, that's X, funcX deals with that".
>
> Can you clarify what sort of link types you'd expect to see?
Well the original problem I mentioned was that we need a way to
resolve space names (or that kind of syntax) which in the most basic
case means being able to say "prepend the space name onto the string
'.tiddlyspace.com' to make the hostname portion of the link".
In my gist[1] that's currently a static string, but what we want is to
be able to declare, somewhere, how space names are resolved,
preferably in a programatic way.
My understanding of what you were suggesting was that link macro,
knowing that it is of space type, would look for a function to perform
the resolution, thus being able to create a correct target.
The main problem here is that the formatter rule and its handler itself
are (correctly) encapsulated and thus don't know that in whatever
context we happen to be in the space domain '.tiddlyspace.com'. In
some _other_ context (running the same code, in the same process)
it might be something else.
It matters naught to me whether there are many or one callback, but
from an extensibility standpoint, assuming you want a single link macro,
and the inevitability of wanting to massage links (beyond simple internal
external-ness), from a writer-of-formatter-rules it would be nice to
be able to declare, in my formatter two things:
* that the link I'm creating is a special
* that this (adjacent piece of code) is the massager to make it behave
All that send I'm not wed to any particular way of doing this. I just
want to be able to get space links working. How is an interesting
concern, but secondary for me. I _really_ want to move on from
the 2.6.x-based twikifier.
[1] https://gist.github.com/2149828
In fact, I think you do want to process all links, not just space links.
The reason is that I think that the encodeURIComponent() that I added
a few weeks ago is part of the same bundle of special logic: how to
treat TiddlySpace links. I can imagine other hosts that might use a
different way of encoding tiddler titles into URIs (perhaps using
dashes for spaces).
But otherwise, yes, I think we're seeing the same problem and the same solution.
> The main problem here is that the formatter rule and its handler itself
> are (correctly) encapsulated and thus don't know that in whatever
> context we happen to be in the space domain '.tiddlyspace.com'. In
> some _other_ context (running the same code, in the same process)
> it might be something else.
Right. I think the formatter can just shovel the space component into
the parameters for the link macro, and let the link macro invoke the
link generator callback to generate the actual link.
> It matters naught to me whether there are many or one callback, but
> from an extensibility standpoint, assuming you want a single link macro,
> and the inevitability of wanting to massage links (beyond simple internal
> external-ness), from a writer-of-formatter-rules it would be nice to
> be able to declare, in my formatter two things:
>
> * that the link I'm creating is a special
> * that this (adjacent piece of code) is the massager to make it behave
I think this might be where we're differing. I don't see such a tight
coupling between the special formatter and the link massaging rules. I
think that's partly because as I mentioned above, I think it's useful
for the syntax for space links to be part of the TW5 core. This means
that the formatters you've written would become part of the core, and
not be packaged along with the massager.
> All that send I'm not wed to any particular way of doing this. I just
> want to be able to get space links working. How is an interesting
> concern, but secondary for me. I _really_ want to move on from
> the 2.6.x-based twikifier.
Terrific. I'll prototype up some code and get back to you,
Best wishes
Jeremy
> [1] https://gist.github.com/2149828
>
>
> --
> Chris Dent http://burningchrome.com/
> [...]
>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWikiDev" group.
> To post to this group, send email to tiddly...@googlegroups.com.
> To unsubscribe from this group, send email to
> tiddlywikide...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/tiddlywikidev?hl=en.
>
--
> Right. I think the formatter can just shovel the space component into
> the parameters for the link macro, and let the link macro invoke the
> link generator callback to generate the actual link.
[...]
> for the syntax for space links to be part of the TW5 core. This means
> that the formatters you've written would become part of the core, and
> not be packaged along with the massager.
This still leaves me not yet understanding where the space component
is coming from?
> Terrific. I'll prototype up some code and get back to you,
Cool, looking forward to it.
The new link formatters would detect the space links, and generate a
link macro with a "space" parameter containing the space, analogous to
the current "target" parameter.
The link massager, via the link macro, would see the "space" parameter
and generate appropriate markup.
Is that
Cheers
Jeremy
>
>
>> Terrific. I'll prototype up some code and get back to you,
>
>
> Cool, looking forward to it.
>
>
> --
> Chris Dent http://burningchrome.com/
> [...]
>
> The new link formatters would detect the space links, and generate a
> link macro with a "space" parameter containing the space, analogous to
> the current "target" parameter.
>
> The link massager, via the link macro, would see the "space" parameter
> and generate appropriate markup.
I get that, but the space is 'cdent'. Where does tiddlyspace.com come
from?
The massager would insert it, I was thinking.
Cheers
Jerm
>>> The new link formatters would detect the space links, and generate a
>>> link macro with a "space" parameter containing the space, analogous to
>>> the current "target" parameter.
>>>
>>> The link massager, via the link macro, would see the "space" parameter
>>> and generate appropriate markup.
>>
>>
>> I get that, but the space is 'cdent'. Where does tiddlyspace.com come
>> from?
>
> The massager would insert it, I was thinking.
I'll wait to see the prototype code, but this is what I was thinking
as well and why I thought there would multiple (and extensible) massagers:
Because you only want to make 'cdent' into 'cdent.tiddlyspace.com' if
the link in question is:
* a space link
* a space link in the tiddlyspace.com domain
https://github.com/Jermolene/TiddlyWiki5/commit/d13e2bacaf99c93f240390728054c78a77b8a49b
Let me know how it goes,
Best wishes
Jeremy
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWikiDev" group.
> To post to this group, send email to tiddly...@googlegroups.com.
> To unsubscribe from this group, send email to
> tiddlywikide...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/tiddlywikidev?hl=en.
>
--
> OK, I've checked in some code:
>
> https://github.com/Jermolene/TiddlyWiki5/commit/d13e2bacaf99c93f240390728054c78a77b8a49b
>
> Let me know how it goes,
I feel like I'm being a bit thick or something, because I'm not sure
I get it.
First off you've got 'href' and 'target' as input parameters. But
then later when generating the Element node, the attribute 'href'
takes the value of 'linkInfo.target', whereas it seems quite likely
one might like to create a link which uses the HTML target attribute, in
which case linkInfo might need a thing for that.
Given that, what are the meaning of: target, space and href;
especially if one's starting point is foo@bar?
My intuition, but I don't see how the code would support this is
that target = 'foo', space='bar', and href would be constructed in
the linkMassager, which is a closure with the upvariable of the space
domain (perhaps 'tiddlyspace.com').
Secondly, I'm not sure how to move forward with the change. You have
installed a default linkMassager in js/App.js.
Presumably in my code[1] when creating the store, a different
linkMassager would be registered. That one would need to:
* duplicate the "linkInfo.target = encodeURIComponent(linkInfo.target);"
in js/App.js, for the sake of correct tiddlywiki-style links
* add code which did something like this:
if (linkInfo.space) {
linkInfo.target = 'http://'
+ linkInf.space
+ '.' + theEnclosedSpaceDomain
+ '/' + encodeURIComponent(linkInfo.target);
}
Is this what you were thinking, or something else?
Thanks.
[1] https://github.com/cdent/tw5ikifier/blob/master/Wikifier.js
> First off you've got 'href' and 'target' as input parameters. But
> then later when generating the Element node, the attribute 'href'
> takes the value of 'linkInfo.target', whereas it seems quite likely
> one might like to create a link which uses the HTML target attribute, in
> which case linkInfo might need a thing for that.
>
> Given that, what are the meaning of: target, space and href;
> especially if one's starting point is foo@bar?
OK, you're not being stupid: part of the confusion is that several TW5
macros use the term "target" for the title of the tiddler that they
refer to (for instance, <<tiddler target:SomeTiddler>>). Accordingly,
the link macro uses the "target" parameter for the title of the
tiddler being linked to (or the URL for an external link).
The other confusion is that the mechanism doesn't, as it should,
permit the linkMassager to manipulate the HTML "target" property. My
first thought for the callback was for it to process the actual
ElementNode generated by the link macro; I did it the way that you see
in an attempt to try to shield the linkMassager from the
implementation of the ElementNode.
> My intuition, but I don't see how the code would support this is
> that target = 'foo', space='bar', and href would be constructed in
> the linkMassager, which is a closure with the upvariable of the space
> domain (perhaps 'tiddlyspace.com').
>
> Secondly, I'm not sure how to move forward with the change. You have
> installed a default linkMassager in js/App.js.
>
> Presumably in my code[1] when creating the store, a different
> linkMassager would be registered. That one would need to:
>
> * duplicate the "linkInfo.target = encodeURIComponent(linkInfo.target);"
> in js/App.js, for the sake of correct tiddlywiki-style links
Yes, that is correct. I'm working on the basis that App.js is the "TW5
app", and that other systems using TW5 components (such as tw5ikifier)
would derive their own equivalents.
The idea is that mapping the link target to the URI using
encodeURIComponent() could be replaced with a slug generator that e.g.
uses dashes instead of spaces.
> * add code which did something like this:
>
> if (linkInfo.space) {
> linkInfo.target = 'http://'
> + linkInf.space
> + '.' + theEnclosedSpaceDomain
> + '/' + encodeURIComponent(linkInfo.target);
> }
> Is this what you were thinking, or something else?
Exactly that, modulo the points above about confusing parameter names,
and the need to re-engineer the callback to permit it to manipulate
the HTML target attribute.
I'll review the design tomorrow and ping you when I've got something better,
Best wishes
Jeremy
> Thanks.
>
> [1] https://github.com/cdent/tw5ikifier/blob/master/Wikifier.js
>
>
>
> --
> Chris Dent http://burningchrome.com/
> [...]
>
> Exactly that, modulo the points above about confusing parameter names,
> and the need to re-engineer the callback to permit it to manipulate
> the HTML target attribute.
>
> I'll review the design tomorrow and ping you when I've got something better,
I see that you've done some refactoring on the LinkMassager stuff[1]. Can
you provide some explanation of how tw5ikifier might make use of it
for space stuff?
Thanks.
[1]
https://github.com/Jermolene/TiddlyWiki5/commit/af7b69e778c1c11fc8edfc67b2323d39c8b79a13
> I see that you've done some refactoring on the LinkMassager stuff[1]. Can
> you provide some explanation of how tw5ikifier might make use of it
> for space stuff?
Sorry about that.
There are docs for the new design at the top of the source for the link macro:
https://github.com/Jermolene/TiddlyWiki5/blob/master/js/macros/link.js
It's now possible for the massager to do whatever it wants to the HTML
attributes of the <a> element, or indeed to completely suppress the
link (I use this option to prevent broken links appearing in the
generated readme.md file on GitHub).
Does that make a bit more sense?
Best wishes
Jeremy
>
> Thanks.
>
> [1]
> https://github.com/Jermolene/TiddlyWiki5/commit/af7b69e778c1c11fc8edfc67b2323d39c8b79a13
>
>
> --
> Chris Dent http://burningchrome.com/
> [...]
>
Just to let you know that I'm now going ahead and implementing
TiddlySpace links directly in TW5, hopefully will be done later today.
You may want to wait until those commits before you pick this up,
Best wishes
Jeremy
I'm now at the point where everything is up and running again, I'm
just fixing some typos and fixing some bugs and then I'll commit the
code.
Once that's done I'll create a starter TiddlySpace plugin that we can
use to refine tw5ikifier.