diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index 2d82459..e1baf9e 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -52,6 +52,20 @@ jobs: userName: '@job_token@' passwordSecret: dockersecret condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL + - !CommandStep + name: push to coolify + runInContainer: true + image: curlimages/curl:latest + interpreter: !DefaultInterpreter + commands: | + curl "$COOLIFY_WEBHOOK" -H "Authorization: Bearer $COOLIFY_TOKEN" + envVars: + - name: COOLIFY_WEBHOOK + value: '@secret:COOLIFY_WEBHOOK@' + - name: COOLIFY_TOKEN + value: '@secret:COOLIFY_TOKEN@' + useTTY: true + condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL triggers: - !DependencyFinishedTrigger projects: crosslang diff --git a/Templates/compiletool/cross.json b/Templates/compiletool/cross.json index 5b69738..7ab38ad 100644 --- a/Templates/compiletool/cross.json +++ b/Templates/compiletool/cross.json @@ -11,6 +11,7 @@ "template_info": { "type": "compile_tool" }, + "template_name_pretty": "Compile Tool", "template_ignored_files": ["bin","obj"], "description": "A tool that can be a dependency to a project (including libraries) that runs at compile time" } diff --git a/Templates/console/cross.json b/Templates/console/cross.json index dda2c32..4705dd9 100644 --- a/Templates/console/cross.json +++ b/Templates/console/cross.json @@ -11,6 +11,7 @@ "template_info": { "type": "console" }, + "template_name_pretty": "Console Application", "template_ignored_files": ["bin","obj"], "description": "A console application" } diff --git a/Templates/emptyweb/cross.json b/Templates/emptyweb/cross.json index 966ac81..74480bb 100644 --- a/Templates/emptyweb/cross.json +++ b/Templates/emptyweb/cross.json @@ -12,6 +12,7 @@ "template_info": { "type": "console" }, + "template_name_pretty": "Empty Website", "template_extra_text_ftles": [], "template_ignored_files": ["bin","obj"] } diff --git a/Templates/gui/res/layout.json b/Templates/gui/res/layout.json deleted file mode 100644 index eea4a62..0000000 --- a/Templates/gui/res/layout.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "Child": { - "Type": "AbsoluteView", - "Items": [ - { - "Bounds": { - "X": 42, - "Y": 42, - "Width": 200, - "Height": 50 - }, - "Type": "ButtonView", - "Text": "Click Me", - "Id": "btn1", - "Active": true - } - ] - }, - "Palette": { - "IsDarkMode": true, - "Accent": "#DB0", - "Border": "#040", - "BorderActive":"#A00", - "BorderHover": "#00A", - "BorderHoverActive": "#A0A", - "FontSize": 20 - }, - "Size": { - "Width": 640, - "Height": 480 - }, - "Text": "%PROJECT_NAME%" -} \ No newline at end of file diff --git a/Templates/gui/src/main.tcross b/Templates/gui/src/main.tcross deleted file mode 100644 index 87c79a2..0000000 --- a/Templates/gui/src/main.tcross +++ /dev/null @@ -1,18 +0,0 @@ -func btn1_Click(sender,e) -{ - Console.WriteLine("Button Clicked"); -} -func main(args) -{ - if(TypeOf(GUI) != "Dictionary") - { - Console.WriteLine("The GUI is not supported, please build tessesframework with TESSESFRAMEWORK_ENABLE_SDL2."); - return 1; - } - var window = GUI.Window.FromJSON(embed("layout.json"), SDL2.Window.Resizable); - var btn1 = window.FindViewById("btn1"); - btn1.Click += btn1_Click; - VM.RunEventLoop(); - btn.Click -= btn1_Click; - window.Dispose(); //we need to destroy it or it will leak -} diff --git a/Templates/lib/cross.json b/Templates/lib/cross.json index 6b53ba4..98f6a7b 100644 --- a/Templates/lib/cross.json +++ b/Templates/lib/cross.json @@ -12,6 +12,7 @@ "type": "lib" }, "template_ignored_files": ["bin","obj"], - "description": "A crosslang library" + "description": "A crosslang library", + "template_name_pretty": "Library" } } diff --git a/Templates/template/cross.json b/Templates/template/cross.json index d54dd42..396f9bb 100644 --- a/Templates/template/cross.json +++ b/Templates/template/cross.json @@ -21,6 +21,7 @@ }, "template_project_dependencies": [], "template_extra_text_ftles": [], - "template_ignored_files": ["bin","obj"] + "template_ignored_files": ["bin","obj"], + "template_name_pretty": "Template" } } diff --git a/Templates/tool/cross.json b/Templates/tool/cross.json index f08dd13..5a6ef1f 100644 --- a/Templates/tool/cross.json +++ b/Templates/tool/cross.json @@ -21,5 +21,6 @@ "license": "MIT" }, "version": "1.0.0.0-prod", - "name": "Tesses.CrossLang.Template.Tool" + "name": "Tesses.CrossLang.Template.Tool", + "template_name_pretty": "Tool" } \ No newline at end of file diff --git a/Templates/web/cross.json b/Templates/web/cross.json index 6125543..cedcdbc 100644 --- a/Templates/web/cross.json +++ b/Templates/web/cross.json @@ -13,5 +13,6 @@ "type": "console" }, "template_ignored_files": ["bin","obj"] - } + }, + "template_name_pretty": "WebSite" } diff --git a/Templates/gui/.crossarchiveignore b/Templates/webapp/.crossarchiveignore similarity index 100% rename from Templates/gui/.crossarchiveignore rename to Templates/webapp/.crossarchiveignore diff --git a/Templates/gui/cross.json b/Templates/webapp/cross.json similarity index 62% rename from Templates/gui/cross.json rename to Templates/webapp/cross.json index ba81d53..2f7c987 100644 --- a/Templates/gui/cross.json +++ b/Templates/webapp/cross.json @@ -2,25 +2,24 @@ "dependencies": [ ], "info": { - "template_extra_text_ftles": [ - "res/layout.json" - ], + "template_ignored_files": [ "bin", "obj" ], "template_info": { - "type": "app", + "type": "webapp", "license": "MIT" }, - "template_name": "gui", + "template_name": "webapp", + "template_name_pretty": "Web Application", "template_project_dependencies": [ ], "repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras", "homepage": "https://crosslang.tesseslanguage.com/", "type": "template", - "description": "A crosslang gui, using tesses-framework's gui library" + "description": "A web app (for webview or eventual cloud OS)" }, - "name": "Tesses.CrossLang.Template.GUI", + "name": "Tesses.CrossLang.Template.WebApp", "version": "1.0.0.0-prod" } \ No newline at end of file diff --git a/Templates/webapp/src/main.tcross b/Templates/webapp/src/main.tcross new file mode 100644 index 0000000..7570b76 --- /dev/null +++ b/Templates/webapp/src/main.tcross @@ -0,0 +1,12 @@ + +func WebAppMain(args) +{ + return (ctx)=>{ + if(ctx.Path == "/") + { + ctx.WithMimeType("text/html").SendText(

Hello, world

); + return true; + } + return false; + }; +} diff --git a/Tesses.CrossLang.PackageServer/src/backend/package.tcross b/Tesses.CrossLang.PackageServer/src/backend/package.tcross index 8314d29..b1a6039 100644 --- a/Tesses.CrossLang.PackageServer/src/backend/package.tcross +++ b/Tesses.CrossLang.PackageServer/src/backend/package.tcross @@ -149,10 +149,11 @@ func DB.UploadPackage(userId, filePath) return {Success=true}; } -func DB.QueryPackages(q, offset, limit,$account) +func DB.QueryPackages(q, offset, limit,$account,$filter) { if(TypeOf(offset) != "Long") offset = 0; if(TypeOf(limit) != "Long") limit = 20; + if(TypeOf(filter) != "String") var filter = ""; var q2 = Sqlite.Escape($"%{q}%"); var accountId = -1; @@ -173,7 +174,7 @@ func DB.QueryPackages(q, offset, limit,$account) } } - var sql = accountId > -1 ? $"SELECT * FROM packages p inner join versions v on p.id = v.packageId and (p.packageName LIKE {q2} OR v.description LIKE {q2}) and v.version = (SELECT MAX(version) FROM versions WHERE packageId = v.packageId) INNER JOIN accounts a on a.id = p.accountId WHERE p.accountId == {accountId} LIMIT {limit} OFFSET {offset};" : $"SELECT * FROM packages p inner join versions v on p.id = v.packageId and (p.packageName LIKE {q2} OR v.description LIKE {q2}) and v.version = (SELECT MAX(version) FROM versions WHERE packageId = v.packageId) INNER JOIN accounts a on a.id = p.accountId LIMIT {limit} OFFSET {offset};"; + var sql = accountId > -1 ? $"SELECT * FROM packages p inner join versions v on p.id = v.packageId{filter} and (p.packageName LIKE {q2} OR v.description LIKE {q2}) and v.version = (SELECT MAX(version) FROM versions WHERE packageId = v.packageId) INNER JOIN accounts a on a.id = p.accountId WHERE p.accountId == {accountId} LIMIT {limit} OFFSET {offset};" : $"SELECT * FROM packages p inner join versions v on p.id = v.packageId and (p.packageName LIKE {q2} OR v.description LIKE {q2}) and v.version = (SELECT MAX(version) FROM versions WHERE packageId = v.packageId) INNER JOIN accounts a on a.id = p.accountId LIMIT {limit} OFFSET {offset};"; DB.Lock(); var dbCon = DB.Open(); var res = Sqlite.Exec(dbCon, sql); diff --git a/Tesses.CrossLang.PackageServer/src/program.tcross b/Tesses.CrossLang.PackageServer/src/program.tcross index b281b1e..4b9e85b 100644 --- a/Tesses.CrossLang.PackageServer/src/program.tcross +++ b/Tesses.CrossLang.PackageServer/src/program.tcross @@ -71,6 +71,26 @@ func main(args) } if(ctx.Path == "/api/v1/search") { + var filter = ctx.QueryParams.TryGetFirst("filter"); + if(TypeOf(filter) != "String") filter = ""; + var filters = filter.Length > 0 filter.Split(",") : []; + + if(filters.Length > 0) + { + filter = " and ("; + var first = true; + each(var item : filters) + { + if(!first) { + filter += " OR "; + } + filter += $"v.type = {Sqlite.Escape(item)}"; + first=false; + } + filter += ")"; + } + + var q = ctx.QueryParams.TryGetFirst("q"); if(TypeOf(q) != "String") q = ""; var offset = ParseLong(ctx.QueryParams.TryGetFirst("offset")); @@ -79,7 +99,7 @@ func main(args) if(TypeOf(limit) != "Long") limit = 20; if(limit <= 0) limit = 20; - var res = DB.QueryPackages(q, offset*limit, limit); + var res = DB.QueryPackages(q, offset*limit, limit, undefined, filter); if(TypeOf(res) != "List") { ctx.StatusCode=500; diff --git a/build.tcross b/build.tcross index e1a0c04..424828c 100644 --- a/build.tcross +++ b/build.tcross @@ -34,7 +34,7 @@ func main(args) cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm","build","Templates/lib"]); cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm","build","Templates/compiletool"]); cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm","build","Templates/tool"]); - cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm","build","Templates/gui"]); + cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm","build","Templates/webapp"]); /* cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm","build","Tesses.CrossLang.PackageServer"]); cmd("crossvm",["./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm","build","Tesses.CrossLang.PackageServer"]); diff --git a/project_types.txt b/project_types.txt index 467367c..daefa59 100644 --- a/project_types.txt +++ b/project_types.txt @@ -1,6 +1,6 @@ console: a console application (or webserver) lib: a library -app: a gui app (used for eventual gui system) +webapp: A web app (for webview or eventual cloud OS) template: used for project templates compile_tool: run before source is compiled for project if it is in the dependency tree for the project (and is not linked to said projects) tool: a tool invokable via crosslang (gets Tesses.CrossLang.Args for free) \ No newline at end of file