From 1b5e64859c879cb2263a9dc0b51c9f4b1159c3e4 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 7 Aug 2017 01:33:17 +0200 Subject: [PATCH] Use selective imports --- source/app.d | 7 ++++++- source/calendarwebapp.d | 10 ++++++++-- source/event.d | 14 +++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/source/app.d b/source/app.d index 9fb58aa..9ce1598 100644 --- a/source/app.d +++ b/source/app.d @@ -1,5 +1,10 @@ import calendarwebapp; -import vibe.vibe; + +import vibe.core.log : logInfo; +import vibe.http.fileserver : serveStaticFiles; +import vibe.http.router : URLRouter; +import vibe.http.server : HTTPServerSettings, listenHTTP, MemorySessionStore; +import vibe.web.web : registerWebInterface; shared static this() { diff --git a/source/calendarwebapp.d b/source/calendarwebapp.d index 26310f0..0e616a0 100644 --- a/source/calendarwebapp.d +++ b/source/calendarwebapp.d @@ -1,13 +1,19 @@ module calendarwebapp; +import core.time : days; + import event; import std.datetime.date : Date; +import std.exception : enforce; import std.typecons : Nullable; -import vibe.vibe; - +import vibe.core.path : Path; +import vibe.http.common : HTTPStatusException; +import vibe.http.server : HTTPServerRequest, HTTPServerResponse; +import vibe.http.status : HTTPStatus; import vibe.web.auth; +import vibe.web.web : errorDisplay, noRoute, redirect, render, SessionVar, terminateSession; struct AuthInfo { diff --git a/source/event.d b/source/event.d index 80597cf..ebf8775 100644 --- a/source/event.d +++ b/source/event.d @@ -4,9 +4,9 @@ import std.datetime.date; import std.typecons : Nullable; import vibe.core.file: existsFile, readFileUTF8, writeFileUTF8; -import vibe.core.path; +import vibe.core.path : Path; import vibe.data.json : deserializeJson, parseJsonString, serializeToPrettyJson; -import vibe.data.serialization; +import vibe.data.serialization : serializationName = name; enum EventType { @@ -19,17 +19,17 @@ enum EventType struct Entry { - @name("date") Date begin; - @name("end_date") Nullable!Date end; + @serializationName("date") Date begin; + @serializationName("end_date") Nullable!Date end; Event event; } struct Event { - @(vibe.data.serialization.name("eid")) string id; + @serializationName("eid") string id; string name; - @(vibe.data.serialization.name("desc")) string[] description; - @(vibe.data.serialization.name("etype")) EventType type; + @serializationName("desc") string[] description; + @serializationName("etype") EventType type; bool shout; }