[etoys-dev] Etoys Inbox: Morphic-tk.31.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Aug 13 19:24:04 EDT 2010


A new version of Morphic was added to project Etoys Inbox:
http://source.squeak.org/etoysinbox/Morphic-tk.31.mcz

==================== Summary ====================

Name: Morphic-tk.31
Author: tk
Time: 13 August 2010, 4:23:02 pm
UUID: 93f5f9f3-85ea-443f-a225-ddfeeb2e0a46
Ancestors: Morphic-bf.30

Integrate Korakurider's changes to QuickGuides.  File index.txt for each language has filename/beautiful name.  The second is the UTF-8 name of the QuickGuide. 
1.  If a guide file is present, but not in the index, show it at the end of the menu list.
2.  If a guide is in the index, but the file is not present, don't crash.
3.  allow index.txt to have either cr or linefeed.
4.  tested the different languages -- Quickguides folder is inside locale/en/ etc.
5.  Title of a guide shows correctly at bottom of help flap.
6.  again allow .pr files.  Very useful when a person is preparing a new guide.
7.  other bug fixes.

=============== Diff against Morphic-bf.30 ===============

Item was changed:
  ----- Method: QuickGuideMorph>>loadPages (in category 'initialization') -----
  loadPages
  	| pageCount newPages page unusedPages |
  	pageCount := PagesForCategory inject: 0 into: [:arg :each | arg + (each size)].
  	newPages _ OrderedCollection new: pageCount.
  
  	page _ pages detect: [:p | (p hasProperty: #quickGuideHolder) and: [p knownName = 'index']] ifNone: [nil].
  	page ifNil: [
  		page _ QuickGuideHolderMorph new.
+ 		page guideName: 'index' translated.
- 		page guideName: 'index'.
  		page setProperty: #transitionSpec toValue:  (Array with:  'silence' with: #none with: #none).
  	].
+ 	page guideNameInWords ifNil: [
+ 			page guideNameInWords: 'Index' translated].
  	newPages add: page.
  
       Categories do: [:categoryRec | | catKey  |
  		catKey := categoryRec first.
  		(PagesForCategory at: catKey) do:  [: rec || guideName guideTitle |
  			guideName := rec first.
  			guideTitle := rec second.
  			page _ pages detect: [:p | (p hasProperty: #quickGuideHolder) and: [p knownName = guideName]] ifNone: [nil].
  			page ifNil: [
  				page _ QuickGuideHolderMorph new.
  				page guideName: guideName.
  				page guideNameInWords: guideTitle.
  				page setProperty: #transitionSpec toValue:  (Array with:  'silence' with: #none with: #none).
  			].
  			newPages add: page.
  		].
  	].
  		
  	unusedPages _ pages reject: [:e | (newPages includes: e)].
  	self newPages: (newPages, unusedPages) currentIndex: 1.!

Item was changed:
  ----- Method: QuickGuideMorph>>htmlForJumpTo (in category 'write web pages') -----
  htmlForJumpTo
  	"Create the html for a long list of guide categories and guides.  Each is a clickable link.  Store in the class var HTMLJumpTo.  For creating web pages from the Guides."
  
+ 	| strm ap |
+ 	1 to: pages size do: [:ii | self goToPage: ii].	"create all pages" 
- 	| strm categories |
  	strm _ WriteStream on: (String new: 500).
  	strm nextPutAll: '<b>Guides about topics in EToys</b><br>
  <i>Help screens for the OLPC<br> XO machine.</i><br>'.
  
+ 	Categories do: [:pair |
+ 		strm nextPutAll: pair second translated; nextPutAll: '<br>'; cr.
+ 		(PagesForCategory at: pair first) do: [:gPair |
+ 			ap := pages detect: [:p | (p hasProperty: #quickGuideHolder) and: [p knownName = gPair first]] ifNone: [nil].
+ 			(ap submorphOfClass: BookMorph) ifNotNil: ["exists"
- 	categories _ self class suggestedCategoryOrder.
- 	categories do: [:catName |
- 		strm nextPutAll: catName translated; nextPutAll: '<br>'; cr.
- 		pages do: [:pp |
- 			pp guideCategory = catName ifTrue: [
  				strm tab; tab.
+ 				strm nextPutAll: '&nbsp;&nbsp;&nbsp;<a href="./', gPair first, '.html">'.
+ 				strm nextPutAll: gPair second; nextPutAll: '</a><br>'; cr]]].
- 				strm nextPutAll: '&nbsp;&nbsp;&nbsp;<a href="./', pp guideName, '.html">'.
- 				strm nextPutAll: pp guideNameInWords translated; nextPutAll: '</a><br>'; cr.
- 				]].
- 		].
  	^ HTMLJumpTo _ strm contents!

Item was changed:
  BookMorph subclass: #QuickGuideMorph
  	instanceVariableNames: 'control order'
  	classVariableNames: 'Categories Colors Descriptions HTMLJumpTo IndexPage IndexPageMimeString PagesForCategory Thumbnails'
  	poolDictionaries: ''
  	category: 'Morphic-Books'!
  
+ !QuickGuideMorph commentStamp: 'tk 8/11/2010 15:57' prior: 0!
- !QuickGuideMorph commentStamp: 'tk 12/7/2007 15:15' prior: 0!
  A BookMorph that holds QuickGuides.
  
  World
+ an AlignmentMorph (the flap)
+ an AlignmentMorph
+ a QuickGuideMorph  (one page per guide, 54 pages.  
+ 		Page may be a stub if guide not in)
- an AlignementMorph (the flap)
- an AlignementMorph
- a QuickGuideMorph  (one page per guide, 54 pages.  Page may be a stub if guide not in)
  a QuickGuideHolderMorph
  a BookMorph (4 pages)
+ a PasteUpMorph (a page)
+ 
+ QuickGuides are stored in .../Etoys-4.1.app/Contents/Resources/QuickGuides/
+ or by language in
+ .../Etoys-4.1.app/Contents/Resources/locale/en/QuickGuides/!
- a PasteUpMorph (a page)!

Item was changed:
  ----- Method: QuickGuideMorph classSide>>defaultOrderIn: (in category 'defaults') -----
  defaultOrderIn: helpCategory
  
+ 	| dir baseNames suggestedOrder ret cat last prs |
- 	| dir baseNames suggestedOrder ret cat last |
  	dir _ FileDirectory on: QuickGuideMorph guidePath.
+ 	baseNames _ ((dir fileNames select: [:f | f endsWith: '.sexp.data.gz']) collect: 
+ 		[:f | f copyFrom: 1 to: f size - '.sexp.data.gz' size]) asSet.
+ 	prs := ((dir fileNames select: [:f | f endsWith: '.pr']) collect: 
+ 		[:f | f copyFrom: 1 to: f size - '.pr' size]).
+ 	prs := prs collect: [:nn | (nn atWrap: nn size-3) = $. 
+ 		ifTrue: [nn allButLast: 4]
+ 		ifFalse: [nn]].
+ 	baseNames addAll: prs.
+ 
- 	baseNames _ ((dir fileNames select: [:f | f endsWith: '.sexp.data.gz']) collect: [:f | f copyFrom: 1 to: f size - '.sexp.data.gz' size]) asSet.
  	suggestedOrder _ self suggestedOrder.
  	helpCategory ifNotNil: [
  		suggestedOrder _ suggestedOrder select: [:e | e beginsWith: helpCategory].
  		baseNames _ baseNames select: [:e | e beginsWith: helpCategory]].
  
  	ret _ OrderedCollection new.
  	baseNames _ baseNames collect: [:bb | bb withoutTrailingDigits].
  	suggestedOrder do: [:e |
  		(baseNames includes: e) ifTrue: [
  			baseNames remove: e.
  			ret add: e.
  		].
  	].
  	baseNames ifNotEmpty: [
  		baseNames asArray do: [:e |
  			cat _ self categoryOf: e.
  			last _ ret reverse detect: [:b | b beginsWith: cat]
  				ifNone: [ret ifNotEmpty: [ret last]].
  			last ifNil: [ret add: e]
  				ifNotNil: [ret add: e after: last].
  		].
  	].
  	^ ret asArray.
  !

Item was changed:
  ----- Method: QuickGuideMorph classSide>>loadIndex (in category 'initialization') -----
  loadIndex
+ 	"Optional catalog file 'catalog.txt' may be placed to where Quickguide contents resides.  Purpose is to allow UTF8 encoded titles and menu items for guides.  It also suggests an order for guides within a category.
+ :NavBar/Navigator                        <--- categoryName/title of category 
+ PaintBrushes/Brushes                  <--- guideName/title of guide
+ PaintColorPalette/Color Palette
+     Titles for categories and guides can be translated.  
+     The file is UTF8 encoded.
+     File name for each guide contents is <guideName>.sexp.data.gz.
+     <guideName> should be named only with ascii characters.
+ Template of catalog file can be generated by evaluating this:
+         QuickGuideMorph buildDefaultIndex.
+         QuickGuideMorph saveCatalog."
+ 
  	| st line rec categoryRec catKey  catTitle guideName guideTitle|
+ 	st := FileStream oldFileOrNoneNamed: QuickGuideMorph guidePath, (FileDirectory slash), 'index.txt'.
+ 	st ifNil: [^ self buildDefaultIndex].
+ 	st wantsLineEndConversion: true.
+ 	st text.
       Categories := OrderedCollection new.
  	PagesForCategory := Dictionary new.
- 	st := FileStream readOnlyFileNamed: QuickGuideMorph guidePath, ( FileDirectory slash), 'index.txt'.
- 	st text.
  	[st atEnd] whileFalse: [
  
+ 		line := (st upTo: Character cr) withoutTrailingBlanks.
- 		line := (st upTo: Character linefeed) withoutTrailingBlanks.
  		(line first = $: ) ifTrue: [	"Category"
+ 			rec := line allButFirst subStrings: '|'.
+ 			catKey := ((rec at: 1) subStrings: '|') at: 1.
- 			rec := line subStrings: '|'.
- 			catKey := ((rec at: 1) subStrings: ':') at: 1.
  			rec size = 2
  				ifTrue:  [ catTitle := rec second]
  				ifFalse:[ catTitle := catKey].
  			categoryRec := {catKey. catTitle}.
  			Categories add: categoryRec.
  
  			PagesForCategory at: catKey put: OrderedCollection new.
  		] ifFalse: [
  			rec := line subStrings: '|'.
  			guideName := rec first.
  			rec size = 2 
  				ifTrue: [
  					guideTitle := rec second]
  				ifFalse: [
  					guideTitle := self getWordyName: guideName forCategory: catKey].
  			(PagesForCategory at: catKey ) add: {guideName. guideTitle}.
  		]
  	].!

Item was added:
+ ----- Method: QuickGuideMorph classSide>>loadIndexAndPeekOnDisk (in category 'initialization') -----
+ loadIndexAndPeekOnDisk
+ 	"If index.txt is present, load it and then scan the actual folder for extra guides.  Add them to the list."
+ 
+ 	| indCat indPages extras |
+ 	(FileStream concreteStream isAFileNamed: 
+ 		QuickGuideMorph guidePath, (FileDirectory slash), 'index.txt')
+ 			ifTrue: [self loadIndex]
+ 			ifFalse: [^ self buildDefaultIndex].	"no index file"
+ 
+ 	"Add in the guides on disk that are not in index.txt"
+ 	indCat := Categories. 	"from index.txt"
+ 	indPages := PagesForCategory.
+ 	self buildDefaultIndex.	"from the file directory"
+ 	Categories "from disk" do: [:categoryRec |
+ 		(indCat includes: categoryRec) ifFalse: [
+ 			indCat addLast: categoryRec]].
+ 	PagesForCategory associationsDo: [:pair |
+ 		 (indPages includesKey: pair key) 
+ 			ifFalse: [indPages at: pair key put: pair value]
+ 			ifTrue: [extras := pair value.
+ 				extras removeAllFoundIn: (indPages at: pair key).
+ 				indPages at: pair key put: 
+ 					(indPages at: pair key), extras]].
+ 	Categories := indCat.
+ 	PagesForCategory := indPages.!

Item was changed:
  ----- Method: QuickGuideHolderMorph>>load (in category 'file in/file out') -----
  load
  	"If 'guide.00x.pr' is present, take the one with the largest x.  If only '.sexp.data.gz', then use it"
+ 	| dir m fileName f unzipped zipped ours proj tm |
- 	| dir m fileName f unzipped zipped ours proj |
  	self submorphs size > 0 ifTrue: [^ self].
  	dir _ FileDirectory on: QuickGuideMorph guidePath.
  	"#('xxx.001.pr' 'xxx.035.pr'  'xxx.sexp.data.gz') asSortedCollection   ('xxx.001.pr' 'xxx.035.pr' 'xxx.sexp.data.gz')"
  	ours _ dir fileNames select: [:fName | 
  		(fName beginsWith: guideName) and: [(fName endsWith: '.pr') or: [fName endsWith: '.sexp.data.gz']]].
  	ours _ ours asSortedCollection.
+ 	ours size = 0 ifTrue: [
+ 		submorphs size = 0 ifTrue: [
+ 			tm := TextMorph new contents: 'guide is missing' translated.
+ 			tm topLeft: self topLeft + (4 at 4).
+ 			self width: (self width max: 200).
+ 			self addMorphFront: tm].
+ 		^ self].
- 	ours size = 0 ifTrue: [^ self].
  	fileName _ ours size > 1 ifTrue: [ours at: (ours size - 1) "most recent .pr file"] ifFalse: [ours last "sexp"].
  	proj _ fileName endsWith: '.pr'.
  	Cursor wait showWhile: [
  		proj ifFalse: [
  			unzipped _ WriteStream on: ByteArray new.
  			f _ dir readOnlyFileNamed: fileName.
  			zipped _ GZipReadStream on: f.
  			unzipped nextPutAll: zipped contents.
  			m _ BookMorph bookFromPagesInSISSFormat: (DataStream on: (ReadStream on: (unzipped contents))) next.
  			f close].
  		proj ifTrue: [
  			m _ self loadPR: fileName dir: dir.
  			m ifNil: [^ self]].
  		m position: 0 at 0.
  		self position: 0 at 0.
  		self extent: m extent.
  		m setNamePropertyTo: guideName.
  		m beSticky.
  		self translateGuide: m.
  		self addMorph: m.
  	].
  !

Item was changed:
  ----- Method: QuickGuideMorph>>guideToWebWithJPEGs: (in category 'write web pages') -----
  guideToWebWithJPEGs: withPics
  	"Write all the info in this guide to a web page.  Pages are images (jPEGs).  Create a page to hold them."
  
  	| dir qgh bk strm ff allText thisText |
  	dir _ FileDirectory default directoryNamed: 'QG-web'.
  	"picutres of guide pages"
  	qgh _ self submorphOfClass: QuickGuideHolderMorph.
+ 	(bk _ qgh submorphOfClass: BookMorph) ifNil: [^ self].
- 	bk _ qgh submorphOfClass: BookMorph.
  	strm _ WriteStream on: (String new: 500).
  	strm nextPutAll: (self htmlPreamble: qgh guideNameInWords).	"includes index side bar"
  	allText _ ''.
  
  	1 to: bk pages size do: [:ii |
  		withPics ifTrue: [	"Make images of pages"
  			bk goToPage: ii.	"show it"
  			self jPegOutDir: dir].
  		thisText _ self allTextIn: (bk pages at: ii).
  		strm nextPutAll: '		  <tr><td>  <img  alt="'.
  		strm nextPutAll: qgh guideName, ', page ', ii printString,'. ', thisText, '"  src="./'.
  		strm nextPutAll: qgh guideName , '-', ii printString,'.jpg"> </tr></tc>
  '.
  		allText _ allText, thisText].
  
  	strm nextPutAll: '		</table>
  
  </td></tc>
  </table>
  
  <p><a href="#thetop">Jump to Top</a></p>
  
  <p>Squeak Etoys is a "media authoring tool"-- software that you can download to your computer <br>
  and then use to create your own media.  You can write out your project and share it with others.  <br>
  Etoys runs on any Mac or Windows machine, as well as on the OLPC XO machine.  <br>
  It is free. &nbsp;&nbsp;
  	<a href="http://www.squeakland.org/whatis/whatismain.html">Find out about Etoys.</a></p>
  
  <p><br><br>Text of this guide (for searching): ', allText, '</p>
  </body>
  </html>                  '.
  	ff _ dir fileNamed: qgh guideName, '.html'.
  	ff nextPutAll: strm contents; close.!

Item was changed:
  ----- Method: QuickGuideMorph>>makeCategoryMenu: (in category 'menu actions') -----
  makeCategoryMenu: catName
  	"return a menu with all guides in this category.  No title"
  
  	| subMenu |
  	subMenu _ MenuMorph new defaultTarget: self.
+ 	PagesForCategory ifNil: [self class loadIndexAndPeekOnDisk].
+ 	(PagesForCategory at: catName ifAbsent: [#()]) 
- 	(PagesForCategory at: catName) 
  			do: [:articleRec |
  				subMenu add: (articleRec second) 
  							target: self 
  							selector: #goToCardNamed: 
  							argument: (articleRec first)].
  	^ subMenu!

Item was changed:
  ----- Method: QuickGuideMorph classSide>>saveIndex (in category 'initialization') -----
  saveIndex
+ 	"Note: file is put into Etoys folder.  A person must move it to resources/QuickGuides"
  	|stream |
  	stream := FileStream forceNewFileNamed: 'index.txt'.
  	stream lineEndConvention: #lf.
  	stream converter: UTF8TextConverter new.
  	[
  		Categories 
  			do: [:catRecord |
  				stream nextPut: $:.
  				stream nextPutAll: catRecord first.  "category key"
  				(catRecord second ) = (catRecord first) 
  					ifFalse:[
  						stream nextPut: $|.
  						stream nextPutAll: catRecord second.  "category title (translated)"
  					].
  				stream cr.
  
  				(PagesForCategory at: (catRecord first)) 
  					do: [:rec |
  						stream nextPutAll: rec first.	"guideName"
  						stream nextPut: $|.
  						stream nextPutAll: rec second.			"guide title (translated)"
  						stream cr.
  					]
  			]
  	]  ensure: [stream close].!



More information about the etoys-dev mailing list