[etoys-dev] Etoys: Morphic-KR.15.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jun 1 04:03:11 EDT 2010


korakurider uploaded a new version of Morphic to project Etoys:
http://source.squeak.org/etoys/Morphic-KR.15.mcz

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

Name: Morphic-KR.15
Author: KR
Time: 1 June 2010, 5:01:32 pm
UUID: 706a55a5-9d83-b04d-88da-14e90a2d29dc
Ancestors: Morphic-KR.14

For SQ-562:
Introduce index file for QuickGuides to translate and and control order of display of guide titles in index page.

+ the  file "index.txt" is placed to where QG contents reside
   Format is like this:

       :NavBar|Navigator                               <--- categoryName|title of category
       PaintBrushes|Brushes                           <--- guideName|title of guide
       PaintColorPalette|Color Palette


   Order of guides in some category can be specified in this file.

   Titles for categories and guides can be translated.
   The file has to be UTF8 encoded.

   File name for each guide contents is  assumed as <guideName>.sexp.data.gz.
   <guideName> should be named only with ascii characters
   for portability among various filename encodings.

+ Template of the index file can be generated by evaluating this:

       QuickGuideMorph buildDefaultIndex.
       QuickGuideMorph saveIndex.

TODO:
+wiki/html/sexp generation functionalities haven't been adopted to this change.
+Buttons on index page are hard coded so aren't affected by translation.

Changes from Morphic-KR.10;
+ terminology change: catalog->index;  also name of file and related methods were changed
+ separator character is now "|"

=============== Diff against Morphic-bf.12 ===============

Item was added:
+ ----- 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'.
+ 		page setProperty: #transitionSpec toValue:  (Array with:  'silence' with: #none with: #none).
+ 	].
+ 	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 added:
+ ----- Method: QuickGuideMorph classSide>>categoryTitleOf: (in category 'initialization') -----
+ categoryTitleOf: catName
+ 	|catTitle|
+ 	Categories do: [:catRec |
+ 		(catRec first = catName )  
+ 			ifTrue: [
+ 				catTitle := catRec second.
+ 				catTitle isNil ifTrue: [^catName]
+ 									ifFalse: [^catTitle].
+ 			].
+ 	].
+ 	^nil!

Item was changed:
  BookMorph subclass: #QuickGuideMorph
  	instanceVariableNames: 'control order'
+ 	classVariableNames: 'Categories Colors Descriptions HTMLJumpTo IndexPage IndexPageMimeString PagesForCategory Thumbnails'
- 	classVariableNames: 'Colors Descriptions HTMLJumpTo IndexPage IndexPageMimeString Thumbnails'
  	poolDictionaries: ''
  	category: 'Morphic-Books'!
  
  !QuickGuideMorph commentStamp: 'tk 12/7/2007 15:15' prior: 0!
  A BookMorph that holds QuickGuides.
  
  World
  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)!

Item was changed:
  ----- Method: QuickGuideMorph>>showDescriptionMenu: (in category 'menu actions') -----
  showDescriptionMenu: evt
  	"The Jump To menu.  Choose a guide to see next"
  	| aMenu categories subMenu aWorld pos |
  	aMenu _ MenuMorph new defaultTarget: self.
  	aMenu addTitle: 'Quick Guides' translated.
  
  	categories _ self class suggestedCategoryOrder.
  	categories do: [:catName |
  		subMenu _ self makeCategoryMenu: catName.
+ 		subMenu items ifNotEmpty: [
+ 				aMenu add: (self class categoryTitleOf: catName)
+ 							subMenu: subMenu]].
- 		subMenu items ifNotEmpty: [aMenu add: catName translated subMenu: subMenu]].
  	aMenu add: 'Index' translated action: #goToIndex.
  	aWorld _ aMenu currentWorld.
  	pos _ aWorld primaryHand position - (aMenu fullBounds extent) + (-2 at 30).
  	aMenu popUpAt: pos forHand: aWorld primaryHand in: aWorld.
  !

