using a macro within the tabs macro

129 views
Skip to first unread message

Saverio

unread,
Mar 25, 2010, 12:10:22 AM3/25/10
to TiddlyWiki
I would like to use the tabs macro as follows:

<<tabs tabID
"tab1 label" "tab1 tooltip" <<tiddler MyMacro with:"parameter">>
"tab2 label" "tab2 tooltip" "tiddler2"
>>

Based on what seemed a promising discussion (http://groups.google.com/
group/tiddlywiki/browse_thread/thread/5aa73a7941df3cf0/
d4f2ed179997e962?lnk=gst&q=tabs+macro#d4f2ed179997e962) [though the
request there was the opposite, to embed the tabs macro within
newTiddler], I tried enclosing the tiddler macro expression in quotes,
breaking up the closing >> into '>' + '>', and enclosing the whole
expression in {{ }}, but nothing has worked. Can anyone help me out?

Anthony Muscio

unread,
Mar 25, 2010, 12:20:24 AM3/25/10
to tiddl...@googlegroups.com
Try the http://tiddlywiki.abego-software.de/#PartTiddlerPlugin plugin.

In a tiddler called "Mode", you can define parts later in your tiddler but reference them in your tabs.

<part partname hidden>

Any macros you want
eg
<<tiddler MyMacro with:"parameter">>

</part>

<<tabs txtaskViewMaster
"Task View Home" "Landing paged for Task View Mode" Mode/Home
"Active Work Tasks" "All active Tasks for Work" Mode/Partname
"Active Personal Tasks" "All active Tasks for Personal" Mode/Partname2
"On Event" "All active Tasks on event" Mode/Partname3
>>

</part>
<part Home hidden>
<<tiddler [[!Using MasterDB]]>>
</part>


This expands the ability to have complex content in your tabs from a single (or multiple files).




TonyM

If you have not found an easy way to do it with TiddlyWiki, you have missed something.
www.tiddlywiki.com




--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To post to this group, send email to tiddl...@googlegroups.com.
To unsubscribe from this group, send email to tiddlywiki+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.


Saverio

unread,
Mar 25, 2010, 3:13:14 PM3/25/10
to TiddlyWiki
Interesting suggestion, but I am unable to get it to work. I've
posted a test TW here:
http://dl.dropbox.com/u/4462381/example2.html

Basically, it consists of a tiddler [[project 1]] which is associated
with links, documents, tasks, meetings, and notes. Links and
documents are defined within [[project 1]], but tasks, meetings, and
notes are independent tiddlers tagged with [[project 1]] and their
type.

I defined a tiddler [[ProjectInfo]] with the "tabs" and "part" macros
that I hoped would bring all related information about a project into
one view. It accepts a parameter which is the project name. But as
you can see in [[TestProjectInfo]], when [[ProjectInfo]] is called
"with:[[project 1]]", the tabs are all empty, instead of displaying
what is intended.

On Mar 25, 12:20 am, Anthony Muscio <anthony.mus...@gmail.com> wrote:
> Try thehttp://tiddlywiki.abego-software.de/#PartTiddlerPluginplugin.

Måns

unread,
Mar 25, 2010, 4:44:20 PM3/25/10
to TiddlyWiki
Hi Saverio

