TiddlyWikiPharo/repository/TiddlyWiki/TWSeed.class.st
2022-01-21 19:29:55 -05:00

108 lines
1.9 KiB
Smalltalk

Class {
#name : #TWSeed,
#superclass : #Object,
#instVars : [
'name',
'demo'
],
#classVars : [
'list'
],
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
TWSeed class >> default [
^ (self list select: [ :seed | seed name = 'ProjectifyMod' ]) first
]
{ #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: '');
add: (self new
name: 'NotebookMod';
demo: '');
add: (self new
name: 'Grafoscopedia';
demo: '');
add: (self new
name: 'Holonica';
demo: '').
^ self
]
{ #category : #accessing }
TWSeed class >> installDefaultInto: folder as: shortName [
| url subfolder file |
url := self default demo.
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 asUrl saveContentsToFile: file.
]
{ #category : #accessing }
TWSeed class >> list [
^ list
ifNil: [ self initialize.
^ self list.
]
]
{ #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
]