-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the initial source commit
- Loading branch information
Showing
141 changed files
with
15,869 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module webd.core; | ||
|
||
public | ||
{ | ||
import webd.core.config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module webd.extensions; | ||
|
||
public | ||
{ | ||
import webd.extensions.view; | ||
} |
Oops, something went wrong.