mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-08 09:05:46 +00:00
Add filter to package server and fix templates for devstudio
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"template_info": {
|
||||
"type": "console"
|
||||
},
|
||||
"template_name_pretty": "Console Application",
|
||||
"template_ignored_files": ["bin","obj"],
|
||||
"description": "A console application"
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"template_info": {
|
||||
"type": "console"
|
||||
},
|
||||
"template_name_pretty": "Empty Website",
|
||||
"template_extra_text_ftles": [],
|
||||
"template_ignored_files": ["bin","obj"]
|
||||
}
|
||||
|
||||
@@ -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%"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
"type": "lib"
|
||||
},
|
||||
"template_ignored_files": ["bin","obj"],
|
||||
"description": "A crosslang library"
|
||||
"description": "A crosslang library",
|
||||
"template_name_pretty": "Library"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -13,5 +13,6 @@
|
||||
"type": "console"
|
||||
},
|
||||
"template_ignored_files": ["bin","obj"]
|
||||
}
|
||||
},
|
||||
"template_name_pretty": "WebSite"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
12
Templates/webapp/src/main.tcross
Normal file
12
Templates/webapp/src/main.tcross
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
func WebAppMain(args)
|
||||
{
|
||||
return (ctx)=>{
|
||||
if(ctx.Path == "/")
|
||||
{
|
||||
ctx.WithMimeType("text/html").SendText(<h1>Hello, world</h1>);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"]);
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user