Modelling configuration options.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-05-30 12:44:20 -05:00
parent 9c7e1c5291
commit 78cf027f39
18 changed files with 2208 additions and 2195 deletions

View File

@ -1,28 +1,28 @@
Extension { #name : #DateAndTime }
{ #category : #'*TiddlyWiki' }
DateAndTime >> asTiddlerFormat [
| hours minutes secondsTemp |
hours := self hours.
minutes := self minutes.
secondsTemp := self seconds.
^ (self dayMonthYearDo: [ :d :m :y |
y asString,
(m < 10
ifTrue: [ '0', m asString ]
ifFalse: [ m asString]),
(d < 10
ifTrue: [ '0', d asString ]
ifFalse: [ d asString])]),
(hours < 10
ifTrue: [ '0',hours asString ]
ifFalse: [ hours asString]),
(minutes < 10
ifTrue: [ '0', minutes asString ]
ifFalse: [ minutes asString]),
(secondsTemp < 10
ifTrue: [ '0', secondsTemp asString ]
ifFalse: [ secondsTemp asString]),
(self nanoSecond asString copyFrom: 1 to: 3)
]
Extension { #name : #DateAndTime }
{ #category : #'*TiddlyWiki' }
DateAndTime >> asTiddlerFormat [
| hours minutes secondsTemp |
hours := self hours.
minutes := self minutes.
secondsTemp := self seconds.
^ (self dayMonthYearDo: [ :d :m :y |
y asString,
(m < 10
ifTrue: [ '0', m asString ]
ifFalse: [ m asString]),
(d < 10
ifTrue: [ '0', d asString ]
ifFalse: [ d asString])]),
(hours < 10
ifTrue: [ '0',hours asString ]
ifFalse: [ hours asString]),
(minutes < 10
ifTrue: [ '0', minutes asString ]
ifFalse: [ minutes asString]),
(secondsTemp < 10
ifTrue: [ '0', secondsTemp asString ]
ifFalse: [ secondsTemp asString]),
(self nanoSecond asString copyFrom: 1 to: 3)
]

View File

@ -1,34 +1,34 @@
Class {
#name : #FedWikiItem,
#superclass : #Object,
#instVars : [
'text',
'id',
'type'
],
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
FedWikiItem >> fromDictionary: aDictionary [
text := aDictionary at: 'text'.
id := aDictionary at: 'id'.
type := aDictionary at: 'type'.
]
{ #category : #accessing }
FedWikiItem >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ',self type, ' | ', self text, ' )'
]
{ #category : #accessing }
FedWikiItem >> text [
^ text
]
{ #category : #accessing }
FedWikiItem >> type [
^ type
]
Class {
#name : #FedWikiItem,
#superclass : #Object,
#instVars : [
'text',
'id',
'type'
],
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
FedWikiItem >> fromDictionary: aDictionary [
text := aDictionary at: 'text'.
id := aDictionary at: 'id'.
type := aDictionary at: 'type'.
]
{ #category : #accessing }
FedWikiItem >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ',self type, ' | ', self text, ' )'
]
{ #category : #accessing }
FedWikiItem >> text [
^ text
]
{ #category : #accessing }
FedWikiItem >> type [
^ type
]

View File

@ -1,98 +1,98 @@
Class {
#name : #FedWikiPage,
#superclass : #Object,
#instVars : [
'url',
'title',
'story',
'journal',
'importJournal'
],
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
FedWikiPage >> dataDictionary [
| dataUrl |
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
dataUrl := self scheme , '://', self host, '/', self titleSegmentUrl, '.json'.
^ STONJSON fromString: dataUrl asUrl retrieveContents
]
{ #category : #accessing }
FedWikiPage >> fromDataDictionary [
title := self title.
story := self story.
self importJournal ifTrue: [ journal := self dataDictionary at: 'journal'].
]
{ #category : #accessing }
FedWikiPage >> host [
^ self url host
]
{ #category : #accessing }
FedWikiPage >> importJournal [
^ importJournal ifNil: [ importJournal := false ]
]
{ #category : #accessing }
FedWikiPage >> importJournal: aBoolean [
importJournal := aBoolean
]
{ #category : #accessing }
FedWikiPage >> isView [
^ self url firstPathSegment = 'view'
]
{ #category : #accessing }
FedWikiPage >> jsonData [
| dataUrl |
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
dataUrl := self scheme , '://', self host, self titleSegmentUrl, '.json'
]
{ #category : #accessing }
FedWikiPage >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ', self title, ' | ', self story size asString, ' items story )'
]
{ #category : #accessing }
FedWikiPage >> scheme [
^ self url scheme
]
{ #category : #accessing }
FedWikiPage >> story [
^ self dataDictionary at: 'story'
]
{ #category : #accessing }
FedWikiPage >> title [
^ self dataDictionary at: 'title'
]
{ #category : #accessing }
FedWikiPage >> titleSegmentUrl [
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
^ self url segments last.
]
{ #category : #accessing }
FedWikiPage >> url [
^ url
]
{ #category : #accessing }
FedWikiPage >> url: aString [
url := aString asZnUrl
]
Class {
#name : #FedWikiPage,
#superclass : #Object,
#instVars : [
'url',
'title',
'story',
'journal',
'importJournal'
],
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
FedWikiPage >> dataDictionary [
| dataUrl |
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
dataUrl := self scheme , '://', self host, '/', self titleSegmentUrl, '.json'.
^ STONJSON fromString: dataUrl asUrl retrieveContents
]
{ #category : #accessing }
FedWikiPage >> fromDataDictionary [
title := self title.
story := self story.
self importJournal ifTrue: [ journal := self dataDictionary at: 'journal'].
]
{ #category : #accessing }
FedWikiPage >> host [
^ self url host
]
{ #category : #accessing }
FedWikiPage >> importJournal [
^ importJournal ifNil: [ importJournal := false ]
]
{ #category : #accessing }
FedWikiPage >> importJournal: aBoolean [
importJournal := aBoolean
]
{ #category : #accessing }
FedWikiPage >> isView [
^ self url firstPathSegment = 'view'
]
{ #category : #accessing }
FedWikiPage >> jsonData [
| dataUrl |
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
dataUrl := self scheme , '://', self host, self titleSegmentUrl, '.json'
]
{ #category : #accessing }
FedWikiPage >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ', self title, ' | ', self story size asString, ' items story )'
]
{ #category : #accessing }
FedWikiPage >> scheme [
^ self url scheme
]
{ #category : #accessing }
FedWikiPage >> story [
^ self dataDictionary at: 'story'
]
{ #category : #accessing }
FedWikiPage >> title [
^ self dataDictionary at: 'title'
]
{ #category : #accessing }
FedWikiPage >> titleSegmentUrl [
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
^ self url segments last.
]
{ #category : #accessing }
FedWikiPage >> url [
^ url
]
{ #category : #accessing }
FedWikiPage >> url: aString [
url := aString asZnUrl
]

View File

@ -1,13 +1,13 @@
"
Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
"
Class {
#name : #ManifestTiddlyWiki,
#superclass : #PackageManifest,
#category : #'TiddlyWiki-Manifest'
}
{ #category : #'code-critics' }
ManifestTiddlyWiki class >> ruleLongMethodsRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#Tiddler #fromDictionary: #false)) #'2022-09-01T15:34:03.846371-05:00') )
]
"
Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
"
Class {
#name : #ManifestTiddlyWiki,
#superclass : #PackageManifest,
#category : #'TiddlyWiki-Manifest'
}
{ #category : #'code-critics' }
ManifestTiddlyWiki class >> ruleLongMethodsRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#Tiddler #fromDictionary: #false)) #'2022-09-01T15:34:03.846371-05:00') )
]

View File

@ -1,15 +1,15 @@
Extension { #name : #OrderedDictionary }
{ #category : #'*TiddlyWiki' }
OrderedDictionary >> asTiddler [
| tiddlerFields response |
response := Tiddler new.
tiddlerFields := response class slotNames copyWithoutAll: #('wiki' 'customFields').
self keysAndValuesDo: [ :key :value |
(tiddlerFields includes: key)
ifFalse: [
response customFields at: key put: value ]
ifTrue: [ response writeSlotNamed: key value: value ]
].
^ response
]
Extension { #name : #OrderedDictionary }
{ #category : #'*TiddlyWiki' }
OrderedDictionary >> asTiddler [
| tiddlerFields response |
response := Tiddler new.
tiddlerFields := response class slotNames copyWithoutAll: #('wiki' 'customFields').
self keysAndValuesDo: [ :key :value |
(tiddlerFields includes: key)
ifFalse: [
response customFields at: key put: value ]
ifTrue: [ response writeSlotNamed: key value: value ]
].
^ response
]

View File

@ -1,22 +1,22 @@
Extension { #name : #String }
{ #category : #'*TiddlyWiki' }
String >> asDateAndTimeForTiddler [
| date |
date := OrderedCollection new.
1 to: 4 do: [ :i | date add: (self at: i) ].
date add: '-'.
5 to: 6 do: [ :i | date add: (self at: i) ].
date add: '-'.
7 to: 8 do: [ :i | date add: (self at: i) ].
date add: 'T'.
9 to: 10 do: [ :i | date add: (self at: i) ].
date add: ':'.
11 to: 12 do: [ :i | date add: (self at: i) ].
date add: ':'.
13 to: 14 do: [ :i | date add: (self at: i) ].
date add: '.'.
15 to: 17 do: [ :i | date add: (self at: i) ].
^ ((date joinUsing: ''), '+00:00') asDateAndTime
]
Extension { #name : #String }
{ #category : #'*TiddlyWiki' }
String >> asDateAndTimeForTiddler [
| date |
date := OrderedCollection new.
1 to: 4 do: [ :i | date add: (self at: i) ].
date add: '-'.
5 to: 6 do: [ :i | date add: (self at: i) ].
date add: '-'.
7 to: 8 do: [ :i | date add: (self at: i) ].
date add: 'T'.
9 to: 10 do: [ :i | date add: (self at: i) ].
date add: ':'.
11 to: 12 do: [ :i | date add: (self at: i) ].
date add: ':'.
13 to: 14 do: [ :i | date add: (self at: i) ].
date add: '.'.
15 to: 17 do: [ :i | date add: (self at: i) ].
^ ((date joinUsing: ''), '+00:00') asDateAndTime
]

View File

@ -1,139 +1,139 @@
Class {
#name : #TWSeed,
#superclass : #Object,
#instVars : [
'name',
'demo'
],
#classVars : [
'list'
],
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
TWSeed class >> default [
^ self selectSeed: 'ProjectifyMod'
]
{ #category : #accessing }
TWSeed class >> deleteWikiFileFromFolder: folder andSubfolder: shortName [
| file |
file := folder / shortName / 'index.html'.
file exists ifFalse: [^ self].
^ file ensureDelete.
]
{ #category : #accessing }
TWSeed class >> initialize [
super initialize.
list := OrderedCollection new.
list
add: (self new
name: 'ProjectifyMod';
demo: 'https://mutabit.com/repos.fossil/tiddlywiki/uv/seeds/projectify/projectify-mod.html');
add: (self new
name: 'Wikilexias';
demo: 'https://mutabit.com/repos.fossil/tiddlywiki/uv/seeds/wikilexias/wikilexias.html');
add: (self new
name: 'NotebookMod';
demo: 'https://mutabit.com/repos.fossil/tiddlywiki/uv/seeds/notebook/notebook-mod.html');
add: (self new
name: 'Grafoscopedia';
demo: 'https://mutabit.com/repos.fossil/grafoscopedia/uv/');
add: (self new
name: 'Holonica';
demo: 'https://mutabit.com/repos.fossil/holonica/uv/');
add: (self new
name: 'Krystal Whitespace';
demo: 'https://krytsal-whitespace.tiddlyhost.com/').
^ self
]
{ #category : #accessing }
TWSeed class >> install: seedName into: folder as: shortName [
| file url seedFile subfolder |
seedFile := self selectSeed: seedName.
subfolder := (folder / shortName) ensureCreateDirectory.
file := subfolder / 'index.html'.
file exists
ifTrue: [ self inform: 'Index file in the wiki subfolder already exists. Please choose:
1 select another folder + shortName combination or
2 run:
self deleteWikiFileFromFolder: folder andSubfolder: shortName.'.
^ self
].
url := seedFile demo.
url asUrl saveContentsToFile: file.
^ TiddlyWiki new
file: file;
name: shortName.
]
{ #category : #accessing }
TWSeed class >> installDefaultInto: folder as: shortName [
^ self install: 'ProjectifyMod' into: folder as: shortName
]
{ #category : #accessing }
TWSeed class >> list [
^ list
ifNil: [ self initialize.
^ self list.
]
]
{ #category : #accessing }
TWSeed class >> preview: wikiSeedName [
WebBrowser openOn: (self selectSeed: wikiSeedName) demo.
]
{ #category : #accessing }
TWSeed class >> selectSeed: aSeedName [
^ (self list select: [ :seed | seed name = aSeedName ]) first
]
{ #category : #accessing }
TWSeed >> demo [
^ demo
]
{ #category : #accessing }
TWSeed >> demo: anUrl [
demo := anUrl asZnUrl
]
{ #category : #accessing }
TWSeed >> name [
^ name
]
{ #category : #accessing }
TWSeed >> name: aString [
name := aString
]
{ #category : #accessing }
TWSeed >> preview: anObject [
^ demo := anObject
]
{ #category : #accessing }
TWSeed >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ', self name, ' )'
]
Class {
#name : #TWSeed,
#superclass : #Object,
#instVars : [
'name',
'demo'
],
#classVars : [
'list'
],
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
TWSeed class >> default [
^ self selectSeed: 'ProjectifyMod'
]
{ #category : #accessing }
TWSeed class >> deleteWikiFileFromFolder: folder andSubfolder: shortName [
| file |
file := folder / shortName / 'index.html'.
file exists ifFalse: [^ self].
^ file ensureDelete.
]
{ #category : #accessing }
TWSeed class >> initialize [
super initialize.
list := OrderedCollection new.
list
add: (self new
name: 'ProjectifyMod';
demo: 'https://mutabit.com/repos.fossil/tiddlywiki/uv/seeds/projectify/projectify-mod.html');
add: (self new
name: 'Wikilexias';
demo: 'https://mutabit.com/repos.fossil/tiddlywiki/uv/seeds/wikilexias/wikilexias.html');
add: (self new
name: 'NotebookMod';
demo: 'https://mutabit.com/repos.fossil/tiddlywiki/uv/seeds/notebook/notebook-mod.html');
add: (self new
name: 'Grafoscopedia';
demo: 'https://mutabit.com/repos.fossil/grafoscopedia/uv/');
add: (self new
name: 'Holonica';
demo: 'https://mutabit.com/repos.fossil/holonica/uv/');
add: (self new
name: 'Krystal Whitespace';
demo: 'https://krytsal-whitespace.tiddlyhost.com/').
^ self
]
{ #category : #accessing }
TWSeed class >> install: seedName into: folder as: shortName [
| file url seedFile subfolder |
seedFile := self selectSeed: seedName.
subfolder := (folder / shortName) ensureCreateDirectory.
file := subfolder / 'index.html'.
file exists
ifTrue: [ self inform: 'Index file in the wiki subfolder already exists. Please choose:
1 select another folder + shortName combination or
2 run:
self deleteWikiFileFromFolder: folder andSubfolder: shortName.'.
^ self
].
url := seedFile demo.
url asUrl saveContentsToFile: file.
^ TiddlyWiki new
file: file;
name: shortName.
]
{ #category : #accessing }
TWSeed class >> installDefaultInto: folder as: shortName [
^ self install: 'ProjectifyMod' into: folder as: shortName
]
{ #category : #accessing }
TWSeed class >> list [
^ list
ifNil: [ self initialize.
^ self list.
]
]
{ #category : #accessing }
TWSeed class >> preview: wikiSeedName [
WebBrowser openOn: (self selectSeed: wikiSeedName) demo.
]
{ #category : #accessing }
TWSeed class >> selectSeed: aSeedName [
^ (self list select: [ :seed | seed name = aSeedName ]) first
]
{ #category : #accessing }
TWSeed >> demo [
^ demo
]
{ #category : #accessing }
TWSeed >> demo: anUrl [
demo := anUrl asZnUrl
]
{ #category : #accessing }
TWSeed >> name [
^ name
]
{ #category : #accessing }
TWSeed >> name: aString [
name := aString
]
{ #category : #accessing }
TWSeed >> preview: anObject [
^ demo := anObject
]
{ #category : #accessing }
TWSeed >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ', self name, ' )'
]

View File

@ -1,31 +1,31 @@
Class {
#name : #TWSeedTest,
#superclass : #TestCase,
#category : #'TiddlyWiki-TiddlyWiki'
}
{ #category : #accessing }
TWSeedTest >> testCreateAlternativeSeed [
| seed folder |
folder := FileLocator temp / 'Wikilexias'.
folder ensureDeleteAll.
seed := TWSeed install: 'Wikilexias' into: FileLocator temp as: 'Wikilexias'.
self assert: seed file equals: (FileLocator temp / 'Wikilexias' / 'index.html')
]
{ #category : #accessing }
TWSeedTest >> testDefaultIsSeed [
| seed |
seed := TWSeed default.
self assert: seed class equals: TWSeed
]
{ #category : #accessing }
TWSeedTest >> testListIsNotEmpty [
| seed |
seed := TWSeed list.
self assert: seed size >= 1
]
Class {
#name : #TWSeedTest,
#superclass : #TestCase,
#category : #'TiddlyWiki-TiddlyWiki'
}
{ #category : #accessing }
TWSeedTest >> testCreateAlternativeSeed [
| seed folder |
folder := FileLocator temp / 'Wikilexias'.
folder ensureDeleteAll.
seed := TWSeed install: 'Wikilexias' into: FileLocator temp as: 'Wikilexias'.
self assert: seed file equals: (FileLocator temp / 'Wikilexias' / 'index.html')
]
{ #category : #accessing }
TWSeedTest >> testDefaultIsSeed [
| seed |
seed := TWSeed default.
self assert: seed class equals: TWSeed
]
{ #category : #accessing }
TWSeedTest >> testListIsNotEmpty [
| seed |
seed := TWSeed list.
self assert: seed size >= 1
]

View File

@ -1,77 +1,77 @@
Class {
#name : #TWServer,
#superclass : #Object,
#instVars : [
'wikis',
'webServer'
],
#category : #TiddlyWiki
}
{ #category : #'instance creation' }
TWServer class >> new [
| instance |
instance := super new.
^ instance
wikis: Dictionary new;
webServer: TLWebserver new
]
{ #category : #'export - json' }
TWServer >> exportTiddlersFrom: aWikiName tagged: aTag into: aFolder [
| wiki |
wiki := wikis at: aWikiName.
^ wiki exportJSONTiddlersTagged: aTag in: aFolder
]
{ #category : #accessing }
TWServer >> initWikiTagDynamicRoute [
webServer teapot
GET: '/<wiki>/<tag>' -> [ :req | (self exportTiddlersFrom: (req at: #wiki) tagged: (req at: #tag) into: FileLocator temp) contents ];
output: #text
]
{ #category : #accessing }
TWServer >> port: aPortInteger [
webServer configuration: { #port -> aPortInteger };
refreshTeapot
]
{ #category : #accessing }
TWServer >> removeAllDynamicRoutes [
webServer teapot removeAllDynamicRoutes
]
{ #category : #accessing }
TWServer >> startAndBrowse [
webServer start.
webServer teapot browse
]
{ #category : #accessing }
TWServer >> webServer: aTealightWebServer [
webServer := aTealightWebServer
]
{ #category : #accessing }
TWServer >> wikiNames [
| return |
return := OrderedCollection new.
wikis keysDo: [ :key | return add: key ].
^ return
]
{ #category : #accessing }
TWServer >> wikis: aTiddlyWikisDictionary [
wikis := aTiddlyWikisDictionary
]
Class {
#name : #TWServer,
#superclass : #Object,
#instVars : [
'wikis',
'webServer'
],
#category : #TiddlyWiki
}
{ #category : #'instance creation' }
TWServer class >> new [
| instance |
instance := super new.
^ instance
wikis: Dictionary new;
webServer: TLWebserver new
]
{ #category : #'export - json' }
TWServer >> exportTiddlersFrom: aWikiName tagged: aTag into: aFolder [
| wiki |
wiki := wikis at: aWikiName.
^ wiki exportJSONTiddlersTagged: aTag in: aFolder
]
{ #category : #accessing }
TWServer >> initWikiTagDynamicRoute [
webServer teapot
GET: '/<wiki>/<tag>' -> [ :req | (self exportTiddlersFrom: (req at: #wiki) tagged: (req at: #tag) into: FileLocator temp) contents ];
output: #text
]
{ #category : #accessing }
TWServer >> port: aPortInteger [
webServer configuration: { #port -> aPortInteger };
refreshTeapot
]
{ #category : #accessing }
TWServer >> removeAllDynamicRoutes [
webServer teapot removeAllDynamicRoutes
]
{ #category : #accessing }
TWServer >> startAndBrowse [
webServer start.
webServer teapot browse
]
{ #category : #accessing }
TWServer >> webServer: aTealightWebServer [
webServer := aTealightWebServer
]
{ #category : #accessing }
TWServer >> wikiNames [
| return |
return := OrderedCollection new.
wikis keysDo: [ :key | return add: key ].
^ return
]
{ #category : #accessing }
TWServer >> wikis: aTiddlyWikisDictionary [
wikis := aTiddlyWikisDictionary
]

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,13 @@
Class {
#name : #TiddlerTest,
#superclass : #TestCase,
#category : #'TiddlyWiki-TiddlyWiki'
}
{ #category : #accessing }
TiddlerTest >> testTiddlerTimeFormatTrasnformation [
| tiddlerTemp |
tiddlerTemp := Tiddler new created: '20220101010101123'.
self assert: tiddlerTemp created equals: tiddlerTemp created asDateAndTimeForTiddler asTiddlerFormat
]
Class {
#name : #TiddlerTest,
#superclass : #TestCase,
#category : #'TiddlyWiki-TiddlyWiki'
}
{ #category : #accessing }
TiddlerTest >> testTiddlerTimeFormatTrasnformation [
| tiddlerTemp |
tiddlerTemp := Tiddler new created: '20220101010101123'.
self assert: tiddlerTemp created equals: tiddlerTemp created asDateAndTimeForTiddler asTiddlerFormat
]

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,14 @@
Class {
#name : #TiddlyWikiExamples,
#superclass : #Object,
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
TiddlyWikiExamples >> createDefaultWiki [
<gtExample>
<description: 'I create a wiki with the default seed as a temporal file.'>
TWSeed deleteWikiFileFromFolder: FileLocator temp andSubfolder: 'test'.
^ TWSeed installDefaultInto: FileLocator temp as: 'test'
]
Class {
#name : #TiddlyWikiExamples,
#superclass : #Object,
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
TiddlyWikiExamples >> createDefaultWiki [
<gtExample>
<description: 'I create a wiki with the default seed as a temporal file.'>
TWSeed deleteWikiFileFromFolder: FileLocator temp andSubfolder: 'test'.
^ TWSeed installDefaultInto: FileLocator temp as: 'test'
]

View File

@ -1,23 +1,23 @@
Extension { #name : #WebVideo }
{ #category : #'*TiddlyWiki' }
WebVideo >> asTiddler [
| tiddler body |
tiddler := Tiddler new
title: self title.
tiddler customFields
at: 'uid' put: self videoId;
at: 'author' put: self author;
at: 'authorId' put: self authorId;
at: 'duration' put: self duration.
body := '' writeStream.
body
nextPutAll: '<<richlink "https://www.youtube.com/watch?v=', self videoId ,'">>';
nextPutAll: '
* ''''Duración:'''' {{!!duration}}
* ''''Autor/a:'''' {{!!author}}'.
tiddler text: body contents withInternetLineEndings.
^ tiddler
]
Extension { #name : #WebVideo }
{ #category : #'*TiddlyWiki' }
WebVideo >> asTiddler [
| tiddler body |
tiddler := Tiddler new
title: self title.
tiddler customFields
at: 'uid' put: self videoId;
at: 'author' put: self author;
at: 'authorId' put: self authorId;
at: 'duration' put: self duration.
body := '' writeStream.
body
nextPutAll: '<<richlink "https://www.youtube.com/watch?v=', self videoId ,'">>';
nextPutAll: '
* ''''Duración:'''' {{!!duration}}
* ''''Autor/a:'''' {{!!author}}'.
tiddler text: body contents withInternetLineEndings.
^ tiddler
]

View File

@ -1,53 +1,53 @@
Class {
#name : #WikiText,
#superclass : #Object,
#instVars : [
'content'
],
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
WikiText >> content [
^ content
]
{ #category : #accessing }
WikiText >> content: aString [
content := aString
]
{ #category : #conversions }
WikiText >> converMarkdownBold [
self content: (self content copyReplaceAll: '**' with: '''''').
]
{ #category : #conversions }
WikiText >> convertMarkdownBold [
self content: (self content copyReplaceAll: '**' with: '''''').
^ self.
]
{ #category : #conversions }
WikiText >> convertMarkdownLinks [
| markdownLinks markdownLinksRegex |
"\[([\w|\s]+)\]\((\S+)\)"
markdownLinksRegex := '\[([\w|\s]+)\]\((\S+)\)'.
"For the explanation of the Regex details see: http://scottradcliff.com/how-to-parse-urls-in-markdown.html"
markdownLinks := self content regex: markdownLinksRegex matchesCollect: [:link | link ].
markdownLinks ifEmpty: [ ^ self content ].
markdownLinks do: [:markdownLink | | linkText closingLinkIndex newContent |
closingLinkIndex := markdownLink indexOf: $].
linkText := markdownLink copyFrom: 2 to: closingLinkIndex.
newContent := self content copyReplaceAll: markdownLink with: '[[', linkText, ']'.
self content: newContent.
].
^ self content
]
{ #category : #accessing }
WikiText >> sample [
^ 'The ''quick'' brown ~~flea~~ fox //jumps// over the `lazy` dog.
This is a link to HelloThere, and one to [[History of TiddlyWiki]] and [[other link]].'
]
Class {
#name : #WikiText,
#superclass : #Object,
#instVars : [
'content'
],
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
WikiText >> content [
^ content
]
{ #category : #accessing }
WikiText >> content: aString [
content := aString
]
{ #category : #conversions }
WikiText >> converMarkdownBold [
self content: (self content copyReplaceAll: '**' with: '''''').
]
{ #category : #conversions }
WikiText >> convertMarkdownBold [
self content: (self content copyReplaceAll: '**' with: '''''').
^ self.
]
{ #category : #conversions }
WikiText >> convertMarkdownLinks [
| markdownLinks markdownLinksRegex |
"\[([\w|\s]+)\]\((\S+)\)"
markdownLinksRegex := '\[([\w|\s]+)\]\((\S+)\)'.
"For the explanation of the Regex details see: http://scottradcliff.com/how-to-parse-urls-in-markdown.html"
markdownLinks := self content regex: markdownLinksRegex matchesCollect: [:link | link ].
markdownLinks ifEmpty: [ ^ self content ].
markdownLinks do: [:markdownLink | | linkText closingLinkIndex newContent |
closingLinkIndex := markdownLink indexOf: $].
linkText := markdownLink copyFrom: 2 to: closingLinkIndex.
newContent := self content copyReplaceAll: markdownLink with: '[[', linkText, ']'.
self content: newContent.
].
^ self content
]
{ #category : #accessing }
WikiText >> sample [
^ 'The ''quick'' brown ~~flea~~ fox //jumps// over the `lazy` dog.
This is a link to HelloThere, and one to [[History of TiddlyWiki]] and [[other link]].'
]

View File

@ -1,47 +1,47 @@
Class {
#name : #WikiTextGrammar,
#superclass : #PP2CompositeNode,
#instVars : [
'document',
'link',
'linkOpen',
'linkContent',
'linkClose'
],
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
WikiTextGrammar >> document [
^ link islandInSea star
]
{ #category : #accessing }
WikiTextGrammar >> link [
^ linkOpen, linkContent, linkClose ==> #second
]
{ #category : #accessing }
WikiTextGrammar >> linkClose [
^ ']]' asPParser
]
{ #category : #accessing }
WikiTextGrammar >> linkContent [
^ #any asPParser starLazy flatten
]
{ #category : #accessing }
WikiTextGrammar >> linkOpen [
^ '[[' asPParser
]
{ #category : #accessing }
WikiTextGrammar >> linkSea [
^ link sea ==> #second
]
{ #category : #accessing }
WikiTextGrammar >> start [
^ document
]
Class {
#name : #WikiTextGrammar,
#superclass : #PP2CompositeNode,
#instVars : [
'document',
'link',
'linkOpen',
'linkContent',
'linkClose'
],
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
WikiTextGrammar >> document [
^ link islandInSea star
]
{ #category : #accessing }
WikiTextGrammar >> link [
^ linkOpen, linkContent, linkClose ==> #second
]
{ #category : #accessing }
WikiTextGrammar >> linkClose [
^ ']]' asPParser
]
{ #category : #accessing }
WikiTextGrammar >> linkContent [
^ #any asPParser starLazy flatten
]
{ #category : #accessing }
WikiTextGrammar >> linkOpen [
^ '[[' asPParser
]
{ #category : #accessing }
WikiTextGrammar >> linkSea [
^ link sea ==> #second
]
{ #category : #accessing }
WikiTextGrammar >> start [
^ document
]

View File

@ -1,25 +1,25 @@
Class {
#name : #WikiTextGrammarTest,
#superclass : #PP2CompositeNodeTest,
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
WikiTextGrammarTest >> parserClass [
^ WikiTextGrammar
]
{ #category : #accessing }
WikiTextGrammarTest >> testDocument [
| input |
input := WikiText new sample.
self parse: input rule: #document.
self assert: result size equals: 2
]
{ #category : #accessing }
WikiTextGrammarTest >> testLink [
self
parse: '[[Just testing]]'
rule: #link
]
Class {
#name : #WikiTextGrammarTest,
#superclass : #PP2CompositeNodeTest,
#category : 'TiddlyWiki-Model'
}
{ #category : #accessing }
WikiTextGrammarTest >> parserClass [
^ WikiTextGrammar
]
{ #category : #accessing }
WikiTextGrammarTest >> testDocument [
| input |
input := WikiText new sample.
self parse: input rule: #document.
self assert: result size equals: 2
]
{ #category : #accessing }
WikiTextGrammarTest >> testLink [
self
parse: '[[Just testing]]'
rule: #link
]

View File

@ -1 +1 @@
Package { #name : #TiddlyWiki }
Package { #name : #TiddlyWiki }