Item was added:
+ ----- Method: QuickGuideMorph classSide>>loadIndex (in category 'initialization') -----
+ loadIndex
+ 	| st line rec categoryRec catKey  catTitle guideName guideTitle|
+      Categories := OrderedCollection new.
+ 	PagesForCategory := Dictionary new.
+ 	st := FileStream readOnlyFileNamed: QuickGuideMorph guidePath, ( FileDirectory slash), 'index.txt'.
+ 	st text.
+ 	[st atEnd] whileFalse: [
+ 
+ 		line := (st upTo: Character linefeed) withoutTrailingBlanks.
+ 		(line first = $: ) ifTrue: [	"Category"
+ 			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>>getWordyName:forCategory: (in category 'initialization') -----
+ getWordyName: guideName forCategory: guideCategory
+ 	"With guideName and category already filled in, make a name in words.  Remove the cat name, and trailing digits.  Separate words at capital letters.  NavBarHowToUse3 -> 'How To Use'  "
+ 
+ 	| gn mm tt |
+ 	gn _ guideName allButFirst: guideCategory size.
+ 	gn _ gn withoutTrailingDigits.
+ 	mm _ gn size.
+ 	gn reversed doWithIndex: [:cc :ind | 
+ 		ind < mm  ifTrue: [
+ 			cc isUppercase ifTrue: [ 
+ 				tt _ mm + 1 - ind.
+ 				gn _ (gn copyFrom: 1 to: tt-1), ' ', (gn copyFrom: tt to: gn size)].
+ 			cc == $- ifTrue: [
+ 				tt _ mm + 1 - ind.
+ 				gn at: tt put: $ ].	"convert dash to space"
+ 			]].
+ 	^ gn!

Item was changed:
  ----- Method: QuickGuideMorph>>showMenuCategory: (in category 'menu actions') -----
  showMenuCategory: catName
  	"put up a menu with all guides in this category"
  
  	| subMenu |
  	subMenu _ self makeCategoryMenu: catName.
+ 	subMenu addTitle: (self class categoryTitleOf: catName).
- 	subMenu addTitle: catName translated.
  	subMenu popUpInWorld.!

Item was changed:
  ----- Method: QuickGuideHolderMorph>>guideName: (in category 'accessing') -----
  guideName: aString
  
  	guideName _ aString.
- 	self setGuideWordyName.
  	self setNamePropertyTo: aString.
  !

Item was added:
+ ----- Method: QuickGuideMorph classSide>>defaultCatalog (in category 'initialization') -----
+ defaultCatalog
+ 	| catalog | 
+ 	catalog := Dictionary new.
+ 	self suggestedCategoryOrder 
+ 			do: [:catKey| |articles|
+ 				articles := OrderedCollection new.
+ 				(self defaultOrderIn: catKey) 
+ 					do: [:guideName | | guideTitle |
+ 						guideTitle := self getWordyName: guideName forCategory: catKey.
+ 						articles add: {guideName. guideTitle}.
+ 					].
+ 				catalog at: catKey put: articles.
+ 			].
+ 	^catalog.!

Item was added:
+ ----- Method: QuickGuideMorph classSide>>buildDefaultIndex (in category 'initialization') -----
+ buildDefaultIndex
+ 	PagesForCategory := self defaultIndex.
+ 	Categories := OrderedCollection new.
+ 	self suggestedCategoryOrder 
+ 			do: [:cat | |rec|
+ 				Categories add: {cat. cat}.
+ 			].
+ 				
+ !

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 at: catName) 
+ 			do: [:articleRec |
+ 				subMenu add: (articleRec second) 
+ 							target: self 
+ 							selector: #goToCardNamed: 
+ 							argument: (articleRec first)].
- 	pages do: [:pp |
- 		pp guideCategory = catName ifTrue: [
- 			subMenu add: pp guideNameInWords translated target: self 
- 					selector: #goToCardNamed: argument: pp guideName]].
  	^ subMenu!

Item was added:
+ ----- Method: QuickGuideMorph classSide>>defaultIndex (in category 'initialization') -----
+ defaultIndex
+ 	| index | 
+ 	index := Dictionary new.
+ 	self suggestedCategoryOrder 
+ 			do: [:catKey| |articles|
+ 				articles := OrderedCollection new.
+ 				(self defaultOrderIn: catKey) 
+ 					do: [:guideName | | guideTitle |
+ 						guideTitle := self getWordyName: guideName forCategory: catKey.
+ 						articles add: {guideName. guideTitle}.
+ 					].
+ 				index at: catKey put: articles.
+ 			].
+ 	^index.!

Item was added:
+ ----- Method: QuickGuideMorph classSide>>saveIndex (in category 'initialization') -----
+ saveIndex
+ 	|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].!

Item was removed:
- ----- Method: QuickGuideHolderMorph>>setGuideWordyName (in category 'initialization') -----
- setGuideWordyName
- 	"With guideName and category already filled in, make a name in words.  Remove the cat name, and trailing digits.  Separate words at capital letters.  NavBarHowToUse3 -> 'How To Use'  "
- 
- 	| gn mm tt |
- 	guideCategory _ QuickGuideMorph categoryOf: guideName.
- 	gn _ guideName allButFirst: guideCategory size.
- 	gn _ gn withoutTrailingDigits.
- 	mm _ gn size.
- 	gn reversed doWithIndex: [:cc :ind | 
- 		ind < mm  ifTrue: [
- 			cc isUppercase ifTrue: [ 
- 				tt _ mm + 1 - ind.
- 				gn _ (gn copyFrom: 1 to: tt-1), ' ', (gn copyFrom: tt to: gn size)].
- 			cc == $- ifTrue: [
- 				tt _ mm + 1 - ind.
- 				gn at: tt put: $ ].	"convert dash to space"
- 			]].
- 	^ guideNameInWords _ gn translated!



More information about the etoys-dev mailing list