'From Squeak3.9alpha of 4 July 2005 [latest update: #6680] on 30 August 2005 at 11:06:29 pm'!
!BookMorph methodsFor: 'fileIn/out' stamp: 'mk 8/30/2005 22:33'!
exportAsHTML
"Export the receiver's as a directory populated with interlinked HTML files representing
particular pages. User is interactively asked to enter directoryname."
| directoryName |
directoryName _ FillInTheBlank request:'Please enter the name' translated initialAnswer: self externalName.
directoryName isEmpty ifTrue: [^self].
(FileDirectory default directoryExists: directoryName)
ifTrue:
[
(PopUpMenu confirm: 'Directory already exists. Overwrite?')
ifTrue:
[
(FileDirectory default directoryNamed: directoryName) recursiveDelete.
self exportAsHTMLbasic: directoryName
]
ifFalse: [self exportAsHTML]
]
ifFalse:
[
self exportAsHTMLbasic: directoryName
]! !
!BookMorph methodsFor: 'fileIn/out' stamp: 'mk 8/30/2005 23:05'!
exportAsHTMLbasic: directoryName
"Export the receiver's pages as a series of HTML pages to a directory with a given name.
The `directoryName' string shouldn't contain any path-name-delimiters (such as `/', `\', ...).
New directory will be created directly in the default directory. This method fails if that
directory already exists."
| directory directoryPathName fileStream progressMorph progressDelta |
directory _ FileDirectory default
createDirectory: directoryName;
directoryNamed: directoryName.
directoryPathName _ directory pathName.
progressMorph _ (ProgressMorph label: 'Rendering ...')
center: World center;
openInWorld.
progressDelta _ 1 / pages size.
1 to: pages size do:
[:pageNumber |
fileStream _ FileStream fileNamed: directoryPathName, directory pathNameDelimiter asString, 'page', pageNumber printString, '.html'.
fileStream
nextPutAll: ''; cr;
nextPutAll: '
'; cr;
nextPutAll: 'page', pageNumber printString, ''; cr;
nextPutAll: ''; cr;
nextPutAll: ''; cr.
1 < pageNumber
ifTrue:
[
fileStream
nextPutAll: '[<<] ';
nextPutAll: '[<] '.
]
ifFalse:
[
fileStream
nextPutAll: '[<<] ';
nextPutAll: '[<] '.
].
fileStream nextPutAll: pageNumber printString, ' '.
pageNumber < pages size
ifTrue:
[
fileStream
nextPutAll: '[>] ';
nextPutAll: '[>>] '.
]
ifFalse:
[
fileStream
nextPutAll: '[>] ';
nextPutAll: '[>>] '.
].
(pages at: pageNumber) exportAsPNGbasic: directoryPathName, directory pathNameDelimiter asString, 'page', pageNumber printString, '.png'.
fileStream
cr; nextPutAll: '
'; cr;
nextPutAll: '
'; cr;
nextPutAll: ''; cr;
nextPutAll: '';
close.
progressMorph incrDone: progressDelta.
].
progressMorph delete! !
!BookMorph reorganize!
('accessing' cardsOrPages currentPage pageNamed: pageNumberOf: pages pages: setAllPagesColor: userString)
('caching' releaseCachedState)
('copying' updateReferencesUsing:)
('dropping/grabbing' allowSubmorphExtraction wantsDroppedMorph:event:)
('e-toy support' configureForKids succeededInRevealing:)
('fileIn/out' exportAsHTML exportAsHTMLbasic:)
('halos and balloon help' defersHaloOnClickTo:)
('initialization' defaultColor fromRemoteStream: fromURL: initialize newPages: newPages:currentIndex: removeEverything setInitialState)
('insert and delete' defaultNameStemForNewPages deletePage deletePageBasic insertPage:pageSize: insertPage:pageSize:atIndex: insertPageColored: insertPageLabel:morphs: insertPageSilentlyAtEnd)
('layout' acceptDroppingMorph:event:)
('menu' addBookMenuItemsTo:hand: bookmarkForThisPage buildThreadOfProjects copyUrl findText: findText:inStrings:startAt:container:pageNum: forgetURLs getAllText getStemUrl goToPage highlightText:at:in: invokeBookMenu keepTogether loadImagesIntoBook makeUniformPageSize menuPageSoundFor:event: menuPageSoundForAll: menuPageSoundForThisPage: menuPageVisualFor:event: menuPageVisualForAll: menuPageVisualForThisPage: pageControlsVisible pasteBookPage reload reserveUrls reserveUrlsIfNeeded saveAsNumberedURLs saveIndexOfOnly: saveIndexOnURL saveOnUrlPage: saveOneOnURL savePagesOnURL setNewPagePrototype setPageColor textSearch textSearch: thumbnailForThisPage toggleFullScreen toggleShowingOfPageControls uncachePageSorter)
('menu commands' sortPages)
('navigation' buildFloatingPageControls goToPage: goToPage:transitionSpec: goToPage:transitionSpec:runTransitionScripts: goToPageMorph: goToPageMorph:fromBookmark: goToPageMorph:runTransitionScripts: goToPageMorph:transitionSpec: goToPageMorph:transitionSpec:runTransitionScripts: goToPageUrl: goto: insertPageMorphInCorrectSpot: lastPage nextPage pageNumber previousPage setWrapPages: showMoreControls transitionSpecFor:)
('other' adjustCurrentPageForFullScreen exitFullScreen goFullScreen isInFullScreenMode makeMinimalControlsWithColor:title: resizePagesTo: setExtentFromHalo:)
('parts bin' initializeToStandAlone)
('printing' pagesHandledAutomatically)
('scripting' chooseAndRevertToVersion installRollBackButtons methodHolderVersions methodHolders revertToCheckpoint:)
('sorting' acceptSortedContentsFrom: morphsForPageSorter sortPages:)
('submorphs-accessing' allNonSubmorphMorphs)
('submorphs-add/remove' abandon)
('*morphic-Postscript Canvases' asPostscript fullDrawPostscriptOn:)
('uniform page size' keepingUniformPageSizeString maintainsUniformPageSize maintainsUniformPageSize: toggleMaintainUniformPageSize uniformPageSize)
('menus' printPSToFile)
!