Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first commit

  • Loading branch information...
commit dfef9d32e70626d3001d40d291a67cafbd147fa5 0 parents
francescoagati authored
1  .gitignore
@@ -0,0 +1 @@
+haxe/www/*
1  haxe/.tmbuild
@@ -0,0 +1 @@
+/Applications/MAMP/htdocs/drupal-7.12/sites/all/modules/menur/haxe/build.hxml
14 haxe/Api.hx
@@ -0,0 +1,14 @@
+import haxe.web.Dispatch;
+
+class Api extends BaseApi {
+
+ public function new() {}
+
+ @view('user')
+ function doUsers(d:Dispatch,id:Int) {
+ render({
+ name:'mario',
+ surname:'rossi'
+ });
+ }
+}
22 haxe/BaseApi.hx
@@ -0,0 +1,22 @@
+import haxe.Template;
+
+class BaseApi {
+
+ public var view:Dynamic;
+ public var layout:Dynamic;
+ public var output:String;
+
+
+ public function render(data:Dynamic) {
+
+ var str = haxe.Resource.getString(view[0]);
+ var t = new haxe.Template(str);
+ output = t.execute(data);
+
+ }
+
+ public function renderString(s:String) {
+ output=s;
+ }
+
+}
38 haxe/DrupalDispatcher.hx
@@ -0,0 +1,38 @@
+import haxe.web.Dispatch;
+using StringTools;
+
+class DrupalDispatcher {
+
+ var url:String;
+ var api:Api;
+
+ function setUrl(base_url:String) {
+ url=untyped __php__("$_GET['q']");
+ url=url.replace(base_url + "/", "");
+ }
+
+ function dispatch() {
+
+ var d = new Dispatch(url,new Hash());
+ api=new Api();
+
+ d.onMeta=function(m,value) {
+ if (m=="view") api.view=value;
+ if (m=="layout") api.layout=value;
+ };
+ d.dispatch(api);
+
+ }
+
+ public function new(base_url:String) {
+ setUrl(base_url);
+ dispatch();
+ }
+
+ public function getOutput():String {
+ return api.output;
+ }
+
+ public static function main() {}
+
+}
9 haxe/Main.hx
@@ -0,0 +1,9 @@
+
+
+class Main {
+
+ public static function main() untyped{
+
+
+ }
+}
4 haxe/build.hxml
@@ -0,0 +1,4 @@
+-main DrupalDispatcher
+-php www
+-resource views/user.tpl@user
+-resource views/users.tpl@users
2  haxe/views/user.tpl
@@ -0,0 +1,2 @@
+::name::<br/>
+::surname::
0  haxe/views/users.tpl
No changes.
3  menur.info
@@ -0,0 +1,3 @@
+name = menur
+description = menur
+core = 7.x
17 menur.module
@@ -0,0 +1,17 @@
+<?
+
+function menur_menu() {
+ $items['haxe'] = array(
+ 'page callback' => 'mymodule_abc_view',
+ 'access arguments' => array('access content'),
+ );
+ return $items;
+ }
+
+ function mymodule_abc_view($ghi = 0, $jkl = '') {
+
+ require_once dirname(__FILE__).'/haxe/www/lib/php/Boot.class.php';
+ $dp=new DrupalDispatcher('haxe');
+ return $dp->getOutput();
+
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.