Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tiddlers/$__config_Search_AutoFocus.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
created: 20190226102210221
creator: Mohammad
modified: 20190316114911871
modifier: Mohammad
title: $:/config/Search/AutoFocus
type: text/vnd.tiddlywiki

false
4 changes: 2 additions & 2 deletions tiddlers/$__plugins_ajh_favorites_list.tid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
created: 20190117104703657
creator: Mohammad
list: [[Worth Reading]] Sandbox $:/.mr/macro/utility [[Tips: Advanced Search with Search Operator]] [[Variables vs. Parameters]] [[Variable Textual Substitution]] [[Shorthand Syntax Summary]] myTemplate/help/xxx
modified: 20190216180307587
list: [[Worth Reading]] Sandbox $:/.mr/macro/utility [[Tips: Advanced Search with Search Operator]] [[Variables vs. Parameters]] [[Variable Textual Substitution]] [[Shorthand Syntax Summary]] myTemplate/help/xxx [[Jeremy Solution ii]]
modified: 20190316114911720
modifier: Mohammad
tags:
title: $:/plugins/ajh/favorites/list
Expand Down
11 changes: 11 additions & 0 deletions tiddlers/10th March 2019.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
created: 20190310093246647
creator: Mohammad
modified: 20190316114912604
modifier: Mohammad
tags: task
title: 10th March 2019
type: text/vnd.tiddlywiki

<<docit>>

https://groups.google.com/d/msg/tiddlywiki/x2auoIxkTOY/1eRRZT_wBAAJ
13 changes: 13 additions & 0 deletions tiddlers/12th March 2019.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
created: 20190312041049827
creator: Mohammad
modified: 20190316114912574
modifier: Mohammad
tags: task
title: 12th March 2019
type: text/vnd.tiddlywiki

<<docit>>

https://groups.google.com/d/msg/tiddlywiki/hyUV1NwYiU4/KO0t_KZ8BQAJ
https://groups.google.com/d/msg/tiddlywiki/FZ1WEpYcr3I/IDQUi3lfBQAJ

56 changes: 56 additions & 0 deletions tiddlers/Add or Remove Tiddler Fields.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
created: 20190121043529373
creator: Mohammad
keywords: field add remove delete
modified: 20190316114912254
modifier: Mohammad
responder: Tiddlywiki.com
tags: exmp29 fieldmangler solution
title: Add or Remove Tiddler Fields
type: text/vnd.tiddlywiki
url: https://tiddlywiki.com/#FieldManglerWidget

! Add new fields
; How to add a new field to a series of tiddlers?
: List them and use `fieldmangler` to add the new filed.

!! Example
Add the new filed `rank` to all tiddlers tagged with `exmp29`

><$macrocall $name="wikitext-example-without-html"
src="""<$button> Add the new rank field
<$list filter="[tag[exmp29]]">
<$fieldmangler>
<$action-sendmessage $message="tm-add-field" $param="rank"/>
</$fieldmangler>
</$list>
</$button>
"""/>

!!! Remarks
# The `list` widget list all tiddlers tagged with `Links`.
# The `action-sendmessage` widget
# The button widget triggers the `tm-add-field` and add the `rank` field to all those tiddlers.

! Remove fields
; How delete a field from a series of tiddlers?
: List them and use `fieldmangler` to delete the filed.

!! Example
Delete the filed `rank` from all tiddlers tagged with `exmp29`

><$macrocall $name="wikitext-example-without-html"
src="""<$button> Delete the rank field
<$list filter="[tag[exmp29]has:field[rank]]">
<$fieldmangler>
<$action-sendmessage $message="tm-remove-field" $param="rank"/>
</$fieldmangler>
</$list>
</$button>
"""/>

!! Remarks
# The `list` widget list all tiddlers tagged with `exmp29` which has a field `rank`
# The `action-sendmessage` widget
# The button widget triggers the `tm-remove-field` and deletes `rank` field from all those tiddlers.

<<alert info "The field mangler widget manipulates the fields and tags of a tiddler.">>
50 changes: 50 additions & 0 deletions tiddlers/Change the Colors of One Editor Toolbar Button.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
created: 20190314032516038
creator: Mohammad
keywords: editor toolbar
modified: 20190316114911902
modifier: Mohammad
responder: JD
tags: solution
title: Change the Colors of One Editor Toolbar Button
type: text/vnd.tiddlywiki
url: https://groups.google.com/d/msg/tiddlywiki/hpBJ1peI4zU/i_9Lw4T9BQAJ

; How to change the background color of list-bullet button in Tiddlywiki editor toolbar?
: Use the below CSS. It is possible to change the background color of all butons in a similar way.

Create a tiddler
Tag it with `$:/tags/Stylesheet`
Put the below CSS inside the tiddler body (text)

