2021-02-23 17:01:54 +00:00
|
|
|
"
|
|
|
|
I model a Tiddler object in [TiddlyWiki](https://tiddlywiki.com/).
|
|
|
|
|
|
|
|
I implement the standard fields as described in the standard documentation at: <https://tiddlywiki.com/#TiddlerFields>
|
|
|
|
|
|
|
|
"
|
|
|
|
Class {
|
2021-10-19 23:23:57 +00:00
|
|
|
#name : #Tiddler,
|
|
|
|
#superclass : #Object,
|
2021-02-23 17:01:54 +00:00
|
|
|
#instVars : [
|
|
|
|
'title',
|
|
|
|
'text',
|
|
|
|
'modified',
|
|
|
|
'created',
|
|
|
|
'creator',
|
|
|
|
'tags',
|
|
|
|
'type',
|
|
|
|
'list',
|
2021-07-15 22:24:05 +00:00
|
|
|
'caption',
|
2021-08-17 17:03:53 +00:00
|
|
|
'modifier',
|
2021-08-29 22:50:17 +00:00
|
|
|
'wiki',
|
|
|
|
'customFields',
|
|
|
|
'bag',
|
|
|
|
'revision'
|
2021-02-23 17:01:54 +00:00
|
|
|
],
|
2021-10-19 23:23:57 +00:00
|
|
|
#category : #'TiddlyWiki-Model'
|
2021-02-23 17:01:54 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #'instance creation' }
|
2021-08-08 18:11:57 +00:00
|
|
|
Tiddler class >> nowLocal [
|
2022-03-08 22:32:41 +00:00
|
|
|
^ ((ZTimestampFormat fromString: '20010203160506700')
|
|
|
|
format: (ZTimestamp fromString: Time nowLocal asDateAndTime asString)) copyFrom: 1 to: 17
|
2021-08-08 18:11:57 +00:00
|
|
|
]
|
|
|
|
|
2022-12-09 17:49:51 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> appendPrefixToText: prefix [
|
|
|
|
|
|
|
|
| textPre |
|
|
|
|
textPre := self text.
|
|
|
|
self text: prefix, textPre.
|
|
|
|
^ self
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-06-05 18:32:51 +00:00
|
|
|
Tiddler >> asDictionary [
|
2021-09-09 16:03:15 +00:00
|
|
|
| response |
|
|
|
|
response := Dictionary new
|
2021-06-05 18:32:51 +00:00
|
|
|
at: 'title' put: self title;
|
|
|
|
at: 'text' put: self text;
|
2022-03-08 22:32:41 +00:00
|
|
|
at: 'created' put: self created;
|
2021-06-05 18:32:51 +00:00
|
|
|
at: 'tags' put: self tags;
|
2021-08-09 13:52:19 +00:00
|
|
|
at: 'type' put: self type;
|
2021-09-04 19:27:49 +00:00
|
|
|
at: 'creator' put: self creator;
|
|
|
|
at: 'modifier' put: self modifier;
|
2022-03-08 22:32:41 +00:00
|
|
|
at: 'modified' put: self modified;
|
2021-09-04 19:27:49 +00:00
|
|
|
at: 'bag' put: self bag;
|
|
|
|
at: 'revision' put: self revision;
|
2021-06-05 18:32:51 +00:00
|
|
|
yourself.
|
2021-09-09 16:03:15 +00:00
|
|
|
self customFields ifNotEmpty: [
|
|
|
|
self customFields keysAndValuesDo: [:k :v |
|
|
|
|
response at: k put: v
|
|
|
|
]
|
|
|
|
].
|
|
|
|
^ response
|
2021-09-09 01:00:14 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #converting }
|
2021-09-08 22:52:03 +00:00
|
|
|
Tiddler >> asJson [
|
2021-09-09 01:00:14 +00:00
|
|
|
^ STONJSON toStringPretty: { self asDictionary }
|
2021-09-08 22:52:03 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #converting }
|
2021-09-08 22:52:03 +00:00
|
|
|
Tiddler >> asJsonString [
|
|
|
|
^ STONJSON toStringPretty: self asDictionary
|
2021-07-15 22:24:05 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-07 22:03:22 +00:00
|
|
|
Tiddler >> asJsonTempFile [
|
2021-08-08 18:11:57 +00:00
|
|
|
^ MarkupFile exportAsFileOn: FileLocator temp / self title, 'json' containing:self asJson
|
2021-08-07 22:03:22 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-08 22:52:03 +00:00
|
|
|
Tiddler >> asStonStringPretty [
|
|
|
|
| output temp |
|
2021-09-09 01:00:14 +00:00
|
|
|
temp := self copy.
|
2021-09-08 22:52:03 +00:00
|
|
|
temp wiki: nil.
|
|
|
|
output := '' writeStream.
|
|
|
|
(STON writer on: output)
|
|
|
|
newLine: String crlf;
|
|
|
|
prettyPrint: true;
|
|
|
|
keepNewLines: true;
|
|
|
|
nextPut: temp.
|
|
|
|
^ output contents
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-29 22:50:17 +00:00
|
|
|
Tiddler >> bag [
|
|
|
|
^ bag
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-29 22:50:17 +00:00
|
|
|
Tiddler >> bag: aString [
|
|
|
|
bag := aString
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> caption [
|
|
|
|
|
|
|
|
^ caption
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> caption: anObject [
|
|
|
|
|
|
|
|
caption := anObject
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> created [
|
|
|
|
|
2022-03-08 22:32:41 +00:00
|
|
|
^ created ifNil: [ created := self class nowLocal ]
|
2021-02-23 17:01:54 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> created: anObject [
|
|
|
|
|
|
|
|
created := anObject
|
|
|
|
]
|
|
|
|
|
2022-07-23 18:43:37 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> createdAsTWFormat [
|
2022-08-08 19:53:00 +00:00
|
|
|
(self created beginsWith: 'NaN') ifTrue: [ self created: self class nowLocal].
|
2022-07-23 18:43:37 +00:00
|
|
|
^ ((ZTimestampFormat fromString: '20010203160506700')
|
|
|
|
format: (ZTimestamp fromString: self created)) copyFrom: 1 to: 17
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
2022-07-24 14:33:28 +00:00
|
|
|
Tiddler >> createdReversableEncoded [
|
|
|
|
"I encode the tiddler creation date with miliseconds precision in a shorter reversable way
|
|
|
|
(from 17 characters to 10).
|
|
|
|
But when tiddlers are created with the same exact date (for example programmatically)
|
|
|
|
I produce the same encoding (because of reversability).
|
|
|
|
I recommend to use nanoID instead to get unique visible different identifiers "
|
2022-07-23 18:43:37 +00:00
|
|
|
| output longDate |
|
|
|
|
longDate := self createdAsTWFormat.
|
2022-07-24 14:33:28 +00:00
|
|
|
output := WriteStream on: ''.
|
2022-07-23 18:43:37 +00:00
|
|
|
1 to: 14 by: 2 do: [ :i |
|
2022-07-24 14:33:28 +00:00
|
|
|
output nextPutAll: (longDate copyFrom: i to: i +1) greaseInteger asCharacterDigit greaseString
|
2022-07-23 18:43:37 +00:00
|
|
|
].
|
2022-07-24 14:33:28 +00:00
|
|
|
output nextPutAll: (longDate copyFrom: 15 to: 17).
|
2022-07-23 18:43:37 +00:00
|
|
|
^ output contents
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> creator [
|
|
|
|
|
|
|
|
^ creator
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> creator: anObject [
|
|
|
|
|
|
|
|
creator := anObject
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-29 22:50:17 +00:00
|
|
|
Tiddler >> customFields [
|
|
|
|
^ customFields ifNil: [ customFields := Dictionary new]
|
|
|
|
]
|
|
|
|
|
2022-03-09 22:53:57 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> deleteUid [
|
|
|
|
self customFields deleteKey: 'uid'.
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-09 16:03:15 +00:00
|
|
|
Tiddler >> exportJSONFile [
|
2022-09-26 23:04:24 +00:00
|
|
|
|
|
|
|
| jsonFile folder |
|
|
|
|
folder := self wiki folder.
|
|
|
|
jsonFile := folder / 'tiddlers' / ((self fileName removeSuffix: '.ston'), '.json').
|
2021-09-09 16:03:15 +00:00
|
|
|
^ MarkupFile exportAsFileOn: jsonFile containing:self asJson
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-09 01:00:14 +00:00
|
|
|
Tiddler >> exportSTONFile [
|
2022-02-12 04:35:44 +00:00
|
|
|
|
2022-02-14 03:48:51 +00:00
|
|
|
^ self exportSTONFileInto: 'tiddlers'
|
2022-02-12 04:35:44 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> exportSTONFileInto: subfolder [
|
|
|
|
|
2022-03-14 15:23:50 +00:00
|
|
|
| stonFile |
|
2022-10-10 16:13:21 +00:00
|
|
|
stonFile := self wiki folder / subfolder / self fileName.
|
2021-09-09 01:00:14 +00:00
|
|
|
^ MarkupFile exportAsFileOn: stonFile containing: self asStonStringPretty
|
|
|
|
]
|
|
|
|
|
2022-03-14 15:23:50 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> exportSTONFileOptimized [
|
|
|
|
|
2022-08-08 19:53:00 +00:00
|
|
|
| exporter wikiFolder tiddlersFolder |
|
2022-10-10 15:20:47 +00:00
|
|
|
wikiFolder := self wiki folder.
|
2022-03-14 15:23:50 +00:00
|
|
|
exporter := wikiFolder / 'scripts' / 'stringAsFileInto'.
|
|
|
|
exporter exists ifFalse: [ self installTiddlerExporter ].
|
2022-08-08 19:53:00 +00:00
|
|
|
tiddlersFolder := wikiFolder / 'tiddlers'.
|
|
|
|
tiddlersFolder exists ifFalse: [ tiddlersFolder ensureCreateDirectory ].
|
2022-03-14 15:23:50 +00:00
|
|
|
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: exporter fullName;
|
|
|
|
arguments: { self asStonStringPretty . self fileName };
|
2022-08-08 19:53:00 +00:00
|
|
|
workingDirectory: tiddlersFolder fullName;
|
|
|
|
runAndWaitOnExitDo: [ :process :outString | ^ tiddlersFolder / self fileName ]
|
2022-03-14 15:23:50 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-04 23:14:24 +00:00
|
|
|
Tiddler >> exportWithTemplate: aTemplate [
|
|
|
|
^ aTemplate asMustacheTemplate value: self asDictionary
|
|
|
|
]
|
|
|
|
|
2022-03-14 15:23:50 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> fileName [
|
|
|
|
| dashedTitle sanitized |
|
|
|
|
dashedTitle := '-' join: (self title substrings collect: [ :each | each ]).
|
|
|
|
sanitized := dashedTitle copyWithoutAll: #($¿ $? $! $¡ $/).
|
2022-08-09 00:59:12 +00:00
|
|
|
^ sanitized , '--', (self uid copyFrom: 1 to: 12), '.ston'.
|
2022-03-14 15:23:50 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-11 17:10:53 +00:00
|
|
|
Tiddler >> fromDictionary: aDictionary [
|
2021-08-29 22:50:17 +00:00
|
|
|
| customKeys |
|
2021-08-11 17:10:53 +00:00
|
|
|
self
|
|
|
|
title: (aDictionary at: 'title');
|
2021-09-06 23:27:40 +00:00
|
|
|
text: (aDictionary at: 'text' ifAbsentPut: [ nil ]);
|
2021-08-11 17:10:53 +00:00
|
|
|
tags: (aDictionary at: 'tags' ifAbsentPut: [ nil ]);
|
2022-01-19 00:56:36 +00:00
|
|
|
created: (aDictionary at: 'created' ifAbsentPut: [ self class nowLocal ]);
|
2021-08-11 17:10:53 +00:00
|
|
|
creator: (aDictionary at: 'creator' ifAbsentPut: [ nil ]);
|
|
|
|
modified: (aDictionary at: 'modified' ifAbsentPut: [ nil ]);
|
|
|
|
modifier: (aDictionary at: 'modifier' ifAbsentPut: [ nil ]);
|
|
|
|
type: (aDictionary at: 'type' ifAbsentPut: [ nil ]);
|
2021-09-01 22:42:21 +00:00
|
|
|
caption: (aDictionary at: 'caption' ifAbsentPut: [ nil ]);
|
|
|
|
bag: (aDictionary at: 'bag' ifAbsentPut: [ nil ]);
|
2021-10-04 20:20:55 +00:00
|
|
|
list: (aDictionary at: 'list' ifAbsentPut: [ nil ]);
|
2021-08-29 22:50:17 +00:00
|
|
|
revision: (aDictionary at: 'revision' ifAbsentPut: [ nil ]).
|
2022-01-18 18:54:14 +00:00
|
|
|
customKeys := aDictionary keys
|
|
|
|
copyWithoutAll: (self class instanceVariables collect: [ :each | each name ]).
|
2022-09-02 15:15:45 +00:00
|
|
|
"(customKeys includes: 'uid') ifFalse: [ self uidGenerator ]."
|
2022-01-18 18:54:14 +00:00
|
|
|
customKeys do: [:key | | valueTemp |
|
|
|
|
valueTemp := aDictionary at: key.
|
|
|
|
valueTemp class = Array
|
|
|
|
ifTrue: [ self customFields at: key put: (self tiddlersListFrom: valueTemp) ]
|
|
|
|
ifFalse: [ self customFields at: key put: valueTemp ].
|
|
|
|
valueTemp class
|
|
|
|
].
|
2021-08-11 17:10:53 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #'instance creation' }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> fromMarkdownParsedItems: aCollection [
|
|
|
|
| outputStream |
|
|
|
|
outputStream := '' writeStream.
|
|
|
|
aCollection children do: [ :each |
|
|
|
|
each children
|
|
|
|
ifEmpty: [ self itemContentsStringFor: each into: outputStream ]
|
|
|
|
ifNotEmpty: [
|
|
|
|
each children do: [ :child |
|
|
|
|
self itemContentsStringFor: child into: outputStream ] ]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2022-01-19 00:56:36 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> gtTextFor: aView [
|
|
|
|
<gtView>
|
|
|
|
^ aView textEditor
|
|
|
|
title: 'Text';
|
|
|
|
text: [ text ]
|
|
|
|
]
|
|
|
|
|
2022-10-31 03:20:36 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> hasUID [
|
|
|
|
|
|
|
|
^ self customFields includesKey: 'uid'
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-04 16:36:20 +00:00
|
|
|
Tiddler >> importFedWikiPage: pageViewUrlString [
|
|
|
|
| pageTitle pageViewUrl pageData |
|
|
|
|
pageViewUrl := pageViewUrlString asZnUrl.
|
|
|
|
pageTitle := pageViewUrl segments second.
|
|
|
|
pageData := (pageViewUrl scheme, '://', pageViewUrl host, '/', pageTitle, '.json') asZnUrl.
|
|
|
|
^ STONJSON fromString: pageData retrieveContents
|
|
|
|
]
|
|
|
|
|
2022-03-14 15:23:50 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> installTiddlerExporter [
|
2022-03-18 23:16:55 +00:00
|
|
|
| folder |
|
2022-09-26 21:46:37 +00:00
|
|
|
folder := (self wiki folder).
|
|
|
|
folder := (folder / 'scripts') ensureCreateDirectory.
|
2022-03-18 23:16:55 +00:00
|
|
|
|
|
|
|
ZnClient new
|
|
|
|
url: 'https://mutabit.com/repos.fossil/mutabit/uv/wiki/scripts/stringAsFileInto';
|
2022-03-22 21:11:01 +00:00
|
|
|
downloadTo: folder / 'stringAsFileInto'.
|
2022-03-18 23:16:55 +00:00
|
|
|
|
|
|
|
ZnClient new
|
|
|
|
url: 'https://mutabit.com/repos.fossil/mutabit/doc/trunk/wiki/scripts/stringAsFileInto.nim';
|
|
|
|
downloadTo: folder / 'stringAsFileInto.nim'.
|
|
|
|
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: 'chmod';
|
|
|
|
arguments: { '+x' . (folder / 'stringAsFileInto') fullName };
|
|
|
|
workingDirectory: folder fullName;
|
|
|
|
redirectStdout;
|
|
|
|
redirectStderr;
|
|
|
|
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
|
2022-03-14 15:23:50 +00:00
|
|
|
]
|
|
|
|
|
2022-02-18 01:16:11 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isImage [
|
|
|
|
|
2022-10-31 04:33:01 +00:00
|
|
|
^ self type ifNil: [ ^ false ];
|
|
|
|
beginsWith: 'image/'
|
2022-02-18 01:16:11 +00:00
|
|
|
]
|
|
|
|
|
2022-02-16 14:34:11 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isJavascript [
|
|
|
|
|
|
|
|
^ self type = 'application/javascript'
|
|
|
|
]
|
|
|
|
|
2022-02-18 01:16:11 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isMarkdown [
|
|
|
|
|
|
|
|
^ self type = 'text/x-markdown'
|
|
|
|
]
|
|
|
|
|
2022-02-16 14:34:11 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isNilType [
|
|
|
|
|
|
|
|
^ self type = nil
|
|
|
|
]
|
|
|
|
|
2022-02-18 01:16:11 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isPDF [
|
|
|
|
|
|
|
|
^ self type = 'application/pdf'
|
|
|
|
]
|
|
|
|
|
2022-02-16 14:34:11 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isShadow [
|
|
|
|
|
|
|
|
^ self title beginsWith: '$:/'
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isTW5Type [
|
|
|
|
|
|
|
|
^ self type = 'text/vnd.tiddlywiki'
|
|
|
|
]
|
|
|
|
|
2022-02-18 01:16:11 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isTextPlain [
|
|
|
|
|
|
|
|
^ self type = 'text/plain'
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #testing }
|
|
|
|
Tiddler >> isXTiddlerDictionary [
|
|
|
|
|
|
|
|
^ self type = 'application/x-tiddler-dictionary'
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #utilities }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> itemContentsStringFor: item into: stream [
|
|
|
|
stream
|
|
|
|
nextPutAll: item text;
|
|
|
|
nextPut: Character cr;
|
|
|
|
nextPut: Character cr
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-17 17:03:53 +00:00
|
|
|
Tiddler >> linkedTiddlers [
|
2021-08-17 18:24:00 +00:00
|
|
|
"At the begining we are going to introduce 'pureTiddlers' as thos included in the wiki which are not linked
|
2021-08-17 17:03:53 +00:00
|
|
|
via aliases. Future versions of this method sould included internal aliased tiddlers."
|
2021-08-17 18:24:00 +00:00
|
|
|
| pureTiddlersTitles |
|
2021-10-20 14:29:35 +00:00
|
|
|
self rawLinks ifNil: [ ^nil ].
|
2021-08-17 18:24:00 +00:00
|
|
|
pureTiddlersTitles := self rawLinks difference: self rawAliasedLinks.
|
|
|
|
^ self wiki tiddlers select: [:tiddler | pureTiddlersTitles includes: tiddler title ].
|
2021-08-17 17:03:53 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> list [
|
|
|
|
|
|
|
|
^ list
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> list: anObject [
|
|
|
|
|
|
|
|
list := anObject
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-10-06 00:26:17 +00:00
|
|
|
Tiddler >> listedTiddlers [
|
2021-10-06 21:17:59 +00:00
|
|
|
"I export all tiddlers in the list field as an alphabetic collection.
|
2021-11-10 15:28:42 +00:00
|
|
|
Future versions should preserve the order in the list.
|
|
|
|
Notice that while '#list' only gives the titles of the listed tiddlers,
|
|
|
|
I return them as proper tiddler objects."
|
2021-10-06 21:17:59 +00:00
|
|
|
| remainList remainListArray listedTiddlers |
|
2021-10-06 00:26:17 +00:00
|
|
|
self list ifNil: [^ nil ].
|
2021-10-06 21:17:59 +00:00
|
|
|
remainList := self list copy.
|
|
|
|
self manualLinksList do: [:manualLink |
|
|
|
|
remainList := remainList copyReplaceAll: manualLink with: ''
|
|
|
|
].
|
|
|
|
remainListArray := (remainList copyReplaceAll: '[[]]' with: '') withBlanksCondensed splitOn: Character space.
|
|
|
|
listedTiddlers := self manualLinksList, remainListArray.
|
|
|
|
^ self wiki tiddlers select: [:tiddler | listedTiddlers includes: tiddler title ].
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-10-06 21:17:59 +00:00
|
|
|
Tiddler >> manualLinksList [
|
|
|
|
self list ifNil: [^ nil].
|
|
|
|
^ WikiTextGrammar new linkSea star parse: self list.
|
2021-10-06 00:26:17 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #utilities }
|
2021-07-15 22:24:05 +00:00
|
|
|
Tiddler >> markdownLinksAsWikiText [
|
|
|
|
"I'm useful to convert _internal_ links between formats, as is a common pattern
|
|
|
|
found when migrating content from Markdown to TiddlyWiki's WikiText.
|
|
|
|
I DON'T work on external links. A better regex could be used for that.
|
|
|
|
See:
|
|
|
|
- https://davidwells.io/snippets/regex-match-markdown-links
|
|
|
|
- http://blog.michaelperrin.fr/2019/02/04/advanced-regular-expressions/"
|
|
|
|
| markdownLinks |
|
|
|
|
markdownLinks := (self text splitOn: Character space) select: [:each | each matchesRegex: '\[(.+)\)'].
|
|
|
|
markdownLinks ifEmpty: [^ self].
|
|
|
|
^ markdownLinks
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> modified [
|
|
|
|
|
2022-03-08 22:32:41 +00:00
|
|
|
^ modified
|
2021-02-23 17:01:54 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> modified: anObject [
|
|
|
|
|
|
|
|
modified := anObject
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-07-15 22:24:05 +00:00
|
|
|
Tiddler >> modifier [
|
2021-02-23 17:01:54 +00:00
|
|
|
|
2021-07-15 22:24:05 +00:00
|
|
|
^ modifier
|
2021-02-23 17:01:54 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-07-15 22:24:05 +00:00
|
|
|
Tiddler >> modifier: anObject [
|
|
|
|
|
|
|
|
modifier := anObject
|
|
|
|
]
|
2021-02-23 17:01:54 +00:00
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-07-15 22:24:05 +00:00
|
|
|
Tiddler >> printOn: aStream [
|
|
|
|
super printOn: aStream.
|
|
|
|
aStream
|
|
|
|
nextPutAll: '( ', self title, ' )'
|
2021-02-23 17:01:54 +00:00
|
|
|
]
|
|
|
|
|
2021-10-20 14:29:35 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-17 17:03:53 +00:00
|
|
|
Tiddler >> rawAliasedLinks [
|
|
|
|
^ self rawLinks select: [ :each | each includesSubstring: '|' ]
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-17 17:03:53 +00:00
|
|
|
Tiddler >> rawLinks [
|
2021-10-20 14:29:35 +00:00
|
|
|
self text ifNil: [ ^ Set new ].
|
2021-08-17 17:03:53 +00:00
|
|
|
^ (WikiTextGrammar new linkSea star parse: self text) asSet
|
|
|
|
]
|
|
|
|
|
2022-12-09 17:49:51 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> removeTag: aTag [
|
|
|
|
|
|
|
|
| tagsPre |
|
|
|
|
tagsPre := self tags.
|
|
|
|
self tags: ('' join: (tagsPre splitOn: aTag)).
|
|
|
|
^ self
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-29 22:50:17 +00:00
|
|
|
Tiddler >> revision [
|
|
|
|
^ revision
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-29 22:50:17 +00:00
|
|
|
Tiddler >> revision: aNumberString [
|
|
|
|
revision := aNumberString
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> tags [
|
|
|
|
|
|
|
|
^ tags
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> tags: anObject [
|
|
|
|
|
|
|
|
tags := anObject
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> text [
|
|
|
|
|
|
|
|
^ text
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> text: anObject [
|
|
|
|
|
|
|
|
text := anObject
|
|
|
|
]
|
|
|
|
|
2022-01-18 18:54:14 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> tiddlersListFrom: anArray [
|
|
|
|
| output |
|
|
|
|
output := '' writeStream.
|
|
|
|
|
|
|
|
anArray doWithIndex: [:each :i |
|
|
|
|
output nextPutAll: '[[', each asString, ']]'.
|
|
|
|
i = anArray size ifFalse: [ output nextPutAll: Character space asString ].
|
|
|
|
].
|
|
|
|
^ output contents.
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> title [
|
|
|
|
|
|
|
|
^ title
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> title: anObject [
|
|
|
|
|
|
|
|
title := anObject
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> type [
|
|
|
|
|
|
|
|
^ type
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
Tiddler >> type: anObject [
|
|
|
|
|
|
|
|
type := anObject
|
|
|
|
]
|
2021-08-17 17:03:53 +00:00
|
|
|
|
2022-03-08 22:49:15 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> uid [
|
2022-03-09 22:53:57 +00:00
|
|
|
^ self customFields at: 'uid' ifAbsentPut: [ self uidGenerator ].
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Tiddler >> uidGenerator [
|
|
|
|
|
2022-08-09 00:59:12 +00:00
|
|
|
^ self customFields at: 'uid' put: NanoID generate.
|
2022-03-10 20:28:32 +00:00
|
|
|
|
2022-03-08 22:49:15 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-17 17:03:53 +00:00
|
|
|
Tiddler >> wiki [
|
|
|
|
^ wiki
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-17 17:03:53 +00:00
|
|
|
Tiddler >> wiki: aTiddlyWiki [
|
|
|
|
wiki := aTiddlyWiki
|
|
|
|
]
|