Browse Source

Merge remote branch 'origin/master'

Göran Krampe 12 years ago
parent
commit
2ccb786c3c

+ 1 - 7
nodejs/hello/Hello.st

@@ -5,11 +5,5 @@ Object subclass: #Hello
 !Hello class methodsFor: 'main'!
 
 main
-	console log: Hello new hello
+	console log: 'Hello world from JTalk in Node.js'
 ! ! 
-
-!Hello methodsFor: 'printing'!
-
-hello
-        ^'Hello world from JTalk in Node.js'
-! !

BIN
webos/eris/DuckQwaq.wav


+ 36 - 0
webos/eris/EnyoJtalk.st

@@ -0,0 +1,36 @@
+"This is a base class for Jtalk Enyo UI classes. We keep track of an optional sister kind
+in Enyo and typically an instance of it, or an instance without a kind, called ui.
+
+NOTE: Inheritance of ivars seems broken, I need to use #ui: in subclass to set it"
+
+Object subclass: #EnyoFriend
+        instanceVariableNames: 'ui kind'
+        category: 'EnyoJtalk'!
+
+!EnyoFriend methodsFor: 'accessing'!
+
+ui
+	^ui
+!
+
+ui: aUI
+	ui := aUI
+!
+
+dollar
+	"Return the $ of ui for easy access to the components of the UI."
+	<return this['@ui'].$>
+!
+
+kind
+	^kind
+! !
+
+!EnyoFriend methodsFor: 'initializing'!
+initialize
+	"We make sure our JS functions can be used transparently from Jtalk,
+	at this moment we do not use it - trying to create Enyo kinds that are
+	at the same time Jtalk classes failed for me."
+	super initialize.
+	<this.allowJavaScriptCalls = true>
+! !

+ 0 - 0
webos/eris/Eris.css


+ 81 - 0
webos/eris/Eris.st

@@ -0,0 +1,81 @@
+EnyoFriend subclass: #Eris
+        instanceVariableNames: ''
+        category: 'Eris'!
+
+!Eris methodsFor: 'actions'!
+
+doIt
+    ^self eval: self dollar richText getValue
+!
+
+clear
+	self dollar richText setValue: ''
+!
+
+eval: aString
+    | compiler node |
+    compiler := Compiler new.
+    node := compiler parseExpression: aString.
+    node isParseFailure ifTrue: [
+	^self warn: 'Ehrm, you are a Smalltalk n00b, right?' button: 'Yup'].
+    ^compiler loadExpression: aString.
+!
+
+printString
+	^''
+!
+
+warn: aString button: caption
+	| block popup |
+	block := [popup close].
+	<props = {kind: 'ModalDialog', caption: 'Parsing error', components: [
+			{kind: 'Control', content: aString, className: 'enyo-text-error warning-icon'},
+			{kind: 'Button', caption: caption, onclick: 'closePopup', style: 'margin-top:10px'}],
+		 closePopup: block}>.
+	popup := enyo create: props.
+	popup openAtCenter
+!
+
+print: aString
+    self dollar richText setValue: (self dollar richText getValue), ' ', aString
+!
+
+quack
+	"(self kind: 'Sound'; src: 'DuckQwaq.wav'; create) play"
+	(enyo create: (Dictionary new at: 'kind' put: 'Sound'; at: 'src' put: 'DuckQwaq.wav'; yourself)) play
+!
+
+printIt
+    self print: self doIt printString
+! !
+
+!Eris methodsFor: 'initialization'!
+initialize
+	| props doItBlock printItBlock quackBlock clearBlock |
+	super initialize.
+	doItBlock := [self doIt].
+	printItBlock := [self printIt].
+	quackBlock := [self quack].
+	clearBlock := [self clear].
+
+	<props = {kind: 'VFlexBox', components: [
+			{kind: 'PageHeader', content: 'Eris'},
+ 			{kind: 'RowGroup', caption: 'Workspace', components: [
+				{kind: 'RichText', richContent: false,
+					value: 'Put some funky Jtalk code here...',
+					autoWordComplete: false, spellcheck: false, autocorrect: false,
+					autoCapitalize: 'lowercase', alwaysLooksFocused: true
+				},
+				{kind: 'Toolbar', components: [
+					{caption: 'Do it', onclick: 'doit'},
+					{caption: 'Print it', onclick: 'printit'},
+					{caption: 'Clear', onclick: 'clear'},
+					{kind: 'Spacer'},
+					{caption: 'Quack!', onclick: 'quack'}]}]}],
+		doit: doItBlock,
+		printit: printItBlock,
+		quack: quackBlock,
+		clear: clearBlock}>.
+	ui := enyo create: props.
+! !
+

+ 38 - 0
webos/eris/Makefile

@@ -0,0 +1,38 @@
+#
+# If you copy this file for an Enyo/Jtalk project, just
+# modify these first two lines
+# and then add .st files as you please. This Makefile
+# should pick them all up and compile into Program.js.
+#
+PACKAGE  := jtalk.eris
+VERSION  := 0.0.1
+
+# -E for Enyo, -O for Closure optimization of js code.
+FLAGS    := -E -C
+IPK      := $(PACKAGE)_$(VERSION)_all.ipk
+FILE     := Program
+SOURCES  := $(wildcard *.st)
+OBJECTS  := $(patsubst %.st,%.js,$(wildcard *.st))
+FILEJS   := $(FILE).js
+
+$(FILEJS): $(SOURCES)
+	../../bin/jtalkc $(FLAGS) $(SOURCES) $(FILE)
+
+$(IPK): $(FILEJS)
+	palm-package .
+
+clean:
+	rm -f $(FILEJS) $(OBJECTS) $(IPK)
+	palm-install -r $(PACKAGE)
+
+install: $(IPK)
+	palm-install $(IPK)
+
+# If you want to run it in the emulator, start the emulator first with palm-emulator
+run:    $(IPK)
+	palm-install $(IPK)
+	palm-launch $(PACKAGE)
+
+# This should fire it up in Chromium (at least under Ubuntu)
+chromium: $(FILEJS)
+	chromium-browser --allow-file-access-from-files index.html

+ 10 - 0
webos/eris/appinfo.json

@@ -0,0 +1,10 @@
+{
+	"id": "jtalk.eris",
+	"version": "0.0.1",
+	"vendor": "Krampe Dynamic Development",
+	"type": "web",
+	"main": "index.html",
+	"title": "Eris",
+	"icon": "icon.png",
+	"uiRevision": 2
+}

+ 4 - 0
webos/eris/depends.js

@@ -0,0 +1,4 @@
+enyo.depends(
+	"Program.js",
+	"Eris.css"
+);

+ 12 - 0
webos/eris/index.html

@@ -0,0 +1,12 @@
+<!doctype html>
+<html>
+<head>
+	<title>Eris</title>
+	<script src="../../../enyo/1.0/framework/enyo.js" type="text/javascript"></script>
+</head>
+<body>
+<script type="text/javascript">
+	smalltalk.Eris._new()._ui().renderInto(document.body);
+</script>
+</body>
+</html>