```
.tc-editor-toolbar > .tc-reveal > button {
display: inline-flex;
padding: 0;
}

.tc-editor-toolbar button .tc-image-button {
padding: 2px;
font-size: 1.25em;
}

.tc-editor-toolbar button .tc-image-list-bullet {
display: flex;
align-items: stretch;
justify-content: stretch;
fill: red;
background-color: yellow;
}
```

!! Remark
If you need to change the background color of all toolbar buttons change the last part of above CSS as below:

```
.tc-editor-toolbar button {
display: flex;
align-items: stretch;
justify-content: stretch;
fill: red;
background-color: yellow;
}
```
48 changes: 48 additions & 0 deletions tiddlers/Check if Macro or Variable Exists.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
created: 20190227065336369
creator: Mohammad
keywords: macro variable exist
modified: 20190316114911890
modifier: Mohammad
responder: Jeremy Ruston
tags: solution exmp52
title: Check if Macro or Variable Exists
type: text/vnd.tiddlywiki
url: Ref: https://groups.google.com/d/msg/tiddlywiki/4rEuAWc4EpM/JFBoPsibBwAJ

;How to check if a macro / variable exists?
A new subfilter `[is[variable]` has been introduced in Tddly 5.1.20 to support checking the existence of a macro variable.

<<dbadge Tiddlywiki 5.1.20+ danger>>

!! Syntax
```
[[VAR_NAME]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro 'VAR_NAME']]

[[currentTiddler]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro ‘currentTiddler']]
```

