TiddlyWikiPharo/repository/TiddlyWiki/TWSeed.class.st

140 lines
3.0 KiB
Smalltalk
Raw Normal View History

2024-05-29 14:42:33 +00:00
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, ' )'
]