Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: How to add new cascade and use it #8472

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

linonetwo
Copy link
Contributor

No description provided.

@linonetwo linonetwo marked this pull request as ready for review August 2, 2024 07:02
Copy link
Member

@Jermolene Jermolene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @linonetwo – I am delighted at your willingness to tackle documentation tasks, and the standard of your contributions is very good.

editions/dev/tiddlers/Cascade Mechanism.tid Outdated Show resolved Hide resolved

!!! The default template as a fallback

(omitted here, see the latest version on [ext[Github|https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/core/ui/ViewTemplate/tags/default.tid]])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to be self contained and transclude the shadow tiddler as a subtiddler from the core plugin. This will ensure that the real shadow is displayed even if it has been overridden.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires /dev doc site use prerelease of TW, will it be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we merge this into master branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @linonetwo yes it looks like this will need to be merged to "master"

editions/dev/tiddlers/Cascade Mechanism.tid Outdated Show resolved Hide resolved
editions/dev/tiddlers/Cascade Mechanism.tid Outdated Show resolved Hide resolved
editions/dev/tiddlers/Cascade Mechanism.tid Outdated Show resolved Hide resolved
@linonetwo
Copy link
Contributor Author

linonetwo commented Aug 2, 2024

@Jermolene There remains two concerns to discuss.

@Jermolene
Copy link
Member

Hi @linonetwo are there any remaining concerns?

@linonetwo linonetwo changed the base branch from tiddlywiki-com to master August 10, 2024 06:04
@linonetwo
Copy link
Contributor Author

linonetwo commented Aug 10, 2024

I don't know how to transclude subtiddler, there is a post https://talk.tiddlywiki.org/t/how-to-transclude-a-subtiddler-with-template-in-tiddlywiki/7100 , I tried the solution on it

<$transclude tiddler="$:/core" subtiddler="$:/core/ui/ViewTemplate/tags/default" template="$:/core/ui/ViewTemplate/body/code"/>

and it is not working.


I see, the syntax is correct, just can't use template. And the render result of it is empty string.

Use view widget instead. But it become plain text, don't have code style. Wrap with pre > code cause transclude fail.

@pmario
Copy link
Member

pmario commented Aug 23, 2024

Your code is wrong. The transclude-widget does not have a template parameter

If you use:

<$tiddler tiddler=HelloThere>
<$transclude $tiddler="$:/core" $subtiddler="$:/core/ui/ViewTemplate/tags/default" />
</$tiddler>

It works just fine at: https://tiddlywiki.com/prerelease/ see: prerelease

@@ -29,6 +30,6 @@ and a listener is registered at the store which executes the refresh function of
[[Techniques for including other tiddlers and Templates|Transclusion and TextReference]] are finally used in [[$:/core/ui/PageTemplate]] to build the TiddlyWiki UI only from tiddlers written in WikiText (with widgets implemented in javascript):

For example to implement the list of open wiki pages the [[$:/core/ui/PageTemplate]] contains a [[navigator widget|$:/core/modules/widgets/navigator.js]] which maintains a list of open tiddlers in a field of [[$:/StoryList]] and handles events like ``tm-navigate`` by adding a tiddler specified as parameter to the top of the list in [[$:/StoryList]].
The [[story tiddler|$:/core/ui/PageTemplate/story]] transcluded in [[$:/core/ui/PageTemplate]] then uses a ~ListWidget to transclude all tiddlers in [[$:/StoryList]] through a special template [[$:/core/ui/ViewTemplate]].
The [[story tiddler|$:/core/ui/PageTemplate/story]] transcluded in [[$:/core/ui/PageTemplate]] then uses a ~ListWidget to transclude all tiddlers in [[$:/StoryList]] through a special template [[$:/core/ui/ViewTemplate]]. All view template can be further override using [[Cascade Mechanism]].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the added sentence does not make sense. -- At least I do not understand it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@linonetwo
Copy link
Contributor Author

<$tiddler tiddler=HelloThere>
<$transclude $tiddler="$:/core" $subtiddler="$:/core/ui/ViewTemplate/tags/default" />
</$tiddler>

Thanks, but this render a tag, instead of a codeblock. Jeremy want to transclude the raw tiddler content as codeblock here.

I leave a link to [[$:/core/ui/ViewTemplate/tags/default]] instead now.