!! Example i
The below macro was proposed by [[S.S.|https://groups.google.com/d/msg/tiddlywiki/4rEuAWc4EpM/8kvLDh7qBwAJ]] and works as expected.

```
\define variable-test(var)
<$list filter="[[$var$]] +[is[variable]]" emptyMessage="''$var$'' - //Undefined variable or macro//">
''$var$'' - Existed variable or macro
</$list>
\end

1. <<variable-test list-links>>

2. <<variable-test list-linkss>>
```

See in [[Example 52: Check if Variable Macro Exists]] the new `subfilter` in action.

!! Example ii
[[Mal|https://groups.google.com/d/msg/tiddlywiki/4rEuAWc4EpM/1qOUvPdhAgAJ]] has proposed the below simple syntax

```
{{{ [[myMacro]] +[!is[variable]addsuffix[ is not defined]] }}}
```

This should produce "myMacro is not defined" or nothing if the macro or variable is defined.
16 changes: 14 additions & 2 deletions tiddlers/Check if Passed the Macro Parameter.tid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
created: 20190214163529629
creator: Mohammad
keywords: macro blank empty parameter
modified: 20190224163831614
modified: 20190316114915029
modifier: Mohammad
responder: Mohammad and Bimlas
tags: solution
Expand Down Expand Up @@ -31,9 +31,21 @@ Do my job!

<<alert info "''Note'': Wrapping the whole macro inside above `list` widget causes macro only run if the parameter gets a non-Empty value.">>

!! Alternative i
A rather robust solution is proposed by BTC as below

```
\define macro2(param)
<$list filter="[<__param__>minlength[1]]">

Do my job!
</$list>
\end
```
In this method, if param has not been passed the `minlength[1]` returns nothing. This operator means the input should have at least one character.


!! Alternative
!! Alternative ii
Bimlas in [[forum|https://groups.google.com/d/msg/tiddlywiki/82N15sAnoPs/iWhtoBjbAwAJ]] proposed this alternative, in that the macro is blank

```
Expand Down
52 changes: 52 additions & 0 deletions tiddlers/Check if Tiddler Newer Than the Other.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
created: 20190314174758260
creator: Mohammad
keywords: newer greater tiddler
modified: 20190316114914999
modifier: Mohammad
responder: BurningTreeC
tags: exmp54 solution
title: Check if Tiddler Newer Than the Other
type: text/vnd.tiddlywiki
url: https://groups.google.com/d/msg/tiddlywiki/9QQvkJkLogA/UbIgaSFSBgAJ

; How to check if a tiddler is newer than the other?
: Compare the modified time of two tiddlers

```
\define is-thisTid-newer(TidA, TidB)
<$set name="tidAMod" value={{{ [[$TidA$]get[modified]] }}}>
<$set name="tidBMod" value={{{ [[$TidB$]get[modified]] }}}>
<$list filter="[<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidAMod>]">
Yes, $TidA$ is newer
</$list>
<$list filter="[<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>]">
No, $TidA$ is older
</$list>
</$set>
</$set>
\end
```

!! Remarks
# The first two `$set` widgets get the date of modification of two tiddlers and stores in related variables
# The first `$list` widget uses a smart filter to determine if //tidAMod// is greater than //tidBMod//.
# The second `$list` widget uses a smart filter to determine if //tidBMod// is greater than //tidAMod//.

!! This is another solution
Here the `$reveal` widget has been used! This is a little longer code in comparison to the above solution.
See for more infor [[BTC|https://groups.google.com/d/msg/tiddlywiki/9QQvkJkLogA/xDWozyJRBgAJ]].

```
\define is-newer(TidA, TidB)
<$set name="tidAMod" value={{{ [[$TidA$]get[modified]] }}}>
<$set name="tidBMod" value={{{ [[$TidB$]get[modified]] }}}>
<$reveal type="match" text="yes" default={{{ [<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>addprefix[yes]removesuffix<tidAMod>] ~[[no]] }}}>
$TidA$ is newer
</$reveal>
<$reveal type="match" text="no" default={{{ [<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>addprefix[yes]removesuffix<tidAMod>] ~[[no]] }}}>
$TidB$ is newer
</$reveal>
</$set>
</$set>
\end
```
81 changes: 81 additions & 0 deletions tiddlers/Create Tiddler with Sequence Number.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
created: 20190222064439458
creator: Mohammad
keywords: create tiddler sequence number
modified: 20190316114914237
modifier: Mohammad
responder: Mohammad
tags: exmp50 solution
title: Create Tiddler with Sequence Number
type: text/vnd.tiddlywiki
url: https://groups.google.com/d/msg/tiddlywiki/3_Xacb7H1p0/BN73J04iAQAJ

Assume you want to create tiddlers all tagged with say `myTag` and have unique title with ordinal number.
So

* tiddlers have title like `myTiddler-1`
* tiddlers all tagged with `myTag`

```
\define newTitle() myTiddler-{{{[tag[myTag]count[]add[1]]}}}
\define newTiddler()
<$wikify name="myTitle" text="<<newTitle>>" >
<$action-createtiddler $basetitle=<<myTitle>> tags="myTag" />
</$wikify>
\end
```

Then use it like below

```
<$button actions=<<newTiddler>>>
Create a new tiddler
</$button>
```

!!! Remarks
* The `wikify` widget, calls newTitle macro, creates a new title using filter transclusion and store it in myTitle variable.
* The `action-createtiddler` creates a new tiddler using myTitle and myTag.

!! Issues and solution
[[Thomas Elmiger|https://groups.google.com/d/msg/tiddlywiki/3_Xacb7H1p0/KSYPzQguAQAJ]] states that if some tiddlers deleted in this between, the above code may overwrite the previous ones. Assume you have myTiddler-1, myTiddler-2, and myTiddler-3. Now you delete myTiddler-2 abd then create another, the current code sees there is two tiddler, so it creates the next and overwrite myTiddler-3.

!!! Solution
* If myTiddler-2 deleted, the code will create myTiddler-3 1. So there is no risk to overwrite
* To overcome this issue, the below recursive macro take cares of this issue as below

```
\define newTitle() myTiddler-{{{[tag[myTag]count[]add[$(inc)$]]}}}

\define newTiddler(n:0)
<$set name="inc" value={{{ [<__n__>add[1]] }}}>
<$wikify name="myTitle" text="<<newTitle>>" >
<$list filter="[<myTitle>] +[!has[title]]"
emptyMessage=""" <$macrocall $name="newTiddler" n=<<inc>> /> """>
<$action-createtiddler $basetitle=<<myTitle>> tags="myTag" />
</$list>
</$wikify>
</$set>
\end

<$button actions=<<newTiddler>>>
Create a new tiddler
</$button>
```

!!! Remarks
* The newTiddler macro check if the tiddler is going to created is existed or not. It uses the `list` widget for this purpose.
* If the tiddler is existed, it calls itself with n icremented by one. This is done by emptyMessage part of `list` widget.
* The newTiddler macro calls itself as many as time to find a sequence number not in use and then creates the tiddler.

!!! Solution iii
[[Mal|https://groups.google.com/d/msg/tiddlywiki/3_Xacb7H1p0/6LqGKyVmAQAJ]] has proposed using zero padded number. A revised version of zero padded number (assuming 3 digits) is given below.

```
\define newTitle() myTiddler-{{{[tag[myTag]count[]add[1]addprefix[0000]split[]last[3]join[]]}}}
\define newTiddler()
<$wikify name="myTitle" text="<<newTitle>>" >
<$action-createtiddler $basetitle=<<myTitle>> tags="myTag" />
</$wikify>
\end
```
See this method in action: [[Example 50: Tiddler Title with Zero Padded Number]].
15 changes: 15 additions & 0 deletions tiddlers/Disable Search Autofocus.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
created: 20190226102239362
creator: Mohammad
keywords: search auto-focus
modified: 20190316114915566
modifier: Mohammad
responder: Jeremy Ruston
tags: solution
title: Disable Search Autofocus
type: text/vnd.tiddlywiki
url: https://groups.google.com/d/msg/tiddlywiki/kuG94UuCnV8/MSVM6MY3DAAJ

Tiddlywiki by default has auofocus on Searchbox on the sidebar. This may cause annoying behaviour when you open a wiki and a search word in the sidebar search box. To disable this feature:

# Open [[$:/config/Search/AutoFocus]]
# Set the text value of this tiddler to `false`.
Loading