2021-02-23 17:01:54 +00:00
|
|
|
"
|
|
|
|
I model a TiddlyWiki.
|
|
|
|
More information:
|
|
|
|
|
|
|
|
https://tiddlywiki.com/
|
|
|
|
"
|
|
|
|
Class {
|
2021-10-19 23:23:57 +00:00
|
|
|
#name : #TiddlyWiki,
|
|
|
|
#superclass : #Object,
|
2021-02-23 17:01:54 +00:00
|
|
|
#instVars : [
|
2022-01-18 18:54:14 +00:00
|
|
|
'name',
|
2021-09-14 01:19:31 +00:00
|
|
|
'file',
|
|
|
|
'remote',
|
2022-01-18 18:54:14 +00:00
|
|
|
'jsonFile',
|
2022-09-13 18:04:56 +00:00
|
|
|
'tiddlers',
|
|
|
|
'folder'
|
2021-02-23 17:01:54 +00:00
|
|
|
],
|
2021-10-20 18:35:57 +00:00
|
|
|
#category : #'TiddlyWiki-Model'
|
2021-02-23 17:01:54 +00:00
|
|
|
}
|
|
|
|
|
2022-10-05 02:19:57 +00:00
|
|
|
{ #category : #'instance - creation' }
|
|
|
|
TiddlyWiki class >> createFromRemote: aRemoteTWUrl in: aFolder [
|
|
|
|
|
|
|
|
| wiki |
|
2022-10-05 02:37:32 +00:00
|
|
|
aFolder hasChildren ifTrue: [ ^ nil ].
|
2022-10-05 02:19:57 +00:00
|
|
|
wiki := TiddlyWiki new
|
|
|
|
remote: aRemoteTWUrl;
|
|
|
|
folder: aFolder;
|
|
|
|
file: (aFolder / 'index.html') ensureCreateFile.
|
|
|
|
^ wiki downloadHTML;
|
|
|
|
tiddlers.
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #'instance - creation' }
|
|
|
|
TiddlyWiki class >> createFromRemote: aRemoteTWUrl in: aFolder named: aNameString [
|
|
|
|
|
|
|
|
| wiki |
|
|
|
|
wiki := self createFromRemote: aRemoteTWUrl in: aFolder.
|
2022-10-05 02:37:32 +00:00
|
|
|
^ wiki ifNotNil: [ ^ wiki name: aNameString ]
|
2022-10-05 02:19:57 +00:00
|
|
|
]
|
|
|
|
|
2021-11-04 01:49:58 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki class >> fromJSONUrl: anUrlString [
|
2021-11-05 22:19:09 +00:00
|
|
|
| rawContents contentsString |
|
|
|
|
rawContents := anUrlString asUrl retrieveContents.
|
|
|
|
rawContents class = ByteArray
|
|
|
|
ifTrue: [ contentsString := rawContents utf8Decoded ]
|
|
|
|
ifFalse: [ contentsString := rawContents ].
|
2021-11-04 01:49:58 +00:00
|
|
|
^ self new
|
2021-11-05 22:19:09 +00:00
|
|
|
fromDictionary: (STONJSON fromString: contentsString);
|
|
|
|
remote: anUrlString;
|
|
|
|
name: anUrlString
|
2021-11-04 01:49:58 +00:00
|
|
|
]
|
|
|
|
|
2022-03-11 13:50:20 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> addRecentChangesToRepo [
|
|
|
|
|
|
|
|
| docsSton docsStonSanitized recentTiddlers repository |
|
|
|
|
repository := self repository.
|
2022-03-17 20:24:01 +00:00
|
|
|
self updateFromHtml.
|
2022-03-11 13:50:20 +00:00
|
|
|
recentTiddlers := self changesAfter: repository checkoutDateAndTime.
|
2022-03-17 20:25:25 +00:00
|
|
|
docsSton := recentTiddlers collect: [:each | each exportSTONFileOptimized ].
|
2022-03-11 13:50:20 +00:00
|
|
|
"Collecting tiddlers file reference as string and adding to the repo"
|
|
|
|
docsStonSanitized := docsSton collect: [ :each |
|
|
|
|
(each fullName removePrefix: repository localRoot) allButFirst ].
|
|
|
|
docsStonSanitized do: [ :each | repository add: each ].
|
|
|
|
^ repository status
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-16 00:21:53 +00:00
|
|
|
TiddlyWiki >> addToConfigFile [
|
2021-11-05 13:21:59 +00:00
|
|
|
| cleaned newConfig |
|
2021-09-16 00:21:53 +00:00
|
|
|
cleaned := self copy.
|
|
|
|
cleaned tiddlers: nil.
|
2021-11-05 13:21:59 +00:00
|
|
|
newConfig := self configDictonary
|
2021-09-16 00:21:53 +00:00
|
|
|
at: cleaned name put: cleaned;
|
|
|
|
yourself.
|
2021-11-05 13:21:59 +00:00
|
|
|
^ MarkupFile exportAsFileOn: self configFile containing:(STON toStringPretty: newConfig)
|
2021-09-16 00:37:57 +00:00
|
|
|
]
|
|
|
|
|
2022-03-12 15:48:28 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> addUnversionedLargeTiddlersToRepo [
|
|
|
|
|
|
|
|
| stonfiles largeTiddlersFileReference repository |
|
|
|
|
repository := self repository.
|
|
|
|
stonfiles := (self file parent / 'largeTiddlers') files
|
|
|
|
select: [ :each | each fullName endsWith: '.ston' ].
|
|
|
|
largeTiddlersFileReference := stonfiles collect: [ :each |
|
|
|
|
each fullName withoutPrefix:
|
|
|
|
repository local fullName , '/' ].
|
|
|
|
largeTiddlersFileReference do: [ :each | repository addUnversioned: each ].
|
|
|
|
^ largeTiddlersFileReference
|
|
|
|
]
|
|
|
|
|
2022-03-04 01:38:14 +00:00
|
|
|
{ #category : #testing }
|
|
|
|
TiddlyWiki >> belongsToLocalRepository [
|
|
|
|
|
|
|
|
| localFolder tempRepo relativeName |
|
|
|
|
localFolder := self detectRepositoryLocal ifNil: [ ^ false ].
|
|
|
|
tempRepo := FossilRepo new
|
|
|
|
local: localFolder.
|
|
|
|
relativeName := self file fullName withoutPrefix: (tempRepo local fullName, '/').
|
|
|
|
^ tempRepo listUnversioned hasLiteral: relativeName
|
|
|
|
]
|
|
|
|
|
2022-02-04 16:47:53 +00:00
|
|
|
{ #category : #accessing }
|
2022-02-11 20:43:43 +00:00
|
|
|
TiddlyWiki >> changesAfter: aDateString [
|
2022-02-04 16:47:53 +00:00
|
|
|
|
2022-02-11 20:43:43 +00:00
|
|
|
| recent created modified wiki aDate |
|
|
|
|
aDate := aDateString asZTimestamp.
|
2022-03-13 23:06:23 +00:00
|
|
|
wiki := self commonTiddlers.
|
2022-03-08 22:32:41 +00:00
|
|
|
created := wiki select: [ :tiddler | tiddler created asZTimestamp > aDate ].
|
2022-02-04 16:47:53 +00:00
|
|
|
modified := wiki select: [ :tiddler | tiddler modified isNotNil
|
2022-03-08 22:32:41 +00:00
|
|
|
and: [ tiddler modified asZTimestamp > aDate ] ].
|
2022-02-04 16:47:53 +00:00
|
|
|
|
|
|
|
recent := OrderedCollection new.
|
2022-02-11 14:56:20 +00:00
|
|
|
recent
|
|
|
|
addAll: created;
|
|
|
|
addAll: modified.
|
|
|
|
^ recent asSet.
|
2022-02-04 16:47:53 +00:00
|
|
|
]
|
|
|
|
|
2022-03-13 23:06:23 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> commonTiddlers [
|
|
|
|
|
|
|
|
| content |
|
|
|
|
content := OrderedCollection new.
|
|
|
|
content
|
|
|
|
addAll: (self contentTiddlers
|
|
|
|
select: [ :each | each isTW5Type or: [ each isNilType ]]);
|
2022-08-08 19:53:00 +00:00
|
|
|
"addAll: (self contentTiddlers select: [ :each | each isJavascript ]);"
|
2022-03-13 23:06:23 +00:00
|
|
|
addAll: (self contentTiddlers select: [ :each | each isXTiddlerDictionary ]);
|
|
|
|
addAll: (self contentTiddlers select: [ :each | each isTextPlain ]);
|
|
|
|
addAll: (self contentTiddlers select: [ :each | each isMarkdown ]).
|
|
|
|
^ content.
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-16 00:37:57 +00:00
|
|
|
TiddlyWiki >> configDictonary [
|
|
|
|
^ STONJSON fromString: self configFile contents.
|
2021-09-16 00:21:53 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-16 00:21:53 +00:00
|
|
|
TiddlyWiki >> configFile [
|
|
|
|
| tempFile |
|
|
|
|
tempFile := FileLocator home / '.config' / 'TiddlyWikiPharo' / 'tiddlywiki.conf.ston'.
|
|
|
|
tempFile ensureCreateFile.
|
|
|
|
tempFile contents isEmpty ifTrue: [
|
|
|
|
MarkupFile exportAsFileOn: tempFile containing: ( STON toStringPretty: Dictionary new)
|
|
|
|
].
|
|
|
|
^ tempFile
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2022-01-18 18:54:14 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> contentTiddlers [
|
|
|
|
^ self tiddlers copyWithoutAll: self shadow
|
|
|
|
]
|
|
|
|
|
2022-03-03 22:50:56 +00:00
|
|
|
{ #category : #accessing }
|
2022-03-04 01:38:14 +00:00
|
|
|
TiddlyWiki >> detectRepositoryLocal [
|
2022-03-03 22:50:56 +00:00
|
|
|
|
|
|
|
| folder folderItems |
|
|
|
|
folder := self file parent.
|
|
|
|
folderItems := folder children.
|
2022-03-04 15:38:15 +00:00
|
|
|
[(folderItems select: [ :path | (path basename beginsWith: '.fslckout') or:
|
|
|
|
[ path basename beginsWith: '.fossil']]) isEmpty
|
2022-03-04 01:38:14 +00:00
|
|
|
and:[ (folder = FileLocator root) not ]]
|
|
|
|
whileTrue: [folder := folder parent.
|
|
|
|
folderItems := folder children.].
|
|
|
|
folder = FileLocator root ifTrue: [ ^ nil ].
|
2022-03-03 22:50:56 +00:00
|
|
|
^ folder
|
|
|
|
]
|
|
|
|
|
2022-09-13 18:04:56 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> downloadHTML [
|
|
|
|
| htmlLink localCopy |
|
|
|
|
self isInTiddlyHost ifTrue: [
|
|
|
|
htmlLink := self remote asString
|
|
|
|
].
|
|
|
|
localCopy := self folder / 'index.html'.
|
|
|
|
localCopy exists ifTrue: [ | timestamp |
|
|
|
|
timestamp := (DateAndTime now asString) copyReplaceAll: ':' with: '_'.
|
|
|
|
localCopy renameTo: 'index', timestamp, '.html'].
|
|
|
|
ZnClient new
|
|
|
|
url: htmlLink;
|
|
|
|
downloadTo: self folder / 'index.html'.
|
|
|
|
^ self folder
|
|
|
|
]
|
|
|
|
|
2022-03-03 19:53:00 +00:00
|
|
|
{ #category : #accessing }
|
2022-03-13 23:06:23 +00:00
|
|
|
TiddlyWiki >> exportCommonTiddlers [
|
2022-03-03 19:53:00 +00:00
|
|
|
|
2022-03-13 23:06:23 +00:00
|
|
|
| content |
|
|
|
|
content := self commonTiddlers.
|
2022-08-09 00:59:12 +00:00
|
|
|
content do: [ :each |
|
2022-03-14 15:23:50 +00:00
|
|
|
each exportSTONFileOptimized ].
|
2022-08-09 00:59:12 +00:00
|
|
|
^ self tiddlersFolder
|
2022-03-03 19:53:00 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
2022-03-13 23:06:23 +00:00
|
|
|
TiddlyWiki >> exportContentShadowAndLargeTiddlersSTONFiles [
|
2022-03-03 19:53:00 +00:00
|
|
|
|
2022-03-13 23:06:23 +00:00
|
|
|
self exportSTONFiles; exportLargeTiddlers
|
2022-02-18 01:16:11 +00:00
|
|
|
]
|
|
|
|
|
2022-02-12 04:35:44 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportContentType: aMimeType [
|
|
|
|
|
|
|
|
| filteredTiddlers tempWiki |
|
|
|
|
filteredTiddlers := self selectContentType: aMimeType.
|
|
|
|
filteredTiddlers do: [ :each | each exportSTONFileInto: self largeTiddlersFolderName ].
|
|
|
|
^ self largeTiddlersFolder
|
|
|
|
]
|
|
|
|
|
2022-01-18 18:54:14 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportJSONFile [
|
|
|
|
| docTree rawJsonTiddlers |
|
|
|
|
self htmlFileExists.
|
|
|
|
docTree := XMLHTMLParser parse: self file contents.
|
|
|
|
rawJsonTiddlers := (docTree xpath: '//script[@class="tiddlywiki-tiddler-store"]') stringValue.
|
|
|
|
^ MarkupFile exportAsFileOn: self jsonFile containing: rawJsonTiddlers
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2022-03-07 16:54:59 +00:00
|
|
|
TiddlyWiki >> exportJSONFileOptimized [
|
2022-03-07 18:29:30 +00:00
|
|
|
|
|
|
|
| exporter wikiFolder |
|
|
|
|
wikiFolder := self file parent.
|
|
|
|
exporter := wikiFolder / 'scripts' / 'exportJsonFile'.
|
2022-03-14 15:23:50 +00:00
|
|
|
exporter exists ifFalse: [ self installJsonExporter ].
|
2022-03-07 22:29:59 +00:00
|
|
|
|
2022-03-07 18:29:30 +00:00
|
|
|
OSSUnixSubprocess new
|
2022-03-07 18:41:18 +00:00
|
|
|
command: exporter fullName;
|
2022-03-07 19:04:09 +00:00
|
|
|
workingDirectory: exporter parent fullName;
|
2022-03-07 23:14:34 +00:00
|
|
|
runAndWaitOnExitDo: [ :process :outString | ^ self jsonFile ]
|
2022-03-07 16:54:59 +00:00
|
|
|
]
|
|
|
|
|
2022-09-26 23:04:24 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportJSONFromRebuildedCommonTiddlers [
|
|
|
|
|
2022-09-27 00:02:00 +00:00
|
|
|
| rebuildedTiddlersJSON dateNowString wikiFolder|
|
|
|
|
wikiFolder := self folder.
|
2022-09-26 23:04:24 +00:00
|
|
|
dateNowString := (DateAndTime now asLocalStringYMDHM copyReplaceAll: ':' with: '-') copyReplaceAll: ' ' with: '-'.
|
|
|
|
rebuildedTiddlersJSON := '[', (',' join: (self rebuildTiddlersWithoutLargeTiddlers collect: [ :each | each asJsonString ])), ']'.
|
2022-09-27 00:02:00 +00:00
|
|
|
^ MarkupFile exportAsFileOn: wikiFolder / 'rebuildedCommonTiddlers', dateNowString, 'json' containing: rebuildedTiddlersJSON
|
2022-09-26 23:04:24 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2022-03-07 16:54:59 +00:00
|
|
|
{ #category : #accessing }
|
2021-10-06 00:26:17 +00:00
|
|
|
TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection [
|
2022-02-12 04:35:44 +00:00
|
|
|
|
|
|
|
^ self exportJSONSubtiddlers: subtiddlersCollection as: 'subtiddlers'
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportJSONSubtiddlers: subtiddlersCollection as: aName [
|
|
|
|
|
|
|
|
^ MarkupFile exportAsFileOn: self file parent / aName, 'json' containing: (self jsonSubtiddlers: subtiddlersCollection)
|
2021-10-06 00:26:17 +00:00
|
|
|
]
|
|
|
|
|
2022-02-16 14:34:11 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportJSTiddlers [
|
|
|
|
|
|
|
|
| jsTiddlers jsNotShadow |
|
|
|
|
jsTiddlers := self tiddlers select: [ :each | each isJavascript ].
|
|
|
|
jsNotShadow := jsTiddlers reject: [ :each | each isShadow ].
|
|
|
|
^ jsNotShadow do: [ :each | each exportSTONFileInto: 'tiddlers' ]
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportLargeTiddlers [
|
|
|
|
|
|
|
|
^ self largeTiddlers do: [ :each |
|
|
|
|
each exportSTONFileInto: self largeTiddlersFolderName ].
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2022-01-18 18:54:14 +00:00
|
|
|
TiddlyWiki >> exportSTONFiles [
|
2022-02-11 17:45:06 +00:00
|
|
|
|
2022-01-18 18:54:14 +00:00
|
|
|
| stonFile wikiTemp shadowFile |
|
2022-02-11 17:45:06 +00:00
|
|
|
self tiddlersJSONFile
|
2021-11-04 09:37:45 +00:00
|
|
|
ifNil: [
|
2022-02-11 17:45:06 +00:00
|
|
|
self inform:
|
|
|
|
'No JSON Tiddlers file found. If you have one, please provide its location'.
|
2021-11-04 09:37:45 +00:00
|
|
|
stonFile := FileLocator temp / 'tiddlers.ston' ]
|
2022-02-11 17:45:06 +00:00
|
|
|
ifNotNil: [
|
2022-03-03 19:53:00 +00:00
|
|
|
stonFile := self tiddlersJSONFile withoutExtension , 'ston' ].
|
2022-02-12 04:35:44 +00:00
|
|
|
shadowFile := self largeTiddlersFolder / '_shadow.ston'.
|
2022-01-18 18:54:14 +00:00
|
|
|
wikiTemp := self copy.
|
2022-03-13 23:06:23 +00:00
|
|
|
wikiTemp tiddlers: self commonTiddlers.
|
2022-01-18 18:54:14 +00:00
|
|
|
GrafoscopioUtils exportAsSton: self shadow on: shadowFile.
|
|
|
|
^ GrafoscopioUtils exportAsSton: wikiTemp on: stonFile
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportSTONTiddlers: aCollection [
|
|
|
|
aCollection do: [:each | each exportSTONFile ]
|
2021-09-01 23:58:15 +00:00
|
|
|
]
|
|
|
|
|
2022-02-16 14:34:11 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> exportTW5Tiddlers [
|
|
|
|
|
|
|
|
| tw5Tiddlers tw5ExplicitTiddlers notShadowTiddlers |
|
|
|
|
tw5Tiddlers := self tiddlers select: [ :each | each isNilType ].
|
|
|
|
tw5ExplicitTiddlers := self tiddlers select: [ :each | each isTW5Type ].
|
|
|
|
|
|
|
|
notShadowTiddlers := OrderedCollection new.
|
|
|
|
notShadowTiddlers addAll: (tw5ExplicitTiddlers reject: [ :each | each isShadow ]).
|
|
|
|
notShadowTiddlers addAll: (tw5Tiddlers reject: [ :each | each isShadow ]).
|
|
|
|
^ notShadowTiddlers do: [ :each | each exportSTONFileInto: 'tiddlers' ]
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-07-15 22:45:53 +00:00
|
|
|
TiddlyWiki >> file [
|
|
|
|
^ file
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-07-15 22:45:53 +00:00
|
|
|
TiddlyWiki >> file: anObject [
|
|
|
|
file := anObject
|
|
|
|
]
|
|
|
|
|
2022-03-17 20:25:25 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> folder [
|
2022-09-13 18:04:56 +00:00
|
|
|
folder ifNotNil: [ ^ folder ].
|
|
|
|
self file
|
|
|
|
ifNotNil: [ folder := self file parent ]
|
|
|
|
ifNil: [ folder := FileLocator temp ]
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> folder: anObject [
|
|
|
|
folder := anObject
|
2022-03-17 20:25:25 +00:00
|
|
|
]
|
|
|
|
|
2021-11-04 01:49:58 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> fromDictionary: tiddlersDict [
|
|
|
|
|
|
|
|
self tiddlers: (tiddlersDict collect: [ :each |
|
|
|
|
Tiddler new
|
|
|
|
fromDictionary: each;
|
|
|
|
wiki: self ])
|
|
|
|
]
|
|
|
|
|
2022-09-22 00:09:37 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> fromString: aJSONString [
|
|
|
|
|
|
|
|
| tiddlersDict |
|
|
|
|
tiddlersDict := STONJSON fromString: aJSONString.
|
|
|
|
self fromDictionary: tiddlersDict
|
|
|
|
]
|
|
|
|
|
2022-01-10 23:19:17 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> fromUrl: anUrlString [
|
|
|
|
| docTree rawJsonTiddlers tiddlersDictionary |
|
|
|
|
self remote: anUrlString.
|
|
|
|
docTree := XMLHTMLParser parse: (self remote retrieveContents).
|
|
|
|
rawJsonTiddlers := (docTree xpath: '//script[@class="tiddlywiki-tiddler-store"]') stringValue.
|
|
|
|
tiddlersDictionary := STONJSON fromString: rawJsonTiddlers.
|
|
|
|
self fromDictionary: tiddlersDictionary
|
|
|
|
]
|
|
|
|
|
2022-01-18 18:54:14 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> htmlFileExists [
|
|
|
|
self file ifNil: [
|
|
|
|
self inform: 'No TiddlyWiki HTML file found. If you have one, please provide its location.'.
|
|
|
|
^ nil
|
|
|
|
].
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-10 16:24:19 +00:00
|
|
|
TiddlyWiki >> importJSONFile [
|
2021-11-04 01:49:58 +00:00
|
|
|
|
2022-03-13 15:03:04 +00:00
|
|
|
"I import a JSON representation of my tiddlers data,
|
|
|
|
that has been previosly exported by
|
|
|
|
#exportJSONFileOptimized or #exportJSONFile"
|
2022-09-22 00:09:37 +00:00
|
|
|
|
2021-08-11 17:10:53 +00:00
|
|
|
self tiddlersJSONFile ifNil: [ ^ self ].
|
2022-09-22 00:09:37 +00:00
|
|
|
self fromString: self tiddlersJSONFile contents.
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> importJSONLink [
|
2022-10-05 02:19:57 +00:00
|
|
|
|
|
|
|
| tiddlersJson |
|
|
|
|
tiddlersJson := (self remote asString, '/tiddlers.json') asUrl retrieveContents.
|
|
|
|
jsonFile := self folder / 'tiddlers.json'.
|
|
|
|
MarkupFile exportAsFileOn: jsonFile containing: tiddlersJson.
|
|
|
|
^ self fromString: tiddlersJson
|
2021-08-11 17:10:53 +00:00
|
|
|
]
|
2021-02-23 17:01:54 +00:00
|
|
|
|
2022-03-07 18:29:30 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> installJsonExporter [
|
|
|
|
|
2022-03-07 19:04:09 +00:00
|
|
|
| folder |
|
|
|
|
folder := (self file parent / 'scripts') ensureCreateDirectory.
|
2022-03-07 18:29:30 +00:00
|
|
|
ZnClient new
|
2022-03-07 23:14:34 +00:00
|
|
|
url: 'https://mutabit.com/repos.fossil/mutabit/uv/wiki/scripts/exportJsonFile';
|
|
|
|
downloadTo: folder / 'exportJsonFile'.
|
|
|
|
ZnClient new
|
|
|
|
url: 'https://mutabit.com/repos.fossil/mutabit/doc/trunk/wiki/scripts/exportJsonFile.nim';
|
|
|
|
downloadTo: folder / 'exportJsonFile.nim'.
|
2022-03-07 19:04:09 +00:00
|
|
|
|
|
|
|
OSSUnixSubprocess new
|
|
|
|
command: 'chmod';
|
|
|
|
arguments: { '+x' . (folder / 'exportJsonFile') fullName };
|
|
|
|
workingDirectory: folder fullName;
|
|
|
|
redirectStdout;
|
|
|
|
redirectStderr;
|
|
|
|
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
|
2022-03-07 18:29:30 +00:00
|
|
|
]
|
|
|
|
|
2022-09-13 18:04:56 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> isInTiddlyHost [
|
2022-09-26 21:46:37 +00:00
|
|
|
|
|
|
|
self remote ifNil: [ ^ false ].
|
2022-09-27 01:34:34 +00:00
|
|
|
^ self remote host endsWith: 'tiddlyhost.com'
|
2022-09-13 18:04:56 +00:00
|
|
|
]
|
|
|
|
|
2022-01-18 18:54:14 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> jsonFile [
|
|
|
|
^ jsonFile ifNil: [
|
2022-10-05 02:19:57 +00:00
|
|
|
self htmlFileExists ifNotNil:
|
|
|
|
[ jsonFile := file parent / 'tiddlers.json' ]
|
|
|
|
]
|
2022-01-18 18:54:14 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> jsonFile: aFileLocator [
|
|
|
|
"I contain the tiddlers representation of the wiki data in JSON format."
|
|
|
|
jsonFile := aFileLocator
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-10-06 00:26:17 +00:00
|
|
|
TiddlyWiki >> jsonSubtiddlers: subtiddlersCollection [
|
|
|
|
| subtiddlersDict |
|
2022-03-19 00:09:44 +00:00
|
|
|
subtiddlersDict := subtiddlersCollection asArray collect: [:tiddler | tiddler asDictionary ].
|
2021-10-06 00:26:17 +00:00
|
|
|
^ STONJSON toStringPretty: subtiddlersDict
|
|
|
|
]
|
|
|
|
|
2022-02-16 14:34:11 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> largeTiddlers [
|
|
|
|
|
|
|
|
| wikiImages wikiPDFs wikiLargeTiddlers |
|
|
|
|
wikiImages := self selectContentType: 'image/'.
|
|
|
|
wikiPDFs := self selectContentType: 'application/pdf'.
|
|
|
|
wikiLargeTiddlers := OrderedCollection new.
|
|
|
|
wikiLargeTiddlers
|
|
|
|
addAll: wikiImages;
|
|
|
|
addAll: wikiPDFs.
|
|
|
|
^ wikiLargeTiddlers
|
|
|
|
]
|
|
|
|
|
2022-02-12 04:35:44 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> largeTiddlersFolder [
|
|
|
|
"I store all shadow tiddlers, i.e. tiddlers that provide functionality to TiddlyWiki,
|
|
|
|
for example the ones that come in the plugins or in system tiddlers.
|
|
|
|
For more information about shadow tiddlers, see #shadow method."
|
|
|
|
|
|
|
|
| folder |
|
|
|
|
folder := self file parent / self largeTiddlersFolderName.
|
|
|
|
folder ensureCreateDirectory.
|
|
|
|
^ folder
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> largeTiddlersFolderName [
|
|
|
|
|
|
|
|
^ 'largeTiddlers'
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-16 00:37:57 +00:00
|
|
|
TiddlyWiki >> loadFromConfig: wikiname [
|
2021-11-10 15:28:42 +00:00
|
|
|
^ (self configDictonary at: wikiname) importJSONFile.
|
2021-09-16 00:37:57 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-14 01:19:31 +00:00
|
|
|
TiddlyWiki >> local [
|
|
|
|
^ self file
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-14 01:19:31 +00:00
|
|
|
TiddlyWiki >> local: aFileRefence [
|
|
|
|
^ self file:aFileRefence
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-14 01:19:31 +00:00
|
|
|
TiddlyWiki >> name [
|
2021-09-15 01:14:20 +00:00
|
|
|
| tempName suffix |
|
|
|
|
name ifNotNil: [ ^ name ].
|
|
|
|
self file ifNotNil: [ ^ name := self file basenameWithoutExtension ].
|
|
|
|
self remote ifNil: [ ^ name := nil ].
|
2022-09-13 18:04:56 +00:00
|
|
|
(self remote host endsWith: 'tiddlyhost.com')
|
|
|
|
ifTrue: [ ^ name := (self remote host splitOn: '.') first ].
|
2021-09-15 01:14:20 +00:00
|
|
|
tempName := self remote file.
|
2022-09-13 18:04:56 +00:00
|
|
|
(tempName endsWithAnyOf: #('.html' '.htm'))
|
|
|
|
ifTrue: [
|
2021-09-15 01:14:20 +00:00
|
|
|
suffix := (tempName splitOn: '.') last.
|
|
|
|
tempName := tempName removeSuffix: '.', suffix.
|
2022-09-13 18:04:56 +00:00
|
|
|
].
|
2021-09-15 01:14:20 +00:00
|
|
|
name := tempName
|
2021-09-14 01:19:31 +00:00
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-14 01:19:31 +00:00
|
|
|
TiddlyWiki >> name: aString [
|
|
|
|
|
|
|
|
name := aString
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-17 18:24:00 +00:00
|
|
|
TiddlyWiki >> networkView [
|
|
|
|
| view |
|
|
|
|
view := GtMondrian new.
|
|
|
|
view nodes
|
|
|
|
with: self tiddlers.
|
|
|
|
view edges
|
|
|
|
connectFromAll: #linkedTiddlers.
|
|
|
|
view layout force.
|
|
|
|
^ view
|
|
|
|
]
|
|
|
|
|
2022-07-12 15:35:43 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> oldestCreatedTiddler [
|
|
|
|
|
|
|
|
| tiddlersTemp oldestDate |
|
|
|
|
tiddlersTemp := self tiddlers.
|
|
|
|
oldestDate := (tiddlersTemp collect: [ :tiddler | tiddler created asDateAndTimeForTiddler ]) asSortedCollection first.
|
|
|
|
^ (tiddlersTemp select:[ :tiddler | tiddler created asDateAndTimeForTiddler = oldestDate ]) first.
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-11 17:10:53 +00:00
|
|
|
TiddlyWiki >> printOn: aStream [
|
|
|
|
super printOn: aStream.
|
|
|
|
aStream
|
2021-11-04 01:49:58 +00:00
|
|
|
nextPutAll: '( ', self name ,' )'
|
2021-02-23 17:01:54 +00:00
|
|
|
]
|
|
|
|
|
2022-02-18 01:16:11 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> rebuildTiddlers [
|
|
|
|
|
2022-03-11 06:19:03 +00:00
|
|
|
| stonTiddlers shadowTiddlersFile |
|
2022-02-18 01:16:11 +00:00
|
|
|
shadowTiddlersFile := self largeTiddlersFolder asFileReference children
|
|
|
|
select: [ :each | each basename beginsWith: '_shadow.ston' ].
|
|
|
|
|
|
|
|
stonTiddlers := OrderedCollection new.
|
|
|
|
stonTiddlers
|
2022-03-11 06:19:03 +00:00
|
|
|
addAll: self rebuildTiddlersWithoutShadows ;
|
|
|
|
addAll: (STON fromString:shadowTiddlersFile first contents).
|
2022-02-18 01:16:11 +00:00
|
|
|
^ stonTiddlers
|
|
|
|
]
|
|
|
|
|
2022-02-12 04:35:44 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> rebuildTiddlersJSON [
|
|
|
|
|
2022-03-04 15:38:15 +00:00
|
|
|
self tiddlers: self rebuildTiddlersWithoutShadows.
|
2022-03-11 06:19:03 +00:00
|
|
|
^ self exportJSONSubtiddlers:
|
2022-03-22 21:11:01 +00:00
|
|
|
(self rebuildTiddlersWithoutShadows) as: 'rebuildedTiddlers'.
|
2022-02-12 04:35:44 +00:00
|
|
|
]
|
|
|
|
|
2022-03-04 15:38:15 +00:00
|
|
|
{ #category : #accessing }
|
2022-03-11 06:19:03 +00:00
|
|
|
TiddlyWiki >> rebuildTiddlersWithoutLargeTiddlers [
|
2022-03-04 15:38:15 +00:00
|
|
|
|
|
|
|
| stonTiddlers contentTiddlersFiles |
|
|
|
|
contentTiddlersFiles := self tiddlersFolder files
|
|
|
|
select: [ :each | each basename endsWith: 'ston' ].
|
|
|
|
|
|
|
|
stonTiddlers := OrderedCollection new.
|
|
|
|
stonTiddlers
|
2022-03-11 06:19:03 +00:00
|
|
|
addAll: (contentTiddlersFiles
|
|
|
|
collect:[ :each | STONJSON fromString: each contents ]).
|
2022-09-26 23:04:24 +00:00
|
|
|
stonTiddlers collect: [ :tiddler | tiddler wiki: self ].
|
2022-03-11 06:19:03 +00:00
|
|
|
^ stonTiddlers
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> rebuildTiddlersWithoutShadows [
|
|
|
|
|
2022-03-13 15:03:04 +00:00
|
|
|
| stonTiddlers largeTiddlersRebuild |
|
|
|
|
largeTiddlersRebuild := (((self largeTiddlersFolder files)
|
|
|
|
reject: [ :each | each basename beginsWith: '_shadow' ])
|
2022-03-11 06:19:03 +00:00
|
|
|
collect: [ :each | STONJSON fromString: each contents ]).
|
|
|
|
|
|
|
|
stonTiddlers := OrderedCollection new.
|
|
|
|
stonTiddlers
|
2022-03-13 15:03:04 +00:00
|
|
|
addAll: largeTiddlersRebuild;
|
2022-03-11 06:19:03 +00:00
|
|
|
addAll: self rebuildTiddlersWithoutLargeTiddlers.
|
2022-03-04 15:38:15 +00:00
|
|
|
^ stonTiddlers
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-14 01:19:31 +00:00
|
|
|
TiddlyWiki >> remote [
|
|
|
|
|
|
|
|
^ remote
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-09-14 01:19:31 +00:00
|
|
|
TiddlyWiki >> remote: aUrlString [
|
|
|
|
|
|
|
|
remote := aUrlString asZnUrl
|
|
|
|
]
|
|
|
|
|
2022-03-04 01:38:14 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> repository [
|
|
|
|
|
|
|
|
| repo |
|
|
|
|
self belongsToLocalRepository ifFalse: [ ^ self ].
|
|
|
|
repo := FossilRepo new
|
|
|
|
local: self detectRepositoryLocal.
|
|
|
|
repo repository.
|
|
|
|
^ repo
|
|
|
|
]
|
|
|
|
|
2022-03-04 15:38:15 +00:00
|
|
|
{ #category : #accessing }
|
2022-03-13 23:06:23 +00:00
|
|
|
TiddlyWiki >> resynchronizeWithRepository [
|
2022-03-04 15:38:15 +00:00
|
|
|
|
2022-03-11 13:50:20 +00:00
|
|
|
| repository return |
|
2022-03-04 15:38:15 +00:00
|
|
|
repository := self repository.
|
|
|
|
repository update.
|
2022-03-12 15:48:28 +00:00
|
|
|
repository syncUnversioned.
|
2022-03-11 13:50:20 +00:00
|
|
|
return := Dictionary new
|
|
|
|
at: 'status' put: self addRecentChangesToRepo.
|
2022-03-13 23:06:23 +00:00
|
|
|
self exportSTONFiles;
|
|
|
|
exportCommonTiddlers;
|
|
|
|
exportLargeTiddlers.
|
2022-03-11 13:50:20 +00:00
|
|
|
^ return
|
2022-03-04 16:10:16 +00:00
|
|
|
at: 'file' put: self rebuildTiddlersJSON;
|
|
|
|
yourself.
|
2022-03-04 15:38:15 +00:00
|
|
|
]
|
|
|
|
|
2022-03-12 17:51:08 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> selectByTagsIncludes: string [
|
|
|
|
|
|
|
|
^ (self tiddlers select: [ :tiddler | tiddler tags notNil ])
|
|
|
|
select: [ :tiddler | tiddler tags includesSubstring: string ]
|
|
|
|
]
|
|
|
|
|
2022-02-12 04:35:44 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> selectContentType: mimeType [
|
|
|
|
|
|
|
|
^ self tiddlers select: [ :tiddler | tiddler type isNotNil and: [tiddler type beginsWith: mimeType ]]
|
|
|
|
]
|
|
|
|
|
2022-03-12 17:51:08 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> selectTitleIncludes: string [
|
|
|
|
|
|
|
|
^ self tiddlers select: [ :tiddler | tiddler title includesSubstring: string ]
|
|
|
|
]
|
|
|
|
|
2022-01-18 18:54:14 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> shadow [
|
2022-02-11 17:45:06 +00:00
|
|
|
"Shadow tiddlers are tiddlers that are loaded from plugins.
|
|
|
|
For more information about them, see:
|
|
|
|
|
|
|
|
- https://tiddlywiki.com/static/ShadowTiddlers.html
|
|
|
|
- https://groups.google.com/g/TiddlyWiki/c/HuyZmaRJTxI"
|
|
|
|
^ self tiddlers select: [:tiddler | tiddler title beginsWith: '$:/']
|
|
|
|
]
|
|
|
|
|
2022-03-11 13:50:20 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> syncRemoteLocalDestructive [
|
|
|
|
|
|
|
|
| repository |
|
|
|
|
repository := self repository.
|
|
|
|
repository update.
|
|
|
|
repository revertRemoteUnversioned.
|
|
|
|
repository exportHTMLUnversioned.
|
|
|
|
self
|
|
|
|
exportJSONFile;
|
|
|
|
importJSONFile.
|
|
|
|
self exportSTONFiles.
|
2022-03-13 23:06:23 +00:00
|
|
|
self exportCommonTiddlers.
|
2022-03-11 13:50:20 +00:00
|
|
|
self exportLargeTiddlers.
|
|
|
|
^ Dictionary new
|
|
|
|
at: 'status' put: repository status;
|
|
|
|
at: 'tiddlers from STON' put: self rebuildTiddlers;
|
|
|
|
yourself.
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-08-17 17:03:53 +00:00
|
|
|
TiddlyWiki >> taggedWith: aTag [
|
|
|
|
^ self tiddlers select: [:tiddler |
|
|
|
|
tiddler tags isNotNil and: [tiddler tags includesSubstring: aTag ]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
TiddlyWiki >> tiddlers [
|
2022-10-05 02:19:57 +00:00
|
|
|
(self isInTiddlyHost and: [ tiddlers isNil ]) ifTrue: [ ^ self importJSONLink].
|
2021-02-23 17:01:54 +00:00
|
|
|
^ tiddlers ifNil: [ tiddlers := OrderedCollection new ]
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-02-23 17:01:54 +00:00
|
|
|
TiddlyWiki >> tiddlers: anOrderedCollection [
|
|
|
|
|
|
|
|
tiddlers := anOrderedCollection
|
|
|
|
]
|
2021-07-15 22:45:53 +00:00
|
|
|
|
2022-02-04 16:47:53 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> tiddlersFolder [
|
|
|
|
|
|
|
|
^ self file parent / 'tiddlers'
|
|
|
|
]
|
|
|
|
|
2021-10-19 23:23:57 +00:00
|
|
|
{ #category : #accessing }
|
2021-07-15 22:45:53 +00:00
|
|
|
TiddlyWiki >> tiddlersJSONFile [
|
2022-01-18 18:54:14 +00:00
|
|
|
|
|
|
|
self jsonFile exists ifFalse: [
|
2021-09-10 16:24:19 +00:00
|
|
|
self inform: 'You need to export tiddlers as JSON from TiddlyWiki and locate it in the same folder as the HTML file'.
|
|
|
|
^ nil
|
|
|
|
].
|
|
|
|
^ jsonFile
|
2021-07-15 22:45:53 +00:00
|
|
|
]
|
2021-10-20 18:35:57 +00:00
|
|
|
|
2021-11-05 13:21:59 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> tiddlersJSONUrl [
|
|
|
|
self remote ifNil: [^ nil].
|
|
|
|
]
|
|
|
|
|
2022-03-13 23:06:23 +00:00
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> updateFromHtml [
|
|
|
|
self
|
|
|
|
exportJSONFileOptimized;
|
|
|
|
importJSONFile.
|
|
|
|
]
|
|
|
|
|
2021-10-20 18:35:57 +00:00
|
|
|
{ #category : #accessing }
|
2022-01-18 18:54:14 +00:00
|
|
|
TiddlyWiki >> withoutContentType: application [
|
2021-10-20 18:35:57 +00:00
|
|
|
| filteredTiddlers tempWiki |
|
2022-02-12 04:35:44 +00:00
|
|
|
filteredTiddlers := self tiddlers reject: [:tiddler | tiddler type isNotNil and: [tiddler type beginsWith: application ]].
|
2021-10-20 18:35:57 +00:00
|
|
|
tempWiki := self copy
|
|
|
|
tiddlers: filteredTiddlers.
|
|
|
|
tempWiki tiddlers do: [:tiddler | tiddler wiki: tempWiki ].
|
|
|
|
^ tempWiki
|
|
|
|
]
|
2021-11-30 19:39:25 +00:00
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> withoutImages [
|
2022-01-18 18:54:14 +00:00
|
|
|
^ self withoutContentType: 'image/'
|
2021-11-30 19:39:25 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
TiddlyWiki >> withoutPDFs [
|
2022-01-18 18:54:14 +00:00
|
|
|
^ self withoutContentType: 'application/pdf'
|
2021-11-30 19:39:25 +00:00
|
|
|
]
|