Permalink
Browse files

refactoring database for new headless CMS project

  • Loading branch information...
markentingh committed Sep 1, 2017
1 parent a502bfd commit 0d0a40b0849efce56f235a786f1e57eff3510bb3
Showing with 274 additions and 1,138 deletions.
  1. BIN .vs/Websilk/v15/sqlite3/storage.ide
  2. +21 −30 App/Core.cs
  3. +19 −22 App/Dashboard/Dashboard.cs
  4. +27 −39 App/Dashboard/Pages/Pages.cs
  5. +2 −1 App/Page.cs
  6. +0 −1 App/Pipeline/WebService.cs
  7. +4 −6 App/Startup.cs
  8. +28 −12 App/User.cs
  9. +1 −1 App/Websilk.csproj
  10. +1 −0 Query/Query.csproj
  11. +3 −0 Query/Query/Security.cs
  12. +3 −0 Query/Query/Users.cs
  13. +7 −5 Query/QuerySql.cs
  14. +9 −13 Query/Sql.cs
  15. +0 −7 Sql/SqlServer/PostDeployment.sql
  16. +73 −0 Sql/SqlServer/Sql.refactorlog
  17. +11 −54 Sql/SqlServer/Sql.sqlproj
  18. +0 −6 Sql/SqlServer/dbo/Sequences/SequencePages.sql
  19. +6 −6 Sql/SqlServer/dbo/Sequences/{SequenceBlock.sql → SequenceSecurityGroups.sql}
  20. +0 −12 Sql/SqlServer/dbo/Stored Procedures/Blocks/Block_Create.sql
  21. +0 −5 Sql/SqlServer/dbo/Stored Procedures/Blocks/Block_Exists.sql
  22. +0 −4 Sql/SqlServer/dbo/Stored Procedures/Blocks/Block_Get.sql
  23. +0 −7 Sql/SqlServer/dbo/Stored Procedures/Blocks/Blocks_GetList.sql
  24. +0 −9 Sql/SqlServer/dbo/Stored Procedures/Blocks/History/Block_History_Create.sql
  25. +0 −20 Sql/SqlServer/dbo/Stored Procedures/Components/Component_Categories_GetList.sql
  26. +0 −19 Sql/SqlServer/dbo/Stored Procedures/Components/Components_GetList.sql
  27. +0 −6 Sql/SqlServer/dbo/Stored Procedures/Documentation/Documentation_Create.sql
  28. +0 −3 Sql/SqlServer/dbo/Stored Procedures/Documentation/Documentation_GetList.sql
  29. +0 −22 Sql/SqlServer/dbo/Stored Procedures/Documentation/Documentation_Search.sql
  30. +0 −5 Sql/SqlServer/dbo/Stored Procedures/Documentation/Documentation_Update.sql
  31. +0 −169 Sql/SqlServer/dbo/Stored Procedures/Log/Log_GetAnalytics.sql
  32. +0 −42 Sql/SqlServer/dbo/Stored Procedures/Log/Log_Request_Create.sql
  33. +0 −20 Sql/SqlServer/dbo/Stored Procedures/Log/Log_Results_GetSqlQueries.sql
  34. +0 −9 Sql/SqlServer/dbo/Stored Procedures/Pages/History/Page_History_Create.sql
  35. +0 −18 Sql/SqlServer/dbo/Stored Procedures/Pages/History/Pages_History_GetList.sql
  36. +0 −44 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Create.sql
  37. +0 −9 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Delete.sql
  38. +0 −5 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_GetTitle.sql
  39. +0 −14 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Info_GetFromDomain.sql
  40. +0 −21 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Info_GetFromDomainAndTitle.sql
  41. +0 −23 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Info_GetFromPageId.sql
  42. +0 −21 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Info_GetFromSubDomainAndTitle.sql
  43. +0 −24 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Parents_GetList.sql
  44. +0 −18 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Publish.sql
  45. +0 −24 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_Update.sql
  46. +0 −5 Sql/SqlServer/dbo/Stored Procedures/Pages/Page_UpdateModified.sql
  47. +0 −34 Sql/SqlServer/dbo/Stored Procedures/Pages/Pages_GetList.sql
  48. +0 −7 Sql/SqlServer/dbo/Stored Procedures/Pages/Shadow/Pages_Shadow_Exists.sql
  49. +0 −7 Sql/SqlServer/dbo/Stored Procedures/Pages/Shadow/Pages_Shadow_GetList.sql
  50. +10 −0 Sql/SqlServer/dbo/Stored Procedures/Security/SecurityGroup_Create.sql
  51. +5 −0 Sql/SqlServer/dbo/Stored Procedures/Security/SecurityGroup_Delete.sql
  52. +4 −0 Sql/SqlServer/dbo/Stored Procedures/Security/SecurityGroup_Get.sql
  53. +4 −0 Sql/SqlServer/dbo/Stored Procedures/Security/SecurityGroup_GetList.sql
  54. +1 −1 Sql/SqlServer/dbo/Stored Procedures/Security/Security_Create.sql
  55. +1 −1 Sql/SqlServer/dbo/Stored Procedures/Security/Security_Update.sql
  56. +2 −40 Sql/SqlServer/dbo/Stored Procedures/Websites/Website_Create.sql
  57. +0 −14 Sql/SqlServer/dbo/Stored Procedures/Websites/Website_TransferOwnership.sql
  58. +0 −16 Sql/SqlServer/dbo/Tables/Applications.sql
  59. +0 −11 Sql/SqlServer/dbo/Tables/ApplicationsOwned.sql
  60. +0 −7 Sql/SqlServer/dbo/Tables/Blocks.sql
  61. +0 −7 Sql/SqlServer/dbo/Tables/Blocks_History.sql
  62. +0 −15 Sql/SqlServer/dbo/Tables/Components.sql
  63. +0 −6 Sql/SqlServer/dbo/Tables/Documentation.sql
  64. +0 −32 Sql/SqlServer/dbo/Tables/Log.sql
  65. +0 −49 Sql/SqlServer/dbo/Tables/LogAnalytics.sql
  66. +0 −39 Sql/SqlServer/dbo/Tables/Pages.sql
  67. +0 −7 Sql/SqlServer/dbo/Tables/Pages_History.sql
  68. +12 −0 Sql/SqlServer/dbo/Tables/Security.sql
  69. +7 −0 Sql/SqlServer/dbo/Tables/SecurityGroups.sql
  70. +13 −24 Sql/SqlServer/dbo/Tables/WebSites.sql
  71. +0 −14 Sql/SqlServer/dbo/Tables/WebsiteDomains.sql
  72. +0 −13 Sql/SqlServer/dbo/Tables/WebsiteSecurity.sql
  73. +0 −13 Sql/SqlServer/dbo/Tables/WebsiteSubDomains.sql
