Skip to content

Commit 341ce01

Browse files
authored
Merge pull request #4 from talha131/update-tiddlers
Update the wiki
2 parents d7c1b70 + f82d82a commit 341ce01

39 files changed

Lines changed: 1088 additions & 15 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
created: 20190226102210221
2+
creator: Mohammad
3+
modified: 20190316114911871
4+
modifier: Mohammad
5+
title: $:/config/Search/AutoFocus
6+
type: text/vnd.tiddlywiki
7+
8+
false

tiddlers/$__plugins_ajh_favorites_list.tid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
created: 20190117104703657
22
creator: Mohammad
3-
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
4-
modified: 20190216180307587
3+
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]]
4+
modified: 20190316114911720
55
modifier: Mohammad
66
tags:
77
title: $:/plugins/ajh/favorites/list

tiddlers/10th March 2019.tid

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
created: 20190310093246647
2+
creator: Mohammad
3+
modified: 20190316114912604
4+
modifier: Mohammad
5+
tags: task
6+
title: 10th March 2019
7+
type: text/vnd.tiddlywiki
8+
9+
<<docit>>
10+
11+
https://groups.google.com/d/msg/tiddlywiki/x2auoIxkTOY/1eRRZT_wBAAJ

tiddlers/12th March 2019.tid

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
created: 20190312041049827
2+
creator: Mohammad
3+
modified: 20190316114912574
4+
modifier: Mohammad
5+
tags: task
6+
title: 12th March 2019
7+
type: text/vnd.tiddlywiki
8+
9+
<<docit>>
10+
11+
https://groups.google.com/d/msg/tiddlywiki/hyUV1NwYiU4/KO0t_KZ8BQAJ
12+
https://groups.google.com/d/msg/tiddlywiki/FZ1WEpYcr3I/IDQUi3lfBQAJ
13+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
created: 20190121043529373
2+
creator: Mohammad
3+
keywords: field add remove delete
4+
modified: 20190316114912254
5+
modifier: Mohammad
6+
responder: Tiddlywiki.com
7+
tags: exmp29 fieldmangler solution
8+
title: Add or Remove Tiddler Fields
9+
type: text/vnd.tiddlywiki
10+
url: https://tiddlywiki.com/#FieldManglerWidget
11+
12+
! Add new fields
13+
; How to add a new field to a series of tiddlers?
14+
: List them and use `fieldmangler` to add the new filed.
15+
16+
!! Example
17+
Add the new filed `rank` to all tiddlers tagged with `exmp29`
18+
19+
><$macrocall $name="wikitext-example-without-html"
20+
src="""<$button> Add the new rank field
21+
<$list filter="[tag[exmp29]]">
22+
<$fieldmangler>
23+
<$action-sendmessage $message="tm-add-field" $param="rank"/>
24+
</$fieldmangler>
25+
</$list>
26+
</$button>
27+
"""/>
28+
29+
!!! Remarks
30+
# The `list` widget list all tiddlers tagged with `Links`.
31+
# The `action-sendmessage` widget
32+
# The button widget triggers the `tm-add-field` and add the `rank` field to all those tiddlers.
33+
34+
! Remove fields
35+
; How delete a field from a series of tiddlers?
36+
: List them and use `fieldmangler` to delete the filed.
37+
38+
!! Example
39+
Delete the filed `rank` from all tiddlers tagged with `exmp29`
40+
41+
><$macrocall $name="wikitext-example-without-html"
42+
src="""<$button> Delete the rank field
43+
<$list filter="[tag[exmp29]has:field[rank]]">
44+
<$fieldmangler>
45+
<$action-sendmessage $message="tm-remove-field" $param="rank"/>
46+
</$fieldmangler>
47+
</$list>
48+
</$button>
49+
"""/>
50+
51+
!! Remarks
52+
# The `list` widget list all tiddlers tagged with `exmp29` which has a field `rank`
53+
# The `action-sendmessage` widget
54+
# The button widget triggers the `tm-remove-field` and deletes `rank` field from all those tiddlers.
55+
56+
<<alert info "The field mangler widget manipulates the fields and tags of a tiddler.">>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
created: 20190314032516038
2+
creator: Mohammad
3+
keywords: editor toolbar
4+
modified: 20190316114911902
5+
modifier: Mohammad
6+
responder: JD
7+
tags: solution
8+
title: Change the Colors of One Editor Toolbar Button
9+
type: text/vnd.tiddlywiki
10+
url: https://groups.google.com/d/msg/tiddlywiki/hpBJ1peI4zU/i_9Lw4T9BQAJ
11+
12+
; How to change the background color of list-bullet button in Tiddlywiki editor toolbar?
13+
: Use the below CSS. It is possible to change the background color of all butons in a similar way.
14+
15+
Create a tiddler
16+
Tag it with `$:/tags/Stylesheet`
17+
Put the below CSS inside the tiddler body (text)
18+
19+
```
20+
.tc-editor-toolbar > .tc-reveal > button {
21+
display: inline-flex;
22+
padding: 0;
23+
}
24+
25+
.tc-editor-toolbar button .tc-image-button {
26+
padding: 2px;
27+
font-size: 1.25em;
28+
}
29+
30+
.tc-editor-toolbar button .tc-image-list-bullet {
31+
display: flex;
32+
align-items: stretch;
33+
justify-content: stretch;
34+
fill: red;
35+
background-color: yellow;
36+
}
37+
```
38+
39+
!! Remark
40+
If you need to change the background color of all toolbar buttons change the last part of above CSS as below:
41+
42+
```
43+
.tc-editor-toolbar button {
44+
display: flex;
45+
align-items: stretch;
46+
justify-content: stretch;
47+
fill: red;
48+
background-color: yellow;
49+
}
50+
```
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
created: 20190227065336369
2+
creator: Mohammad
3+
keywords: macro variable exist
4+
modified: 20190316114911890
5+
modifier: Mohammad
6+
responder: Jeremy Ruston
7+
tags: solution exmp52
8+
title: Check if Macro or Variable Exists
9+
type: text/vnd.tiddlywiki
10+
url: Ref: https://groups.google.com/d/msg/tiddlywiki/4rEuAWc4EpM/JFBoPsibBwAJ
11+
12+
;How to check if a macro / variable exists?
13+
A new subfilter `[is[variable]` has been introduced in Tddly 5.1.20 to support checking the existence of a macro variable.
14+
15+
<<dbadge Tiddlywiki 5.1.20+ danger>>
16+
17+
!! Syntax
18+
```
19+
[[VAR_NAME]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro 'VAR_NAME']]
20+
21+
[[currentTiddler]] +[is[variable]addsuffix[ is a variable]] ~[[Undefined variable or macro ‘currentTiddler']]
22+
```
23+
24+
!! Example i
25+
The below macro was proposed by [[S.S.|https://groups.google.com/d/msg/tiddlywiki/4rEuAWc4EpM/8kvLDh7qBwAJ]] and works as expected.
26+
27+
```
28+
\define variable-test(var)
29+
<$list filter="[[$var$]] +[is[variable]]" emptyMessage="''$var$'' - //Undefined variable or macro//">
30+
''$var$'' - Existed variable or macro
31+
</$list>
32+
\end
33+
34+
1. <<variable-test list-links>>
35+
36+
2. <<variable-test list-linkss>>
37+
```
38+
39+
See in [[Example 52: Check if Variable Macro Exists]] the new `subfilter` in action.
40+
41+
!! Example ii
42+
[[Mal|https://groups.google.com/d/msg/tiddlywiki/4rEuAWc4EpM/1qOUvPdhAgAJ]] has proposed the below simple syntax
43+
44+
```
45+
{{{ [[myMacro]] +[!is[variable]addsuffix[ is not defined]] }}}
46+
```
47+
48+
This should produce "myMacro is not defined" or nothing if the macro or variable is defined.

tiddlers/Check if Passed the Macro Parameter.tid

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
created: 20190214163529629
22
creator: Mohammad
33
keywords: macro blank empty parameter
4-
modified: 20190224163831614
4+
modified: 20190316114915029
55
modifier: Mohammad
66
responder: Mohammad and Bimlas
77
tags: solution
@@ -31,9 +31,21 @@ Do my job!
3131

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

34+
!! Alternative i
35+
A rather robust solution is proposed by BTC as below
36+
37+
```
38+
\define macro2(param)
39+
<$list filter="[<__param__>minlength[1]]">
40+
41+
Do my job!
42+
</$list>
43+
\end
44+
```
45+
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.
3446

3547

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

3951
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
created: 20190314174758260
2+
creator: Mohammad
3+
keywords: newer greater tiddler
4+
modified: 20190316114914999
5+
modifier: Mohammad
6+
responder: BurningTreeC
7+
tags: exmp54 solution
8+
title: Check if Tiddler Newer Than the Other
9+
type: text/vnd.tiddlywiki
10+
url: https://groups.google.com/d/msg/tiddlywiki/9QQvkJkLogA/UbIgaSFSBgAJ
11+
12+
; How to check if a tiddler is newer than the other?
13+
: Compare the modified time of two tiddlers
14+
15+
```
16+
\define is-thisTid-newer(TidA, TidB)
17+
<$set name="tidAMod" value={{{ [[$TidA$]get[modified]] }}}>
18+
<$set name="tidBMod" value={{{ [[$TidB$]get[modified]] }}}>
19+
<$list filter="[<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidAMod>]">
20+
Yes, $TidA$ is newer
21+
</$list>
22+
<$list filter="[<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>]">
23+
No, $TidA$ is older
24+
</$list>
25+
</$set>
26+
</$set>
27+
\end
28+
```
29+
30+
!! Remarks
31+
# The first two `$set` widgets get the date of modification of two tiddlers and stores in related variables
32+
# The first `$list` widget uses a smart filter to determine if //tidAMod// is greater than //tidBMod//.
33+
# The second `$list` widget uses a smart filter to determine if //tidBMod// is greater than //tidAMod//.
34+
35+
!! This is another solution
36+
Here the `$reveal` widget has been used! This is a little longer code in comparison to the above solution.
37+
See for more infor [[BTC|https://groups.google.com/d/msg/tiddlywiki/9QQvkJkLogA/xDWozyJRBgAJ]].
38+
39+
```
40+
\define is-newer(TidA, TidB)
41+
<$set name="tidAMod" value={{{ [[$TidA$]get[modified]] }}}>
42+
<$set name="tidBMod" value={{{ [[$TidB$]get[modified]] }}}>
43+
<$reveal type="match" text="yes" default={{{ [<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>addprefix[yes]removesuffix<tidAMod>] ~[[no]] }}}>
44+
$TidA$ is newer
45+
</$reveal>
46+
<$reveal type="match" text="no" default={{{ [<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>addprefix[yes]removesuffix<tidAMod>] ~[[no]] }}}>
47+
$TidB$ is newer
48+
</$reveal>
49+
</$set>
50+
</$set>
51+
\end
52+
```
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
created: 20190222064439458
2+
creator: Mohammad
3+
keywords: create tiddler sequence number
4+
modified: 20190316114914237
5+
modifier: Mohammad
6+
responder: Mohammad
7+
tags: exmp50 solution
8+
title: Create Tiddler with Sequence Number
9+
type: text/vnd.tiddlywiki
10+
url: https://groups.google.com/d/msg/tiddlywiki/3_Xacb7H1p0/BN73J04iAQAJ
11+
12+
Assume you want to create tiddlers all tagged with say `myTag` and have unique title with ordinal number.
13+
So
14+
15+
* tiddlers have title like `myTiddler-1`
16+
* tiddlers all tagged with `myTag`
17+
18+
```
19+
\define newTitle() myTiddler-{{{[tag[myTag]count[]add[1]]}}}
20+
\define newTiddler()
21+
<$wikify name="myTitle" text="<<newTitle>>" >
22+
<$action-createtiddler $basetitle=<<myTitle>> tags="myTag" />
23+
</$wikify>
24+
\end
25+
```
26+
27+
Then use it like below
28+
29+
```
30+
<$button actions=<<newTiddler>>>
31+
Create a new tiddler
32+
</$button>
33+
```
34+
35+
!!! Remarks
36+
* The `wikify` widget, calls newTitle macro, creates a new title using filter transclusion and store it in myTitle variable.
37+
* The `action-createtiddler` creates a new tiddler using myTitle and myTag.
38+
39+
!! Issues and solution
40+
[[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.
41+
42+
!!! Solution
43+
* If myTiddler-2 deleted, the code will create myTiddler-3 1. So there is no risk to overwrite
44+
* To overcome this issue, the below recursive macro take cares of this issue as below
45+
46+
```
47+
\define newTitle() myTiddler-{{{[tag[myTag]count[]add[$(inc)$]]}}}
48+
49+
\define newTiddler(n:0)
50+
<$set name="inc" value={{{ [<__n__>add[1]] }}}>
51+
<$wikify name="myTitle" text="<<newTitle>>" >
52+
<$list filter="[<myTitle>] +[!has[title]]"
53+
emptyMessage=""" <$macrocall $name="newTiddler" n=<<inc>> /> """>
54+
<$action-createtiddler $basetitle=<<myTitle>> tags="myTag" />
55+
</$list>
56+
</$wikify>
57+
</$set>
58+
\end
59+
60+
<$button actions=<<newTiddler>>>
61+
Create a new tiddler
62+
</$button>
63+
```
64+
65+
!!! Remarks
66+
* The newTiddler macro check if the tiddler is going to created is existed or not. It uses the `list` widget for this purpose.
67+
* If the tiddler is existed, it calls itself with n icremented by one. This is done by emptyMessage part of `list` widget.
68+
* The newTiddler macro calls itself as many as time to find a sequence number not in use and then creates the tiddler.
69+
70+
!!! Solution iii
71+
[[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.
72+
73+
```
74+
\define newTitle() myTiddler-{{{[tag[myTag]count[]add[1]addprefix[0000]split[]last[3]join[]]}}}
75+
\define newTiddler()
76+
<$wikify name="myTitle" text="<<newTitle>>" >
77+
<$action-createtiddler $basetitle=<<myTitle>> tags="myTag" />
78+
</$wikify>
79+
\end
80+
```
81+
See this method in action: [[Example 50: Tiddler Title with Zero Padded Number]].

0 commit comments

Comments
 (0)