'From etoys2.3 of 2 December 2007 [latest update: #1870] on 6 January 2008 at 12:34:45 pm'!
"Change Set: GuideToWeb-tk
Date: 4 January 2008
Author: Ted Kaehler
Code that writes out the QuickGuides as web pages. User will then move manually them to:
http://tinlizzie.org/olpc/QG-web/
Some Guides will need new .jpeg images of their pages. The other guides will need the index in the left sidebar updated. Call to write all Guides including page images. Also call to write a few Guides, and correct the index of the rest.
Creates the text of an index page. User can install it at:
http://wiki.laptop.org/go/Etoys_QuickGuides_Index
Also, all digits at the end of Guide names are removed."!
!QuickGuideGenerator commentStamp: 'tk 1/3/2008 10:32' prior: 0!
Used to generate .sexp files for the Quick Guides. These are the help system for Etoys.
How to use:
Pressing the Help button [?] at the top left of the screen, brings up the QuickGuides flap. The index page has categories of help. The Jump To... button allows you to get to any help guide.
To create a new guide, copy the bookmorph out of the flap. Use the halos to completely change the contents. Create help pages for a new topic.
When you are done, write the entire project out using "Keep the current project". It is now a .pr file.
If you put the .pr into the QuickGuides folder, you will be able to see it in the Help flap. (Click the Help button [?] once to close help, and once again to open it.)
You can test a .pr file in the QuickGuides folder, but it is not in the proper format to include in the OLPC build.
The purpose of QuickGuideGenerator is to put a guide in to the proper format for distribution.
0) Get the new Guides from http://tinlizzie.org/quickguides
1) Make a folder called "To-Be-Translated" at the top level of your file system. Put the .pr files of all new guides into this folder.
1.5) Make a folder called "Newer" in the folder that has the Etoys image file. Must be a fresh new folder.
2) Start Etoys. You will NOT save this image.
3) Execute
QuickGuideGenerator new openInWorld.
4) Wait until a new window appears.
5) Find the folder "To-Be-Translated" in the list and click on it. It's path will appear in the top pane.
6) Press the "Generate" button. Wait.
7) Quit Etoys.
8) "Newer" will now have a .sexp file for each guide that was a .pr file. Files ending in .sexp contain Yoshiki's S-expression linearization of object trees.
9) Copy the .sexp files to QuickGuides, and delete the .pr files of the same name.
10) Rename Newer to be Newer-day-month-year
11) Copy Newer-xx to http://tinlizzie.org/share/QG-compressed
12) copy the .sexp files into http://tinlizzie.org/share/QG-compressed/Quickguides
!
]style[(745 88 16 1111 1)f3,f2,f3,f2,f3!
BookMorph subclass: #QuickGuideMorph
instanceVariableNames: 'control order '
classVariableNames: 'Colors Descriptions IndexPage IndexPageMimeString Thumbnails HTMLJumpTo '
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)!
!QuickGuideMorph methodsFor: 'initialization' stamp: 'tk 1/4/2008 10:44'!
preloadIndex
"At system build time, load the Guide Index from file 'preload-index.sexp.data.gz'. Save in IndexPage."
| dir firstPage |
dir _ (FileDirectory on: Smalltalk imagePath) directoryNamed: 'QuickGuides'.
(dir fileExists: 'index.pr') ifTrue: [
self inform: 'Raw index.pr is not supposed to be in QuickGuides
during a build. I will delete it now'.
dir deleteFileNamed: 'index.pr'].
(dir fileExists: 'preload-index.sexp.data.gz') ifFalse: [
^ self error: 'could not find QuickGuides/preload-index.sexp.data.gz'].
firstPage _ pages first.
firstPage guideName: 'preload-index'.
firstPage guideCategory: ''.
firstPage load. "allow index.sexp.data.gz"
firstPage guideName: 'index'.
self class indexPage: firstPage submorphs first. "the goal, sets name"
IndexPageMimeString _ ''. "remove old"
self class purgeIndexProjects.
^ true
! !
!QuickGuideMorph methodsFor: 'transition' stamp: 'tk 1/4/2008 10:45'!
checkForIndexOnDisk
"For debugging only, Look on disk every time for a new Index as a .pr file. Must be named index.pr. Overwrite IndexPage if found."
| dir firstPage |
dir _ (FileDirectory on: Smalltalk imagePath) directoryNamed: 'QuickGuides'.
(dir fileExists: 'index.pr') ifFalse: [
(dir fileExists: 'index.sexp.data.gz') ifFalse: [^ false]].
firstPage _ pages first.
firstPage guideName: 'index'.
firstPage guideCategory: ''.
firstPage load. "allow index.sexp.data.gz"
IndexPage _ firstPage submorphs first.
^ true
" IndexPage _ QuickGuideHolderMorph new loadPR: 'index.pr' dir: dir. "
! !
!QuickGuideMorph methodsFor: 'transition' stamp: 'tk 1/4/2008 10:44'!
goToPageMorph: newPage transitionSpec: transitionSpec
newPage load.
super goToPageMorph: newPage transitionSpec: transitionSpec.
! !
!QuickGuideMorph methodsFor: 'write web pages' stamp: 'tk 1/4/2008 13:34'!
allGuidesToWeb
"Write out web pages for each of the Guides in the QuickGuides folder. In an inspector on the current help flap, evaluate
self allGuidesToWeb.
Write both a web page and the .jpegs for each guide page.
Method to write N new guides, and update the index for the others:
self rewriteGuidesAndIndexInOthers: 'name name name'.
Return the text for the wiki page: http://wiki.laptop.org/go/Etoys_QuickGuides_Index
self guidesIndexForWiki.
To allow the text in Guides to show in other languages.
When the text of guides change, we need to write it out to the .pot and .po files.
To translate guides that are already written out in English:
In the folder po/quickguides/ copy an existing .po file and name it similar to pt-BR.po (pt for Portugese and BR for Brazil).
Edit the file in a UFT-8 aware editor (not the Squeak file list).
Save As in UFT-8.
In the shell terminal. (langCode is pt_BR in this example) execute
msgfmt langCode.po -o quickguides.mo
(how add on to existing .mo with other languages?)
Move quickguides.mo to lang/langCode/LC_MESSAGES/
Get into Etoys, set the language to the language you are working with, and look at a guide.
"
self htmlForJumpTo. "reset"
1 to: pages size do: [:ii |
self goToPage: ii.
self guideToWebWithJPEGs: true ].
self beep.! !
!QuickGuideMorph methodsFor: 'write web pages' stamp: 'tk 1/2/2008 13:07'!
guidesIndexForWiki
"Create the html for a long list of guide categories and guides. Each is a clickable link. For the laptop.org wiki. An index to the web pages for the Guides.
Inspect a Guide and go up the owner chain to a QuickGuideMorph. self guidesIndexForWiki "
| strm categories |
strm _ WriteStream on: (String new: 6000).
strm nextPutAll: 'At the top left of the screen in Etoys is a "?" button. Clicking it brings up a help flap with more than 50 QuickGuides. These tell how to use different parts of Etoys.
[[Image:Help-icon.jpeg]]
The QuickGuides are also available on the web. Note that the active buttons and Etoys controls will not work in the web version.
__NOTOC__'; cr.
strm nextPutAll: '=== Guides about topics in EToys ==='; cr; cr.
categories _ self class suggestedCategoryOrder.
categories do: [:catName |
strm nextPutAll: '==== '; nextPutAll: catName translated; nextPutAll: ' ===='; cr.
pages do: [:pp |
pp guideCategory = catName ifTrue: [
strm nextPutAll: '* [http://tinlizzie.org/olpc/QG-web/', pp guideName, '.html'.
strm space; nextPutAll: pp guideNameInWords translated; nextPutAll: ']'; cr.
]].
].
^ strm contents
" "! !
!QuickGuideMorph methodsFor: 'write web pages' stamp: 'tk 1/2/2008 12:20'!
guideToWeb
"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 |
dir _ FileDirectory default directoryNamed: 'QG-web'.
"picutres of guide pages"
qgh _ self submorphOfClass: QuickGuideHolderMorph.
bk _ qgh submorphOfClass: BookMorph.
strm _ WriteStream on: (String new: 500).
strm nextPutAll: (self htmlPreamble: qgh guideNameInWords).
1 to: bk pages size do: [:ii |
false ifTrue: [ "can turn off image writing when tuning the text"
bk goToPage: ii. "show it"
self jPegOutDir: dir].
strm nextPutAll: '