Browse Source

Making hello build. It does not load, mysteriously.

Herbert Vojčík 10 years ago
parent
commit
a1a6783fc3
4 changed files with 40 additions and 11 deletions
  1. 24 0
      hello/Gruntfile.js
  2. 3 3
      hello/index.html
  3. 12 7
      hello/js/HelloApp.js
  4. 1 1
      hello/st/HelloApp.st

+ 24 - 0
hello/Gruntfile.js

@@ -0,0 +1,24 @@
+module.exports = function(grunt) {
+  grunt.loadNpmTasks('../../node_modules/amber-dev');
+
+  grunt.registerTask('default', ['amberc:hello']);
+
+  grunt.initConfig({
+    pkg: grunt.file.readJSON('../package.json'),
+
+    amberc: {  
+      options: {
+        amber_dir: '../bower_components/amber',
+        closure_jar: ''
+      },
+      hello: {
+        src: ['st/HelloApp.st'],
+        libraries: ['Web'],
+        output_dir: 'js',
+        deploy: true,
+        amd_namespace: 'amber_examples_hello'
+      }
+    }
+  });
+
+}

+ 3 - 3
hello/index.html

@@ -2,8 +2,8 @@
 <html>
   <head>
     <title>My First Amber Project</title>
-    <script src="../vendor/amber/support/amber.js"></script>
-    <script src="../vendor/amber/support/requirejs/require.min.js"></script>
+    <script src="../bower_components/amber/support/amber.js"></script>
+    <script src="../bower_components/amber/support/requirejs/require.min.js"></script>
     <script type="text/javascript">
       require.config({ paths: {
         'com_example_hello': 'js', //mapping compiled .js files
@@ -19,7 +19,7 @@
   <body>
     <article>
       <h1>My First Amber Project</h1>
-      <button onclick="require('amber_vm/smalltalk').Browser._open()">class browser</button>
+      <button onclick="require('amber/helpers').globals.Browser._open()">class browser</button>
       <button id="sayHello">say hello</button>
     </article>
   </body>

+ 12 - 7
hello/js/HelloApp.js

@@ -1,29 +1,34 @@
-define("com_example_hello/HelloApp", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Kernel-Objects"], function(smalltalk,nil,_st){
+define("amber_examples_hello/HelloApp", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){
+var smalltalk=$boot.vm,nil=$boot.nil,_st=$boot.asReceiver,globals=$boot.globals;
 smalltalk.addPackage('HelloApp');
-smalltalk.packages["HelloApp"].transport = {"type":"amd","amdNamespace":"com_example_hello"};
+smalltalk.packages["HelloApp"].transport = {"type":"amd","amdNamespace":"amber_examples_hello"};
 
-smalltalk.addClass('Hello', smalltalk.Object, [], 'HelloApp');
+smalltalk.addClass('Hello', globals.Object, [], 'HelloApp');
 smalltalk.addMethod(
 smalltalk.method({
 selector: "begin",
-category: 'not yet classified',
+protocol: 'not yet classified',
 fn: function (){
 var self=this;
 var msg,button;
 return smalltalk.withContext(function($ctx1) { 
+var $1,$2;
 msg="Hello world!";
 button="#sayHello"._asJQuery();
 _st(button)._click_((function(){
 return smalltalk.withContext(function($ctx2) {
-return _st(button)._after_(_st("<p>".__comma(msg)).__comma("</p>"));
+$1=button;
+$2=_st("<p>".__comma(msg)).__comma("</p>");
+$ctx2.sendIdx[","]=1;
+return _st($1)._after_($2);
 }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
-return self}, function($ctx1) {$ctx1.fill(self,"begin",{msg:msg,button:button},smalltalk.Hello)})},
+return self}, function($ctx1) {$ctx1.fill(self,"begin",{msg:msg,button:button},globals.Hello)})},
 args: [],
 source: "begin\x0a\x22Makes me say hello to the user.\x22\x0a\x0a| msg button |\x0amsg := 'Hello world!'.\x0abutton := '#sayHello' asJQuery.\x0abutton click: [button after: '<p>' , msg , '</p>'].",
 messageSends: ["asJQuery", "click:", "after:", ","],
 referencedClasses: []
 }),
-smalltalk.Hello);
+globals.Hello);
 
 
 });

+ 1 - 1
hello/st/HelloApp.st

@@ -1,4 +1,4 @@
-Smalltalk current createPackage: 'HelloApp'!
+Smalltalk createPackage: 'HelloApp'!
 Object subclass: #Hello
 	instanceVariableNames: ''
 	package: 'HelloApp'!