I would do this in tiddler [[ProjectInfo]] - however it doesn't seem
to work in your tw??!! Maybe theres a conflict with the
parttiddlerplugin - or we found a new bug in TW 2.6??
I have an (overly complicated (I know - but it works)) example, where
I use all kinds of macros in tabs here: http://stormp.tiddlyspot.com/#Tr%C3%A6Manager
<<tabs txtProjectInfo
'Tasks' 'Project tasks' [[ProjectInfo##Tasks]]
'Links' 'Project-related links' [[ProjectInfo##Links]]
'Documents' 'Important documents' ProjectInfo##Documents
'Minutes' 'Meeting minutes' ProjectInfo##Minutes
'Notes' 'Project notes' ProjectInfo##Notes
>>
/%
!Tasks
<<matchTags *%0 "" "$1" AND task>>
!end
!Links
<<tiddler [[$1##Links]]>>
!end
!Documents
<<tiddler [[$1##Documents]]>>
!end
!Minutes
<<matchTags *%0 "" "$1" AND meeting>>
!end
!Notes
<<matchTags *%0 "" "$1" AND note>>
!end %/

Regards Måns Mårtensson

Saverio

unread,
Mar 25, 2010, 5:33:38 PM3/25/10
to TiddlyWiki
I tried before using PartTiddlerPlugin, but was only partially
successful, hence my original post. The tabs that reference the
slices correctly display, but not the tabs that are populated by the
matchTags macro.

I uploaded both versions for people to play with. I removed
PartTiddlerPlugin from the slices example to rule out an interaction
with MatchTagsPlugin. Could there be an issue with MatchTagsPlugin?

http://dl.dropbox.com/u/4462381/example_using_slices.html
http://dl.dropbox.com/u/4462381/example_using_parts.html

Måns

unread,
Mar 25, 2010, 6:19:42 PM3/25/10
to TiddlyWiki
Ahaa - This works
[[ProjectInfo]]
<<tabs txtFavourite
alpha one "ProjectInfo##Foo"
bravo two "ProjectInfo##Bar"
>>
/%
!Foo
<<tiddler [[project 1]]>>
!end
!Bar
<<matchTags "#[[%0]] (%2)<br>^^%5^^" "\n" sort:-modified ->>
!end
%/

Please try it out

Regards Måns Mårtensson

On 25 Mar., 22:33, Saverio <saverio.mavig...@gmail.com> wrote:
> I tried before using PartTiddlerPlugin, but was only partially
> successful, hence my original post.  The tabs that reference the
> slices correctly display, but not the tabs that are populated by the
> matchTags macro.
>
> I uploaded both versions for people to play with.  I removed
> PartTiddlerPlugin from the slices example to rule out an interaction
> with MatchTagsPlugin.  Could there be an issue with MatchTagsPlugin?
>

> http://dl.dropbox.com/u/4462381/example_using_slices.htmlhttp://dl.dropbox.com/u/4462381/example_using_parts.html

Saverio

unread,
Mar 25, 2010, 10:06:44 PM3/25/10
to TiddlyWiki
Yes, but I am trying to make [[ProjectInfo]] generic for any project,
so I need to be able to send it a parameter. I think that's what
causes the macros to break down, because the sent parameter does not
get down to the level of the slices/parts, where they are needed.

Anthony Muscio

unread,
Mar 26, 2010, 3:05:40 AM3/26/10
to tiddl...@googlegroups.com
I am doing something very similar.

I achieved this using the inline tabs plugin


I have a project tiddler with this as it's content;


<<tiddler !.Project with: {{tiddler.title}} >>

So it uses it's tiddler name to invoke a generic Project Tiddler that brings together all it's tiddler lists.

What makes it work (under 2.6.0) is the inline tabs plugin
found via http://tw.lewcid.org/

Where the simple note says;

create tabs from a single tiddler using an easy {{{<tabs></tabs>}}} syntax.
Get it in the [[sandbox|http://tw.lewcid.org/sandbox]].


How ever that link is broken so here it is

//{{{
config.formatters.unshift( {
    name: "inlinetabs",
    match: "\\<tabs",
        lookaheadRegExp: /(?:<tabs (.*)>\n)((?:.|\n)*?)(?:\n<\/tabs>)/mg,
    handler: function(w)
    {
        this.lookaheadRegExp.lastIndex = w.matchStart;
        var lookaheadMatch = this.lookaheadRegExp.exec(w.source)
        if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
            {
             var cookie = lookaheadMatch[1];
               var wrapper = createTiddlyElement(null,"div",null,cookie);
             var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
             tabset.setAttribute("cookie",cookie);
             var validTab = false;
             var firstTab = '';
             var tabregexp = /(?:<tab (.*)>)(?:(?:\n)?)((?:.|\n)*?)(?:<\/tab>)/mg;
             while((m = tabregexp.exec(lookaheadMatch[2])) != null)
                 {
                 if (firstTab == '') firstTab = m[1];
                 var tab = createTiddlyButton(tabset,m[1],m[1],story.onClickInlineTab,"tab tabUnselected");
                 tab.setAttribute("tab",m[1]);
                 tab.setAttribute("content",m[2]);
                 tab.title = m[1];
                 if(config.options[cookie] == m[1])
                     validTab = true;
                 }
             if(!validTab)
                 config.options[cookie] = firstTab;
             w.output.appendChild(wrapper);
             story.switchInlineTab(tabset,config.options[cookie]);
             w.nextMatch = this.lookaheadRegExp.lastIndex;
            }
    }
})

Story.prototype.switchInlineTab = function(tabset,tab)
{
    var cookie = tabset.getAttribute("cookie");
    var theTab = null
    var nodes = tabset.childNodes;
    for(var t=0; t<nodes.length; t++)
    if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab)
        {
        theTab = nodes[t];
        theTab.className = "tab tabSelected";
        }
    else
        nodes[t].className = "tab tabUnselected"
    if(theTab)
        {
        if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
            tabset.parentNode.removeChild(tabset.nextSibling);
        var tabContent = createTiddlyElement(null,"div",null,"tabContents");
        tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
        wikify(theTab.getAttribute("content"),tabContent);
        if(cookie)
            {
            config.options[cookie] = tab;
            saveOptionCookie(cookie);
            }
        }
}
   
Story.prototype.onClickInlineTab = function(e)
{
    story.switchInlineTab(this.parentNode,this.getAttribute("tab"));
    return false;
}
//}}}

My Project tiddler looks like this (Bold for specific example)

<tabs mytabs>
<tab ProjectTasks>
~ProjectTasks for "$1"
''Open communications Item(s) - <<tiddler !Count with:"$1,=comms,-=inactive,-=closed">>''
++++(UrProj)[Urgent Project Tasks]
<<tiddler !Active with: "-=comms,.projectTask,=urgent,$1" "200" "Trash">>
===

+++(WipProj)[WIP Project Tasks]
<<tiddler !Active with: "-=comms,.projectTask,=WIP,-=urgent,$1" "200" "Trash">>
===

+++(NonUrProj)[Non-Urgent]
<<tiddler !Active with: "-=comms,.projectTask,-=WIP,-=urgent,$1" "200" "Trash">>
===
</tab>

<tab Reminders>
Reminders from Now to 14 days from now
<<showReminders leadtime:0...14 format:"|DIFF|''TITLE''|DATE |In TIDDLER|" tag:"$1">>
Last week
<<showReminders leadtime:-7...-1 format:"|DIFF|TITLE|DATE|TIDDLER|" tag:"$1">>
</tab>
</tabs>


See if that helps - feel free to ask questions.

Regards


TonyM

If you have not found an easy way to do it with TiddlyWiki, you have missed something.
www.tiddlywiki.com



Måns

unread,
Mar 26, 2010, 3:27:43 AM3/26/10
to TiddlyWiki
Hi again

The 'with-argument' doesn't seem to work inside the tabs macro *but*
it does outside - therefore you can do this*1 - and put it in the
viewtemplate*2 to be shown in tiddlers tagged with project, if you
implement ie HideWhenPlugin:
*1 [[ProjectInfo]]
<<tabs txtFavourite


Tasks 'Project tasks' "ProjectInfo##Tasks"
Links 'Project-related links' "ProjectInfo##Links"
Documents 'Important documents' "ProjectInfo##Documents"
Minutes 'Meeting minutes' "ProjectInfo##Minutes"
Notes 'Project notes' "ProjectInfo##Notes"
>>
/%
!Tasks

<<tiddler ProjectInfo##tasks with: {{tiddler.title}}>>
!end
!tasks


<<matchTags *%0 "" "$1" AND task>>
!end
!Links

<<tiddler ProjectInfo##links with: {{tiddler.title}}>>
!end
!links
<<tiddler [[$1##Links]]>>
!end
!Documents
<<tiddler ProjectInfo##documents with: {{tiddler.title}}>>
!end
!documents
<<tiddler [[$1##Documents]]>>
!end
!Minutes
<<tiddler ProjectInfo##minutes with: {{tiddler.title}}>>
!end
!minutes


<<matchTags *%0 "" "$1" AND meeting>>
!end
!Notes

<<tiddler ProjectInfo##notes with: {{tiddler.title}}>>
!end
!notes


<<matchTags *%0 "" "$1" AND note>>
!end %/

*2
[[ViewTemplate]]
<div class='tab' macro='tiddler ProjectInfo'></div>

It actually works :-)

Regards Måns Mårtensson

Måns

unread,
Mar 26, 2010, 3:35:28 AM3/26/10
to TiddlyWiki
See it in action here:
http://dl.dropbox.com/u/3105342/TW/example3.html

Check out the tiddler [[project 1]] and the ViewTemplate

Regards Måns Mårtensson

Måns

unread,
Mar 26, 2010, 4:38:50 AM3/26/10
to TiddlyWiki
Here's yet another one using autotabs and forEachTiddlerPlugin:
http://dl.dropbox.com/u/3105342/TW/example4.html

Regards Måns Mårtensson

Saverio

unread,
Mar 26, 2010, 8:31:31 AM3/26/10
to TiddlyWiki
Thank you both, Måns and Anthony!! The TW support on this Google
group is awesome!

On Mar 26, 3:05 am, Anthony Muscio <anthony.mus...@gmail.com> wrote:
> I am doing something very similar.
>
> I achieved this using the inline tabs plugin

On Mar 26, 3:27 am, Måns <humam...@gmail.com> wrote:
> Hi again
>
> The 'with-argument' doesn't seem to work inside the tabs macro *but*
> it does outside - therefore you can do this*1 - and put it in the
> viewtemplate*2 to be shown in tiddlers tagged with project

Saverio

unread,
Mar 26, 2010, 10:33:46 AM3/26/10
to TiddlyWiki
Just for closure, I was able to simplify Måns's approach:

<<tabs projectInfo
"Tasks" "Project tasks" ProjectInfo##Tasks
"Links" "Project-related links" {{tiddler.title+'##Links'}}
"Documents" "Important documents" {{tiddler.title + '##Documents'}}


"Minutes" "Meeting minutes" ProjectInfo##Minutes
"Notes" "Project notes" ProjectInfo##Notes
>>
/%
!Tasks

<<matchTags *%0 "" {{tiddler.title}} AND task>>
!Minutes
<<matchTags *%0 "" {{tiddler.title}} AND meeting>>
!Notes
<<matchTags *%0 "" {{tiddler.title}} AND note>>
!end
%/

Reply all
Reply to author
Forward
0 new messages