@pmario
Copy link
Member

pmario commented Aug 24, 2024

<pre><$view tiddler="$:/core" subtiddler="$:/core/ui/ViewTemplate/tags/default" mode=block format=text/>
</pre>

image

@Jermolene
Copy link
Member

Thanks @linonetwo. I am afraid that this hasn't turned out as well as I had hoped, and I am really struggling to follow it. I don't have time at the moment to edit it properly, but perhaps another English-speaking contributor may be prepared to help.

@Jermolene
Copy link
Member

Hi @linonetwo sorry if that sounds harsh, I did start to work through some edits but I found it hard to track the intention in some areas. Here are my changes:

Partially completed edits
This guide shows you how to add a new [[cascade|https://tiddlywiki.com/#Cascades]] to the ~TiddlyWiki core or to your own plugins. This allows third-party plugins to extend the functionality of the core or your plugin.

!! Create a Control Panel Tab

To create a new tab under ControlPanel - Advanced - [[Cascade|$:/core/ui/ControlPanel/Cascades]].

title: $:/core/ui/ControlPanel/ViewTemplateTags
tags: $:/tags/ControlPanel/Cascades
caption: {{$:/language/ControlPanel/ViewTemplateTags/Caption}}

\define lingo-base() $:/language/ControlPanel/ViewTemplateTags/

<<lingo Hint>>

{{$:/tags/ViewTemplateTagsFilter||$:/snippets/ListTaggedCascade}}

It is important to add the related language files as follows:

title: $:/language/ControlPanel/

ViewTemplateTags/Caption: View Template Tags
ViewTemplateTags/Hint: This rule cascade is used by the default view template to dynamically choose the template for displaying the tags area of a tiddler.

!! Add Default Configuration

title: $:/config/ViewTemplateTagsFilters/
tags: $:/tags/ViewTemplateTagsFilter

default: [[$:/core/ui/ViewTemplate/tags/default]]

!! Use The New Cascade

This is a simplified example based on real-world use case. It provides a button to toggle the "EditMode" based on a state tiddler. It will show how the default template we created above can be overridden by a custom template.

!!! Your template

Add what you want to show conditionally, and update publisher/plugin-name to your own plugin name.

This template doesn't have anything directly related to the cascade mechanism we just created, but its title will be used later.

code-body: yes
title: $:/plugins/publisher/plugin-name/EditMode

\whitespace trim
<$reveal type="nomatch" stateTitle=<<folded-state>> text="hide" tag="div" retain="yes" animate="yes">
  <div class="tc-tags-wrapper" style="display:flex;">
    <$transclude tiddler="$:/core/ui/EditTemplate/tags"/>
    <$button class="tc-btn-invisible" style="margin-left:1em;">
      {{$:/core/images/done-button}}
      <$action-deletetiddler $tiddler={{{ [[$:/state/edit-view-mode-tags/]addsuffix<storyTiddler>] }}}/>
    </$button>
  </div>
</$reveal>

!!! The condition

Write a filter ends with the then[$:/plugins/publisher/plugin-name/EditMode].

code-body: yes
tags: $:/tags/ViewTemplateTagsFilter
title: $:/plugins/publisher/plugin-name/CascadeEditMode
list-before: $:/config/ViewTemplateTagsFilters/default

[[$:/state/edit-view-mode-tags/]addsuffix<currentTiddler>get[text]compare:string:eq[yes]then[$:/plugins/publisher/plugin-name/EditMode]]

!!! A button to trigger the condition

code-body: yes
tags: $:/tags/ViewTemplate/Tags
title: $:/plugins/publisher/plugin-name/TriggerEdit

\whitespace trim
<%if [<storyTiddler>get[tags]!is[blank]] %>
  <$button class="tc-btn-invisible" set={{{ [[$:/state/edit-view-mode-tags/]addsuffix<storyTiddler>] }}} setTo="yes" tooltip="add tags">
    {{$:/core/images/new-here-button}}
  </$button>
<%endif%>

@linonetwo
Copy link
Contributor Author

Never mind, I'm also updating it. Please take your time review other PRs first.

@linonetwo
Copy link
Contributor Author

@pmario Thanks, that works, I'm using it. And I update it to the forum https://talk.tiddlywiki.org/t/how-to-transclude-a-subtiddler-with-template-in-tiddlywiki/7100/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants