Commit 914308d3 authored by Bat's avatar Bat
Browse files

Merge branch 'master' into 'master'

fix #54 + removing libsoup dependency



See merge request !16
parents b511bce6 5713deff
Pipeline #9432 passed with stage
in 4 minutes and 19 seconds
# Add .exe if you are on Windows
TESTOUTPUT = tests/serv
LINUXLIB = --pkg libscgi-1.0 -X "-I." -X libscgi-1.0.so --pkg libsoup-2.4 --pkg gee-0.8 --pkg sqlite3
WINDOWSLIB = --pkg libscgi-1.0 -X "-I." -X libscgi-1.0.dll --pkg libsoup-2.4 --pkg gee-1.0 --pkg sqlite3
LINUXLIB = --pkg libscgi-1.0 -X "-I." -X libscgi-1.0.so --pkg gio-2.0 --pkg gee-0.8 --pkg sqlite3
WINDOWSLIB = --pkg libscgi-1.0 -X "-I." -X libscgi-1.0.dll --pkg gio-2.0 --pkg gee-1.0 --pkg sqlite3
FILES = valse/*.vala valse/core/*.vala valse/wala/*.vala valse/default/*.vala
WINOUT = out/valse.dll
LINUXOUT = out/valse.o
......@@ -29,7 +29,7 @@ tests: linux
cp libscgi-1.0.h ./tests
cd ./tests
export LD_LIBRARY_PATH=.
valac *.vala models/*.vala --vapidir=. --pkg valse --pkg libscgi-1.0 --pkg gio-2.0 --pkg gee-0.8 --pkg libsoup-2.4 -X "-I." -X "valse.o" -X "-I." -X libscgi-1.0.so -o serv
valac *.vala models/*.vala --vapidir=. --pkg valse --pkg libscgi-1.0 --pkg gio-2.0 --pkg gee-0.8 -X "-I." -X "valse.o" -X "-I." -X libscgi-1.0.so -o serv
./serv
.ONESHELL:
......@@ -42,7 +42,7 @@ unit: linux
cp libscgi-1.0.h ./unit-tests
cd ./unit-tests
export LD_LIBRARY_PATH=.
valac *.vala --vapidir=. --pkg valse --pkg libscgi-1.0 --pkg gio-2.0 --pkg gee-0.8 --pkg libsoup-2.4 -X "-I." -X "valse.o" -X "-I." -X libscgi-1.0.so -o tests
valac *.vala --vapidir=. --pkg valse --pkg libscgi-1.0 --pkg gio-2.0 --pkg gee-0.8 -X "-I." -X "valse.o" -X "-I." -X libscgi-1.0.so -o tests
@echo
@echo
@echo "--- Starting tests ---"
......
......@@ -41,7 +41,7 @@ public class UserController : Controller {
base_arr += usr;
}
Many<User> usrs = new Many<User>.from_array (base_arr);
Many<User> usrs = new Many<User>.wrap (base_arr);
UserList list = new UserList ();
list.users = usrs;
......
using Soup;
using Gee;
namespace Valse {
......
......@@ -38,21 +38,8 @@ namespace Valse {
public string body { get; set; }
/**
* Creates a new Response from {@link Soup.Message}
*
* @param msg The {@link Soup.Message} used to initialize {@link Valse.Response}
* Create an empty response, that should be modified before sending.
*/
[Version (deprecated = true, deprecated_since = "alpha 2", replacement = "Response or Response.from_html")]
public Response.from_soup (Soup.Message msg) {
// gets Soup's headers
msg.response_headers.foreach ((name, val) => {
this.headers [name] = val;
});
// default error code and body
this.error_code = 200;
this.body = "";
}
public Response () {
this.error_code = 200;
this.body = "";
......
using Soup;
using Gee;
using Sqlite;
using Valse.Default;
......@@ -206,10 +205,9 @@ namespace Valse {
is_static = true;
res.mime_type = get_mime (req.path);
Soup.Date expiration = new Soup.Date.from_now (0);
expiration.year += 1;
res.headers ["Expires"] = expiration.to_string (DateFormat.HTTP);
res.headers ["Last-Modified"] = new Soup.Date.from_now (-10).to_string (DateFormat.HTTP);
const string http_date_format = "%a, %d %b %Y %T GMT";
res.headers["Expires"] = new DateTime.now_utc ().add_years (1).format (http_date_format);
res.headers["Last-Modified"] = new DateTime.now_utc ().add_seconds (-10.0).format (http_date_format);
} catch (Error err) {
print ("[ERROR] \"static%s\" not found.\n", req.path);
res.error_code = 404;
......
......@@ -2,6 +2,53 @@ using Gee;
namespace Valse {
public class Many<G> : ArrayList<G> {
public Many (EqualDataFunc<G>? eq_func = null) {
base (eq_func);
}
public Many.wrap (owned G[] base_arr, EqualDataFunc<G>? eq_func = null) {
base.wrap (base_arr, eq_func);
}
public HashMap<string, string> to_hashmap () {
HashMap<string, string> result = new HashMap<string, string> ();
Type t = typeof (G);
int index = 0;
foreach (G item in this) {
string key = "[%d]".printf (index);
if (t.is_a (typeof (Object))) {
Object obj = (Object) item;
foreach (var spec in obj.get_class ().list_properties ()) {
if (spec.value_type == typeof (string)) {
Value val = Value (typeof (string));
obj.get_property (spec.get_nick (), ref val);
result [key + "." + spec.get_nick ()] = (string) val;
} else if (spec.value_type == typeof (int)) {
Value val = Value (typeof (int));
obj.get_property (spec.get_nick (), ref val);
result [key + "." + spec.get_nick ()] = ((int) val).to_string ();
}
}
} else if (t == typeof (string)) {
result [key] = (string) item;
} else if (t == typeof (int)) {
result [key] = ((int) item).to_string ();
}
index++;
}
result [".count"] = index.to_string ();
return result;
}
}
/*
public class Many<G> : Object {
private G[] _arr {get; set; default = new G[] {};}
......@@ -67,5 +114,5 @@ namespace Valse {
return result;
}
}
}*/
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment