'From Squeak3.2gamma of 27 January 2002 [latest update: #4857] on 5 May 2002 at 8:52:46 pm'! "Change Set: StackMorph-exportHTML-dgd Date: 5 May 2002 Author: Diego Gomez Deck Add a new menu item to generate html files for all the Stack. Pages generated: 1) index.html: with thumbnails for all cards, take the bgcolor from the morph color and the title from the morph #externalName 2) cardN.html: one page per card with a jpeg representation of the card and a navigation toolbar. TODO: - recollect all text from all the cards and generate hidden text in the pages so the web search engines will find the content "! !Color methodsFor: 'printing' stamp: 'bolot 3/17/2001 22:16'! hex ^(self red * 255) asInteger asCharacter hex, (self green * 255) asInteger asCharacter hex, (self blue * 255) asInteger asCharacter hex! ! !StackMorph methodsFor: 'exporting - html' stamp: 'dgd 5/5/2002 19:05'! exportAsHTML "ask the user for a name and then export as HTML" | directoryName | directoryName _ FillInTheBlank request: 'Please enter the directory name' initialAnswer: self externalName. directoryName isEmpty ifTrue: [^ self]. self exportAsHTML: directoryName! ]style[(12 2 49 3 14 4 13 3 14 10 33 16 4 16 13 22 4 23 13)f1b,f1,f1cred;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1c152050000,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b! ! !StackMorph methodsFor: 'exporting - html' stamp: 'dgd 5/5/2002 19:49'! exportAsHTML: directoryNameString "export as HTML in the directory given" Cursor write showWhile: [| fullDirectoryName fileDirectory | fullDirectoryName _ FileDirectory default fullPathFor: directoryNameString. fileDirectory _ FileDirectory on: fullDirectoryName. fileDirectory assureExistence. self exportAsHTMLIndexOn: fileDirectory. self exportAsHTMLCardsOn: fileDirectory]! ]style[(14 19 3 39 2 6 23 17 1 13 7 17 3 13 22 19 5 13 3 13 5 17 5 13 21 4 22 13 5 4 22 13 1)f1b,f1cmagenta;ib,f1,f1cred;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1! ! !StackMorph methodsFor: 'exporting - html' stamp: 'dgd 5/5/2002 20:49'! exportAsHTMLCard: card on: fileDirectory "exporte as HTML the given card on fileDirectory" "todo: recollect all text in all submorphs and generate hidden text for web indexers" | file cardForm imageName cardIndex title buttons | cardIndex _ self cardIndexOf: card. buttons _ self htmlButtonsForCardIndex: cardIndex. "" file _ fileDirectory forceNewFileNamed: 'card' , cardIndex asString , '.html'. title _ self externalName asHtml , ' #' , cardIndex asString. file nextPutAll: '' , title , ''. file nextPutAll: '
'. file nextPutAll: buttons. "" imageName _ 'card' , cardIndex asString , '.jpeg'. file nextPutAll: ''. cardForm _ self formForCard: cardIndex. cardForm writeJPEGfileNamed: (fileDirectory fullPathFor: imageName). "" file nextPutAll: buttons. file nextPutAll: '
'. file cr. file close! ]style[(18 4 5 13 3 139 3 48 4 9 3 4 14 4 3 7 3 4 1 24 1 9 3 2 2 4 3 13 20 6 3 9 12 7 3 5 3 4 23 4 3 9 12 4 13 21 3 5 3 17 3 4 13 18 3 4 13 12 3 4 13 7 3 2 2 9 3 6 3 9 12 7 3 4 13 12 3 9 3 4 3 8 3 4 14 9 3 8 24 13 14 9 4 2 2 4 13 7 3 4 13 25 3 4 6 4 6)f1b,f1cmagenta;ib,f1b,f1cmagenta;ib,f1,f1cred;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1b,f1,f1cmagenta;b,f1,f1cred;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cblue;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cred;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cred;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cmagenta;b,f1! ! !StackMorph methodsFor: 'exporting - html' stamp: 'dgd 5/5/2002 20:41'! exportAsHTMLCardsOn: fileDirectory "export all cards" | cardsCount | cardsCount _ self cards size. Utilities informUserDuring: [:bar | "" self cards withIndexDo: [:card :index | bar value: 'exporting html: ' , (index / cardsCount * 100) rounded asString , '%'. self exportAsHTMLCard: card on: fileDirectory]]! ]style[(21 13 24 11 4 10 3 4 14 9 22 5 2 2 4 4 25 13 8 3 8 18 4 5 3 10 3 3 21 3 7 4 19 4 5 13 2)f1b,f1cmagenta;ib,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cblue;b,f1,f1cmagenta;i,f1,f1cred;b,f1,f1cblue;b,f1,f1cmagenta;i,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1c152050000,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1! ! !StackMorph methodsFor: 'exporting - html' stamp: 'dgd 5/5/2002 20:48'! exportAsHTMLIndexOn: fileDirectory "export the index.html file for this Stack Morph" "todo: recollect all text in all submorphs of all cards and generate hidden text for web indexers" | file cardForm | file _ fileDirectory forceNewFileNamed: 'index.html'. file nextPutAll: '' , self externalName asHtml , ''. file nextPutAll: ''. file nextPutAll: '

' , self externalName asHtml , '

'. file nextPutAll: '
'. "" file nextPutAll: '
'. self cards withIndexDo: [:card :index | | thumbnailName | thumbnailName _ 'thumbnail-card' , index asString , '.jpeg'. file nextPutAll: ''. file nextPutAll: ''. file nextPutAll: ' '. cardForm _ self formForCard: index. (cardForm magnifyBy: 1 / 3) writeJPEGfileNamed: (fileDirectory fullPathFor: thumbnailName)]. "" file nextPutAll: '
'. file nextPutAll: '
'. file nextPutAll: ''. file cr. file close! ]style[(21 13 3 151 3 14 4 4 3 13 20 12 3 4 13 21 3 4 23 17 3 4 13 18 3 4 13 4 3 4 13 14 3 4 23 16 3 4 13 13 3 4 37 4 3 2 2 4 13 10 3 4 23 13 8 13 6 13 3 16 3 5 12 7 5 4 13 15 3 5 12 9 5 4 13 12 3 13 3 15 5 4 13 7 5 8 3 4 14 5 6 8 12 1 3 1 27 13 14 13 5 2 2 4 13 11 3 4 13 13 3 4 37 4 3 4 13 16 3 4 6 4 6)f1b,f1cmagenta;ib,f1,f1cred;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cblue;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cblue;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cblue;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cblue;b,f1,f1c152050000,f1,f1cred;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cblue;b,f1,f1cmagenta;i,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cred;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cblue;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cmagenta;b,f1! ! !StackMorph methodsFor: 'exporting - html' stamp: 'dgd 5/5/2002 19:56'! formForCard: cardNumber "answer a Form for the card given" | currentCard result morphForForm | currentCard _ self currentCard. self goToCardNumber: cardNumber. morphForForm _ self submorphs detect:[:each | each isKindOf: PasteUpMorph ] ifNone:[self]. result _ morphForForm imageForm. self goToCard: currentCard. ^ result! ]style[(13 10 3 34 3 19 17 11 3 4 15 4 17 10 96 6 28 4 11 11 5 6)f1b,f1cmagenta;ib,f1,f1cred;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cmagenta;b! ! !StackMorph methodsFor: 'exporting - html' stamp: 'dgd 5/5/2002 20:42'! htmlButtonsForCardIndex: cardIndex "answer a html fragment for navigation buttons" "todo: create more funny graphicals buttons" | cardCount result | cardCount _ self cards size. result _ String new writeStream. result nextPutAll: '
'. result nextPutAll: '^ '. cardIndex = 1 ifFalse: ["" result nextPutAll: '' , '<<' asHtml , ' '. result nextPutAll: '' , '<' asHtml , ' ']. cardIndex = cardCount ifFalse: ["" result nextPutAll: '' , '>' asHtml , ' '. result nextPutAll: '' , '>>' asHtml , ' ']. result nextPutAll: '
'. ^ result contents! ]style[(25 9 3 93 3 17 4 9 3 4 14 6 3 6 19 6 13 35 3 6 13 29 3 9 3 1 13 2 4 6 13 23 3 4 10 7 5 6 13 15 4 9 3 1 13 9 3 3 10 7 4 9 3 9 13 2 4 6 13 15 4 9 3 1 13 9 3 3 10 7 5 6 13 15 3 9 12 9 3 4 10 7 4 6 13 29 5 6 9)f1b,f1cmagenta;ib,f1,f1cred;b,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1cblue;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cred;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1c152050000,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1c152050000,f1,f1c152050000,f1,f1c152050000,f1,f1cmagenta;b,f1,f1cmagenta;b,f1,f1cred;b,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1c152050000,f1,f1c152050000,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1c152050000,f1,f1c152050000,f1,f1cmagenta;b,f1,f1c152050000,f1,f1cmagenta;b,f1! ! !StackMorph methodsFor: 'menu' stamp: 'dgd 5/5/2002 18:51'! invokeBookMenu "Invoke the book's control panel menu." | aMenu | aMenu _ MenuMorph new defaultTarget: self. aMenu addTitle: 'Stack'. aMenu addStayUpItem. aMenu addList: #( ('find...' textSearch) ('find via this template' findViaTemplate) ('show designations' showDesignationsOfObjects) ('explain designations' explainDesignations) - ('previous card' goToPreviousCardInStack) ('next card' goToNextCardInStack) ('first card' goToFirstCardOfStack) ('last card' goToLastCardOfStack) ('go to card...' goToCard) - ('add a card of this background' insertCard) ('add a card of background...' insertCardOfBackground) ('make a new background...' makeNewBackground) - ('insert cards from clipboard data' addCardsFromClipboardData 'Create new cards from a formatted string on the clipboard') ('insert cards from a file...' addCardsFromAFile 'Create new cards from data in a file') - ('instance variable order...' changeInstVarOrder 'Caution -- DANGER. Change the order of the variables on the cards') ('be defaults for new cards' beDefaultsForNewCards 'Make these current field values be the defaults for their respective fields on new cards') ('sort cards by...' sortCards 'Sort all the cards of the current background using some field as the sort key') - ('delete this card' deleteCard) ('delete all cards *except* this one' deleteAllCardsExceptThisOne) - ('move card to front of stack' makeCurrentCardFirstInStack) ('move card to back of stack' makeCurrentCardLastInStack) ('move card one position earlier' moveCardOnePositionEarlier) ('move card one position later' moveCardOnePositionLater) - ('scripts for this background' browseCardClass) - ('debug...' offerStackDebugMenu) ('bookish items...' offerBookishMenu) - ('export as html' exportAsHTML)). aMenu addUpdating: #showingPageControlsString action: #toggleShowingOfPageControls. aMenu addUpdating: #showingFullScreenString action: #toggleFullScreen. aMenu popUpEvent: self world activeHand lastEvent in: self world ! ! StackMorph removeSelector: #buttonsForCardIndex:! StackMorph removeSelector: #exportAsHTMLCard:number:on:! StackMorph removeSelector: #exportCardsHTMLOn:! StackMorph removeSelector: #exportHTMLCardsOn:! StackMorph removeSelector: #exportIndexHTMLOn:! !StackMorph reorganize! ('as yet unclassified' commitCardData defaultNameStemForNewPages explainDesignations insertCardOfBackground insertCardOfBackground: openInsideLook relaxGripOnVariableNames showDesignationsOfObjects stackDo:) ('background' addCardsFromAFile addCardsFromClipboardData addCardsFromClipboardDataForInstanceVariables: addCardsFromFile: addCardsFromString: addCardsFromString:slotNames: backgroundWithCard: backgrounds beDefaultsForNewCards changeInstVarOrder insertAsBackground:resize: makeNewBackground reassessBackgroundShape reshapeBackground sortByField: sortCards) ('card access' browseCardClass cardIndexOf: cards cardsOrPages currentCard deleteAllCardsExceptThisOne deleteCard deleteCard: goToCard goToCard: goToCardNumber: goToFirstCardInBackground goToFirstCardOfStack goToLastCardInBackground goToLastCardOfStack goToNextCardInStack goToPreviousCardInStack insertCard insertCardOfBackground:withDataFrom:forInstanceVariables: makeCurrentCardFirstInStack makeCurrentCardLastInStack moveCardOnePositionEarlier moveCardOnePositionLater) ('controls' fullControlSpecs pageControlsMorphFrom: shortControlSpecs) ('debugging' inspectCurrentBackground inspectCurrentCard inspectCurrentStack) ('exporting - html' exportAsHTML exportAsHTML: exportAsHTMLCard:on: exportAsHTMLCardsOn: exportAsHTMLIndexOn: formForCard: htmlButtonsForCardIndex:) ('initialization' initialize initializeToStandAlone initializeWith:) ('menu' addBookMenuItemsTo:hand: findText: findText:inStrings:startAt:container:cardNum: findViaTemplate formatList: getAllText invokeBookMenu offerBookishMenu offerStackDebugMenu templateMatches writeSingletonData) ('submorphs-accessing' allNonSubmorphMorphs) !