View
Binary file not shown.
View
@@ -1,26 +1,19 @@
using Microsoft.AspNetCore.Http;
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
namespace Websilk
{
public class Core
{
public Server Server;
public Utility.Util Util;
public Sql Sql;
public User User;
public UserSession User;
public HttpContext Context;
public HttpRequest Request;
public HttpResponse Response;
public ISession Session;
public bool isFirstLoad = false;
public WebResources javascript;
public WebResources javascriptFiles;
public WebResources css;
public WebResources cssFiles;
public WebResources html;
public WebResources htmlEditor;
private string _connString = "";
public Core(Server server, HttpContext context)
{
@@ -30,39 +23,37 @@ public Core(Server server, HttpContext context)
Request = context.Request;
Response = context.Response;
Session = context.Session;
Sql = new Sql(Server, Util);
User = new User();
javascript = new WebResources(this);
javascriptFiles = new WebResources(this);
css = new WebResources(this);
cssFiles = new WebResources(this);
html = new WebResources(this);
htmlEditor = new WebResources(this);
User = new UserSession();
//load user session
if (Session.Get("user") != null)
{
User = (User)Util.Serializer.ReadObject(Util.Str.GetString(Session.Get("user")), User.GetType());
User = (UserSession)Util.Serializer.ReadObject(Util.Str.GetString(Session.Get("user")), User.GetType());
}
User.Load(this);
User.Init(this);
}
public void Unload()
{
if(User.saveSession == true)
if (User.saveSession == true)
{
Session.Set("user", Util.Serializer.WriteObject(User));
}
Sql.Close();
}
public bool isSessionLost()
{
if(isFirstLoad == false && Session.Get("user") == null) {
return true;
public string SqlConnectionString{
get {
if(_connString == "")
{
var config = new ConfigurationBuilder()
.AddJsonFile(Server.MapPath("config.json"))
.Build();
var sqlActive = config.GetSection("Data:Active").Value;
_connString = config.GetSection("Data:" + sqlActive).Value;
}
return _connString;
}
return false;
}
}
View
@@ -19,11 +19,10 @@ public struct structMenuItem
public Dashboard(Core WebsilkCore): base(WebsilkCore){}
public override string Render(string path)
public override string Render(string[] path, string query)
{
//load the dashboard layout
var scaffold = new Scaffold(S, "/Dashboard/dashboard.html");
S.cssFiles.Add("dashboard", "/css/dashboard/dashboard.css");
var scaffMenu = new Scaffold(S, "/Dashboard/menu-item.html");
//load user profile
@@ -32,16 +31,16 @@ public override string Render(string path)
scaffold.Data["profile-name"] = S.User.displayName;
//load website info
var domains = page.getDomainsForWebsite();
var domain = "";
if(domains.Count > 0)
{
domain = domains[0].domain;
scaffold.Data["has-domain"] = "true";
scaffold.Data["website-name"] = page.websiteTitle;
scaffold.Data["website-url"] = "http://www." + domain;
scaffold.Data["website-url-name"] = "www." + domain;
}
//var domains = page.getDomainsForWebsite();
//var domain = "";
//if(domains.Count > 0)
//{
// domain = domains[0].domain;
// scaffold.Data["has-domain"] = "true";
// scaffold.Data["website-name"] = page.websiteTitle;
// scaffold.Data["website-url"] = "http://www." + domain;
// scaffold.Data["website-url-name"] = "www." + domain;
//}
//generate menu system
var menu = new StringBuilder();
@@ -94,20 +93,21 @@ private string LoadSubPage(string path)
Page service = null;
var html = "";
var paths = path.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
var subpath = paths.Skip(1).ToArray();
else if(paths[0] == "downloads") {
if (paths[0] == "downloads") {
service = new DashboardPages.Downloads(S);
html = service.Render(string.Join("/", paths.Skip(1).ToArray()));
html = service.Render(subpath);
}
else if (paths[0] == "pages")
{
service = new DashboardPages.Pages(S);
html = service.LoadSubPage(string.Join("/", paths.Skip(1).ToArray()));
html = service.Render(subpath);
}
else if (paths[0] == "photos")
{
service = new DashboardPages.Photos(S);
html = service.LoadSubPage(string.Join("/", paths.Skip(1).ToArray()));
html = service.Render(subpath);
}
else if (paths[0] == "settings")
{
@@ -116,22 +116,19 @@ private string LoadSubPage(string path)
if(paths[1] == "themes")
{
service = new DashboardPages.Settings.Themes(S);
html = service.LoadSubPage(string.Join("/", paths.Skip(2).ToArray()));
section = "settings-themes";
html = service.Render(paths.Skip(2).ToArray());
}
}
}
else if (paths[0] == "timeline")
{
service = new DashboardPages.Timeline(S);
html = service.LoadSubPage(string.Join("/", paths.Skip(1).ToArray()));
section = "timeline";
html = service.Render(subpath);
}
else if (paths[0] == "users")
{
service = new DashboardPages.Users(S);
html = service.LoadSubPage(string.Join("/", paths.Skip(1).ToArray()));
section = "users";
html = service.Render(subpath);
}
return html;
}
@@ -4,51 +4,39 @@
namespace Websilk.Pages.DashboardPages
{
public class Pages: StaticPage
public class Pages: Page
{
public Pages(Core WebsilkCore, Page page): base(WebsilkCore, page) { }
public Pages(Core WebsilkCore) : base(WebsilkCore)
{
}
public override Services.Inject LoadSubPage(string path)
public override string Render(string[] path, string query = "")
{
var inject = new Services.Inject();
if(path != "")
{
//load sub page
switch (path)
{
case "settings":
break;
}
}else
//load pages list
var scaffold = new Scaffold(S);
var servePage = new Services.Dashboard.Pages(S);
var websiteId = page.websiteId;
if (S.Request.Query.ContainsKey("websiteid")) { websiteId = int.Parse(S.Request.Query["websiteid"]); }
servePage.page = page;
scaffold = new Scaffold(S, "/Dashboard/Pages/pages.html");
scaffold.Data["page-list"] = servePage.View(websiteId, 0, 1, 1000, 4, 0, "");
scaffold.Data["page-create"] = S.Server.LoadFileFromCache("/Dashboard/Pages/create.html");
S.javascriptFiles.Add("dash-pages", "/js/dashboard/pages/pages.js");
S.javascript.Add("dash-pages", "S.dashboard.pages.init();");
//get list of available shadow templates
var reader = page.sql.GetShadowTemplatesForWebsite(page.websiteId);
var js = "S.dashboard.pages.shadow_templates = [";
var i = 0;
while (reader.Read())
{
//load pages list
var servePage = new Services.Dashboard.Pages(S);
var websiteId = page.websiteId;
if (S.Request.Query.ContainsKey("websiteid")) { websiteId = int.Parse(S.Request.Query["websiteid"]); }
servePage.page = page;
scaffold = new Scaffold(S, "/Dashboard/Pages/pages.html");
scaffold.Data["page-list"] = servePage.View(websiteId, 0, 1, 1000, 4, 0, "");
scaffold.Data["page-create"] = S.Server.LoadFileFromCache("/Dashboard/Pages/create.html");
S.javascriptFiles.Add("dash-pages", "/js/dashboard/pages/pages.js");
S.javascript.Add("dash-pages", "S.dashboard.pages.init();");
//get list of available shadow templates
var reader = page.sql.GetShadowTemplatesForWebsite(page.websiteId);
var js = "S.dashboard.pages.shadow_templates = [";
var i = 0;
while (reader.Read())
{
if(i > 0) { js += ","; }
js += "{id:" + reader.GetInt("pageId").ToString() + ", title:'" + reader.Get("title").Replace("'", "\\'") + "', url:'/" + reader.Get("path").Replace(" ", "-") + "'}";
i++;
}
js += "];";
S.javascript.Add("dash-page-shadows", js);
if(i > 0) { js += ","; }
js += "{id:" + reader.GetInt("pageId").ToString() + ", title:'" + reader.Get("title").Replace("'", "\\'") + "', url:'/" + reader.Get("path").Replace(" ", "-") + "'}";
i++;
}
inject.html = scaffold.Render();
return inject;
js += "];";
return scaffold.Render();
}
}
}
View
@@ -6,13 +6,14 @@ public class Page
{
public Core S;
public string websiteId;
public Page(Core WebsilkCore)
{
S = WebsilkCore;
}
public virtual string Render(string[] path, string query)
public virtual string Render(string[] path, string query = "")
{
return "";
}
@@ -3,7 +3,6 @@
using System.IO;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
View
@@ -7,25 +7,23 @@
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Chroniton;
namespace Websilk
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
//set up server-side memory cache
services.AddDistributedMemoryCache();
services.AddMemoryCache();
services.AddSession(opts =>
{
//set up cookie expiration
opts.CookieName = "Websilk";
opts.Cookie.Name = "Websilk";
opts.IdleTimeout = TimeSpan.FromMinutes(60);
});
//add server-side scheduler service (like CRON jobs)
services.AddSingleton<ISingularity, Singularity>(serviceProvider => Singularity.Instance);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
Oops, something went wrong.

0 comments on commit 0d0a40b

Please sign in to comment.