Преглед на файлове

add Dlang hunt web framework (#2650)

* add hunt framework

* add hunt framework resources

* add travis.yml

* add travis.yml

* modify benchmark_config script name

* modify travis.yml in project root

* add travis.tml

* add travis.tml

* delete travis.yml

* delete travis.yml

* modify setup.sh

* add http header
viile преди 8 години
родител
ревизия
1afb016ed2

+ 1 - 0
.travis.yml

@@ -39,6 +39,7 @@ env:
     - "TESTDIR=Crystal/crystal"
     - "TESTDIR=Crystal/kemal"
     - "TESTDIR=D/vibed"
+    - "TESTDIR=D/hunt"
     - "TESTDIR=D/collie"
     - "TESTDIR=Dart/dart-raw"
     - "TESTDIR=Dart/redstone"

+ 18 - 0
frameworks/D/hunt/README.md

@@ -0,0 +1,18 @@
+# Versions
+
+* dub 1.2.1
+* dmd 2.073.1
+
+# Test URLs
+
+### JSON Encoding Test
+
+    - http://localhost:8080/json
+    - http://localhost:8080/plaintext
+
+# Contact
+
+viile [email protected] - github:[viile](https://github.com/viile) 
+Core developer team - [putao Dlang team](https://github.com/huntlabs)
+
+

+ 25 - 0
frameworks/D/hunt/benchmark_config.json

@@ -0,0 +1,25 @@
+{
+  "framework": "hunt",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "plaintext_url": "/plaintext",
+      "json_url": "/json",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "hunt",
+      "language": "D",
+      "flavor": "DLang2",
+      "orm": "raw",
+      "platform": "None",
+      "webserver": "nginx",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "hunt",
+      "notes": "",
+      "versus": "hunt"
+    }
+  }]
+}

+ 31 - 0
frameworks/D/hunt/config/application.conf

@@ -0,0 +1,31 @@
+application.name=MYSITE
+application.baseUrl=http://localhost:8080/
+application.defaultCookieDomain=.example.com
+application.defaultLanguage=zh-CN
+application.languages=zh-CN,en-US
+application.secret=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+application.encoding=UTF-8
+
+session.prefix=hunt
+session.storage=memcache
+session.expire=3600
+
+http.address=0.0.0.0
+http.port=8080
+http.workerThreads=4
+http.cacheControl=0
+http.path=/data/www/example.com/htdocs/
+
+https.enabled=true
+https.protocol = "TLS";
+https.keyStore=keystore.p12
+https.keyStoreType=PKCS12
+https.keyStorePassword=secret
+
+log.level=DEBUG
+log.path=
+log.file=
+
+upload.path=data/attachments/
+upload.maxSize=4096000
+

+ 13 - 0
frameworks/D/hunt/config/routes

@@ -0,0 +1,13 @@
+#
+# [GET,POST,PUT...]    path    controller.method
+#
+
+*	/json	index.json
+*	/db	index.db
+*	/queries	index.queries
+*	/fortunes	index.fortunes
+*	/update	index.update
+*	/plaintext	index.plaintext
+*	/mongodb/db	index.mongodbDb
+*	/mongodb/queries	index.mongodbQueries
+*	/mongodb/fortunes	index.mongodbFortunes

+ 13 - 0
frameworks/D/hunt/dub.json

@@ -0,0 +1,13 @@
+{
+	"name": "website",
+	"description": "A minimal D application.",
+	"copyright": "Copyright © 2016, huntframework.com",
+	"targetType": "executable",
+	"stringImportPaths": [
+		"./resources/views",
+	],
+	"mainSourceFile": "./source/bootstrap.d",
+	"dependencies": {
+		"hunt": "0.6.2"
+	},
+}

+ 17 - 0
frameworks/D/hunt/dub.selections.json

@@ -0,0 +1,17 @@
+{
+	"fileVersion": 1,
+	"versions": {
+		"collie": "0.9.7",
+		"ddbc": "0.3.2",
+		"derelict-pq": "2.0.3",
+		"derelict-util": "2.0.6",
+		"entity": "0.1.1",
+		"hunt": "0.6.2",
+		"libasync": "0.7.9",
+		"libevent": "2.0.2+2.0.16",
+		"memutils": "0.4.9",
+		"mysql-native": "1.0.0",
+		"openssl": "1.1.5+1.0.1g",
+		"vibe-d": "0.7.30"
+	}
+}

+ 2 - 0
frameworks/D/hunt/resources/main.html

@@ -0,0 +1,2 @@
+<html>
+</html>

+ 12 - 0
frameworks/D/hunt/setup.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+
+fw_depends dlang
+
+# Clean any files from last run
+rm -f website
+rm -rf .dub
+rm -f dub.selections.json
+
+dub build -f -b release -v
+
+./website

+ 0 - 0
frameworks/D/hunt/source/app/.gitkeeper


+ 0 - 0
frameworks/D/hunt/source/app/controller/.gitkeeper


+ 55 - 0
frameworks/D/hunt/source/app/controller/index.d

@@ -0,0 +1,55 @@
+/*
+ * Hunt - a framework for web and console application based on Collie using Dlang development
+ *
+ * Copyright (C) 2015-2016  Shanghai Putao Technology Co., Ltd 
+ *
+ * Developer: putao's Dlang team
+ *
+ * Licensed under the BSD License.
+ *
+ */
+module app.controller.index;
+import hunt.application;
+import std.experimental.logger;
+import std.exception;
+import std.datetime;
+import std.conv;
+import std.string;
+version(USE_ENTITY) import app.model.index;
+
+class IndexController : Controller
+{
+	mixin MakeController;
+	this()
+	{
+	}
+	Response res(){return request.createResponse();}
+	@Action void json()
+	{
+		import std.json;
+		JSONValue js = JSONValue([
+				"message" : "Hello, World!"		
+		]);
+		res.setHeader("Date",printDate);
+		res.json(js);
+	}
+
+	@Action void plaintext()
+	{
+		res.setHeader("Date",printDate);
+		res.html("Hello, World!");
+	}
+
+	private string printDate() {
+		DateTime date = cast(DateTime)Clock.currTime;
+		return format(
+				"%.3s, %02d %.3s %d %02d:%02d:%02d GMT", // could be UTC too
+				to!string(date.dayOfWeek).capitalize,
+				date.day,
+				to!string(date.month).capitalize,
+				date.year,
+				date.hour,
+				date.minute,
+				date.second);
+	}
+}

+ 55 - 0
frameworks/D/hunt/source/app/model/index.d

@@ -0,0 +1,55 @@
+module app.model.index;
+
+version(USE_ENTITY):
+import hunt.application;
+public import entity;
+
+
+@Table("test2")
+struct Test
+{
+	@Primarykey()
+	int id;
+
+	@Field ("floatcol")
+	float fcol;
+
+	@Field("doublecol")
+	double dcol;
+
+	@Field("datecol")
+	Date date;
+
+	@Field("datetimecol")
+	DateTime dt;
+
+	@Field("timecol")
+	Time time;
+
+	@Field()
+	string stringcol;
+
+	@Field()
+	ubyte[] ubytecol;
+} 
+
+class IndexModel : Model!Test
+{
+    void showTest2()
+    {
+		auto iterator = Select();
+
+		if(iterator !is null)
+			foreach(tp; iterator)
+            {
+                writeln("float is  : ", tp.fcol);
+                writeln("the string is : ", tp.stringcol);
+                writeln("the ubyte is : ", cast(string)tp.ubytecol);
+            }
+    }
+    
+    void insertNew(Test t)
+    {
+		Insert(t);
+    }
+}

+ 12 - 0
frameworks/D/hunt/source/bootstrap.d

@@ -0,0 +1,12 @@
+import std.stdio;
+import std.functional;
+import std.experimental.logger;
+
+import hunt;
+
+void main()
+{
+    auto app = Application.getInstance();
+	app.run();
+}
+

BIN
frameworks/D/hunt/website