├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── LICENSE
├── README.md
├── app
├── api.d
├── appcache.d
├── diamondapp.d
├── files.d
├── server.d
└── web.d
├── authentication
├── auth.d
├── package.d
├── permissions.d
└── roles.d
├── controllers
├── action.d
├── attributes.d
├── authentication.d
├── basecontroller.d
├── controller.d
├── package.d
├── rest
│ ├── package.d
│ ├── parser.d
│ ├── routedatatype.d
│ ├── routepart.d
│ └── routetype.d
└── status.d
├── core
├── apptype.d
├── cache.d
├── collections.d
├── debugging.d
├── filterservice.d
├── io.d
├── logging.d
├── meta.d
├── package.d
├── senc.d
├── string.d
├── traits.d
├── webconfig.d
├── webinitialization.d
└── websettings.d
├── css
├── css3selector.d
└── package.d
├── data
├── i18n
│ ├── loader.d
│ ├── messages.d
│ └── package.d
├── mapping
│ ├── attributes.d
│ ├── engines
│ │ ├── mssql
│ │ │ ├── mssqladapter.d
│ │ │ ├── mssqlentityformatter.d
│ │ │ ├── mssqlmodel.d
│ │ │ └── package.d
│ │ ├── mysql
│ │ │ ├── mysqladapter.d
│ │ │ ├── mysqlentityformatter.d
│ │ │ ├── mysqlmodel.d
│ │ │ └── package.d
│ │ ├── package.d
│ │ └── sqlshared
│ │ │ ├── package.d
│ │ │ ├── sqladapter.d
│ │ │ └── sqlentityformatter.d
│ ├── model.d
│ └── package.d
├── package.d
├── snapshot.d
└── transaction.d
├── database
├── mongo
│ ├── operations.d
│ └── package.d
└── package.d
├── dom
├── domattribute.d
├── domdocument.d
├── domexception.d
├── domnode.d
├── domparser.d
├── domparsersettings.d
└── package.d
├── errors
├── checks.d
├── errorhandler.d
├── exceptions
│ ├── domexception.d
│ ├── enforceexception.d
│ ├── filesecurityexception.d
│ ├── htmlexception.d
│ ├── package.d
│ ├── routeexception.d
│ ├── sensitivedataexception.d
│ ├── soapexception.d
│ ├── viewexception.d
│ ├── xhtmlexception.d
│ └── xmlexception.d
└── package.d
├── extensions
├── extensionemitinfo.d
├── extensionemitter.d
├── extensionmanager.d
├── extensiontype.d
└── package.d
├── html
├── htmldocument.d
├── htmlexception.d
├── htmlnode.d
├── htmlparsersettings.d
└── package.d
├── http
├── client.d
├── cookies.d
├── method.d
├── package.d
├── privacy.d
├── remote.d
├── routing.d
├── sessions.d
├── status.d
└── websockets.d
├── io
├── file.d
├── package.d
└── path.d
├── mail
├── package.d
└── smtp.d
├── markdown
├── package.d
├── parser.d
├── part.d
└── type.d
├── package.json
├── security
├── backup
│ ├── backuppath.d
│ ├── backupservice.d
│ ├── filebackup.d
│ └── package.d
├── csrf.d
├── html.d
├── network.d
├── package.d
├── tokens
│ ├── generictoken.d
│ ├── package.d
│ ├── sessiontoken.d
│ └── tokengenerator.d
└── validation
│ ├── creditcard.d
│ ├── email.d
│ ├── file.d
│ ├── package.d
│ ├── sensitive.d
│ ├── types.d
│ └── url.d
├── seo
├── package.d
└── schema
│ ├── package.d
│ ├── schemaobject.d
│ └── structures
│ ├── contactpoint.d
│ ├── event.d
│ ├── events
│ ├── businessevent.d
│ ├── childrensevent.d
│ ├── comedyevent.d
│ ├── courseinstance.d
│ ├── danceevent.d
│ ├── deliveryevent.d
│ ├── educationevent.d
│ ├── exhibitionevent.d
│ ├── festival.d
│ ├── foodevent.d
│ ├── literaryevent.d
│ ├── musicevent.d
│ ├── package.d
│ ├── publicationevent.d
│ ├── saleevent.d
│ ├── screeningevent.d
│ ├── socialevent.d
│ ├── sportsevent.d
│ ├── theaterevent.d
│ └── visualartsevent.d
│ ├── offer.d
│ ├── organization.d
│ ├── organizations
│ ├── airline.d
│ ├── corporation.d
│ ├── educationalorganization.d
│ ├── governmentorganization.d
│ ├── localbusiness.d
│ ├── localbusinesses
│ │ ├── animalshelter.d
│ │ ├── automotivebusiness.d
│ │ ├── childcare.d
│ │ ├── dentist.d
│ │ ├── drycleaningorlaundry.d
│ │ ├── emergencyservice.d
│ │ ├── employmentagency.d
│ │ ├── entertainmentbusiness.d
│ │ ├── financialservice.d
│ │ ├── foodestablishment.d
│ │ ├── governmentoffice.d
│ │ ├── healthandbeautybusiness.d
│ │ ├── homeandconstructionbusiness.d
│ │ ├── internetcafe.d
│ │ ├── legalservice.d
│ │ ├── library.d
│ │ ├── lodgingbusiness.d
│ │ ├── package.d
│ │ ├── professionalservice.d
│ │ ├── radiostation.d
│ │ ├── realestateagent.d
│ │ ├── recyclingcenter.d
│ │ ├── selfstorage.d
│ │ ├── shoppingcenter.d
│ │ ├── sportsactivitylocation.d
│ │ ├── store.d
│ │ ├── televisionstation.d
│ │ ├── touristinformationcenter.d
│ │ └── travelagency.d
│ ├── medicalorganization.d
│ ├── ngo.d
│ ├── package.d
│ ├── performinggroup.d
│ └── sportsorganization.d
│ ├── package.d
│ ├── person.d
│ ├── place.d
│ ├── postaladdress.d
│ ├── product.d
│ └── products
│ ├── individualproduct.d
│ ├── package.d
│ ├── productmodel.d
│ ├── someproducts.d
│ └── vehicle.d
├── tasks
├── core.d
├── delayedtasks.d
├── package.d
└── scheduler.d
├── templates
├── characterincludemode.d
├── contentmode.d
├── grammar.d
├── package.d
├── parser.d
└── part.d
├── unittesting
├── attributes.d
├── initialization.d
├── package.d
└── request.d
├── views
├── package.d
├── view.d
├── viewcache.d
├── viewformats.d
├── viewgenerator.d
├── viewparser.d
└── viewroute.d
├── web
├── elements
│ ├── block.d
│ ├── button.d
│ ├── checkbox.d
│ ├── date.d
│ ├── element.d
│ ├── email.d
│ ├── file.d
│ ├── form.d
│ ├── hidden.d
│ ├── image.d
│ ├── input.d
│ ├── link.d
│ ├── numeric.d
│ ├── package.d
│ ├── paragraph.d
│ ├── password.d
│ ├── radio.d
│ ├── select.d
│ ├── submit.d
│ ├── text.d
│ └── textarea.d
├── file
│ ├── download.d
│ ├── package.d
│ └── upload.d
├── package.d
└── soap
│ ├── client
│ ├── client.d
│ ├── envelope.d
│ ├── envelopebody.d
│ ├── envelopeparameter.d
│ ├── package.d
│ └── soapclient.d
│ ├── package.d
│ ├── server
│ └── package.d
│ └── service
│ ├── aliastype.d
│ ├── attributes.d
│ ├── binding.d
│ ├── complextype.d
│ ├── datatypes.d
│ ├── element.d
│ ├── envelopetype.d
│ ├── loader.d
│ ├── message.d
│ ├── messageoperation.d
│ ├── package.d
│ ├── parameter.d
│ ├── parser
│ ├── bindingparser.d
│ ├── messageparser.d
│ ├── package.d
│ ├── porttypeparser.d
│ ├── serviceparser.d
│ ├── typeparser.d
│ └── wsdlparser.d
│ ├── simpletype.d
│ └── soaptype.d
├── xhtml
├── package.d
├── xhtmldocument.d
├── xhtmlexception.d
├── xhtmlnode.d
└── xhtmlparsersettings.d
└── xml
├── package.d
├── xmldocument.d
├── xmlexception.d
├── xmlnode.d
└── xmlparsersettings.d
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 |
5 | ---
6 |
7 | **Describe the bug**
8 | A clear and concise description of what the bug is.
9 |
10 | **To Reproduce**
11 | Steps to reproduce the behavior:
12 | 1. Step 1
13 | 2. Step 2
14 | 3. Step 3
15 | 4. ...
16 | 5. See error
17 |
18 | **Expected behavior**
19 | A clear and concise description of what you expected to happen.
20 |
21 | **Screenshots**
22 | If applicable, add screenshots to help explain your problem.
23 |
24 | **Platform (please complete the following information):**
25 | - Environment: [e.g. Azure, AWS, Heroku, Self-hosting, Nginx]
26 | - OS: [e.g. Linux]
27 | - Arch [e.g. x86, x64]
28 | - Diamond Version [e.g. 2.10.1]
29 |
30 | **Additional context**
31 | Add any other context about the problem here.
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 |
5 | ---
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9 |
10 | **Describe the solution you'd like**
11 | A clear and concise description of what you want to happen.
12 |
13 | **Describe alternatives you've considered**
14 | A clear and concise description of any alternative solutions or features you've considered.
15 |
16 | **Additional context**
17 | Add any other context or screenshots about the feature request here.
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 - 2018 DiamondMVC
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/api.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.app.api;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWebApi)
11 | {
12 | import diamond.http;
13 |
14 | /**
15 | * The handler for a webapi request.
16 | * Params:
17 | * client = The client.
18 | */
19 | void handleWebApi(HttpClient client)
20 | {
21 | import diamond.app.web : getControllerAction;
22 |
23 | auto controllerAction = getControllerAction(client.route.name);
24 |
25 | if (!controllerAction)
26 | {
27 | client.notFound();
28 | }
29 |
30 | import diamond.controllers.status;
31 |
32 | auto status = controllerAction(client).handle();
33 |
34 | if (status == Status.notFound)
35 | {
36 | client.notFound();
37 | }
38 | else if (status != Status.end)
39 | {
40 | import diamond.core.webconfig;
41 |
42 | foreach (headerKey,headerValue; webConfig.defaultHeaders.general)
43 | {
44 | client.rawResponse.headers[headerKey] = headerValue;
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/diamondapp.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamondapp;
7 |
8 | import diamond.core : isWeb;
9 |
10 | public import diamond.app.web;
11 |
12 | // static if (isWeb)
13 | // {
14 | //
15 | // }
16 | // else
17 | // {
18 | // import diamond.views;
19 | //
20 | // mixin GenerateViews;
21 | //
22 | // static foreach (viewResult; generateViewsResult)
23 | // {
24 | // mixin("#line 1 \"view: " ~ viewResult.name ~ "\"\n" ~ viewResult.source);
25 | // }
26 | //
27 | // mixin GenerateGetView;
28 | //
29 | // /// Shared static constructor for stand-alone applications.
30 | // shared static this()
31 | // {
32 | // // ...
33 | // }
34 | // }
35 |
--------------------------------------------------------------------------------
/app/files.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.app.files;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import vibe.d : HTTPServerRequestDelegateS;
13 |
14 | import diamond.http;
15 |
16 | /**
17 | * The handler for static file requests.
18 | * Params:
19 | * client = The client.
20 | * staticFile = The static file handler.
21 | */
22 | package(diamond.app) void handleStaticFiles
23 | (
24 | HttpClient client,
25 | HTTPServerRequestDelegateS staticFile
26 | )
27 | {
28 | import diamond.authentication;
29 |
30 | if (hasRoles && !hasAccess(client.role, client.method, client.route.toString()))
31 | {
32 | client.error(HttpStatus.unauthorized);
33 | }
34 |
35 | import diamond.extensions;
36 | mixin ExtensionEmit!(ExtensionType.staticFileExtension, q{
37 | if (!{{extensionEntry}}.handleStaticFile(client))
38 | {
39 | return;
40 | }
41 | });
42 | emitExtension();
43 |
44 | import diamond.core.webconfig;
45 |
46 | foreach (headerKey,headerValue; webConfig.defaultHeaders.staticFiles)
47 | {
48 | client.rawResponse.headers[headerKey] = headerValue;
49 | }
50 |
51 | import std.array : split, join;
52 |
53 | version (VIBE_D_OLD)
54 | {
55 | client.path = "/" ~ client.path.split("/")[2 .. $].join("/");
56 | }
57 | else
58 | {
59 | client.path = "/" ~ client.path.split("/")[1 .. $].join("/");
60 | }
61 |
62 | import diamond.core.websettings;
63 |
64 | if (webSettings)
65 | {
66 | webSettings.onStaticFile(client);
67 | }
68 |
69 | staticFile(client.rawRequest, client.rawResponse);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/authentication/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.authentication;
7 |
8 | public
9 | {
10 | import diamond.authentication.roles;
11 | import diamond.authentication.permissions;
12 | import diamond.authentication.auth;
13 | }
14 |
--------------------------------------------------------------------------------
/controllers/authentication.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.controllers.authentication;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.http;
13 |
14 | /// Wrapper for an authentication status.
15 | final class AuthStatus
16 | {
17 | private:
18 | /// The client.
19 | HttpClient _client;
20 |
21 | /// Boolean determining whether the authentication was successful or not.
22 | bool _authenticated;
23 |
24 | /// The message of the authentication.
25 | string _message;
26 |
27 | public:
28 | /**
29 | * Creates a new authentcation status.
30 | * Params:
31 | * client = The client that was authenticated.
32 | * authenticated = Boolean determining whehter the authentication was successful or not.
33 | * message = (optional) The message of the authentication status.
34 | */
35 | this(HttpClient client, bool authenticated, string message = null)
36 | {
37 | _client = client;
38 | _authenticated = authenticated;
39 | _message = message;
40 | }
41 |
42 | @property
43 | {
44 | /// Gets the client that was authenticated.
45 | HttpClient client() { return _client; }
46 |
47 | /// Gets a boolean determining whether the authentication was successful or not.
48 | bool authenticated() { return _authenticated; }
49 |
50 | /// Gets the message of the authentication status.
51 | string message() { return _message; }
52 | }
53 | }
54 |
55 | /// Interface to implement authentication.
56 | interface IControllerAuth
57 | {
58 | /**
59 | * Function called to validate authentication for a client.
60 | * Params:
61 | * client = The client to validate for authentication.
62 | * Returns:
63 | * True if the client is authenticated.
64 | */
65 | AuthStatus isAuthenticated(HttpClient client);
66 |
67 | /**
68 | * Function called when authentication fails.
69 | * Params:
70 | * status = The status of the failed authentication.
71 | */
72 | void authenticationFailed(AuthStatus status);
73 | }
74 |
75 | // TODO: Implement basic auth + digest auth wrappers.
76 | }
77 |
--------------------------------------------------------------------------------
/controllers/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.controllers;
7 |
8 | public
9 | {
10 | import diamond.controllers.action;
11 | import diamond.controllers.status;
12 | import diamond.controllers.basecontroller;
13 | import diamond.controllers.controller;
14 | import diamond.controllers.attributes;
15 | import diamond.controllers.authentication;
16 | import diamond.controllers.rest;
17 | }
18 |
--------------------------------------------------------------------------------
/controllers/rest/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.controllers.rest;
7 |
8 | public
9 | {
10 | import diamond.controllers.rest.parser;
11 | import diamond.controllers.rest.routedatatype;
12 | import diamond.controllers.rest.routepart;
13 | import diamond.controllers.rest.routetype;
14 | }
15 |
--------------------------------------------------------------------------------
/controllers/rest/routedatatype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.controllers.rest.routedatatype;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | package (diamond.controllers):
13 |
14 | /// Enumeration of route data types.
15 | enum RouteDataType : string
16 | {
17 | /// A signed 8 bit integer.
18 | int8 = "byte",
19 |
20 | /// A signed 16 bit integer.
21 | int16 = "short",
22 |
23 | /// A signed 32 bit integer.
24 | int32 = "int",
25 |
26 | /// A signed 64 bit integer.
27 | int64 = "long",
28 |
29 | /// An unsigned 8 bit integer.
30 | uint8 = "ubyte",
31 |
32 | /// An unsigned 16 bit integer.
33 | uint16 = "ushort",
34 |
35 | /// An unsigned 32 bit integer.
36 | uint32 = "uint",
37 |
38 | /// An unsigned 64 bit integer.
39 | uint64 = "ulong",
40 |
41 | /// A string.
42 | stringType = "string",
43 |
44 | /// A boolean.
45 | boolean = "bool"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/controllers/rest/routepart.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.controllers.rest.routepart;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.controllers.rest.routetype;
13 | import diamond.controllers.rest.routedatatype;
14 |
15 | package (diamond.controllers):
16 |
17 | /// A route part.
18 | final class RoutePart
19 | {
20 | package(diamond.controllers.rest)
21 | {
22 | /// The route type.
23 | RouteType _routeType;
24 |
25 | /// The identifier.
26 | string _identifier;
27 |
28 | /// The type.
29 | RouteDataType _type;
30 |
31 | /// Creates a new route part.
32 | final this() { }
33 |
34 | @property
35 | {
36 | /// Sets the route type.
37 | final void routeType(RouteType newRouteType)
38 | {
39 | _routeType = newRouteType;
40 | }
41 |
42 | /// Sets the identifier.
43 | final void identifier(string newIdentifier)
44 | {
45 | _identifier = newIdentifier;
46 | }
47 |
48 | /// Sets the type.
49 | final void type(RouteDataType newType)
50 | {
51 | _type = newType;
52 | }
53 | }
54 | }
55 |
56 | final:
57 | @property
58 | {
59 | /// Gets the route type.
60 | RouteType routeType() { return _routeType; }
61 |
62 | /// Gets the identifier.
63 | string identifier() { return _identifier; }
64 |
65 | /// Gets the type.
66 | RouteDataType type() { return _type; }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/controllers/rest/routetype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.controllers.rest.routetype;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | package (diamond.controllers):
13 |
14 | /// Enumeration of route types.
15 | enum RouteType
16 | {
17 | /// An action identifier.
18 | action,
19 |
20 | /// An identifier.
21 | identifier,
22 |
23 | /// A type.
24 | type,
25 |
26 | /// A type identifier.
27 | typeIdentifier,
28 |
29 | /// A wildcard.
30 | wildcard
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/controllers/status.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.controllers.status;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | /// Enumeration of controller statuses.
13 | enum Status
14 | {
15 | /// Indicates the controller action was executed successfully.
16 | success,
17 | /// Indicates the controller action wasn't found.
18 | notFound,
19 | /**
20 | * Indicates the response should end after executing the actions.
21 | * This is useful if you're redirecting or responding with a different type of data than html such as json etc.
22 | */
23 | end,
24 | /// indicates the user isn't authorized for the action.
25 | unauthorized
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/core/collections.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.core.collections;
7 |
8 | /// A simple hash set implementation using the build-in AA.
9 | final class HashSet(T)
10 | {
11 | private:
12 | /// The build-in AA.
13 | ubyte[T] _set;
14 |
15 | public:
16 | final:
17 | /// Creates a new hash set.
18 | this() { }
19 |
20 | /**
21 | * Creates a new hash set from a sequence of elements.
22 | */
23 | this(T[] elements)
24 | {
25 | if (elements && elements.length)
26 | {
27 | foreach (element; elements)
28 | {
29 | _set[element] = 0;
30 | }
31 | }
32 | }
33 |
34 | /**
35 | * Adds a value to the hash set.
36 | * Params:
37 | * value = The value added to the hash set.
38 | */
39 | void add(T value)
40 | {
41 | _set[value] = 0;
42 | }
43 |
44 | /**
45 | * Checks whether the hash set contains the given value.
46 | * Params:
47 | * value = The value to check for existence within the set.
48 | * Returns:
49 | * True if the set contains the given value.
50 | */
51 | bool has(T value)
52 | {
53 | if (!_set)
54 | {
55 | return false;
56 | }
57 |
58 | if (value in _set)
59 | {
60 | return true;
61 | }
62 |
63 | return false;
64 | }
65 |
66 | /**
67 | * Operator overload for accessing the set like an array.
68 | * This calls "bool has(T value);"
69 | */
70 | bool opIndex(T value)
71 | {
72 | return has(value);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/core/debugging.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.core.debugging;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (debugging)
11 | {
12 | public import diamond.core.io;
13 |
14 | /// A stack logger wrapper.
15 | class StackLogger
16 | {
17 | private:
18 | /// The call stack of the logger.
19 | string[] _callStack;
20 |
21 | /// Creates a new stack logger.
22 | this() {}
23 |
24 | public:
25 | /// Gets the current callstack.
26 | @property const(string[]) callStack() { return _callStack; }
27 |
28 | /// Logs the current call.
29 | void log(in string file = __FILE__, in size_t line = __LINE__, in string mod = __MODULE__, in string func = __PRETTY_FUNCTION__)
30 | {
31 | import std.string : format;
32 |
33 | _callStack ~= format("file: '%s' line: '%s' module: '%s' function: '%s'", file, line, mod, func);
34 | }
35 |
36 | /// Clears the call stack.
37 | void clear()
38 | {
39 | _callStack = null;
40 | }
41 |
42 | /// Prints the call stack.
43 | void printCallStack()
44 | {
45 | print(_callStack);
46 | }
47 | }
48 |
49 | /// The thread-local stack logger.
50 | private StackLogger _stackLogger;
51 |
52 | /// Gets the stack logger for the current thread.
53 | @property StackLogger stackLogger()
54 | {
55 | if (_stackLogger)
56 | {
57 | return _stackLogger;
58 | }
59 |
60 | _stackLogger = new StackLogger;
61 |
62 | return _stackLogger;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/core/io.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.core.io;
7 |
8 | import stdio = std.stdio : writeln, writefln, readln;
9 |
10 | /// Mixin template to handle files at compile-time.
11 | mixin template handleCTFEFile(string fileName, string fileHandler)
12 | {
13 | /// Function that must be called to handle the file.
14 | void handle()
15 | {
16 | static if (__traits(compiles, { auto s = import(fileName); }))
17 | {
18 | mixin("{
19 | enum __fileResult = import(fileName);
20 | " ~ fileHandler ~
21 | "}");
22 | }
23 | }
24 | }
25 |
26 | /**
27 | * Prints a message to the standard output.
28 | * Params:
29 | * msg = The message to print.
30 | */
31 | void print(string msg)
32 | {
33 | stdio.writeln(msg);
34 | }
35 |
36 | /**
37 | * Prints a formatted message to the standard output.
38 | * Params:
39 | * msg = The message to print.
40 | * args = The arguments to print.
41 | */
42 | void print(Args...)(string msg, Args args)
43 | {
44 | stdio.writefln(msg, args);
45 | }
46 |
47 | /**
48 | * Prints data to the standard output.
49 | * Params:
50 | * data = The data to print.
51 | */
52 | void print(T)(T data)
53 | {
54 | print("Data: %s", data);
55 | }
56 |
57 | void wait()
58 | {
59 | readInput();
60 | }
61 |
62 | auto readInput()
63 | {
64 | return stdio.readln();
65 | }
66 |
--------------------------------------------------------------------------------
/core/meta.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.core.meta;
7 |
8 | /// A string equivalent to the current version of Diamond.
9 | static const diamondVersion = "3.0.0";
10 |
--------------------------------------------------------------------------------
/core/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.core;
7 |
8 | public
9 | {
10 | import diamond.core.apptype;
11 | import diamond.core.webconfig;
12 | import diamond.core.debugging;
13 | import diamond.core.io;
14 | import diamond.core.websettings;
15 | import diamond.core.collections;
16 | import diamond.core.senc;
17 | import diamond.core.string;
18 | import diamond.core.traits;
19 | import diamond.core.logging;
20 | import diamond.core.webinitialization;
21 | import diamond.core.cache;
22 | import diamond.core.meta;
23 | import diamond.core.filterservice;
24 | }
25 |
--------------------------------------------------------------------------------
/core/string.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.core.string;
7 |
8 | import std.traits : isSomeString;
9 |
10 | /**
11 | * Converts the first character of a string to lowercase.
12 | * Params:
13 | * s = The string to lowercase the first character.
14 | * Returns:
15 | * Returns a new string with the first character lowercased. The string is returned unmodified if its null or empty.
16 | */
17 | TString firstToLower(TString)(TString s)
18 | if (isSomeString!TString)
19 | {
20 | import std.string : toLower;
21 | import std.conv : to;
22 |
23 | if (!s || !s.length)
24 | {
25 | return s;
26 | }
27 |
28 | if (s.length == 1)
29 | {
30 | return s.toLower();
31 | }
32 |
33 | return to!string(s[0]).toLower() ~ s[1 .. $];
34 | }
35 |
36 | /**
37 | * Converts the first character of a string to uppercase.
38 | * Params:
39 | * s = The string to uppercase the first character.
40 | * Returns:
41 | * Returns a new string with the first character uppercased. The string is returned unmodified if its null or empty.
42 | */
43 | TString firstToUpper(TString)(TString s)
44 | if (isSomeString!TString)
45 | {
46 | import std.string : toUpper;
47 | import std.conv : to;
48 |
49 | if (!s || !s.length)
50 | {
51 | return s;
52 | }
53 |
54 | if (s.length == 1)
55 | {
56 | return s.toUpper();
57 | }
58 |
59 | return to!string(s[0]).toUpper() ~ s[1 .. $];
60 | }
61 |
62 | /**
63 | * Splits a string input into grouped words.
64 | * Params:
65 | * input = The input to split into grouped words.
66 | * Returns:
67 | * The string split into grouped words.
68 | */
69 | string[] splitIntoGroupedWords(string input)
70 | {
71 | import std.array : split;
72 |
73 | auto inputs = input.split(" ");
74 | string[] words = [];
75 |
76 | foreach (i; 0 .. inputs.length)
77 | {
78 | string current = inputs[i];
79 | string next1 = i < (inputs.length - 1) ? (" " ~ inputs[i + 1]) : null;
80 | string next2 = i < (inputs.length - 2) ? (" " ~ inputs[i + 2]) : null;
81 |
82 | words ~= current;
83 |
84 | if (next1)
85 | {
86 | words ~= current ~ next1;
87 | }
88 |
89 | if (next2)
90 | {
91 | words ~= current ~ next1 ~ next2;
92 | }
93 | }
94 |
95 | return words;
96 | }
97 |
--------------------------------------------------------------------------------
/core/traits.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.core.traits;
7 |
8 | /// Creates a string to use with mixin that is an exact copy members of an enum
9 | string createEnumAlias(T)(string name)
10 | {
11 | import std.traits : EnumMembers, OriginalType;
12 | import std.conv : to;
13 | import std.string : format;
14 | import std.array : array, join;
15 | import std.algorithm : map;
16 | import std.meta : NoDuplicates;
17 |
18 | return format("enum %s : %s { ", name, (OriginalType!T).stringof) ~ [NoDuplicates!(EnumMembers!T)]
19 | .map!
20 | (
21 | (member)
22 | {
23 | return format("%s = %s", to!string(member), cast(OriginalType!T)member);
24 | }
25 | )
26 | .array.join(",") ~ " }";
27 | }
28 |
29 | /// Mixin template to handle fields of a type.
30 | mixin template HandleFields(T, string handler)
31 | {
32 | string handleThem()
33 | {
34 | mixin HandleField!(T, [FieldNameTuple!T], handler);
35 |
36 | return handle();
37 | }
38 | }
39 |
40 | /// Mixin template to handle a specific field of a fieldname collection.
41 | mixin template HandleField
42 | (
43 | T,
44 | string[] fieldNames,
45 | string handler
46 | )
47 | {
48 | import std.array : replace;
49 |
50 | string handle()
51 | {
52 | string s = "";
53 |
54 | foreach (fieldName; fieldNames)
55 | {
56 | s ~= "{" ~
57 | handler
58 | .replace("{{fieldName}}", fieldName)
59 | .replace("{{fullName}}", T.stringof ~ "." ~ fieldName)
60 | ~ "}";
61 | }
62 |
63 | return s;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/css/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.css;
7 |
8 | public
9 | {
10 | import diamond.css.css3selector;
11 | }
12 |
--------------------------------------------------------------------------------
/data/i18n/messages.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.data.i18n.messages;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.http;
13 |
14 | /// Alias for an associative array.
15 | private alias Language = string[string];
16 |
17 | /// A collection of localization messages.
18 | private __gshared Language[string] _messages;
19 |
20 | /// The default language.
21 | package(diamond) __gshared string _defaultLanguage;
22 |
23 | /**
24 | * Sets the default language of the application.
25 | * Params:
26 | * language = The language.
27 | */
28 | void setDefaultLanguage(string language)
29 | {
30 | _defaultLanguage = language;
31 | }
32 |
33 | /**
34 | * Gets a message.
35 | * Params:
36 | * clent = The client to use the language of.
37 | * key = The key of the message to retrieve.
38 | * Returns:
39 | * The message if found for the client's language, otherwise it will attempt to get the default language's message and if that fails too then it returns an empty string.
40 | */
41 | string getMessage(HttpClient client, string key)
42 | {
43 | return getMessage(client.language, key);
44 | }
45 |
46 | /**
47 | * Gets a message.
48 | * Params:
49 | * languageName = The language to retrieve a message from.
50 | * key = The key of the message to retrieve.
51 | * Returns:
52 | * The message if found for the specified language, otherwise it will attempt to get the default language's message and if that fails too then it returns an empty string.
53 | */
54 | string getMessage(string languageName, string key)
55 | {
56 | auto language = _messages.get(languageName, null);
57 |
58 | if (!language)
59 | {
60 | language = _messages.get(_defaultLanguage, null);
61 | }
62 |
63 | if (!language)
64 | {
65 | return "";
66 | }
67 |
68 | return language.get(key, "");
69 | }
70 |
71 | /**
72 | * Adds a message to a specific language.
73 | * Params:
74 | * language = The language to add the message to.
75 | * key = The key of the message.
76 | * message = The message to add.
77 | */
78 | void addMessage(string language, string key, string message)
79 | {
80 | _messages[language][key] = message;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/data/i18n/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.data.i18n;
7 |
8 | public
9 | {
10 | import diamond.data.i18n.messages;
11 | import diamond.data.i18n.loader;
12 | }
13 |
--------------------------------------------------------------------------------
/data/mapping/attributes.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.data.mapping.attributes;
7 |
8 | /// Attribute for excluding fields.
9 | struct DbNoMap { }
10 |
11 | /// Attribute for marking fields as nullable.
12 | struct DbNull { }
13 |
14 | /// Attribute for marking fields as db-enums.
15 | struct DbEnum { }
16 |
17 | /// Attribute for ids.
18 | struct DbId { }
19 |
20 | /// Attribute for timestamps.
21 | struct DbTimestamp { }
22 |
23 | // Attribute to mark data as personal. Use this to easily integrate with GDPR.
24 | struct DbPersonal { }
25 |
26 | /// Attribute for relationships.
27 | struct DbRelationship
28 | {
29 | /// A custom sql to retrieve the relationship data.
30 | string sql;
31 | /// An associative array of members to match when generating the sql to retrieve the relationship data.
32 | string[string] members;
33 |
34 | /// Disables the default ctor for the struct.
35 | @disable this();
36 |
37 | /**
38 | * Creates a db relationship with a custom sql query.
39 | * Params:
40 | * sql = The sql query.
41 | */
42 | this(string sql)
43 | {
44 | this.sql = sql;
45 | this.members = null;
46 | }
47 |
48 | /**
49 | * Creates a db relationship with an array of members to use for the query generation.
50 | * Params:
51 | * members = The members.
52 | */
53 | this(string[string] members)
54 | {
55 | this.sql = null;
56 | this.members = members;
57 | }
58 | }
59 |
60 | /// Attribute for custom data-type handling.
61 | struct DbProxy
62 | {
63 | /// The name of the custom read handler.
64 | string readHandler;
65 | /// The name of the custom write handler.
66 | string writeHandler;
67 | }
68 |
--------------------------------------------------------------------------------
/data/mapping/engines/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.data.mapping.engines;
7 |
8 | public
9 | {
10 | import diamond.data.mapping.engines.sqlshared;
11 | import diamond.data.mapping.engines.mysql;
12 | import diamond.data.mapping.engines.mssql;
13 | }
14 |
--------------------------------------------------------------------------------
/data/mapping/engines/sqlshared/sqlentityformatter.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.data.mapping.engines.sqlshared.sqlentityformatter;
7 |
8 | /// Wrapper around a mysql entity formatter.
9 | abstract class SqlEntityFormatter(TModel)
10 | {
11 | protected:
12 | /// Creates a new sql entity formatter.
13 | this()
14 | {
15 |
16 | }
17 |
18 | public:
19 | /// Generates the read mixin.
20 | abstract string generateRead();
21 |
22 | /// Generates the insert mixin.
23 | abstract string generateInsert();
24 |
25 | /// Generates the update mixin.
26 | abstract string generateUpdate();
27 |
28 | /// Generates the delete mixin.
29 | abstract string generateDelete();
30 |
31 | /// Generates the read relationship mixin.
32 | abstract string generateReadRelationship();
33 | }
34 |
--------------------------------------------------------------------------------
/data/mapping/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.data.mapping;
7 |
8 | public
9 | {
10 | import diamond.data.mapping.attributes;
11 | import diamond.data.mapping.model;
12 | import MySql = diamond.data.mapping.engines.mysql;
13 | import MsSql = diamond.data.mapping.engines.mssql;
14 | }
15 |
--------------------------------------------------------------------------------
/data/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.data;
7 |
8 | public
9 | {
10 | import diamond.data.snapshot;
11 | import diamond.data.transaction;
12 | import diamond.data.mapping;
13 | import diamond.data.i18n;
14 | }
15 |
--------------------------------------------------------------------------------
/database/mongo/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.database.mongo;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import vibe.db.mongo.mongo;
13 | import vibe.db.mongo.client;
14 |
15 | /// The mongo db client.
16 | private static __gshared MongoClient _client;
17 |
18 | public
19 | {
20 | import MongoDb = diamond.database.mongo.operations;
21 | }
22 |
23 | package(diamond)
24 | {
25 | /**
26 | * Initializes the mongo db connection.
27 | * Params:
28 | * host = The host of the mongo db.
29 | * port = The port of the mongo db host. Only specify this the host is an ip address.
30 | */
31 | void initializeMongo(string host, ushort port = 0)
32 | {
33 | if (port)
34 | {
35 | _client = connectMongoDB(host, port);
36 | }
37 | else
38 | {
39 | _client = connectMongoDB(host);
40 | }
41 | }
42 |
43 | /// Gets the raw vibe.d mongo client.
44 | @property MongoClient client()
45 | {
46 | return _client;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/database/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.database;
7 |
8 | import std.variant : Variant;
9 |
10 | import diamond.core.apptype;
11 |
12 | public
13 | {
14 | import std.datetime : Date, DateTime, Clock, SysTime;
15 |
16 | import diamond.data.mapping.attributes;
17 |
18 | import diamond.data.mapping.engines.mysql;
19 | import MySql = diamond.data.mapping.engines.mysql;
20 |
21 | static if (hasMsSql)
22 | {
23 | import diamond.data.mapping.engines.mssql;
24 | import MsSql = diamond.data.mapping.engines.mssql;
25 | }
26 |
27 | /// A variant db parameter type.
28 | alias DbParam = Variant;
29 |
30 | /// A variant db value type.
31 | alias DbValue = Variant;
32 |
33 | import diamond.database.mongo;
34 | }
35 |
36 | /// Gets an associative array to use for specialized parameters.
37 | auto getParams()
38 | {
39 | DbParam[string] params;
40 |
41 | return params;
42 | }
43 |
44 | /// Gets a static-sized array to use for raw sql statements.
45 | auto getParams(size_t count)
46 | {
47 | return new DbParam[count];
48 | }
49 |
--------------------------------------------------------------------------------
/dom/domattribute.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.dom.domattribute;
7 |
8 | import std.string : strip, toLower;
9 |
10 | import diamond.errors.checks;
11 |
12 | /// A dom attribute.
13 | final class DomAttribute
14 | {
15 | private:
16 | /// The name of the attribute.
17 | string _name;
18 | /// The value of the attribute.
19 | string _value;
20 |
21 | public:
22 | /**
23 | * Creates a new dom attribute.
24 | * Params:
25 | * name = The name.
26 | * value = The value.
27 | */
28 | this(string name, string value) @safe
29 | {
30 | enforce(name !is null, "The name cannot be null.");
31 |
32 | _name = name.strip().toLower();
33 | _value = value ? value.strip() : null;
34 | }
35 |
36 | @property
37 | {
38 | /// Gets the name of the attribute.
39 | string name() @safe { return _name; }
40 |
41 | /// Sets the name of the attribute.
42 | void name(string newName) @safe
43 | {
44 | enforce(name !is null, "The name cannot be null.");
45 |
46 | _name = newName.strip().toLower();
47 | }
48 |
49 | /// Gets the value of the attribute.
50 | string value() @safe { return _value; }
51 |
52 | /// Sets the value of the attribute.
53 | void value(string newValue) @safe
54 | {
55 | _value = newValue ? newValue.strip() : null;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/dom/domdocument.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.dom.domdocument;
7 |
8 | import diamond.dom.domnode;
9 | import diamond.dom.domparsersettings;
10 |
11 | /// A dom document.
12 | abstract class DomDocument
13 | {
14 | private:
15 | /// The settings used for parsing the document.
16 | DomParserSettings _parserSettings;
17 |
18 | protected:
19 | /**
20 | * Creates a new dom document.
21 | * Params:
22 | * parserSettings = The settings used for parsing the document.
23 | */
24 | this(DomParserSettings parserSettings) @safe
25 | {
26 | import diamond.errors.checks;
27 |
28 | enforce(parserSettings !is null, "The parser settings cannot be null.");
29 |
30 | _parserSettings = parserSettings;
31 | }
32 |
33 | public:
34 | /**
35 | * Parses the elements from the dom to the document.
36 | * Params:
37 | * elements = The parsed dom elements.
38 | */
39 | abstract void parseElements(DomNode[] elements) @safe;
40 |
41 | /// Repairs the document if possible.
42 | abstract void repairDocument() @safe;
43 |
44 | final:
45 | @property
46 | {
47 | /// Gets the settings used for parsing the document.
48 | DomParserSettings parserSettings() @safe { return _parserSettings; }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/dom/domexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.dom.domexception;
7 |
8 | public import diamond.errors.exceptions.domexception;
9 |
--------------------------------------------------------------------------------
/dom/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.dom;
7 |
8 | public
9 | {
10 | import diamond.dom.domdocument;
11 | import diamond.dom.domnode;
12 | import diamond.dom.domattribute;
13 | import diamond.dom.domexception;
14 | import diamond.dom.domparser;
15 | import diamond.dom.domparsersettings;
16 | }
17 |
--------------------------------------------------------------------------------
/errors/checks.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.checks;
7 |
8 | import diamond.errors.exceptions : EnforceException;
9 |
10 | /**
11 | * Enforces the value of an input to be defined.
12 | * Params:
13 | * value = The value of an input.
14 | * message = A given message when the value is undefined.
15 | * Returns:
16 | * The value of the input.
17 | */
18 | T enforceInput(T)(T value, lazy string message = null) @trusted
19 | if (is(typeof({ if (!value) {} })))
20 | {
21 | if (!value)
22 | {
23 | throw new EnforceException(message ? message : "Enforcement failed.");
24 | }
25 |
26 | return value;
27 | }
28 |
29 | /**
30 | * Enforces a value to be defined.
31 | * Params:
32 | * value = The value.
33 | * message = A given message when the value is undefined.
34 | */
35 | void enforce(T)(T value, lazy string message = null) @trusted
36 | if (is(typeof({ if (!value) {} })))
37 | {
38 | if (!value)
39 | {
40 | throw new EnforceException(message ? message : "Enforcement failed.");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/errors/exceptions/domexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.domexception;
7 |
8 | final class DomException : Exception
9 | {
10 | public:
11 | /**
12 | * Creates a new dom exception.
13 | * Params:
14 | * message = The message.
15 | * fn = The file.
16 | * ln = The line.
17 | */
18 | this(string message, string fn = __FILE__, size_t ln = __LINE__) @safe
19 | {
20 | super(message, fn, ln);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/errors/exceptions/enforceexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.enforceexception;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (debugging)
11 | {
12 | /// Error wrapper for enforcements.
13 | final class EnforceError : Error
14 | {
15 | /**
16 | * Creates a new enforcement error.
17 | * Params:
18 | * message = The message of the error.
19 | */
20 | this(string message)
21 | {
22 | super(message);
23 | }
24 | }
25 |
26 | /// Alias to mask throws to the error in debug-mode.
27 | alias EnforceException = EnforceError;
28 | }
29 | else
30 | {
31 | /// Exception wrapper for enforcements.
32 | final class EnforceException : Exception
33 | {
34 | /**
35 | * Creates a new enforcement exception.
36 | * Params:
37 | * message = The message of the exception.
38 | */
39 | this(string message)
40 | {
41 | super(message);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/errors/exceptions/filesecurityexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.filesecurityexception;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | final class FileSecurityException : Exception
13 | {
14 | public:
15 | /**
16 | * Creates a new file security exception.
17 | * Params:
18 | * message = The message.
19 | * fn = The file.
20 | * ln = The line.
21 | */
22 | this(string message, string fn = __FILE__, size_t ln = __LINE__)
23 | {
24 | super(message, fn, ln);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/errors/exceptions/htmlexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.htmlexception;
7 |
8 | final class HtmlException : Exception
9 | {
10 | public:
11 | /**
12 | * Creates a new html exception.
13 | * Params:
14 | * message = The message.
15 | * fn = The file.
16 | * ln = The line.
17 | */
18 | this(string message, string fn = __FILE__, size_t ln = __LINE__) @safe
19 | {
20 | super(message, fn, ln);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/errors/exceptions/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions;
7 |
8 | public
9 | {
10 | import diamond.errors.exceptions.enforceexception;
11 | import diamond.errors.exceptions.viewexception;
12 | import diamond.errors.exceptions.routeexception;
13 | import diamond.errors.exceptions.filesecurityexception;
14 | import diamond.errors.exceptions.sensitivedataexception;
15 | import diamond.errors.exceptions.domexception;
16 | import diamond.errors.exceptions.xmlexception;
17 | import diamond.errors.exceptions.soapexception;
18 | import diamond.errors.exceptions.htmlexception;
19 | }
20 |
--------------------------------------------------------------------------------
/errors/exceptions/routeexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.routeexception;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | final class RouteException : Exception
13 | {
14 | public:
15 | /**
16 | * Creates a new route exception.
17 | * Params:
18 | * message = The message.
19 | * fn = The file.
20 | * ln = The line.
21 | */
22 | this(string message, string fn = __FILE__, size_t ln = __LINE__)
23 | {
24 | super(message, fn, ln);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/errors/exceptions/sensitivedataexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.sensitivedataexception;
7 |
8 | final class SensitiveDataException : Exception
9 | {
10 | public:
11 | /**
12 | * Creates a new sensitive data exception.
13 | * Params:
14 | * message = The message.
15 | * fn = The file.
16 | * ln = The line.
17 | */
18 | this(string message, string fn = __FILE__, size_t ln = __LINE__)
19 | {
20 | super(message, fn, ln);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/errors/exceptions/soapexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.soapexception;
7 |
8 | final class SoapException : Exception
9 | {
10 | public:
11 | /**
12 | * Creates a new soap exception.
13 | * Params:
14 | * message = The message.
15 | * fn = The file.
16 | * ln = The line.
17 | */
18 | this(string message, string fn = __FILE__, size_t ln = __LINE__) @safe
19 | {
20 | super(message, fn, ln);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/errors/exceptions/viewexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.viewexception;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWebServer)
11 | {
12 | /// Exception thrown by a view.
13 | final class ViewException : Exception
14 | {
15 | private:
16 | /// The view name.
17 | string _viewName;
18 |
19 | public:
20 | /**
21 | * Creates a new view exception.
22 | * Params:
23 | * viewName = The name of the view that threw the error.
24 | * throwable = The throwable.
25 | * fn = The file.
26 | * ln = The line.
27 | */
28 | this(string viewName, Throwable throwable, string fn = __FILE__, size_t ln = __LINE__)
29 | {
30 | _viewName = viewName;
31 |
32 | super("...", fn, ln, throwable);
33 | }
34 |
35 | /**
36 | * Retrieves a string equivalent to the exception text.
37 | * Returns:
38 | * A string equivalent to the exception text.
39 | */
40 | override string toString()
41 | {
42 | return "view: " ~ _viewName ~ "\r\n\r\n" ~ super.toString();
43 | }
44 | }
45 |
46 | /// Error thrown by a view.
47 | final class ViewError : Error
48 | {
49 | private:
50 | /// The view name.
51 | string _viewName;
52 |
53 | public:
54 | /**
55 | * Creates a new view error.
56 | * Params:
57 | * viewName = The name of the view that threw the error.
58 | * throwable = The throwable.
59 | * fn = The file.
60 | * ln = The line.
61 | */
62 | this(string viewName, Throwable throwable, string fn = __FILE__, size_t ln = __LINE__)
63 | {
64 | _viewName = viewName;
65 |
66 | super("...", fn, ln, throwable);
67 | }
68 |
69 | /**
70 | * Retrieves a string equivalent to the error text.
71 | * Returns:
72 | * A string equivalent to the error text.
73 | */
74 | override string toString()
75 | {
76 | return "view: " ~ _viewName ~ "\r\n\r\n" ~ super.toString();
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/errors/exceptions/xhtmlexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.xhtmlexception;
7 |
8 | final class XHtmlException : Exception
9 | {
10 | public:
11 | /**
12 | * Creates a new xhtml exception.
13 | * Params:
14 | * message = The message.
15 | * fn = The file.
16 | * ln = The line.
17 | */
18 | this(string message, string fn = __FILE__, size_t ln = __LINE__) @safe
19 | {
20 | super(message, fn, ln);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/errors/exceptions/xmlexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors.exceptions.xmlexception;
7 |
8 | final class XmlException : Exception
9 | {
10 | public:
11 | /**
12 | * Creates a new xml exception.
13 | * Params:
14 | * message = The message.
15 | * fn = The file.
16 | * ln = The line.
17 | */
18 | this(string message, string fn = __FILE__, size_t ln = __LINE__) @safe
19 | {
20 | super(message, fn, ln);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/errors/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.errors;
7 |
8 | public
9 | {
10 | import diamond.errors.exceptions;
11 | import diamond.errors.checks;
12 | import diamond.errors.errorhandler;
13 | }
14 |
--------------------------------------------------------------------------------
/extensions/extensionemitinfo.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.extensions.extensionemitinfo;
7 |
8 | import diamond.extensions.extensiontype;
9 |
10 | /// Wrapper for extension emit information.
11 | final class ExtensionEmitInfo
12 | {
13 | private:
14 | /// The type of the extension.
15 | ExtensionType _type;
16 |
17 | /// The name of the extension.
18 | string _name;
19 |
20 | /// The name of the extension's module.
21 | string _moduleName;
22 |
23 | public:
24 | final:
25 | /**
26 | * Creates a new extension emit info.
27 | * Params:
28 | * type = The type of the extension.
29 | * name = The name of the extension.
30 | * moduleName = The name of the extension's module.
31 | */
32 | this(ExtensionType type, string name, string moduleName)
33 | {
34 | _type = type;
35 | _name = name;
36 | _moduleName = moduleName;
37 | }
38 |
39 | @property
40 | {
41 | /// Gets the type of the extension.
42 | ExtensionType type() { return _type; }
43 |
44 | /// Gets the name of the extension.
45 | string name() { return _name; }
46 |
47 | /// Gets the name of the extension's module.
48 | string moduleName() { return _moduleName; }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/extensions/extensionmanager.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.extensions.extensionmanager;
7 |
8 | import diamond.extensions.extensiontype;
9 | import diamond.extensions.extensionemitinfo;
10 |
11 | /**
12 | * Gets extensions based on an extension type.
13 | * Params:
14 | * extensionType = The type of the extensions to get.
15 | * Returns:
16 | * An array of the extensions emit info.
17 | */
18 | ExtensionEmitInfo[] getExtensions(ExtensionType extensionType)
19 | {
20 | import std.string : strip;
21 | import std.array : replace, split, array;
22 | import std.algorithm : filter;
23 |
24 | import diamond.core.io : handleCTFEFile;
25 |
26 | ExtensionEmitInfo[] extensions;
27 |
28 | mixin handleCTFEFile!("extensions.config", q{
29 | auto lines = __fileResult.replace("\r", "").split("\n");
30 |
31 | foreach (line; lines)
32 | {
33 | if (!line || !line.strip().length)
34 | {
35 | continue;
36 | }
37 |
38 | auto data = line.split("|");
39 |
40 | if (data.length != 3)
41 | {
42 | continue;
43 | }
44 |
45 | extensions ~= new ExtensionEmitInfo(cast(ExtensionType)data[0], data[1], data[2]);
46 | }
47 | });
48 | handle();
49 |
50 | return extensions.filter!(e => e.type == extensionType).array;
51 | }
52 |
--------------------------------------------------------------------------------
/extensions/extensiontype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.extensions.extensiontype;
7 |
8 | /// Enumeration of extension types.
9 | enum ExtensionType
10 | {
11 | /// An extension used to handle application start.
12 | applicationStart = "ApplicationStart",
13 |
14 | /// An extension used to add custom grammars.
15 | customGrammar = "CustomGrammar",
16 |
17 | /// An extension used to parse a view part.
18 | partParser = "PartParser",
19 |
20 | /// An extension used to extend the general view class.
21 | viewExtension = "ViewExtension",
22 |
23 | /// An extension used to extend the general view constructor.
24 | viewCtorExtension = "ViewCtorExtension",
25 |
26 | /// An extension used to extend the general controller class.
27 | controllerExtension = "ControllerExtension",
28 |
29 | /// An extension to handle the http settings of Diamond.
30 | httpSettings = "HttpSettings",
31 |
32 | /// An extension used to handle http requests.
33 | httpRequest = "HttpRequest",
34 |
35 | /// An extension used to handle errors.
36 | handleError = "HandleError",
37 |
38 | /// An extension used to handle static file requests.
39 | staticFileExtension = "StaticFiles"
40 | }
41 |
--------------------------------------------------------------------------------
/extensions/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.extensions;
7 |
8 | public
9 | {
10 | import diamond.extensions.extensiontype;
11 | import diamond.extensions.extensionemitinfo;
12 | import diamond.extensions.extensionmanager;
13 | import diamond.extensions.extensionemitter;
14 | }
15 |
--------------------------------------------------------------------------------
/html/htmlexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.html.htmlexception;
7 |
8 | public import diamond.errors.exceptions.htmlexception;
9 |
--------------------------------------------------------------------------------
/html/htmlnode.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.html.htmlnode;
7 |
8 | import diamond.dom.domnode;
9 |
10 | /// Alias to an html node.
11 | public alias HtmlNode = DomNode;
12 |
--------------------------------------------------------------------------------
/html/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.html;
7 |
8 | public
9 | {
10 | import diamond.html.htmldocument;
11 | import diamond.html.htmlexception;
12 | import diamond.html.htmlnode;
13 | import diamond.html.htmlparsersettings;
14 | }
15 |
--------------------------------------------------------------------------------
/http/method.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.http.method;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import vibe.d : HTTPMethod;
13 |
14 | import diamond.core.traits;
15 |
16 | /// Alias to HTTPMethod.
17 | mixin(createEnumAlias!HTTPMethod("HttpMethod"));
18 |
19 | public
20 | {
21 | /// Alias to be able to type "HttpGet" instead of "HttpMethod.GET"
22 | enum HttpGet = HttpMethod.GET;
23 |
24 | /// Alias to be able to type "HttpPost" instead of "HttpMethod.POST"
25 | enum HttpPost = HttpMethod.POST;
26 |
27 | /// Alias to be able to type "HttpPut" instead of "HttpMethod.PUT"
28 | enum HttpPut = HttpMethod.PUT;
29 |
30 | /// Alias to be able to type "HttpDelete" instead of "HttpMethod.DELETE"
31 | enum HttpDelete = HttpMethod.DELETE;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/http/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.http;
7 |
8 | public
9 | {
10 | import diamond.http.routing;
11 | import diamond.http.method;
12 | import diamond.http.status;
13 | import diamond.http.client;
14 | import diamond.http.cookies;
15 | import diamond.http.sessions;
16 | import diamond.http.websockets;
17 | import diamond.http.remote;
18 | import diamond.http.privacy;
19 | }
20 |
--------------------------------------------------------------------------------
/http/privacy.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.http.privacy;
7 |
8 | /// Wrapper around a privacy collection.
9 | final class PrivacyCollection
10 | {
11 | private:
12 | /// Collection of privacy configurations.
13 | PrivacyConfiguration[string] _configurations;
14 |
15 | final:
16 | /// Creates a new privacy collection.
17 | package(diamond) this() { }
18 |
19 | public:
20 | /**
21 | * Operator overload for accessing privacy configurations.
22 | * Params:
23 | * key = The key of the privacy configuration.
24 | * Returns:
25 | * The privacy configurations tied to the key.
26 | */
27 | PrivacyConfiguration opIndex(string key)
28 | {
29 | auto config = _configurations.get(key, null);
30 |
31 | if (!config)
32 | {
33 | config = new PrivacyConfiguration;
34 |
35 | _configurations[key] = config;
36 | }
37 |
38 | return config;
39 | }
40 | }
41 |
42 | /// Wrapper around privacy configurations.
43 | public final class PrivacyConfiguration
44 | {
45 | private:
46 | /// Creates a new privacy configuration.
47 | this() { }
48 |
49 | public:
50 | /// Boolean determining whether the data is visible to the public.
51 | bool publicVisible;
52 | /// Boolean determining whether the data is visible to associates.
53 | bool associateVisible;
54 | /// Boolean determining whether the data is visible to contacts.
55 | bool contactVisible;
56 | /// Boolean determining whether the data is visible to staff.
57 | bool staffVisible;
58 | /// Boolean determining whehter the data is visible to admins.
59 | bool adminVisible;
60 | }
61 |
--------------------------------------------------------------------------------
/http/remote.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.http.remote;
7 |
8 | import vibe.d : HTTPClientRequest, HTTPClientResponse, requestHTTP, HTTPMethod;
9 |
10 | import diamond.http.method;
11 |
12 | /**
13 | * Creates a remote request.
14 | * Params:
15 | * url = The url of the resource.
16 | * method = The http method of the request.
17 | * responser = Handler for managing the response of the resource.
18 | * requester = Handler for setting up custom request configurations.
19 | */
20 | void remoteRequest
21 | (
22 | string url,
23 | HttpMethod method,
24 | scope void delegate(scope HTTPClientResponse) responder = null,
25 | scope void delegate(scope HTTPClientRequest) requester = null,
26 | )
27 | {
28 | return requestHTTP
29 | (
30 | url,
31 | (scope request)
32 | {
33 | request.method = cast(HTTPMethod)method;
34 |
35 | if (requester !is null)
36 | {
37 | requester(request);
38 | }
39 | },
40 | (scope response)
41 | {
42 | if (responder !is null)
43 | {
44 | responder(response);
45 | }
46 | }
47 | );
48 | }
49 |
50 | /**
51 | * Creates a remote json request.
52 | * Params:
53 | * url = The url of the resource.
54 | * method = The http method of the request.
55 | * responser = Handler for managing the json response.
56 | * requester = Handler for setting up custom request configurations.
57 | */
58 | void remoteJson(T, CTORARGS...)
59 | (
60 | string url,
61 | HttpMethod method,
62 | scope void delegate(T) responder,
63 | scope void delegate(scope HTTPClientRequest) requester,
64 | CTORARGS args
65 | )
66 | {
67 | return fetchRemote
68 | (
69 | url, method,
70 | (scope response)
71 | {
72 | import vibe.data.json;
73 |
74 | static if (is(T == struct))
75 | {
76 | T value;
77 |
78 | value.deserializeJson(json);
79 |
80 | responder(value);
81 | }
82 | else static if (is(T == class))
83 | {
84 | auto value = new T(args);
85 |
86 | value.deserializeJson(json);
87 |
88 | responder(value);
89 | }
90 | else
91 | {
92 | static assert(0);
93 | }
94 | },
95 | requester
96 | );
97 | }
98 |
--------------------------------------------------------------------------------
/http/status.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.http.status;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import vibe.d : HTTPStatus;
13 |
14 | import diamond.core.traits;
15 |
16 | /// Alias to HTTPStatus.
17 | mixin(createEnumAlias!HTTPStatus("HttpStatus"));
18 | }
19 |
--------------------------------------------------------------------------------
/io/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.io;
7 |
8 | public
9 | {
10 | import diamond.core.io;
11 |
12 | import diamond.io.file;
13 | import diamond.io.path;
14 | }
15 |
--------------------------------------------------------------------------------
/io/path.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.io.path;
7 |
8 | public import std.path;
9 |
--------------------------------------------------------------------------------
/mail/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.mail;
7 |
8 | public
9 | {
10 | import diamond.mail.smtp;
11 | }
12 |
--------------------------------------------------------------------------------
/markdown/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.markdown;
7 |
8 | public
9 | {
10 | import diamond.markdown.parser;
11 | import diamond.markdown.part;
12 | import diamond.markdown.type;
13 | }
14 |
--------------------------------------------------------------------------------
/markdown/part.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.markdown.part;
7 |
8 | import diamond.markdown.type;
9 |
10 | /// Wrapper around a markdown part.
11 | final class MarkdownPart
12 | {
13 | private:
14 | /// The type.
15 | MarkdownType _type;
16 | /// The content.
17 | string _content;
18 | /// The volume.
19 | size_t _volume;
20 | /// The metadata.
21 | string[string] _metadata;
22 |
23 | public:
24 | final:
25 | /**
26 | * Creates a new markdown part.
27 | * Params:
28 | * type = The type of the markdown part.
29 | */
30 | this(MarkdownType type)
31 | {
32 | _type = type;
33 | }
34 |
35 | @property
36 | {
37 | /// Gets the type of the markdown part.
38 | MarkdownType type() { return _type; }
39 |
40 | /// Gets the content of the markdown part.
41 | string content() { return _content; }
42 |
43 | /// Gets the volume of the markdown part.
44 | size_t volume() { return _volume; }
45 |
46 | package(diamond.markdown)
47 | {
48 | /// Sets the type of the markdown part.
49 | void type(MarkdownType newType)
50 | {
51 | _type = newType;
52 | }
53 |
54 | /// Sets the content of the markdown part.
55 | void content(string newContent)
56 | {
57 | _content = newContent;
58 | }
59 |
60 | /// Sets the volume of the markdown part.
61 | void volume(size_t newVolume)
62 | {
63 | _volume = newVolume;
64 | }
65 | }
66 | }
67 |
68 | /**
69 | * Gets a metadata value.
70 | * Params:
71 | * key = The key of the metadata to get.
72 | * Returns:
73 | * The metadata value if existing, null otherwise.
74 | */
75 | string getMetadata(string key)
76 | {
77 | return _metadata.get(key, null);
78 | }
79 |
80 | /**
81 | * Sets a metadata.
82 | * Params:
83 | * key = The key of the metadata.
84 | * value = The value of the metadata.
85 | */
86 | package(diamond.markdown) void setMetadata(string key, string value)
87 | {
88 | _metadata[key] = value;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/markdown/type.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.markdown.type;
7 |
8 | /// Enumeration of markdown types.
9 | enum MarkdownType
10 | {
11 | /// Plain content.
12 | content,
13 | /// New-line.
14 | newline,
15 | /// The start of content wrapping elements.
16 | contentWrapStart,
17 | /// The end of content wrapping elements.
18 | contentWrapEnd,
19 | /// Header.
20 | header,
21 | /// Unordered list-start.
22 | ulistStart,
23 | /// Unordered list-end.
24 | ulistEnd,
25 | /// Ordered list-start.
26 | olistStart,
27 | /// Ordered list-end.
28 | olistEnd,
29 | /// List-item start.
30 | listItemStart,
31 | /// List-item end.
32 | listItemEnd,
33 | /// Link.
34 | link,
35 | /// Image.
36 | image,
37 | /// Code-block start.
38 | codeStart,
39 | /// Code-block end.
40 | codeEnd,
41 | /// Block-quote start
42 | blockQuoteStart,
43 | /// Block-quote end
44 | blockQuoteEnd,
45 | /// Table start
46 | tableStart,
47 | /// Table-row start
48 | tableRowStart,
49 | /// Table-head start
50 | tableHeadStart,
51 | /// Table-cell start
52 | tableCellStart,
53 | /// Table end
54 | tableEnd,
55 | /// Table-row end
56 | tableRowEnd,
57 | /// Table-head end
58 | tableHeadEnd,
59 | /// Table-cell end
60 | tableCellEnd,
61 | /// Horizontal
62 | horizontal,
63 | // Inline-code
64 | inlineCode
65 | }
66 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "diamond",
3 | "description": "Powerful Full-stack MVC web-framework using vibe.d",
4 | "authors": [
5 | "Jacob Jensen"
6 | ],
7 | "homepage": "http://diamondmvc.org/",
8 | "license": "The MIT License (MIT)",
9 | "copyright": "Copyright © 2016-2018 Diamond MVC",
10 | "targetType": "sourceLibrary",
11 | "sourcePaths": [
12 | "app", "authentication", "controllers",
13 | "core", "css", "data",
14 | "database", "dom", "errors",
15 | "extensions", "html", "http",
16 | "io", "mail", "markdown",
17 | "security", "seo", "tasks",
18 | "templates", "unittesting", "views",
19 | "web", "xhtml", "xml"
20 | ],
21 | "dependencies": {
22 | "vibe-d": {
23 | "version": "~>0.8.3"
24 | },
25 | "mysql-native": {
26 | "version": "~>2.2.1"
27 | },
28 | "ddbc": {
29 | "version": "~master",
30 | "optional": true
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/security/backup/backuppath.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.backup.backuppath;
7 |
8 | /// Wrapper around a backup path.
9 | struct BackupPath
10 | {
11 | /// The source path.
12 | string source;
13 | /// The destination path.
14 | string destination;
15 | }
16 |
--------------------------------------------------------------------------------
/security/backup/backupservice.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.backup.backupservice;
7 |
8 | import diamond.security.backup.backuppath;
9 |
10 | /// Wrapper around a backup service.
11 | abstract class BackupService
12 | {
13 | private:
14 | /// The paths to backup.
15 | BackupPath[] _paths;
16 | /// The time to wait between backing up.
17 | size_t _time;
18 |
19 | protected:
20 | /**
21 | * Creates a new backup service.
22 | * Params:
23 | * time = The time to wait between backing up.
24 | */
25 | this(size_t time)
26 | {
27 | _time = time;
28 | }
29 |
30 | /**
31 | * Handler for performing a backup.
32 | * Params:
33 | * paths = The paths to backup.
34 | */
35 | abstract void onBackup(const(BackupPath[]) paths);
36 |
37 | public:
38 | @property
39 | {
40 | /// Gets the time to wait between backing up.
41 | const(size_t) time() { return _time; }
42 | }
43 | /**
44 | * Adds a path to backup.
45 | * Params:
46 | * path = The path to backup.
47 | */
48 | void addPath(BackupPath path)
49 | {
50 | _paths ~= path;
51 | }
52 |
53 | package(diamond):
54 | /// Performs the specified backup.
55 | void backup()
56 | {
57 | if (_paths)
58 | {
59 | onBackup(_paths);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/security/backup/filebackup.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.backup.filebackup;
7 |
8 | import diamond.security.backup.backupservice;
9 | import diamond.security.backup.backuppath;
10 |
11 | /// Wrapper around a file backup service.
12 | final class FileBackupService : BackupService
13 | {
14 | public:
15 | /**
16 | * Creates a new file backup service.
17 | * Params:
18 | * time = The time to wait between backing up.
19 | */
20 | this(size_t time)
21 | {
22 | super(time);
23 | }
24 |
25 | protected:
26 | /**
27 | * Handler for performing a file backup.
28 | * Params:
29 | * paths = The paths to backup.
30 | */
31 | override void onBackup(const(BackupPath[]) paths)
32 | {
33 | import std.file : dirEntries, SpanMode, exists, isFile, isDir, rmdirRecurse, copy;
34 | import std.path : dirName;
35 | import std.array : replace;
36 |
37 | foreach (path; paths)
38 | {
39 | if (path.source.isDir && path.destination.isDir)
40 | {
41 | if (!path.destination.exists)
42 | {
43 | rmdirRecurse(path.destination);
44 | }
45 |
46 | foreach (string entryPath; dirEntries(path.source, SpanMode.depth))
47 | {
48 | auto subEntryPath = path.destination ~ "/" ~ entryPath.replace(path.source, "");
49 |
50 | if (subEntryPath.isDir && !subEntryPath.exists)
51 | {
52 | rmdirRecurse(subEntryPath);
53 | }
54 | else if (subEntryPath.isFile)
55 | {
56 | if (!subEntryPath.dirName.exists)
57 | {
58 | rmdirRecurse(subEntryPath.dirName);
59 | }
60 |
61 | entryPath.copy(subEntryPath);
62 | }
63 | }
64 | }
65 | else if (path.source.isFile && path.destination.isFile)
66 | {
67 | if (!path.destination.dirName.exists)
68 | {
69 | rmdirRecurse(path.destination.dirName);
70 | }
71 |
72 | path.source.copy(path.destination);
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/security/backup/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.backup;
7 |
8 | public
9 | {
10 | import diamond.security.backup.backupservice;
11 | import diamond.security.backup.backuppath;
12 | import diamond.security.backup.filebackup;
13 | }
14 |
15 | /// Collection of backup services.
16 | private static __gshared BackupService[] _backupServices;
17 |
18 | /**
19 | * Adds a backup service.
20 | * Params:
21 | * service = The backup service to add.
22 | */
23 | void addBackupService(BackupService service)
24 | {
25 | _backupServices ~= service;
26 | }
27 |
28 | /// Executes the backup services.
29 | package(diamond) void executeBackup()
30 | {
31 | if (!_backupServices)
32 | {
33 | return;
34 | }
35 |
36 | import diamond.tasks;
37 |
38 | foreach (service; _backupServices)
39 | {
40 | executeTask
41 | ({
42 | while (true)
43 | {
44 | sleep(service.time.minutes);
45 | service.backup();
46 | }
47 | });
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/security/csrf.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.csrf;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.http;
13 | import diamond.errors.checks;
14 |
15 | /// The key of the token's storage in the session.
16 | private static const __gshared CSRFTokenKey = "__D_CSRFTOKEN";
17 |
18 | /**
19 | * Generates a CSRF token.
20 | * Params:
21 | * client = The client.
22 | * Returns:
23 | * The generated csrf token. If a token already exist, the existing token is returned.
24 | */
25 | string generateCSRFToken(HttpClient client)
26 | {
27 | auto token = client.session.getValue!string(CSRFTokenKey);
28 |
29 | if (token)
30 | {
31 | return token;
32 | }
33 |
34 | import diamond.security.tokens.generictoken;
35 |
36 | token = genericToken.generate()[0 .. 64];
37 |
38 | client.session.setValue(CSRFTokenKey, token);
39 |
40 | return token;
41 | }
42 |
43 | /**
44 | * Clears the csrf token.
45 | * Params:
46 | * client = The client.
47 | */
48 | void clearCSRFToken(HttpClient client)
49 | {
50 | client.session.removeValue(CSRFTokenKey);
51 | }
52 |
53 | /**
54 | * Checks whether a token is a valid csrf token for the request.
55 | * Params:
56 | * client = The client.
57 | * token = The token to validate.
58 | * removeToken = Boolean determining whether the token should be cleared after validation.
59 | * Returns:
60 | * Returns true if the token is valid, false otherwise.
61 | */
62 | bool isValidCSRFToken
63 | (
64 | HttpClient client,
65 | string token, bool removeToken
66 | )
67 | {
68 | enforce(token && token.length == 64, "Invalid csrf token.");
69 |
70 | auto csrfToken = client.session.getValue!string(CSRFTokenKey);
71 |
72 | if (csrfToken && removeToken)
73 | {
74 | client.session.removeValue(CSRFTokenKey);
75 | }
76 |
77 | return csrfToken !is null && token == csrfToken;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/security/network.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.network;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.core.webconfig;
13 | import diamond.http;
14 |
15 | /**
16 | * Validates the client ip against the "restrictedIPs" field in the web configuration file.
17 | * Params:
18 | * client = The client to validate the ip of.
19 | */
20 | void validateRestrictedIPs(HttpClient client)
21 | {
22 | if (webConfig.restrictedIPs)
23 | {
24 | validateRestrictedIPs(webConfig.restrictedIPs, client);
25 | }
26 | }
27 |
28 | /**
29 | * Validates the client ip against the "globalRestrictedIPs" field in the web configuration file.
30 | * Params:
31 | * client = The client to validate the ip of.
32 | */
33 | void validateGlobalRestrictedIPs(HttpClient client)
34 | {
35 | if (webConfig.globalRestrictedIPs)
36 | {
37 | validateRestrictedIPs(webConfig.globalRestrictedIPs, client);
38 | }
39 | }
40 |
41 | /**
42 | * Validates the client ip against the passed restricted ips.
43 | * Params:
44 | * restrictedIPs = The restricted ips to validate with.
45 | * client = The client to validate the ip of.
46 | */
47 | private void validateRestrictedIPs
48 | (
49 | const(string[]) restrictedIPs, HttpClient client
50 | )
51 | {
52 | bool allowed;
53 |
54 | foreach (ip; restrictedIPs)
55 | {
56 | if (client.ipAddress == ip)
57 | {
58 | allowed = true;
59 | break;
60 | }
61 | }
62 |
63 | if (!allowed)
64 | {
65 | client.error(HttpStatus.unauthorized);
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/security/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security;
7 |
8 | public
9 | {
10 | import diamond.security.tokens;
11 | import diamond.security.csrf;
12 | import diamond.security.network;
13 | import diamond.security.backup;
14 | import diamond.security.validation;
15 | import diamond.security.html;
16 | }
17 |
--------------------------------------------------------------------------------
/security/tokens/generictoken.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.tokens.generictoken;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.security.tokens.tokengenerator;
13 |
14 | /// Wrapper for a generic token generator.
15 | final class GenericToken : TokenGenerator
16 | {
17 | import vibe.crypto.cryptorand;
18 |
19 | private:
20 | /// The random generator for the generic token. TODO: Better RNG implementation ...
21 | SHA1HashMixerRNG _randomGenerator;
22 |
23 | /// Creates a new generic token generator.
24 | this()
25 | {
26 | super();
27 |
28 | _randomGenerator = new SHA1HashMixerRNG;
29 | }
30 |
31 | public:
32 | final:
33 | /**
34 | * Generates a token.
35 | * Returns:
36 | * Returns the generated token.
37 | */
38 | override string generate()
39 | {
40 | import diamond.core.senc;
41 |
42 | ubyte[64] randomBuffer;
43 | _randomGenerator.read(randomBuffer);
44 |
45 | return SENC.encode(randomBuffer);
46 | }
47 |
48 | /**
49 | * Generates a token. The input is ignored.
50 | * Params:
51 | * input = Discarded for generic tokens.
52 | * Returns:
53 | * Returns the generated token.
54 | */
55 | override string generate(string input)
56 | {
57 | return generate();
58 | }
59 |
60 | /**
61 | * Generates a token and passes it to the parent generator.
62 | * Params:
63 | * parentGenerator = The parent generator to use with the generated token.
64 | * Returns:
65 | * Returns the generated token.
66 | */
67 | override string generate(TokenGenerator parentGenerator)
68 | {
69 | import diamond.errors.checks;
70 | enforce(parentGenerator, "Passed no parent generator.");
71 |
72 | return parentGenerator.generate(this.generate());
73 | }
74 | }
75 |
76 | /// The generic token instance for the current thread.
77 | private GenericToken _genericToken;
78 |
79 | @property
80 | {
81 | /// Gets the generic token generator.
82 | GenericToken genericToken()
83 | {
84 | if (!_genericToken)
85 | {
86 | _genericToken = new GenericToken;
87 | }
88 |
89 | return _genericToken;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/security/tokens/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.tokens;
7 |
8 | public
9 | {
10 | import diamond.security.tokens.tokengenerator;
11 | import diamond.security.tokens.generictoken;
12 | import diamond.security.tokens.sessiontoken;
13 | }
14 |
--------------------------------------------------------------------------------
/security/tokens/sessiontoken.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.tokens.sessiontoken;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.security.tokens.tokengenerator;
13 |
14 | /// Wrapper for a session token generator.
15 | final class SessionToken : TokenGenerator
16 | {
17 | private:
18 | /// Creates a new instance of the session token generator.
19 | this()
20 | {
21 | super();
22 | }
23 |
24 | public:
25 | /**
26 | * Generates a token.
27 | * Returns:
28 | * Returns the generated token.
29 | */
30 | override string generate()
31 | {
32 | import diamond.security.tokens.generictoken;
33 |
34 | return genericToken.generate();
35 | }
36 |
37 | /**
38 | * Generates a token based on an input.
39 | * Params:
40 | * input = An input to append to the token.
41 | * Returns:
42 | * Returns the generated token.
43 | */
44 | override string generate(string input)
45 | {
46 | import diamond.core.senc;
47 |
48 | return generate() ~ SENC.encode(input);
49 | }
50 |
51 | /**
52 | * Generates a token and passes it to the parent generator.
53 | * Params:
54 | * parentGenerator = The parent generator to use with the generated token.
55 | * Returns:
56 | * Returns the generated token.
57 | */
58 | override string generate(TokenGenerator parentGenerator)
59 | {
60 | import diamond.errors.checks;
61 | enforce(parentGenerator, "Passed no parent generator.");
62 |
63 | return parentGenerator.generate(this.generate());
64 | }
65 | }
66 |
67 | /// The session token generator instance for the current thread.
68 | private SessionToken _sessionToken;
69 |
70 | @property
71 | {
72 | /// Gets the session token.
73 | SessionToken sessionToken()
74 | {
75 | if (!_sessionToken)
76 | {
77 | _sessionToken = new SessionToken;
78 | }
79 |
80 | return _sessionToken;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/security/tokens/tokengenerator.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.tokens.tokengenerator;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | /// Wrapper for a token generator.
13 | abstract class TokenGenerator
14 | {
15 | protected:
16 | /// Creates a new instance of the token generator.
17 | this() { }
18 |
19 | public:
20 | /**
21 | * Generates a token.
22 | * Returns:
23 | * Returns the generated token.
24 | */
25 | abstract string generate();
26 |
27 | /**
28 | * Generates a token based on an input.
29 | * Params:
30 | * input = The input to generate the token based on.
31 | * Returns:
32 | * Returns the generated token.
33 | */
34 | abstract string generate(string input);
35 |
36 | /**
37 | * Generates a token and passes it to the parent generator.
38 | * Params:
39 | * parentGenerator = The parent generator to use with the generated token.
40 | * Returns:
41 | * Returns the generated token.
42 | */
43 | abstract string generate(TokenGenerator parentGenerator);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/security/validation/creditcard.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.validation.creditcard;
7 |
8 | /**
9 | * Validates a credit-card number using luhn's algorithm.
10 | * Params:
11 | * creditCardNumber = The number of the credit card.
12 | * allowedDigits = The allowed length of digits. If it's null it allows credit card numbers to be any length.
13 | * Returns:
14 | * True if the credit card number is valid according to the allowed digits and luhn's algorithm, false otherwise.
15 | */
16 | bool isValidCreditCard(string creditCardNumber, size_t[] allowedDigits = null)
17 | {
18 | import std.conv : to;
19 | import std.algorithm : map, canFind;
20 |
21 | import diamond.errors.checks;
22 |
23 | import diamond.security.validation.types : isValidNumber;
24 |
25 | enforce(creditCardNumber && creditCardNumber.length, "A credit card number must be specified.");
26 | enforce(isValidNumber(creditCardNumber), "The credit card number must be numeric");
27 |
28 | if (allowedDigits)
29 | {
30 | if (!allowedDigits.canFind(creditCardNumber.length))
31 | {
32 | return false;
33 | }
34 | }
35 |
36 | size_t sum;
37 |
38 | foreach (digit; creditCardNumber.map!(d => to!string(d)))
39 | {
40 | auto value = to!size_t(digit);
41 |
42 | if (value % 2 == 0)
43 | {
44 | value *= 2;
45 |
46 | if (value > 9)
47 | {
48 | value = 1 + (value % 10);
49 | }
50 | }
51 |
52 | sum += value;
53 | }
54 |
55 | return (sum % 10) == 0;
56 | }
57 |
--------------------------------------------------------------------------------
/security/validation/email.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.validation.email;
7 |
8 | import std.net.isemail : isEmail;
9 |
10 | public import std.net.isemail : EmailStatusCode;
11 |
12 | /**
13 | * Checks whether a given email is valid or not.
14 | * Standards:
15 | * RFC 5321
16 | * RFC 5322
17 | * Params:
18 | * email = The email to validate.
19 | * checkDns = Boolean determining whether it should check dns for validation.
20 | * errorLevel = The error level boundary.
21 | * Returns:
22 | * True if the email is valid according to the given configurations, false otherwise.
23 | */
24 | bool isValidEmail(string email, bool checkDns = false, EmailStatusCode errorLevel = EmailStatusCode.none)
25 | {
26 | import std.typecons : Yes, No;
27 |
28 | return isEmail(email, checkDns ? Yes.checkDns : No.checkDns, errorLevel).valid;
29 | }
30 |
--------------------------------------------------------------------------------
/security/validation/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.validation;
7 |
8 | public
9 | {
10 | import diamond.security.validation.creditcard;
11 | import diamond.security.validation.file;
12 | import diamond.security.validation.email;
13 | import diamond.security.validation.types;
14 | import diamond.security.validation.url;
15 | import diamond.security.validation.sensitive;
16 | }
17 |
--------------------------------------------------------------------------------
/security/validation/types.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.validation.types;
7 |
8 | import std.traits : isNumeric;
9 |
10 | /**
11 | * Checks whether a given string input is a number or not.
12 | * Params:
13 | * input = The string input to validate.
14 | * Returns:
15 | * True if the input is a valid number, false otherwise.
16 | */
17 | bool isValidNumber(string input)
18 | {
19 | import std.string : isNumeric;
20 |
21 | return input.isNumeric;
22 | }
23 |
24 | /**
25 | * Checks whether a given string input is a boolean or not.
26 | * Params:
27 | * input = The string input to validate.
28 | * Returns:
29 | * True if the input is a valid boolean, false otherwise.
30 | */
31 | bool isValidBoolean(string input)
32 | {
33 | return input == "true" || input == "false";
34 | }
35 |
36 | /**
37 | * Checks whether a given numeric input is a boolean or not.
38 | * Params:
39 | * input = The numeric input to validate.
40 | * Returns:
41 | * True if the input is a valid boolean, false otherwise.
42 | */
43 | bool isValidBoolean(TNumber)(TNumber input)
44 | if (isNumeric!TNumber)
45 | {
46 | return input == 0 || input == 1;
47 | }
48 |
--------------------------------------------------------------------------------
/security/validation/url.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.security.validation.url;
7 |
8 | /**
9 | * Checks whether a given url is valid or not.
10 | * Params:
11 | * url = The url to validate.
12 | * Returns:
13 | * True if the url is valid, false otherwise.
14 | */
15 | bool isValidUrl(string url)
16 | {
17 | import vibe.inet.url;
18 |
19 | try
20 | {
21 | URL.parse(url);
22 |
23 | return true;
24 | }
25 | catch (Exception)
26 | {
27 | return false;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/seo/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo;
7 |
8 | public
9 | {
10 | import diamond.seo.schema;
11 | }
12 |
--------------------------------------------------------------------------------
/seo/schema/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema;
7 |
8 | public
9 | {
10 | import diamond.seo.schema.schemaobject;
11 | import diamond.seo.schema.structures;
12 | }
13 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/businessevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.businessevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/BusinessEvent
15 | final class BusinessEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new business event.
23 | this()
24 | {
25 | super("BusinessEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/childrensevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.childrensevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/ChildrensEvent
15 | final class ChildrensEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new childrens event.
23 | this()
24 | {
25 | super("ChildrensEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/comedyevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.comedyevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/ComedyEvent
15 | final class ComedyEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new comedy event.
23 | this()
24 | {
25 | super("ComedyEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/courseinstance.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.courseinstance;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/CourseInstance
15 | final class CourseInstance : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new course instance.
23 | this()
24 | {
25 | super("CourseInstance");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/danceevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.danceevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/DanceEvent
15 | final class DanceEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new dance event.
23 | this()
24 | {
25 | super("DanceEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/deliveryevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.deliveryevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/DeliveryEvent
15 | final class DeliveryEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new delivery event.
23 | this()
24 | {
25 | super("DeliveryEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/educationevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.educationevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/EducationEvent
15 | final class EducationEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new education event.
23 | this()
24 | {
25 | super("EducationEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/exhibitionevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.exhibitionevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/ExhibitionEvent
15 | final class ExhibitionEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new exhibition event.
23 | this()
24 | {
25 | super("ExhibitionEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/festival.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.festival;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/Festival
15 | final class Festival : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new festival.
23 | this()
24 | {
25 | super("Festival");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/foodevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.foodevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/FoodEvent
15 | final class FoodEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new food event.
23 | this()
24 | {
25 | super("FoodEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/literaryevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.literaryevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/LiteraryEvent
15 | final class LiteraryEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new literary event.
23 | this()
24 | {
25 | super("LiteraryEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/musicevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.musicevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/MusicEvent
15 | final class MusicEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new music event.
23 | this()
24 | {
25 | super("MusicEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events;
7 |
8 | public
9 | {
10 | import diamond.seo.schema.structures.events.businessevent;
11 | import diamond.seo.schema.structures.events.childrensevent;
12 | import diamond.seo.schema.structures.events.comedyevent;
13 | import diamond.seo.schema.structures.events.courseinstance;
14 | import diamond.seo.schema.structures.events.danceevent;
15 | import diamond.seo.schema.structures.events.deliveryevent;
16 | import diamond.seo.schema.structures.events.educationevent;
17 | import diamond.seo.schema.structures.events.exhibitionevent;
18 | import diamond.seo.schema.structures.events.festival;
19 | import diamond.seo.schema.structures.events.foodevent;
20 | import diamond.seo.schema.structures.events.literaryevent;
21 | import diamond.seo.schema.structures.events.musicevent;
22 | import diamond.seo.schema.structures.events.publicationevent;
23 | import diamond.seo.schema.structures.events.saleevent;
24 | import diamond.seo.schema.structures.events.screeningevent;
25 | import diamond.seo.schema.structures.events.socialevent;
26 | import diamond.seo.schema.structures.events.sportsevent;
27 | import diamond.seo.schema.structures.events.theaterevent;
28 | import diamond.seo.schema.structures.events.visualartsevent;
29 | }
30 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/publicationevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.publicationevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/PublicationEvent
15 | final class PublicationEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new publication event.
23 | this()
24 | {
25 | super("PublicationEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/saleevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.saleevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/SaleEvent
15 | final class SaleEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new sale event.
23 | this()
24 | {
25 | super("SaleEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/screeningevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.screeningevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/ScreeningEvent
15 | final class ScreeningEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new screening event.
23 | this()
24 | {
25 | super("ScreeningEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/socialevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.socialevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/SocialEvent
15 | final class SocialEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new social event.
23 | this()
24 | {
25 | super("SocialEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/sportsevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.sportsevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/SportsEvent
15 | final class SportsEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new sports event.
23 | this()
24 | {
25 | super("SportsEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/theaterevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.theaterevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/TheaterEvent
15 | final class TheaterEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new theather event.
23 | this()
24 | {
25 | super("TheaterEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/events/visualartsevent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.events.visualartsevent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.event;
13 |
14 | /// http://schema.org/VisualArtsEvent
15 | final class VisualArtsEvent : Event
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new visual arts event.
23 | this()
24 | {
25 | super("VisualArtsEvent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/airline.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.airline;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/Airline
15 | final class Airline : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new airline.
23 | this()
24 | {
25 | super("Airline");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/corporation.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.corporation;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/Corporation
15 | final class Corporation : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new corporation.
23 | this()
24 | {
25 | super("Corporation");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/educationalorganization.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.educationalorganization;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/EducationalOrganization
15 | final class EducationalOrganization : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new educational organization.
23 | this()
24 | {
25 | super("EducationalOrganization");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/governmentorganization.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.governmentorganization;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/GovernmentOrganization
15 | final class GovernmentOrganization : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new government organization.
23 | this()
24 | {
25 | super("GovernmentOrganization");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusiness.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusiness;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/LocalBusiness
15 | class LocalBusiness : Organization
16 | {
17 | private:
18 | /// The image.
19 | string _image;
20 | /// The opening hours.
21 | string[] _openingHours;
22 | /// The price range.
23 | string _priceRange;
24 |
25 | public:
26 | /// Creates a new local business.
27 | this()
28 | {
29 | super("LocalBusiness");
30 | }
31 |
32 | /**
33 | * Creates a new local business.
34 | * Params:
35 | * localBusinessType = The type of the local business.
36 | */
37 | protected this(string localBusinessType)
38 | {
39 | super(localBusinessType);
40 | }
41 |
42 | @property
43 | {
44 | final
45 | {
46 | /// Gets the image.
47 | string image() { return _image; }
48 |
49 | /// Sets the image.
50 | void image(string newImage)
51 | {
52 | _image = newImage;
53 |
54 | super.addField("image", _image);
55 | }
56 |
57 | /// Gets the opening hours.
58 | string[] openingHours() { return _openingHours; }
59 |
60 | /// Sets the opening hours.
61 | void openingHours(string[] newOpeningHours)
62 | {
63 | _openingHours = newOpeningHours;
64 |
65 | super.addField("openingHours", _openingHours);
66 | }
67 |
68 | /// Gets the price range.
69 | string priceRange() { return _priceRange; }
70 |
71 | /// Sets the price range.
72 | void priceRange(string newPriceRange)
73 | {
74 | _priceRange = newPriceRange;
75 |
76 | super.addField("priceRange", _priceRange);
77 | }
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/animalshelter.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.animalshelter;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/AnimalShelter
15 | final class AnimalShelter : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new animal shelter.
23 | this()
24 | {
25 | super("AnimalShelter");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/automotivebusiness.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.automotivebusiness;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/AutoMotiveBusiness
15 | final class AutoMotiveBusiness : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new auto-motive business.
23 | this()
24 | {
25 | super("AutoMotiveBusiness");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/childcare.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.childcare;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/ChildCare
15 | final class ChildCare : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new child care.
23 | this()
24 | {
25 | super("ChildCare");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/dentist.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.dentist;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/Dentist
15 | final class Dentist : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new dentist.
23 | this()
24 | {
25 | super("Dentist");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/drycleaningorlaundry.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.drycleaningorlaundry;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/DryCleaningOrLaundry
15 | final class DryCleaningOrLaundry : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new dry cleaning or laundry.
23 | this()
24 | {
25 | super("DryCleaningOrLaundry");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/emergencyservice.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.emergencyservice;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/EmergencyService
15 | final class EmergencyService : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new emergency service.
23 | this()
24 | {
25 | super("EmergencyService");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/employmentagency.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.employmentagency;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/EmploymentAgency
15 | final class EmploymentAgency : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new employment agency.
23 | this()
24 | {
25 | super("EmploymentAgency");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/entertainmentbusiness.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.entertainmentbusiness;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/EntertainmentBusiness
15 | final class EntertainmentBusiness : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new entertainment business.
23 | this()
24 | {
25 | super("EntertainmentBusiness");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/financialservice.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.financialservice;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/FinancialService
15 | final class FinancialService : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new financial service.
23 | this()
24 | {
25 | super("FinancialService");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/foodestablishment.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.foodestablishment;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/FoodEstablishment
15 | final class FoodEstablishment : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new food establishment.
23 | this()
24 | {
25 | super("FoodEstablishment");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/governmentoffice.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.governmentoffice;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/GovernmentOffice
15 | final class GovernmentOffice : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new government office.
23 | this()
24 | {
25 | super("GovernmentOffice");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/healthandbeautybusiness.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.healthandbeautybusiness;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/HealthAndBeautyBusiness
15 | final class HealthAndBeautyBusiness : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new health and beauty business.
23 | this()
24 | {
25 | super("HealthAndBeautyBusiness");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/homeandconstructionbusiness.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.homeandconstructionbusiness;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/HomeAndConstructionBusiness
15 | final class HomeAndConstructionBusiness : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new home and construction business.
23 | this()
24 | {
25 | super("HomeAndConstructionBusiness");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/internetcafe.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.internetcafe;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/InternetCafe
15 | final class InternetCafe : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new internet cafe.
23 | this()
24 | {
25 | super("InternetCafe");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/legalservice.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.legalservice;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/LegalService
15 | final class LegalService : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new legal service.
23 | this()
24 | {
25 | super("LegalService");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/library.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.library;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/Library
15 | final class Library : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new library.
23 | this()
24 | {
25 | super("Library");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/lodgingbusiness.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.lodgingbusiness;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/LodgingBusiness
15 | final class LodgingBusiness : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new lodging business.
23 | this()
24 | {
25 | super("LodgingBusiness");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/professionalservice.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.professionalservice;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/ProfessionalService
15 | final class ProfessionalService : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new professional service.
23 | this()
24 | {
25 | super("ProfessionalService");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/radiostation.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.radiostation;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/RadioStation
15 | final class RadioStation : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new radio station.
23 | this()
24 | {
25 | super("RadioStation");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/realestateagent.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.realestateagent;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/RealEstateAgent
15 | final class RealEstateAgent : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new real estate agent.
23 | this()
24 | {
25 | super("RealEstateAgent");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/recyclingcenter.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.recyclingcenter;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/RecyclingCenter
15 | final class RecyclingCenter : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new recycling center.
23 | this()
24 | {
25 | super("RecyclingCenter");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/selfstorage.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.selfstorage;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/SelfStorage
15 | final class SelfStorage : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new self storage.
23 | this()
24 | {
25 | super("SelfStorage");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/shoppingcenter.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.shoppingcenter;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/ShoppingCenter
15 | final class ShoppingCenter : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new shopping center.
23 | this()
24 | {
25 | super("ShoppingCenter");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/sportsactivitylocation.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.sportsactivitylocation;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/SportsActivityLocation
15 | final class SportsActivityLocation : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new sports activity location.
23 | this()
24 | {
25 | super("SportsActivityLocation");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/store.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.store;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/Store
15 | final class Store : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new store.
23 | this()
24 | {
25 | super("Store");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/televisionstation.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.televisionstation;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/TelevisionStation
15 | final class TelevisionStation : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new television station.
23 | this()
24 | {
25 | super("TelevisionStation");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/touristinformationcenter.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.touristinformationcenter;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/TouristInformationCenter
15 | final class TouristInformationCenter : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new tourist information center.
23 | this()
24 | {
25 | super("TouristInformationCenter");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/localbusinesses/travelagency.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.localbusinesses.travelagency;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organizations.localbusiness;
13 |
14 | /// http://schema.org/TravelAgency
15 | final class TravelAgency : LocalBusiness
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new travel agency.
23 | this()
24 | {
25 | super("TravelAgency");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/medicalorganization.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.medicalorganization;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/MedicalOrganization
15 | final class MedicalOrganization : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new medical organization.
23 | this()
24 | {
25 | super("MedicalOrganization");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/ngo.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.ngo;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/Ngo
15 | final class Ngo : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new ngo.
23 | this()
24 | {
25 | super("Ngo");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations;
7 |
8 | public
9 | {
10 | import diamond.seo.schema.structures.organizations.localbusiness;
11 | import diamond.seo.schema.structures.organizations.airline;
12 | import diamond.seo.schema.structures.organizations.corporation;
13 | import diamond.seo.schema.structures.organizations.educationalorganization;
14 | import diamond.seo.schema.structures.organizations.governmentorganization;
15 | import diamond.seo.schema.structures.organizations.medicalorganization;
16 | import diamond.seo.schema.structures.organizations.ngo;
17 | import diamond.seo.schema.structures.organizations.performinggroup;
18 | import diamond.seo.schema.structures.organizations.sportsorganization;
19 |
20 | import diamond.seo.schema.structures.organizations.localbusinesses;
21 | }
22 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/performinggroup.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.performinggroup;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/PerformingGroup
15 | final class PerformingGroup : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new performing group.
23 | this()
24 | {
25 | super("PerformingGroup");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/organizations/sportsorganization.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.organizations.sportsorganization;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.organization;
13 |
14 | /// http://schema.org/SportsOrganization
15 | final class SportsOrganization : Organization
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new sports organization.
23 | this()
24 | {
25 | super("SportsOrganization");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures;
7 |
8 | public
9 | {
10 | import diamond.seo.schema.structures.organization;
11 | import diamond.seo.schema.structures.contactpoint;
12 | import diamond.seo.schema.structures.postaladdress;
13 | import diamond.seo.schema.structures.person;
14 | import diamond.seo.schema.structures.event;
15 |
16 | import diamond.seo.schema.structures.organizations;
17 | import diamond.seo.schema.structures.events;
18 | }
19 |
--------------------------------------------------------------------------------
/seo/schema/structures/place.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.place;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.schemaobject;
13 | import diamond.seo.schema.structures.postaladdress;
14 |
15 | /// http://schema.org/Place
16 | final class Place : SchemaObject
17 | {
18 | private:
19 | /// The name.
20 | string _name;
21 | /// The address.
22 | PostalAddress _address;
23 |
24 | public:
25 | final:
26 | /// Creates a new place.
27 | this()
28 | {
29 | super("Place");
30 | }
31 |
32 | @property
33 | {
34 | /// Gets the name.
35 | string name() { return _name; }
36 |
37 | /// Sets the name.
38 | void name(string newName)
39 | {
40 | _name = newName;
41 | }
42 |
43 | /// Gets the address.
44 | PostalAddress address() { return _address; }
45 |
46 | /// Sets the address.
47 | void address(PostalAddress newAddress)
48 | {
49 | _address = newAddress;
50 |
51 | super.addField("address", _address);
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/seo/schema/structures/product.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.product;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.schemaobject;
13 |
14 | /// http://schema.org/Product
15 | class Product : SchemaObject
16 | {
17 | private:
18 |
19 | public:
20 | /// Creates a new product.
21 | this()
22 | {
23 | super("Product");
24 | }
25 |
26 | /**
27 | * Creates a new product.
28 | * Params:
29 | * productType = The type of the product.
30 | */
31 | protected this(string productType)
32 | {
33 | super(productType);
34 | }
35 |
36 | @property
37 | {
38 | final
39 | {
40 |
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/seo/schema/structures/products/individualproduct.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.products.individualproduct;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.product;
13 |
14 | /// http://schema.org/IndividualProduct
15 | final class IndividualProduct : Product
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new individual product.
23 | this()
24 | {
25 | super("IndividualProduct");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/products/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.products;
7 |
8 | public
9 | {
10 | import diamond.seo.schema.structures.products.individualproduct;
11 | import diamond.seo.schema.structures.products.productmodel;
12 | import diamond.seo.schema.structures.products.someproducts;
13 | import diamond.seo.schema.structures.products.vehicle;
14 | }
15 |
--------------------------------------------------------------------------------
/seo/schema/structures/products/productmodel.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.products.productmodel;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.product;
13 |
14 | /// http://schema.org/ProductModel
15 | final class ProductModel : Product
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new product model.
23 | this()
24 | {
25 | super("ProductModel");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/products/someproducts.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.products.someproducts;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.product;
13 |
14 | /// http://schema.org/SomeProducts
15 | final class SomeProducts : Product
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new some products.
23 | this()
24 | {
25 | super("SomeProducts");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/seo/schema/structures/products/vehicle.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.seo.schema.structures.products.vehicle;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.seo.schema.structures.product;
13 |
14 | /// http://schema.org/Vehicle
15 | final class Vehicle : Product
16 | {
17 | private:
18 |
19 |
20 | public:
21 | final:
22 | /// Creates a new vehicle.
23 | this()
24 | {
25 | super("Vehicle");
26 | }
27 |
28 | @property
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tasks/core.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.tasks.core;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | private import vibecore = vibe.core.core;
13 |
14 | public alias runTask = vibecore.runTask;
15 | public alias sleep = vibecore.sleep;
16 |
17 | /**
18 | * Executes an asynchronous task.
19 | * This is a wrapper around vibe.core.core.runTask.
20 | * Params:
21 | * task = The task to execute.
22 | * args = The arguments to pass to the task.
23 | */
24 | void executeTask(ARGS...)(void delegate(ARGS) @safe task, auto ref ARGS args)
25 | {
26 | runTask(task, args);
27 | }
28 |
29 | /**
30 | * Executes an asynchronous task.
31 | * This is a wrapper around vibe.core.core.runTask.
32 | * Params:
33 | * task = The task to execute.
34 | * args = The arguments to pass to the task.
35 | */
36 | void executeTask(ARGS...)(void delegate(ARGS) @system task, auto ref ARGS args) @system
37 | {
38 | runTask(task, args);
39 | }
40 |
41 | /**
42 | * Executes an asynchronous task.
43 | * This is a wrapper around vibe.core.core.runTask.
44 | * Params:
45 | * task = The task to execute.
46 | * args = The arguments to pass to the task.
47 | */
48 | void executeTask(CALLABLE, ARGS...)(CALLABLE task, auto ref ARGS args)
49 | if (!is(CALLABLE : void delegate(ARGS)) && is(typeof(CALLABLE.init(ARGS.init))))
50 | {
51 | runTask(task, args);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/tasks/delayedtasks.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.tasks.delayedtasks;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 |
13 | public import core.time : Duration, dur, weeks, days, hours, minutes, seconds,
14 | msecs, usecs, hnsecs, nsecs;
15 |
16 | import diamond.tasks.core;
17 |
18 | /**
19 | * Executes a delayed asynchronous task.
20 | * Params:
21 | * delay = The time to delay the task.
22 | * task = The task to execute.
23 | * args = The arguments to pass to the task.
24 | */
25 | void delayTask(ARGS...)(Duration delay, void delegate(ARGS) @safe task, auto ref ARGS args)
26 | {
27 | sleep(delay);
28 |
29 | executeTask(task, args);
30 | }
31 |
32 | /**
33 | * Executes a delayed asynchronous task.
34 | * Params:
35 | * delay = The time to delay the task.
36 | * task = The task to execute.
37 | * args = The arguments to pass to the task.
38 | */
39 | void delayTask(ARGS...)(Duration delay, void delegate(ARGS) @system task, auto ref ARGS args) @system
40 | {
41 | sleep(delay);
42 |
43 | executeTask(task, args);
44 | }
45 |
46 | /**
47 | * Executes a delayed asynchronous task.
48 | * Params:
49 | * delay = The time to delay the task.
50 | * task = The task to execute.
51 | * args = The arguments to pass to the task.
52 | */
53 | void delayTask(CALLABLE, ARGS...)(Duration delay, CALLABLE task, auto ref ARGS args)
54 | if (!is(CALLABLE : void delegate(ARGS)) && is(typeof(CALLABLE.init(ARGS.init))))
55 | {
56 | sleep(delay);
57 |
58 | executeTask(task, args);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/tasks/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.tasks;
7 |
8 | public
9 | {
10 | import core.time : Duration, dur, weeks, days, hours, minutes, seconds,
11 | msecs, usecs, hnsecs, nsecs;
12 |
13 | import diamond.tasks.core;
14 | import diamond.tasks.delayedtasks;
15 | import diamond.tasks.scheduler;
16 | }
17 |
--------------------------------------------------------------------------------
/templates/characterincludemode.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.templates.characterincludemode;
7 |
8 | /// Enumeration of character include modes.
9 | enum CharacterIncludeMode
10 | {
11 | /// Neither the start- or end character will be included.
12 | none,
13 | /// The start character will be included.
14 | start,
15 | /// The end character will be included.
16 | end,
17 | /// Both the start- and end character will be included.
18 | both
19 | }
20 |
--------------------------------------------------------------------------------
/templates/contentmode.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.templates.contentmode;
7 |
8 | /// Enumeration of content modes.
9 | enum ContentMode
10 | {
11 | /// Will append content to the view.
12 | appendContent,
13 | /// Will append content to the view with a placeholder
14 | appendContentPlaceholder,
15 | /// Will mixin the content as D code.
16 | mixinContent,
17 | /// Will parse the content as meta and handle it as such
18 | metaContent,
19 | /// Will discard the content.
20 | discardContent
21 | }
22 |
--------------------------------------------------------------------------------
/templates/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.templates;
7 |
8 | public
9 | {
10 | import diamond.templates.grammar;
11 | import diamond.templates.contentmode;
12 | import diamond.templates.characterincludemode;
13 | import diamond.templates.part;
14 | import diamond.templates.parser;
15 | }
16 |
--------------------------------------------------------------------------------
/unittesting/attributes.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.unittesting.attributes;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb && isTesting)
11 | {
12 | /// Attribute to define a test.
13 | struct HttpTest
14 | {
15 | /// The name of the test.
16 | string name;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/unittesting/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.unittesting;
7 |
8 | public
9 | {
10 | import diamond.unittesting.initialization;
11 | import diamond.unittesting.request;
12 | import diamond.unittesting.attributes;
13 |
14 | import diamond.core.apptype : isTesting;
15 | }
16 |
--------------------------------------------------------------------------------
/views/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.views;
7 |
8 | public
9 | {
10 | import diamond.views.viewgenerator;
11 | import diamond.views.viewformats;
12 | import diamond.views.viewparser;
13 | import diamond.views.view;
14 | import diamond.views.viewroute;
15 | import diamond.views.viewcache;
16 | }
17 |
--------------------------------------------------------------------------------
/views/viewcache.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.views.viewcache;
7 |
8 | import diamond.http.client : HttpClient;
9 |
10 | /**
11 | * Caches a view.
12 | * Params:
13 | * client = The client to cache from.
14 | * result = The result to cache.
15 | * cacheTime = The time to cache the view. 0 equals process-lifetime.
16 | */
17 | package(diamond) void cacheView(HttpClient client, string result, size_t cacheTime)
18 | {
19 | import diamond.app.appcache;
20 |
21 | cache.updateCache(client, result);
22 |
23 | if (cacheTime)
24 | {
25 | import diamond.tasks : executeTask, sleep, msecs;
26 |
27 | executeTask(
28 | {
29 | sleep(cacheTime.msecs);
30 |
31 | cache.removeCache(client);
32 | });
33 | }
34 | }
35 |
36 | /**
37 | * Gets the result of a cached view.
38 | * Params:
39 | * client = The client to get the cached view from.
40 | * Returns:
41 | * The cached view result if present.
42 | */
43 | string getCachedView(HttpClient client)
44 | {
45 | import diamond.app.appcache;
46 |
47 | return cache.retrieveCache(client);
48 | }
49 |
--------------------------------------------------------------------------------
/views/viewgenerator.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.views.viewgenerator;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWebServer || !isWeb)
11 | {
12 | /// Mixin template for the view generator.
13 | mixin template GenerateViews()
14 | {
15 | import diamond.core.webconfig;
16 | import diamond.views.viewparser;
17 |
18 | struct ViewResult
19 | {
20 | string name;
21 | string source;
22 | }
23 |
24 | /**
25 | * Generates the strings of the view classes to use with mixin.
26 | * Returns:
27 | * An array consisting of the generated classes of the views.
28 | * The first element of the array is the routable data.
29 | */
30 | private ViewResult[] generateViews()
31 | {
32 | ViewResult[] viewGenerations = [];
33 |
34 | string routableViewsMixin = "private static __gshared string[string] _routableViews;
35 | @property string[string] routableViews()
36 | {
37 | if (_routableViews) return _routableViews;
38 | ";
39 |
40 | mixin LoadViewData;
41 |
42 | foreach (viewName,viewContent; getViewData)
43 | {
44 | import diamond.templates.parser : parseTemplate;
45 |
46 | auto parts = parseTemplate(viewContent);
47 |
48 | string route;
49 | viewGenerations ~= ViewResult(viewName, parseViewParts(parts, viewName, route));
50 |
51 | if (route && route.length)
52 | {
53 | import std.string : format;
54 | routableViewsMixin ~= "_routableViews[\"%s\"] = \"%s\";".format(route, viewName);
55 | }
56 | }
57 |
58 | routableViewsMixin ~= "return _routableViews;
59 | }";
60 |
61 | return [ViewResult("__routes", routableViewsMixin)] ~ viewGenerations;
62 | }
63 |
64 | /// The result of the generated views.
65 | enum generateViewsResult = generateViews();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/web/elements/block.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.block;
7 |
8 | import diamond.web.elements.element;
9 |
10 | import std.traits : BaseClassesTuple;
11 | import std.meta : AliasSeq;
12 |
13 | /// Wrapper around a block element. Default implementation is a div.
14 | class Block(TElement = Element) : Element
15 | if
16 | (
17 | is(BaseClassesTuple!TElement == AliasSeq!(Element, Object)) ||
18 | is(TElement == Element)
19 | )
20 | {
21 | private:
22 | /// Collection of inner elements.
23 | TElement[] _elements;
24 |
25 | public:
26 | final:
27 | /// Creates a new block element.
28 | this()
29 | {
30 | super("div");
31 | }
32 |
33 | /**
34 | * Creates a new block element.
35 | * Params:
36 | * tagName = The name of the block element's tag.
37 | */
38 | package(diamond.web.elements) this(string tagName)
39 | {
40 | super(tagName);
41 | }
42 |
43 | /**
44 | * Adds an element to the block.
45 | * Params:
46 | * element = The element to add.
47 | */
48 | void addElement(TElement element)
49 | {
50 | _elements ~= element;
51 | }
52 |
53 | protected:
54 | /// Generates the appropriate html for the element.
55 | override string generateHtml()
56 | {
57 | import std.string : format;
58 | import std.array : array, join;
59 | import std.algorithm : map;
60 |
61 | string innerHtml;
62 |
63 | if (_elements)
64 | {
65 | innerHtml = _elements ? _elements.map!(e => e.toString()).array.join("\n") : "";
66 | }
67 |
68 | if (!innerHtml || !innerHtml.length)
69 | {
70 | innerHtml = super.inner ? super.inner : "";
71 | }
72 |
73 | return `
74 | <%1$s %2$s>
75 | %3$s
76 | %1$s>`.format(super.tagName, super.attributeHtml(), innerHtml);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/web/elements/button.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.button;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a button element.
11 | final class Button : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new button element.
16 | this()
17 | {
18 | super("button");
19 | }
20 |
21 | @property
22 | {
23 | /// Gets the text.
24 | string text() { return super.inner; }
25 |
26 | /// Sets the text.
27 | void text(string newText)
28 | {
29 | super.inner = newText;
30 | }
31 | }
32 |
33 | protected:
34 | /// Generates the appropriate html for the element.
35 | override string generateHtml()
36 | {
37 | import std.string : format;
38 |
39 | return "<%1$s %2$s>%3$s%1$s>".format(super.tagName, super.attributeHtml(), text ? text : "");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/web/elements/checkbox.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.checkbox;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a checkbox input.
11 | final class CheckBox : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new checkbox input.
16 | this()
17 | {
18 | super();
19 |
20 | addAttribute("type", "checkbox");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/web/elements/date.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.date;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a date input.
11 | final class Date : Input
12 | {
13 | private:
14 | /// The min date.
15 | string _minDate;
16 | /// The max date.
17 | string _maxDate;
18 |
19 | public:
20 | final:
21 | /// Creates a new date input.
22 | this()
23 | {
24 | super();
25 |
26 | addAttribute("type", "date");
27 | }
28 |
29 | /**
30 | * Creates a new date input.
31 | * Params:
32 | * date = The date of the input.
33 | */
34 | this(string date)
35 | {
36 | this();
37 |
38 | super.value = date;
39 | }
40 |
41 | @property
42 | {
43 | /// Gets the min date.
44 | string minDate() { return _minDate; }
45 |
46 | /// Sets the min date.
47 | void minDate(string newMinDate)
48 | {
49 | _minDate = newMinDate;
50 |
51 | addAttribute("min", _minDate);
52 | }
53 |
54 | /// Gets the max date.
55 | string maxDate() { return _maxDate; }
56 |
57 | /// Sets the min date.
58 | void maxDate(string newMaxDate)
59 | {
60 | _maxDate = newMaxDate;
61 |
62 | addAttribute("max", _maxDate);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/web/elements/email.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.email;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a email input.
11 | final class Email : Input
12 | {
13 | private:
14 | /// Boolean determining whether the input allows multiple emails or not.
15 | bool _multiple;
16 |
17 | public:
18 | final:
19 | /// Creates a new email input.
20 | this()
21 | {
22 | super();
23 |
24 | addAttribute("type", "email");
25 | }
26 |
27 | @property
28 | {
29 | /// Gets a boolean determining whether the input allows multiple emails or not.
30 | bool multiple() { return _multiple; }
31 |
32 | /// Sets a boolean determining whether the input allows multiple emails or not.
33 | void multiplate(bool allowMultiple)
34 | {
35 | _multiple = allowMultiple;
36 |
37 | addAttribute("multiple", null);
38 | }
39 |
40 | /// Gets a boolean determining whether the input allows an empty value.
41 | bool allowsEmptyValue()
42 | {
43 | return _multiple;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/web/elements/file.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.file;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a file input.
11 | final class File : Input
12 | {
13 | private:
14 | /// Boolean determining whether the input allows multiple files or not.
15 | bool _multiple;
16 |
17 | public:
18 | final:
19 | /// Creates a new file input.
20 | this()
21 | {
22 | super();
23 |
24 | addAttribute("type", "file");
25 | }
26 |
27 | @property
28 | {
29 | /// Gets a boolean determining whether the input allows multiple files or not.
30 | bool multiple() { return _multiple; }
31 |
32 | /// Sets a boolean determining whether the input allows multiple files or not.
33 | void multiplate(bool allowMultiple)
34 | {
35 | _multiple = allowMultiple;
36 |
37 | addAttribute("multiple", null);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/web/elements/form.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.form;
7 |
8 | import diamond.core.apptype;
9 | import diamond.http.method;
10 | import diamond.web.elements.block;
11 | import diamond.web.elements.input;
12 |
13 | /// Wrapper around a form.
14 | final class Form : Block!Input
15 | {
16 | private:
17 | /// The action.
18 | string _action;
19 | /// The mime-type.
20 | string _mimeType;
21 |
22 | static if (isWeb)
23 | {
24 | /// The http method.
25 | HttpMethod _method;
26 | }
27 | else
28 | {
29 | /// The http method.
30 | string _method;
31 | }
32 |
33 | public:
34 | final:
35 | /// Creates a new form.
36 | this()
37 | {
38 | super("form");
39 | }
40 |
41 | @property
42 | {
43 | /// Gets the action.
44 | string action() { return _action; }
45 |
46 | /// Sets the action.
47 | void action(string newAction)
48 | {
49 | _action = newAction;
50 |
51 | addAttribute("action", _action);
52 | }
53 |
54 | /// Gets the mime-type.
55 | string mimeType() { return _mimeType; }
56 |
57 | /// Sets the mime-type.
58 | void mimeType(string newMimeType)
59 | {
60 | _mimeType = newMimeType;
61 |
62 | addAttribute("enctype", _mimeType);
63 | }
64 |
65 | static if (isWeb)
66 | {
67 | /// Gets the http method.
68 | HttpMethod method() { return _method; }
69 |
70 | /// Sets the http method.
71 | void method(HttpMethod method)
72 | {
73 | import std.conv;
74 |
75 | _method = method;
76 | addAttribute("method", to!string(method));
77 | }
78 | }
79 | else
80 | {
81 | /// Gets the http method.
82 | string method() { return _method; }
83 |
84 | /// Sets the http method.
85 | void method(string method)
86 | {
87 | _method = method;
88 | addAttribute("method", _method);
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/web/elements/hidden.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.hidden;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a hidden input.
11 | final class Hidden : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new hidden input.
16 | this()
17 | {
18 | super();
19 |
20 | addAttribute("type", "hidden");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/web/elements/image.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.image;
7 |
8 | import diamond.web.elements.element;
9 |
10 | /// Wrapper around a image.
11 | final class Image : Element
12 | {
13 | private:
14 | /// The source.
15 | string _source;
16 | /// The alt text.
17 | string _alt;
18 |
19 | public:
20 | final:
21 | /// Creates a new image.
22 | this()
23 | {
24 | super("img");
25 |
26 | alt = "";
27 | }
28 |
29 | /**
30 | * Creates a new image.
31 | * Params:
32 | * source = The source of the image.
33 | */
34 | this(string source)
35 | {
36 | this();
37 |
38 | this.source = source;
39 | }
40 |
41 | @property
42 | {
43 | /// Gets the source.
44 | string source() { return _source; }
45 |
46 | /// Sets the source.
47 | void source(string newSource)
48 | {
49 | _source = newSource;
50 | addAttribute("src", _source);
51 | }
52 |
53 | /// Gets the alt text.
54 | string alt() { return _alt; }
55 |
56 | /// Sets the alt text.
57 | void alt(string newAlt)
58 | {
59 | _alt = newAlt;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/web/elements/input.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.input;
7 |
8 | import diamond.web.elements.element;
9 |
10 | /// Wrapper around an input element.
11 | abstract class Input : Element
12 | {
13 | private:
14 | /// The value.
15 | string _value;
16 | /// The placeholder.
17 | string _placeholder;
18 | /// The label.
19 | string _label;
20 |
21 | public:
22 | final
23 | {
24 | /// Creates a new input element.
25 | this()
26 | {
27 | super("input");
28 | }
29 |
30 | package(diamond.web.elements) this(string tagName)
31 | {
32 | super(tagName);
33 | }
34 |
35 | @property
36 | {
37 | /// Gets the value.
38 | string value() { return _value; }
39 |
40 | /// Sets the value.
41 | void value(string newValue)
42 | {
43 | _value = newValue;
44 |
45 | addAttribute("value", _value);
46 | }
47 |
48 | /// Gets the placeholder.
49 | string placeholder() { return _placeholder; }
50 |
51 | /// Sets the placeholder.
52 | void placeholder(string newPlaceholder)
53 | {
54 | _placeholder = newPlaceholder;
55 |
56 | addAttribute("placeholder", _placeholder);
57 | }
58 |
59 | /// Gets the label.
60 | string label() { return _label; }
61 |
62 | /// Sets the label.
63 | void label(string newLabel)
64 | {
65 | _label = newLabel;
66 | }
67 | }
68 | }
69 |
70 | protected:
71 | /// Generates the appropriate html for the element.
72 | override string generateHtml()
73 | {
74 | import std.string : format;
75 |
76 | return "%3$s<%1$s %2$s>".format
77 | (
78 | super.tagName, super.attributeHtml(),
79 | _label && _label.length && super.id && super.id.length ?
80 | "".format(super.id, _label) : ""
81 | );
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/web/elements/link.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.link;
7 |
8 | import diamond.web.elements.block;
9 |
10 | /// Wrapper around a hyperlink.
11 | final class Link : Block!()
12 | {
13 | public:
14 | final:
15 | /**
16 | * Creates a new hyperlink.
17 | * Params:
18 | * destination = The destination of the hyperlink.
19 | * target = The target of the hyperlink.
20 | */
21 | this(string destination, string target = null)
22 | {
23 | super("a");
24 |
25 | addAttribute("href", destination);
26 |
27 | if (target)
28 | {
29 | addAttribute("target", target);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/web/elements/numeric.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.numeric;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a numeric input.
11 | final class Numeric : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new numeric input.
16 | this()
17 | {
18 | super();
19 |
20 | addAttribute("type", "number");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/web/elements/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements;
7 |
8 | public
9 | {
10 | import diamond.web.elements.element;
11 | import diamond.web.elements.input;
12 | import diamond.web.elements.block;
13 | import diamond.web.elements.paragraph;
14 | import diamond.web.elements.link;
15 | import diamond.web.elements.checkbox;
16 | import diamond.web.elements.radio;
17 | import diamond.web.elements.date;
18 | import diamond.web.elements.email;
19 | import diamond.web.elements.file;
20 | import diamond.web.elements.hidden;
21 | import diamond.web.elements.numeric;
22 | import diamond.web.elements.password;
23 | import diamond.web.elements.text;
24 | import diamond.web.elements.submit;
25 | import diamond.web.elements.button;
26 | import diamond.web.elements.form;
27 | import diamond.web.elements.select;
28 | import diamond.web.elements.textarea;
29 | import diamond.web.elements.image;
30 | }
31 |
--------------------------------------------------------------------------------
/web/elements/paragraph.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.paragraph;
7 |
8 | import diamond.web.elements.block;
9 |
10 | /// Wrapper around a paragraph.
11 | final class Paragraph : Block!()
12 | {
13 | public:
14 | final:
15 | /// Creates a new paragraph.
16 | this()
17 | {
18 | super("p");
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/web/elements/password.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.password;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a password input.
11 | final class Password : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new password input.
16 | this()
17 | {
18 | super();
19 |
20 | addAttribute("type", "password");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/web/elements/radio.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.radio;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a radio input.
11 | final class Radio : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new radio input.
16 | this()
17 | {
18 | super();
19 |
20 | addAttribute("type", "radio");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/web/elements/select.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.select;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a select input.
11 | final class Select : Input
12 | {
13 | private:
14 | /// The associated form.
15 | string _form;
16 |
17 | /// The options.
18 | string[string] _options;
19 |
20 | public:
21 | final:
22 | /// Creates a new select input.
23 | this()
24 | {
25 | super("select");
26 | }
27 |
28 | @property
29 | {
30 | /// Gets the form.
31 | string form() { return _form; }
32 |
33 | /// Sets the form.
34 | void form(string newForm)
35 | {
36 | _form = newForm;
37 |
38 | addAttribute("form", _form);
39 | }
40 | }
41 |
42 | /**
43 | * Adds an option.
44 | * Params:
45 | * value = The value of the option.
46 | * text = The text of the option.
47 | */
48 | void addOption(string value, string text)
49 | {
50 | _options[value] = text;
51 | }
52 |
53 | /**
54 | * Gets an option.
55 | * Params:
56 | * value = The value of the option.
57 | * Returns:
58 | * The text of the option if found, null otherwise.
59 | */
60 | string getOption(string value)
61 | {
62 | return _options.get(value, null);
63 | }
64 |
65 | /**
66 | * Removes an option.
67 | * Params:
68 | * value = The value of the option to remove.
69 | */
70 | void removeOption(string value)
71 | {
72 | _options.remove(value);
73 | }
74 |
75 | protected:
76 | /// Generates the appropriate html for the element.
77 | override string generateHtml()
78 | {
79 | import std.string : format;
80 | import std.array : join;
81 |
82 | string[] options;
83 |
84 | foreach (value,text; _options)
85 | {
86 | options ~= "".format(value,text);
87 | }
88 |
89 | auto optionsHtml = options ? options.join("\n") : "";
90 |
91 | return "%3$s<%1$s %2$s>%4$s%1$s>".format
92 | (
93 | super.tagName, super.attributeHtml(),
94 | super.label && super.label.length && super.id && super.id.length ?
95 | "".format(super.id, super.label) : "",
96 | optionsHtml
97 | );
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/web/elements/submit.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.submit;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a submit input.
11 | final class Submit : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new submit input.
16 | this()
17 | {
18 | super();
19 |
20 | addAttribute("type", "submit");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/web/elements/text.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.text;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a text input.
11 | final class Text : Input
12 | {
13 | public:
14 | final:
15 | /// Creates a new text input.
16 | this()
17 | {
18 | super();
19 |
20 | addAttribute("type", "text");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/web/elements/textarea.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.elements.textarea;
7 |
8 | import diamond.web.elements.input;
9 |
10 | /// Wrapper around a textarea input.
11 | final class TextArea : Input
12 | {
13 | private:
14 | /// The associated form.
15 | string _form;
16 | /// The rows.
17 | size_t _rows;
18 | /// The columns.
19 | size_t _columns;
20 |
21 | public:
22 | final:
23 | /// Creates a new textarea input.
24 | this()
25 | {
26 | super("textarea");
27 | }
28 |
29 | @property
30 | {
31 | /// Gets the form.
32 | string form() { return _form; }
33 |
34 | /// Sets the form.
35 | void form(string newForm)
36 | {
37 | _form = newForm;
38 |
39 | addAttribute("form", _form);
40 | }
41 |
42 | /// Gets the rows.
43 | size_t rows() { return _rows; }
44 |
45 | /// Sets the rows.
46 | void rows(size_t newRows)
47 | {
48 | _rows = newRows;
49 | addAttribute("rows", _rows);
50 | }
51 |
52 | /// Gets the columns.
53 | size_t columns() { return _columns; }
54 |
55 | /// Sets the columns.
56 | void columns(size_t newColumns)
57 | {
58 | _columns = newColumns;
59 | addAttribute("cols", _columns);
60 | }
61 | }
62 |
63 | protected:
64 | /// Generates the appropriate html for the element.
65 | override string generateHtml()
66 | {
67 | import std.string : format;
68 |
69 | return "%3$s<%1$s %2$s>%4$s%1$s>".format
70 | (
71 | super.tagName, super.attributeHtml(),
72 | super.label && super.label.length && super.id && super.id.length ?
73 | "".format(super.id, super.label) : "",
74 | super.value ? super.value : ""
75 | );
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/web/file/download.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.file.download;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | /**
13 | * Downloads data from a remote url.
14 | * Params:
15 | * url = The url of the data to download.
16 | * downloadedHandler = A handler for when the data has been downloaded.
17 | */
18 | void download(string url, scope void delegate(scope ubyte[] data) downloadedHandler)
19 | {
20 | import diamond.http;
21 |
22 | remoteRequest(
23 | url,
24 | HttpMethod.GET,
25 | (scope resp)
26 | {
27 | import vibe.stream.operations : readAll;
28 |
29 | if (downloadedHandler)
30 | {
31 | downloadedHandler(resp.bodyReader.readAll());
32 | }
33 | }
34 | );
35 | }
36 |
37 | /**
38 | * Downloads a remote file and places in the file system.
39 | * Params:
40 | * url = The url of the file to download.
41 | * destination = The destination path of the file in the file system.
42 | */
43 | void downloadFile(string url, string destination)
44 | {
45 | download(url, (scope data)
46 | {
47 | import std.file : write;
48 |
49 | write(destination, data);
50 | });
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/web/file/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.file;
7 |
8 | public
9 | {
10 | import diamond.web.file.upload;
11 | import diamond.web.file.download;
12 | }
13 |
--------------------------------------------------------------------------------
/web/file/upload.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.file.upload;
7 |
8 | import diamond.core.apptype;
9 |
10 | static if (isWeb)
11 | {
12 | import diamond.http.client;
13 |
14 | /**
15 | * Simplified upload handler to handle file uploads.
16 | * Params:
17 | * client = The client that performed the upload.
18 | * uploadedHandler = Handler for handling the uploaded files.
19 | */
20 | void uploaded(HttpClient client, void delegate(string tempPath, string fileName) uploadedHandler)
21 | {
22 | if (!uploadedHandler)
23 | {
24 | return;
25 | }
26 |
27 | foreach (name, file; client.files)
28 | {
29 | uploadedHandler(file.tempPath.toString(), name);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/web/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web;
7 |
8 | public
9 | {
10 | import diamond.web.elements;
11 | import diamond.web.file;
12 | import diamond.web.soap;
13 | }
14 |
--------------------------------------------------------------------------------
/web/soap/client/client.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.soapclient;
7 |
8 | import std.traits : Parameters;
9 |
10 | import diamond.http;
11 |
12 | /// Wrapper around a soap client.
13 | final class SoapClient
14 | {
15 | public:
16 | final:
17 | /// Creates a new soap client.
18 | this() { }
19 |
20 | ReturnType!f sendRequestFromFunctionDefinition(alias f)(Parameters!f)
21 | {
22 | // TODO: Construct request ...
23 | return null;
24 | }
25 |
26 | void sendRawRequest(string url, string soapAction, string soapEnvelope)
27 | {
28 | remoteRequest(url, HttpMethod.POST,
29 | (scope responder)
30 | {
31 | /// ...
32 | },
33 | (scope requester)
34 | {
35 | requester.headers["SOAPAction"] = soapAction;
36 |
37 | requester.bodyWriter.write(soapEnvelope);
38 | }
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/web/soap/client/envelopebody.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.client.envelopebody;
7 |
8 | import diamond.web.soap.client.envelopeparameter;
9 |
10 | /// Wrapper around a soap envelope body.
11 | final class SoapEnvelopeBody
12 | {
13 | private:
14 | /// The method.
15 | string _method;
16 | /// The parameters.
17 | SoapEnvelopeParameter[] _parameters;
18 |
19 | public:
20 | final:
21 | /**
22 | * Creates a new soap envelope body.
23 | * Params:
24 | * method = The method of the body.
25 | */
26 | this(string method)
27 | {
28 | _method = method;
29 | }
30 |
31 | @property
32 | {
33 | /// Gets the method of the body.
34 | string method() { return _method; }
35 |
36 | /// Gets the parameters of the body.
37 | SoapEnvelopeParameter[] parameters() { return _parameters; }
38 | }
39 |
40 | /**
41 | * Adds a parameter to the body.
42 | * Params:
43 | * name = The name.
44 | * value = The value.
45 | */
46 | void addParameter(string name, string value)
47 | {
48 | _parameters ~= new SoapEnvelopeParameter(name, value);
49 | }
50 |
51 | /**
52 | * Gets a parameter from the body.
53 | * Params:
54 | * name = The name of the parameter.
55 | * Returns:
56 | * The parameter if found, null otherwise.
57 | */
58 | SoapEnvelopeParameter getParameter(string name)
59 | {
60 | import std.algorithm : filter;
61 | import std.array : array;
62 | import std.string : toLower, strip;
63 |
64 | if (!name || !name.length)
65 | {
66 | return null;
67 | }
68 |
69 | if (!_parameters || !_parameters.length)
70 | {
71 | return null;
72 | }
73 |
74 | auto parameter = _parameters.filter!(p => p.name.toLower().strip() == name.toLower().strip()).array;
75 |
76 | if (!parameter || !parameter.length)
77 | {
78 | return null;
79 | }
80 |
81 | return parameter[0];
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/web/soap/client/envelopeparameter.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.client.envelopeparameter;
7 |
8 | /// Wrapper around a soap envelope parameter.
9 | final class SoapEnvelopeParameter
10 | {
11 | private:
12 | /// The name.
13 | string _name;
14 | /// The value.
15 | string _value;
16 |
17 | public:
18 | final:
19 | /**
20 | * Creates a new soap envelope parameter.
21 | * Params:
22 | * name = The name of the parameter.
23 | * value = The value of the parameter.
24 | */
25 | this(string name, string value)
26 | {
27 | _name = name;
28 | _value = value;
29 | }
30 |
31 | @property
32 | {
33 | /// Gets the name.
34 | string name() { return _name; }
35 |
36 | /// Gets the value.
37 | string value() { return _value; }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/web/soap/client/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.client;
7 |
8 | public
9 | {
10 | import diamond.web.soap.client.soapclient;
11 | import diamond.web.soap.client.envelope;
12 | import diamond.web.soap.client.envelopebody;
13 | import diamond.web.soap.client.envelopeparameter;
14 | }
15 |
--------------------------------------------------------------------------------
/web/soap/client/soapclient.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.client.soapclient;
7 |
8 | import diamond.http;
9 | import diamond.web.soap.client.envelope;
10 |
11 | /// Wrapper around a soap client.
12 | final class SoapClient
13 | {
14 | public:
15 | final:
16 | /// Creates a new soap client.
17 | this() { }
18 |
19 | /**
20 | * Sends a soap envelope to the specified url over HTTP.
21 | * Params:
22 | * url = The url of the soap method.
23 | * envelope = The envelope to send.
24 | * soapAction = The soap action.
25 | */
26 | void sendHttp(string url, SoapEnvelope envelope, string soapAction = null)
27 | {
28 | sendHttp(HttpMethod.POST, url, envelope, soapAction);
29 | }
30 |
31 | /**
32 | * Sends a soap envelope to the specified url over HTTP.
33 | * Params:
34 | * method = The http method to send the soap envelope over.
35 | * url = The url of the soap method.
36 | * envelope = The envelope to send.
37 | * soapAction = The soap action.
38 | */
39 | void sendHttp(HttpMethod method, string url, SoapEnvelope envelope, string soapAction = null)
40 | {
41 | remoteRequest(url, method,
42 | (scope responder)
43 | {
44 | // TODO: Convert the response into a proper soap response object ...
45 | // TODO: Callback for the response creation
46 | // TODO: Callback for the request creation
47 | },
48 | (scope requester)
49 | {
50 | import std.string : toLower;
51 |
52 | requester.contentType = "application/soap+xml; charset=" ~ envelope.xmlEncoding.toLower();
53 |
54 | if (soapAction && soapAction.length)
55 | {
56 | requester.headers["SOAPAction"] = soapAction;
57 | }
58 |
59 | requester.bodyWriter.write(envelope.toString);
60 | }
61 | );
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/web/soap/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | *
6 | * DO NOT USE THIS PACKAGE YET, IT'S UNFINISHED AND NOT STABLE.
7 | *
8 | */
9 | module diamond.web.soap;
10 |
11 | public
12 | {
13 | import diamond.web.soap.client;
14 | import diamond.web.soap.server;
15 | import diamond.web.soap.service;
16 | }
17 |
--------------------------------------------------------------------------------
/web/soap/server/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.server;
7 |
8 | public
9 | {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/web/soap/service/aliastype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.aliastype;
7 |
8 | import diamond.web.soap.service.soaptype;
9 | import diamond.web.soap.service.element;
10 |
11 | package(diamond.web.soap):
12 | /// Wrapper around an alias type.
13 | final class SoapAliasType : SoapType
14 | {
15 | private:
16 | string _aliasName;
17 |
18 | public:
19 | final:
20 | /**
21 | * Creates a new alias type.
22 | * Params:
23 | * name = The name of the complex type.
24 | * aliasType = The alias type.
25 | */
26 | this(string name, string aliasType)
27 | {
28 | super(name);
29 |
30 | _aliasName = aliasType;
31 | }
32 |
33 | @property
34 | {
35 | /// Gets the alias name of the type.
36 | string aliasName() { return _aliasName; }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/web/soap/service/attributes.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.attributes;
7 |
8 | /// Wrapper around a soap action.
9 | struct SoapAction
10 | {
11 | /// The url of the soap action.
12 | string url;
13 | }
14 |
15 | /// Wrapper around a soap operation.
16 | struct SoapOperation
17 | {
18 | /// The url of the soap operation;
19 | string url;
20 | }
21 |
--------------------------------------------------------------------------------
/web/soap/service/binding.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.binding;
7 |
8 | /// Wrapper around a soap binding.
9 | abstract class SoapBinding
10 | {
11 | /// Creates a new soap binding.
12 | protected this() { }
13 | }
14 |
--------------------------------------------------------------------------------
/web/soap/service/complextype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.complextype;
7 |
8 | import diamond.web.soap.service.soaptype;
9 | import diamond.web.soap.service.element;
10 |
11 | package(diamond.web.soap.service):
12 | /// Wrapper around a complex type.
13 | final class SoapComplexType : SoapType
14 | {
15 | private:
16 | /// The elements of the type.
17 | SoapElement[] _elements;
18 |
19 | public:
20 | final:
21 | /**
22 | * Creates a new complex type.
23 | * Params:
24 | * name = The name of the complex type.
25 | */
26 | this(string name)
27 | {
28 | super(name);
29 | }
30 |
31 | @property
32 | {
33 | /// Gets the elements of the complex type.
34 | SoapElement[] elements() { return _elements; }
35 | }
36 |
37 | /**
38 | * Adds an element to the complex type.
39 | * Params:
40 | * element = The element to add.
41 | */
42 | void addElement(SoapElement element)
43 | {
44 | _elements ~= element;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/web/soap/service/element.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.element;
7 |
8 | import diamond.web.soap.service.soaptype;
9 |
10 | package(diamond.web.soap.service):
11 | /// Wrapper around a soap element.
12 | final class SoapElement : SoapType
13 | {
14 | private:
15 | /// The type.
16 | string _type;
17 |
18 | public:
19 | final:
20 | /**
21 | * Creates a new soap element.
22 | * Params:
23 | * name = The name.
24 | * type = The type.
25 | */
26 | this(string name, string type)
27 | {
28 | super(name);
29 |
30 | _type = type;
31 | }
32 |
33 | @property
34 | {
35 | /// Gets the type of the element.
36 | string type() { return _type; }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/web/soap/service/envelopetype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.envelopetype;
7 |
8 | /// Wrapper around a soap envelope type.
9 | abstract class SoapEnvelopeType
10 | {
11 | /// Creates a new soap envelope type.
12 | protected this() { }
13 | }
14 |
--------------------------------------------------------------------------------
/web/soap/service/loader.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.loader;
7 |
8 | /**
9 | * Loads soap definitions from a wsdl file.
10 | * The wsdl file can be a physical file or a remote url.
11 | * Params:
12 | * name = The name of the soap service.
13 | * wsdl = The path to the wsdl.
14 | * moduleName = The name of the resulting service module.
15 | */
16 | package(diamond) void loadSoapDefinition(string name, string wsdl, string moduleName)
17 | {
18 | auto originalWsdl = wsdl;
19 |
20 | import std.file : readText, exists;
21 |
22 | import diamond.security.validation.url : isValidUrl;
23 | import diamond.dom;
24 | import diamond.xml;
25 | import diamond.web.soap.service.parser;
26 | import diamond.errors.exceptions;
27 |
28 | if (isValidUrl(originalWsdl))
29 | {
30 | import std.net.curl : get;
31 |
32 | wsdl = cast(string)get(originalWsdl);
33 | }
34 | else if (exists(originalWsdl))
35 | {
36 | wsdl = readText(originalWsdl);
37 | }
38 | else
39 | {
40 | throw new SoapException("The wsdl file was not found remote or locally.");
41 | }
42 |
43 | auto document = parseDom!XmlDocument(wsdl, new XmlParserSettings);
44 |
45 | if (document.root.name != "definitions" && document.root.name != "wsdl:definitions" && document.root.name != "xs:definitions" && document.root.name != "xsd:definitions")
46 | {
47 | throw new SoapException("The wsdl file does not contain 'definitions' as root element.");
48 | }
49 |
50 | parseWsdl(name, originalWsdl, document, moduleName);
51 | }
52 |
--------------------------------------------------------------------------------
/web/soap/service/message.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.message;
7 |
8 | import diamond.web.soap.service.parameter;
9 |
10 | package(diamond.web.soap.service):
11 | /// Wrapper around a soap message.
12 | final class SoapMessage
13 | {
14 | private:
15 | /// The input name.
16 | string _inputName;
17 | /// The output name.
18 | string _outputName;
19 | /// The input parameters.
20 | SoapParameter[] _inputParameters;
21 | /// The output parameter.
22 | SoapParameter _outputParameter;
23 |
24 | public:
25 | final:
26 | /**
27 | * Creates a new soap message.
28 | * Params:
29 | * inputName = The name of the input mesage.
30 | * outputName = The name of the output message.
31 | */
32 | this(string inputName, string outputName)
33 | {
34 | _inputName = inputName;
35 | _outputName = outputName;
36 | }
37 |
38 | /**
39 | * Adds an input parameter to the message.
40 | * Params:
41 | * name = The name of the input parameter.
42 | * type = The type of the input parameter.
43 | */
44 | void addInputParameter(string name, string type)
45 | {
46 | _inputParameters ~= new SoapParameter(name, type);
47 | }
48 |
49 | @property
50 | {
51 | /// Gets the input name.
52 | string inputName() { return _inputName; }
53 |
54 | /// Gets the output name.
55 | string outputName() { return _outputName; }
56 |
57 | /// Gets the input parameters.
58 | SoapParameter[] input() { return _inputParameters; }
59 |
60 | /// Gets the output parameter.
61 | SoapParameter output() { return _outputParameter; }
62 |
63 | /// Sets the output parameter.
64 | void output(SoapParameter newOutput)
65 | {
66 | _outputParameter = newOutput;
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/web/soap/service/messageoperation.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.messageoperation;
7 |
8 | import diamond.web.soap.service.parameter;
9 |
10 | package(diamond.web.soap.service):
11 | /// Wrapper around a soap message operation.
12 | final class SoapMessageOperation
13 | {
14 | private:
15 | string _action;
16 | string _name;
17 | string _returnType;
18 | string _parameters;
19 |
20 | public:
21 | final:
22 | /**
23 | * Creates a new soap message.
24 | * Params:
25 | * action = The action.
26 | * name = The name.
27 | * returnType = The return type.
28 | * parameters = The parameters.
29 | */
30 | this(string action, string name, string returnType, string parameters)
31 | {
32 | _action = action;
33 | _name = name;
34 | _returnType = returnType;
35 | _parameters = parameters;
36 | }
37 |
38 | @property
39 | {
40 | /// Gets the action.
41 | string action() { return _action; }
42 |
43 | /// Gets the name.
44 | string name() { return _name; }
45 |
46 | /// Gets the return type.
47 | string returnType() { return _returnType; }
48 |
49 | /// Gets the parameters.
50 | string parameters() { return _parameters; }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/web/soap/service/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service;
7 |
8 | public
9 | {
10 | import diamond.web.soap.service.loader;
11 | import diamond.web.soap.service.parser;
12 | import diamond.web.soap.service.complextype;
13 | import diamond.web.soap.service.element;
14 | import diamond.web.soap.service.simpletype;
15 | import diamond.web.soap.service.envelopetype;
16 | import diamond.web.soap.service.aliastype;
17 | import diamond.web.soap.service.message;
18 | import diamond.web.soap.service.parameter;
19 | import diamond.web.soap.service.binding;
20 | import diamond.web.soap.service.messageoperation;
21 | import diamond.web.soap.service.attributes;
22 | }
23 |
--------------------------------------------------------------------------------
/web/soap/service/parameter.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.parameter;
7 |
8 | package(diamond.web.soap.service):
9 | /// Wrapper around a soap parameter.
10 | final class SoapParameter
11 | {
12 | private:
13 | /// The name.
14 | string _name;
15 | /// The type.
16 | string _type;
17 |
18 | public:
19 | final:
20 | /**
21 | * Creates a new soap parameter.
22 | * Params:
23 | * name = The name.
24 | * type = The type.
25 | */
26 | this(string name, string type)
27 | {
28 | _name = name;
29 | _type = type;
30 | }
31 |
32 | @property
33 | {
34 | /// Gets the name.
35 | string name() { return _name; }
36 |
37 | /// Gets the type.
38 | string type() { return _type; }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/web/soap/service/parser/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.parser;
7 |
8 | public
9 | {
10 | import diamond.web.soap.service.parser.wsdlparser;
11 | import diamond.web.soap.service.parser.typeparser;
12 | import diamond.web.soap.service.parser.messageparser;
13 | import diamond.web.soap.service.parser.porttypeparser;
14 | import diamond.web.soap.service.parser.bindingparser;
15 | import diamond.web.soap.service.parser.serviceparser;
16 | }
17 |
--------------------------------------------------------------------------------
/web/soap/service/parser/serviceparser.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.parser.serviceparser;
7 |
8 | import std.array : split;
9 | import std.string : format;
10 |
11 | import diamond.dom;
12 | import diamond.xml;
13 |
14 | package(diamond.web.soap.service.parser):
15 | /**
16 | * Parses the services of the wsdl file.
17 | * Params:
18 | * root = The root node of the wsdl file.
19 | */
20 | string parseServices(XmlNode root)
21 | {
22 | auto services = root.getByTagName("wsdl:service");
23 |
24 | if (!services || !services.length)
25 | {
26 | services = root.getByTagName("xs:service");
27 | }
28 |
29 | if (!services || !services.length)
30 | {
31 | services = root.getByTagName("xsd:service");
32 | }
33 |
34 | if (!services || !services.length)
35 | {
36 | services = root.getByTagName("soap:service");
37 | }
38 |
39 | if (!services || !services.length)
40 | {
41 | services = root.getByTagName("service");
42 | }
43 |
44 | auto result = q{
45 | private static immutable(string[string]) __services;
46 |
47 | static this()
48 | {
49 | %s
50 | }
51 | };
52 |
53 | string endpoints = "";
54 |
55 | foreach (service; services)
56 | {
57 | auto ports = service.getByTagName("wsdl:port");
58 |
59 | if (!ports || !ports.length)
60 | {
61 | ports = service.getByTagName("xs:port");
62 | }
63 |
64 | if (!ports || !ports.length)
65 | {
66 | ports = service.getByTagName("xsd:port");
67 | }
68 |
69 | if (!ports || !ports.length)
70 | {
71 | ports = service.getByTagName("port");
72 | }
73 |
74 | if (!ports || !ports.length)
75 | {
76 | ports = service.getByTagName("soap:port");
77 | }
78 |
79 | foreach (port; ports)
80 | {
81 | auto bindingAttribute = port.getAttribute("binding");
82 | auto binding = bindingAttribute.value.split(":").length == 2 ? bindingAttribute.value.split(":")[1] : bindingAttribute.value;
83 |
84 | auto locations = port.getByAttributeName("location");
85 |
86 | if (locations && locations.length)
87 | {
88 | endpoints ~= "\t__services[\"" ~ binding ~ "\"] = \"" ~ locations[0].getAttribute("location").value ~ "\";\r\n";
89 | }
90 | }
91 | }
92 |
93 | return result.format(endpoints);
94 | }
95 |
--------------------------------------------------------------------------------
/web/soap/service/simpletype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.simpletype;
7 |
8 | import diamond.web.soap.service.soaptype;
9 |
10 | package(diamond.web.soap.service):
11 | /// Enumeration of simple type definitions.
12 | enum SoapSimpleTypeDefinition
13 | {
14 | /// A restricted simple type.
15 | restriction,
16 | /// A list.
17 | list
18 | }
19 |
20 | /// Wrapper around a simple type.
21 | final class SoapSimpleType : SoapType
22 | {
23 | private:
24 | /// The type name.
25 | string _typeName;
26 | /// The definition.
27 | SoapSimpleTypeDefinition _definition;
28 |
29 | public:
30 | final:
31 | /**
32 | * Creates a new simple type.
33 | * Params:
34 | * name = The name.
35 | * typeName = The type name.
36 | * definition = The definition.
37 | */
38 | this(string name, string typeName, SoapSimpleTypeDefinition definition)
39 | {
40 | super(name);
41 |
42 | _typeName = typeName;
43 | _definition = definition;
44 | }
45 |
46 | @property
47 | {
48 | /// Gets the type name.
49 | string typeName() { return _typeName; }
50 |
51 | /// Gets the definition.
52 | SoapSimpleTypeDefinition definition() { return _definition; }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/web/soap/service/soaptype.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.web.soap.service.soaptype;
7 |
8 | package(diamond.web.soap.service):
9 | /// Wrapper around a soap type.
10 | abstract class SoapType
11 | {
12 | private:
13 | /// The name.
14 | string _name;
15 |
16 | /**
17 | * Creates a new soap type.
18 | * Params:
19 | * name = The name of the soap type.
20 | */
21 | protected this(string name)
22 | {
23 | _name = name;
24 | }
25 |
26 | public:
27 | final
28 | {
29 | /// Gets the name of the soap type.
30 | string name() { return _name; }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/xhtml/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xhtml;
7 |
8 | public
9 | {
10 | import diamond.xhtml.xhtmldocument;
11 | import diamond.xhtml.xhtmlexception;
12 | import diamond.xhtml.xhtmlnode;
13 | import diamond.xhtml.xhtmlparsersettings;
14 | }
15 |
--------------------------------------------------------------------------------
/xhtml/xhtmlexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xhtml.xhtmlexception;
7 |
8 | public import diamond.errors.exceptions.xhtmlexception;
9 |
--------------------------------------------------------------------------------
/xhtml/xhtmlnode.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xhtml.xhtmlnode;
7 |
8 | import diamond.dom.domnode;
9 |
10 | /// Alias to an xhtml node.
11 | public alias XHtmlNode = DomNode;
12 |
--------------------------------------------------------------------------------
/xhtml/xhtmlparsersettings.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xhtml.xhtmlparsersettings;
7 |
8 | import diamond.dom.domparsersettings;
9 |
10 | /// Wrapper around xhtml parser settings.
11 | final class XHtmlParserSettings : DomParserSettings
12 | {
13 | public:
14 | final:
15 | /// Creates a new xhtml parser settings:
16 | this() @safe
17 | {
18 | super
19 | (
20 | false, // XHtml is not strict
21 | // Tags that can contain flexible content.
22 | ["script", "pre", "code", "style"],
23 | // XHtml does not allow self-closing tags.
24 | false,
25 | // XHtml has no self-closing tags.
26 | null,
27 | // Standard tags are not relevant without self-closing tags.
28 | null,
29 | // XHtml documents cannot be repaired.
30 | null, null
31 | );
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/xml/package.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xml;
7 |
8 | public
9 | {
10 | import diamond.xml.xmldocument;
11 | import diamond.xml.xmlexception;
12 | import diamond.xml.xmlnode;
13 | import diamond.xml.xmlparsersettings;
14 | }
15 |
--------------------------------------------------------------------------------
/xml/xmlexception.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xml.xmlexception;
7 |
8 | public import diamond.errors.exceptions.xmlexception;
9 |
--------------------------------------------------------------------------------
/xml/xmlnode.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xml.xmlnode;
7 |
8 | import diamond.dom.domnode;
9 |
10 | /// Alias to an xml node.
11 | public alias XmlNode = DomNode;
12 |
--------------------------------------------------------------------------------
/xml/xmlparsersettings.d:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright © DiamondMVC 2019
3 | * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 | * Author: Jacob Jensen (bausshf)
5 | */
6 | module diamond.xml.xmlparsersettings;
7 |
8 | import diamond.dom.domparsersettings;
9 |
10 | /// Wrapper around xml parser settings.
11 | final class XmlParserSettings : DomParserSettings
12 | {
13 | public:
14 | final:
15 | /// Creates a new xml parser settings.
16 | this() @safe
17 | {
18 | // Xml is strict, has no flexible tags, allows no self-closing tags, has no standard tags and cannot be repaired.
19 | super(true, null, false, null, null, null, null);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------