From d691b79e6ef3f518bc36b1e0ebc7044887101db3 Mon Sep 17 00:00:00 2001 From: Ruidajo Date: Thu, 3 Feb 2022 20:22:45 -0500 Subject: [PATCH] Creating automation for versioning tiddlywikis. --- repository/Fossil/FossilRepo.class.st | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/repository/Fossil/FossilRepo.class.st b/repository/Fossil/FossilRepo.class.st index 21266cd..437ee5b 100644 --- a/repository/Fossil/FossilRepo.class.st +++ b/repository/Fossil/FossilRepo.class.st @@ -66,6 +66,34 @@ FossilRepo >> add: fileRelativePath [ runAndWaitOnExitDo: [ :process :outString | ^ outString ] ] +{ #category : #accessing } +FossilRepo >> addRecentChangesFromWiki: aTiddlywikiFileLocator [ + + | wiki created modified recent docsSton docsStonSanitized tiddlersFolder | + "Declaring the wiki, exporting tiddlers.json file and importing tiddlers as objects" + wiki := TiddlyWiki new + file: aTiddlywikiFileLocator. + wiki exportJSONFile; importJSONFile. + + "Filtering created and modified tiddlers after checkout repo and exporting as .ston files" + created := wiki withoutImages withoutPDFs contentTiddlers + select: [:tiddler | tiddler created > (self checkoutAsZTimestamp)]. + modified := wiki withoutImages withoutPDFs contentTiddlers + select: [:tiddler | tiddler modified isNotNil + and: [ tiddler modified > (self checkoutAsZTimestamp)]]. + recent := OrderedCollection new. + recent addAll: created; addAll: modified; yourself. + docsSton := recent collect: [:each | each exportSTONFile]. + + "Collecting tiddlers file reference as string and adding to the repo" + tiddlersFolder := aTiddlywikiFileLocator / 'tiddlers'. + docsStonSanitized := docsSton collect: [ :each | + (each fullName removePrefix: + (tiddlersFolder parent parent absolutePath fullName)) allButFirst ]. + docsStonSanitized do: [ :each | self add: each ]. + ^ self status +] + { #category : #authentication } FossilRepo >> authTokenFor: anUserName withPassword: passwordString [ ^ ((self loginAs: anUserName withPassword: passwordString) at: 'payload') at: 'authToken' @@ -95,6 +123,19 @@ FossilRepo >> checkinsFor: relativeFilePath [ ^ payload at: 'checkins' ] +{ #category : #accessing } +FossilRepo >> checkoutAsZTimestamp [ + + | date time dateTime | + date := ((self status lines detect: [ :line | line beginsWith: 'checkout:' ]) + splitOn: ' ') at: 7. + time := ((self status lines detect: [ :line | line beginsWith: 'checkout:' ]) + splitOn: ' ') at: 8. + dateTime := OrderedCollection new. + dateTime addAll: date; addAll: time. + ^ ('' join: dateTime) asZTimestamp +] + { #category : #accessing } FossilRepo >> command: aCommandArgument [ @@ -146,6 +187,12 @@ FossilRepo >> createPage: pageName [ ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'create/', pageName) ] +{ #category : #accessing } +FossilRepo >> diff [ + + ^ self command: 'diff' +] + { #category : #accessing } FossilRepo >> extra [ @@ -298,6 +345,24 @@ FossilRepo >> loginUrlWithName: aUser andPassword: passwd [ queryAt: 'password' put: passwd. ] +{ #category : #accessing } +FossilRepo >> open [ + + OSSUnixSubprocess new + command: 'fossil'; + arguments: { 'open' . self repository. '-f' }; + workingDirectory: self localRoot; + redirectStdout; + redirectStderr; + runAndWaitOnExitDo: [ :process :outString | ^ outString ] +] + +{ #category : #accessing } +FossilRepo >> openUpdate [ + + ^ self open; update +] + { #category : #wiki } FossilRepo >> pageList [ ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'list')