Skip to content

Commit

Permalink
updated Query project to use CoreQuery submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
markentingh committed May 28, 2018
1 parent 9592aab commit 559c290
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 188 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -10,3 +10,6 @@
[submodule "App/Scripts/utility/launchpad"]
path = App/Scripts/utility/launchpad
url = http://github.com/datasilk/launchpad
[submodule "Query/Core"]
path = Query/Core
url = https://github.com/datasilk/corequery
25 changes: 13 additions & 12 deletions App/Common/Platform/Website.cs
Expand Up @@ -156,21 +156,16 @@ public static void SaveFile(string path, string content)
}

//process saved files
var pubdir = "/wwwroot/content/pages/" + string.Join("/", paths.Skip(1)).Replace(file, "");
if (pubdir[pubdir.Length - 1] != '/') { pubdir += "/"; }

if (paths[0].ToLower() == "/content/pages")
{
var pubdir = "/wwwroot/content/pages/" + string.Join("/", paths.Skip(1)).Replace(file, "");
if(pubdir[pubdir.Length - 1] != '/') { pubdir += "/"; }
switch (ext)
//create public folder in wwwroot
if (!Directory.Exists(Server.MapPath(pubdir)))
{
case "js": case "css": case "less":
//create public folder in wwwroot
if (!Directory.Exists(Server.MapPath(pubdir)))
{
Directory.CreateDirectory(Server.MapPath(pubdir));
}
break;
Directory.CreateDirectory(Server.MapPath(pubdir));
}

switch (ext)
{
case "js": case "css":
Expand Down Expand Up @@ -212,8 +207,14 @@ public static void SaveFile(string path, string content)
{
if(ext == "js")
{
pubdir = "/wwwroot/js/" + string.Join("/", paths.Skip(1)).Replace(file, "");
if (pubdir[pubdir.Length - 1] != '/') { pubdir += "/"; }
//create public folder in wwwroot
if (!Directory.Exists(Server.MapPath(pubdir)))
{
Directory.CreateDirectory(Server.MapPath(pubdir));
}
//copy javascript files from /Scripts to /wwwroot/js
var pubdir = "/wwwroot/js/" + string.Join("/", paths.Skip(1)).Replace(file, "");
File.Copy(Server.MapPath(filepath), Server.MapPath(pubdir + file), true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion App/Scripts/platform
Submodule platform updated 1 files
+2 −1 util.js
2 changes: 1 addition & 1 deletion App/Startup.cs
Expand Up @@ -11,7 +11,7 @@ public class Startup : Datasilk.Startup {
public override void Configured(IApplicationBuilder app, IHostingEnvironment env, IConfigurationRoot config)
{
base.Configured(app, env, config);
Saber.Query.QuerySql.connectionString = server.sqlConnectionString;
Query.QuerySql.connectionString = server.sqlConnectionString;
var query = new Saber.Query.Users();
var resetPass = query.HasPasswords();
server.hasAdmin = query.HasAdmin();
Expand Down
57 changes: 39 additions & 18 deletions App/Views/Editor/editor.js
Expand Up @@ -2,6 +2,7 @@ S.editor = {
type: 0, //0 = Monaco, 1 = Ace
instance: null,
sessions: {},
viewstates: {},
selected: '',
path: '',
theme: 'dark',
Expand Down Expand Up @@ -506,8 +507,12 @@ S.editor = {
require(['vs/editor/editor.main'], function () {
var session = monaco.editor.createModel(code, mode);
S.editor.sessions[id] = session;

S.editor.viewstates[id] = null;
if (S.editor.selected != '') {
S.editor.sessions.saveViewState(S.editor.fileId(S.editor.selected));
}
if (select !== false) {
S.editor.instance.saveViewState();
S.editor.instance.setModel(session);
S.editor.filebar.code.show();
S.editor.codebar.update();
Expand Down Expand Up @@ -539,6 +544,25 @@ S.editor = {
remove: function (id) {
S.editor.sessions[id].destroy();
delete S.editor.sessions[id];
},

saveViewState(id) {
//save previous viewstate
switch (S.editor.type) {
case 0: //monaco
S.editor.viewstates[id] = S.editor.instance.saveViewState();
break;
}
},

restoreViewState(id) {
if (S.editor.viewstates[id]) {
switch (S.editor.type) {
case 0: //monaco
S.editor.instance.restoreViewState(S.editor.viewstates[id]);
break;
}
}
}
},

Expand Down Expand Up @@ -682,6 +706,10 @@ S.editor = {
open: function (path, code, isready, callback) {
//opens a resource that exists on the server
var id = S.editor.fileId(path);
var prevId = '';
if (S.editor.selected != '') {
prevId = S.editor.fileId(S.editor.selected);
}

if (isready !== false) {
//update selected session
Expand Down Expand Up @@ -785,7 +813,14 @@ S.editor = {
S.editor.filebar.code.show();
switch (S.editor.type) {
case 0: //monaco
//save viewstate for currently viewed session
S.editor.sessions.saveViewState(prevId);

//load selected session
editor.setModel(session);

//restore viewstate for selected session
S.editor.sessions.restoreViewState(id);
editor.focus();
break;
case 1: //ace
Expand Down Expand Up @@ -962,9 +997,8 @@ S.editor = {
);
} else if (S.editor.files.js.changed == true) {
changeJs();
} else {
showContent();
}
showContent();

//update Rhino browser window (if applicable)
if (S.editor.Rhino) {
Expand All @@ -976,23 +1010,10 @@ S.editor = {
$('#website_js').remove();
S.util.js.load('/js/website.js' + '?r=' + rnd, 'website_js',
function () {
if (S.editor.files.js.changed == true) {
if (S.editor.files.js.changed == true || htmlChanged == true) {
S.editor.files.js.changed = false;
tagjs.remove();
S.util.js.load(src + '?r=' + rnd, 'page_js',
function () { showContent(); }
);
} else {
if (htmlChanged === true) {
//reload javascript anyway since HTML changed
tagjs.remove();
S.util.js.load(src, 'page_js',
function () { showContent(); }
);
} else {
//no need to reload Js, HTML didn't change
showContent();
}
S.util.js.load(src + '?r=' + rnd, 'page_js');
}
}
);
Expand Down
2 changes: 1 addition & 1 deletion App/Views/Editor/editor.less
Expand Up @@ -26,7 +26,7 @@
}

/* editor tab (in preview mode) */
.editor-tab{position:fixed; bottom:8px; right:15px; transition:opacity 0.4s;
.editor-tab{position:fixed; bottom:8px; right:15px; transition:opacity 0.4s; z-index:1000;
.col.icon{opacity:0.4;}
.row:hover .col.icon{opacity:1;}
& > .bg{border-radius:30px; box-shadow: 4px 4px 30px 0px rgba(0, 0, 0, 0.2); overflow:hidden;
Expand Down
2 changes: 1 addition & 1 deletion App/Views/Shared/layout.html
Expand Up @@ -38,7 +38,7 @@
</script>
<script src="/js/platform.js"></script>
{{/platform-3}}
{{scripts}}
<script src="/js/website.js" id="website_js"></script>
{{scripts}}
</body>
</html>
1 change: 1 addition & 0 deletions Query/Core
Submodule Core added at 571719
2 changes: 1 addition & 1 deletion Query/Query/Languages.cs
Expand Up @@ -2,7 +2,7 @@

namespace Saber.Query
{
public class Languages : QuerySql
public class Languages : global::Query.QuerySql
{
public Languages() { }

Expand Down
2 changes: 1 addition & 1 deletion Query/Query/PageTitles.cs
Expand Up @@ -2,7 +2,7 @@

namespace Saber.Query
{
public class PageTitles : QuerySql
public class PageTitles : global::Query.QuerySql
{
public PageTitles() { }

Expand Down
2 changes: 1 addition & 1 deletion Query/Query/Users.cs
Expand Up @@ -2,7 +2,7 @@

namespace Saber.Query
{
public class Users : QuerySql
public class Users : global::Query.QuerySql
{
public Users() { }

Expand Down
15 changes: 0 additions & 15 deletions Query/QuerySql.cs

This file was deleted.

136 changes: 0 additions & 136 deletions Query/Sql.cs

This file was deleted.

0 comments on commit 559c290

Please sign in to comment.