Skip to content

Commit

Permalink
Initial Source Commit
Browse files Browse the repository at this point in the history
This is the initial source commit
  • Loading branch information
bausshf committed Mar 5, 2018
1 parent 54cb9d4 commit d827b02
Show file tree
Hide file tree
Showing 141 changed files with 15,869 additions and 0 deletions.
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "webd",
"description": "Open-source & Free CMS/E-commerce/Intranet System based on Diamond MVC.",
"authors": [
"Jacob Jensen"
],
"license": "The MIT License (MIT)",
"copyright": "Copyright © 2018 Jacob Jensen",
"targetType": "sourceLibrary",
"sourcePaths": [
"src"
]
}
50 changes: 50 additions & 0 deletions src/core/config.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module webd.core.config;

import vibe.data.serialization : optional;

/// Webd configurations.
class WebdConfig
{
/// The name of the website.
string websiteName;

/// The root path of the website.
@optional string rootPath;

/// The language.
@optional string language;
}

/// The webd configuration.
private static __gshared WebdConfig _webdConfig;

/// Gets the webd configuration.
@property WebdConfig webdConfig() { return _webdConfig; }

/// Loads the webd configuration.
void loadWebdConfig()
{
import vibe.d : deserializeJson;
import std.file : readText;

_webdConfig = deserializeJson!WebdConfig(readText("config/webd.json"));

import std.file : thisExePath;
import std.path : dirName, absolutePath;

if (!_webdConfig.rootPath)
{
_webdConfig.rootPath = absolutePath(dirName(thisExePath));
}

import webd.dal;
auto website = getWebsite(_webdConfig.websiteName);

if (website)
{
if (!_webdConfig.language)
{
_webdConfig.language = website.language;
}
}
}
6 changes: 6 additions & 0 deletions src/core/package.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module webd.core;

public
{
import webd.core.config;
}
15 changes: 15 additions & 0 deletions src/dal/modules.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module webd.dal.modules;

import diamond.database;

import webd.models.database;

auto getModule(ulong id)
{
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `deleted` = '0' LIMIT 1";

auto params = getParams();
params["id"] = id;

return MySql.readSingle!WebdModule(sql, params);
}
11 changes: 11 additions & 0 deletions src/dal/package.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module webd.dal;

public
{
import webd.dal.websites;
import webd.dal.webpages;
import webd.dal.webitems;
import webd.dal.webparagraphs;
import webd.dal.webitemlists;
import webd.dal.modules;
}
15 changes: 15 additions & 0 deletions src/dal/webitemlists.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module webd.dal.webitemlists;

import diamond.database;

import webd.models.database;

auto getItemList(ulong id)
{
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `deleted` = '0' LIMIT 1";

auto params = getParams();
params["id"] = id;

return MySql.readSingle!WebdWebItemList(sql, params);
}
36 changes: 36 additions & 0 deletions src/dal/webitems.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module webd.dal.webitems;

import diamond.database;

import webd.models.database;

auto getItem(ulong id)
{
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `disabled` = '0' AND `deleted` = '0' LIMIT 1";

auto params = getParams();
params["id"] = id;

return MySql.readSingle!WebdWebItem(sql, params);
}

auto getItemValues(ulong itemId)
{
static const sql = "SELECT * FROM @table WHERE `itemId` = @itemId AND `parentValue` IS NULL AND `deleted` = '0'";

auto params = getParams();
params["itemId"] = itemId;

return MySql.readMany!WebdWebItemEntry(sql, params);
}

auto getItemValues(ulong itemId, ulong parentValue)
{
static const sql = "SELECT * FROM @table WHERE `itemId` = @itemId AND `parentValue` = @parentValue AND `deleted` = '0'";

auto params = getParams();
params["itemId"] = itemId;
params["parentValue"] = parentValue;

return MySql.readMany!WebdWebItemEntry(sql, params);
}
67 changes: 67 additions & 0 deletions src/dal/webpages.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module webd.dal.webpages;

import diamond.database;

import webd.models.database;

auto getWebPage(string name)
{
static const sql = "SELECT * FROM @table WHERE `name` = @name AND `published` = '1' AND `deleted` = '0' LIMIT 1";

auto params = getParams();
params["name"] = name;

return MySql.readSingle!WebdWebPage(sql, params);
}

auto getWebPageFromRoute(string route)
{
static const sql = "SELECT * FROM @table WHERE `route` = @route AND `published` = '1' AND `deleted` = '0' LIMIT 1";

auto params = getParams();
params["route"] = route;

return MySql.readSingle!WebdWebPage(sql, params);
}

auto getWebPage(ulong id)
{
static const sql = "SELECT * FROM @table WHERE `id` = @id AND `published` = '1' AND `deleted` = '0' LIMIT 1";

auto params = getParams();
params["id"] = id;

return MySql.readSingle!WebdWebPage(sql, params);
}

auto getAllWebPages()
{
static const sql = "SELECT * FROM @table WHERE `published` = '1' AND `deleted` = '0' ORDER BY `id` DESC";

return MySql.readMany!WebdWebPage(sql, null);
}

WebdWebPage[] getAllSubWebPages(ulong parentPageId)
{
static const sql = "SELECT * FROM @table WHERE `parentPage` = @parentPage AND `published` = '1' AND `deleted` = '0' ORDER BY `id` DESC";
auto params = getParams();
params["parentPage"] = parentPageId;

import std.array : array;

auto result = MySql.readMany!WebdWebPage(sql, params).array;

foreach (page; result)
{
result ~= getAllSubWebPages(page.id);
}

return result;
}

auto getAllDeletedWebPages()
{
static const sql = "SELECT * FROM @table WHERE `deleted` = '1' ORDER BY `id` DESC";

return MySql.readMany!WebdWebPage(sql, null);
}
15 changes: 15 additions & 0 deletions src/dal/webparagraphs.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module webd.dal.webparagraphs;

import diamond.database;

import webd.models.database;

auto getParagraphs(ulong pageId)
{
static const sql = "SELECT * FROM @table WHERE `pageId` = @pageId AND `disabled` = '0' AND `deleted` = '0'";

auto params = getParams();
params["pageId"] = pageId;

return MySql.readMany!WebdWebParagraph(sql, params);
}
32 changes: 32 additions & 0 deletions src/dal/websites.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module webd.dal.websites;

import diamond.database;

import webd.models.database;

auto getWebsite(string name)
{
static const sql = "SELECT * FROM @table WHERE `name` = @name LIMIT 1";

auto params = getParams();
params["name"] = name;

return MySql.readSingle!WebdWebsite(sql, params);
}

auto getWebsite(ulong id)
{
static const sql = "SELECT * FROM @table WHERE `id` = @id LIMIT 1";

auto params = getParams();
params["id"] = id;

return MySql.readSingle!WebdWebsite(sql, params);
}

auto getAllWebsites()
{
static const sql = "SELECT * FROM @table WHERE ORDER BY `id` DESC";

return MySql.readMany!WebdWebsite(sql, null);
}
6 changes: 6 additions & 0 deletions src/extensions/package.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module webd.extensions;

public
{
import webd.extensions.view;
}
Loading

0 comments on commit d827b02

Please sign in to comment.