















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















































StringMorph subclass: #ClickableStringMorph instanceVariableNames: 'model normalColor clickAction doubleClickAction contentSelector stateSelector ' classVariableNames: '' poolDictionaries: '' category: 'Newspaper'! !ClickableStringMorph commentStamp: '
!ClickableStringMorph methodsFor: 'accessing' stamp: 'npm 2/14/2000 18:14'! clickAction: aBlock "Set the action associated with a single-click. The provided block must accept an argument for the model of this ClickableStringMorph." clickAction := aBlock. !! !ClickableStringMorph methodsFor: 'accessing' stamp: 'npm 2/13/2000 19:56'! contentSelector: aContentSelector "What message should the model be sent for this ClickableStringMorph to retrieve its contents?" contentSelector := aContentSelector. !! !ClickableStringMorph methodsFor: 'accessing' stamp: 'npm 2/14/2000 18:14'! doubleClickAction: aBlock "Set the action associated with a double-click. The provided block must accept an argument for the model of this ClickableStringMorph." doubleClickAction := aBlock.!! !ClickableStringMorph methodsFor: 'accessing' stamp: 'npm 2/14/2000 18:15'! isSelected: aBoolean "Adjusts the display properties of this ClickableStringMorph as necessary." (aBoolean) ifTrue: [self color: normalColor.] ifFalse: [self color: (normalColor muchLighter).].!! !ClickableStringMorph methodsFor: 'accessing' stamp: 'npm 2/14/2000 18:15'! model: aModel "Set the model attribute of this ClickableStringMorph." model := aModel. model addDependent: self. !! !ClickableStringMorph methodsFor: 'accessing' stamp: 'npm 2/13/2000 19:57'! stateSelector: aStateSelector "What message should the model be sent in order for this ClickableStringMorph to determine its select state?" stateSelector := aStateSelector.!! !ClickableStringMorph methodsFor: 'initialization' stamp: 'npm 2/14/2000 18:03'! initialize "Set the instance variables of this ClickableStringMorph to their default values." normalColor := (Color blue). clickAction := []. doubleClickAction := [].
EmbeddedServerAction subclass: #DeselectAction instanceVariableNames: 'webpaper ' classVariableNames: '' poolDictionaries: '' category: 'Newspaper'! !DeselectAction commentStamp: '
name := aName. self changed: #name. !! !NewsCategory methodsFor: 'accessing' stamp: 'npm 2/13/2000 20:57'! newsSources "What are the NewsSources associated with this NewsCategory?" ^sources.!! !NewsCategory methodsFor: 'accessing' stamp: 'npm 2/14/2000 18:23'! removeNewsSource: aNewsSource "Remove the specified NewsSource from this NewsCategory." sources remove: aNewsSource. self changed: #newsSources.!! !NewsCategory methodsFor: 'accessing' stamp: 'gy 3/22/2000 09:48'! selected:aBoolean "comment stating purpose of message" isSelected := aBoolean.!! !NewsCategory methodsFor: 'accessing' stamp: 'npm 2/13/2000 21:52'! toggle "Toggle the select Boolean of this NewsCategory." isSelected := isSelected not. self changed: #isSelected. !! !NewsCategory methodsFor: 'initializing' stamp: 'npm 3/1/2000 20:34'! initialize "Initialize the instance variables of this NewsCategory to their default values." isPrimary := false. isSelected := false. name := nil. sources := OrderedCollection new. !! !NewsCategory methodsFor: 'file storage' stamp: 'npm 2/14/2000 15:48'! stringSummary "Returns a string summary of this NewsCategory (string format: NewsCategory name followed by a dollar sign followed by the select boolean followed by NewsSource summaries on separate lines)." | summary | summary := name , '$' , (isSelected asString).
sources do: [:source | summary := summary , (String cr) , (source stringSummary).]. ^(summary asString).!! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! NewsCategory class instanceVariableNames: ''! !NewsCategory class methodsFor: 'instance creation' stamp: 'npm 2/14/ 16:01'! fromString: aString "Instantiates a NewsCategory object based upon the provided string (string format: NewsCategory name followed by a dollar sign followed by the select boolean followed by NewsSource summaries on separate lines). " | aNewsCategory tokens categoryInfo categoryName categoryIsSelected | tokens := aString findTokens: (String cr). "Create a NewsCategory object with appropriate name and select values." categoryInfo := (tokens at: 1) findTokens: '$'. categoryName := (categoryInfo at: 1). categoryIsSelected := ((categoryInfo at: 2) = 'true'). aNewsCategory := NewsCategory named: categoryName isSelected: categoryIsSelected. "Add the associated NewsSources to this NewsCategory." 2 to: (tokens size) do: [:index | aNewsCategory addNewsSource: (NewsSource fromString: (tokens at: index)).]. ^aNewsCategory. !! !NewsCategory class methodsFor: 'instance creation' stamp: 'npm 2/9/2000 21:12'! named: aName "Instantiates a NewsCategory object with the provided name and performs initialization." | aNewsCategory | aNewsCategory := super new initialize. aNewsCategory name: aName. ^aNewsCategory. !! !NewsCategory class methodsFor: 'instance creation' stamp: 'npm 2/10/ 17:37'! named: aName isSelected: aBoolean "Instantiates a NewsCategory object with the provided name & select value." | aNewsCategory |
EmbeddedServerAction subclass: #NewsCategoryAction instanceVariableNames: 'webpaper ' classVariableNames: '' poolDictionaries: '' category: 'Newspaper'! !NewsCategoryAction commentStamp: '
Object subclass: #NewsCategoryDisplay instanceVariableNames: 'newsPaper newsCategories ' classVariableNames: '' poolDictionaries: '' category: 'Newspaper'! !NewsCategoryDisplay commentStamp: '
primButton color: (windowColor slightlyDarker). closeButton := SimpleButtonMorph new. closeButton target: window. closeButton actionSelector: #delete. closeButton label: 'Close'. closeButton borderWidth: 1. closeButton borderColor: (Color blue). closeButton color: (windowColor slightlyDarker). buttonPanel addMorph: closeButton. buttonPanel addMorph: (spacer fullCopy). buttonPanel addMorph: saveAsButton. buttonPanel addMorph: (spacer fullCopy). buttonPanel addMorph: primButton. "Finally add the button panel to the bottom 1/4 of the Window." window addMorph: buttonPanel frame: ([email protected] extent: [email protected]). "Open the Window once all the components have been added." window visible: false. window openInWorld. window newBounds: ((window position) extent: 400@300). window visible: true. !! !NewsCategoryDisplay methodsFor: 'event handling' stamp: 'npm 2/23/2000 19:08'! saveAs "Prompt the user for a file path and save the current Newspaper configuration to that file." | fileName | "Have the user input the file name via a FillInTheBlankMorph. Then have the Newspaper save the current configuration." fileName := FillInTheBlankMorph request: 'Configuration File Name' initialAnswer: (newsPaper fileLastUsed). (fileName isEmpty) ifFalse: [newsPaper saveToFile: fileName.]. !! !NewsCategoryDisplay methodsFor: 'event handling' stamp: 'gy 4/4/2000 22:28'! selectPrimaryNewsCategory "Have the user select the primary NewsCategory of the Newspaper." | primaryCategory categories | "Retrieve the name of the primary NewsCategory via a FillInTheBlankMorph."
primaryCategory :=FillInTheBlankMorph request: 'Primary Category Name'. Transcript show: 'primary is ', primaryCategory asString.Transcript cr. categories := (self newsPaper) newsCategories. categories do:[ :aCat| ((aCat name asString) sameAs:(primaryCategory asString))ifTrue:[ Transcript show:'setting ', (aCat name) asString, ' to primary'.Transcript cr. aCat isPrimaryCategory:true. Transcript show:(aCat isPrimaryCategory) asString.]]. !! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! NewsCategoryDisplay class instanceVariableNames: ''! !NewsCategoryDisplay class methodsFor: 'instance creation' stamp: 'npm 2/14/ 19:21'! openOn: aNewspaper "Instantiates & displays a NewsCategoryDisplay on the provided Newspaper." | aNewsCategoryDisplay | aNewsCategoryDisplay := super new. aNewsCategoryDisplay newsPaper: aNewspaper. aNewsCategoryDisplay display. ^aNewsCategoryDisplay. !!
"The below code was found in the Scamper method for generating a plain-text HTML page." "document := (HtmlParser parse: (ReadStream on: anHTMLArticle))." " formatter := HtmlFormatter new. document addToFormatter: formatter. formattedPage := formatter text." "Add some delimiter strings to the formatted article to distinguish it from other artcles." topDelimeter := '
'. topDelimeter := topDelimeter , '', ((aNewsReporter newsCategory) name) , ' - ' , (((aNewsReporter newsSource) sourceURL) asString),'
' , '------------------------------------------------------------------' , '
' , '
','
', '
' , '
'. "Add the article to the newspaper file." formattedPage := topDelimeter , anHTMLArticle, bottomDelimeter. temp2 nextPutAll: formattedPage.]. temp2 close.] ifFalse:[ articles do: [:anHTMLArticle | "The below code was found in the Scamper method for generating a plain-text HTML page." "document := (HtmlParser parse: (ReadStream on: anHTMLArticle))." " formatter := HtmlFormatter new. document addToFormatter: formatter. formattedPage := formatter text." "Add some delimiter strings to the formatted article to distinguish it from other artcles." topDelimeter := '
'. topDelimeter := topDelimeter , '', ((aNewsReporter newsCategory) name) , ' - ' , (((aNewsReporter newsSource) sourceURL) asString),'
' , '------------------------------------------------------------------' , '
' , '
','
bottomDelimeter:= '
', '
' , '
'. "Add the article to the newspaper file." formattedPage := topDelimeter , anHTMLArticle, bottomDelimeter. aFileStream nextPutAll: formattedPage.]. ]!! !NewsEditor methodsFor: 'generating' stamp: 'npm 3/1/2000 21:39'! generateNewspaper "Generates a viewable Newspaper based upon the preferences of the user." "First, create the requisite NewsReporters based upon the user's selections." self hireNewsReporters. "Next dispatch each NewsReporter to collect news articles. I may implement this with multiple threads/processes at a later date." self dispatchNewsReporters. "Produce a Newspaper file containing the reported articles." self generateNewspaperFile. !! !NewsEditor methodsFor: 'generating' stamp: 'gy 4/4/2000 22:38'! generateNewspaperFile "Produces a crude plain-text file containing the news articles collected by the NewsReporters." | fs fd fileName temp2 temp1 | "The NewsEditor will store the generated newspaper in a file named 'newspaper.txt'." fileName := 'temp1.html'. "Delete the old newspaper file." fd := FileDirectory default. fd deleteFileNamed: fileName. "Create a new newspaper file containing the collected articles." fs := FileStream fileNamed: fileName. newsReporters do: [:aNewsReporter | self addArticlesFrom: aNewsReporter toFile: fs.]. fs close. (FileStream isAFileNamed:'temp2.html') ifTrue:[ temp2:=FileStream fileNamed:'temp2.html'] ifFalse:[temp2:=nil.]. temp1 := FileStream fileNamed:'temp1.html'. fs := FileStream fileNamed:'newspaper.html'.
^newsEditor. !!
Object subclass: #NewsReporter instanceVariableNames: 'newsSource newsCategory newsEditor newsArticles maximumNumberOfArticles ' classVariableNames: '' poolDictionaries: '' category: 'Newspaper'! !NewsReporter commentStamp: '