├── .github └── FUNDING.yml ├── Images └── Diagrams │ ├── DatasilkCoreMvc-View.fla │ └── DatasilkCoreMvc-View.jpg ├── Test ├── test.html ├── App.xaml ├── App.xaml.cs ├── Test.csproj ├── AssemblyInfo.cs ├── MainWindow.xaml.cs └── MainWindow.xaml ├── Core ├── Web │ ├── IRequest.cs │ ├── IService.cs │ ├── Request.cs │ ├── Routes.cs │ ├── Response.cs │ ├── Service.cs │ ├── IController.cs │ ├── Parameters.cs │ ├── Controller.cs │ └── View.cs ├── Attributes │ └── RequestMethods.cs ├── Extensions │ └── Mvc.cs ├── LICENSE ├── Core.csproj └── Middleware │ ├── MvcOptions.cs │ └── Mvc.cs ├── LICENSE ├── Core.sln ├── README.nuget.md ├── .gitignore └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [datasilk] -------------------------------------------------------------------------------- /Images/Diagrams/DatasilkCoreMvc-View.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Datasilk/Core/HEAD/Images/Diagrams/DatasilkCoreMvc-View.fla -------------------------------------------------------------------------------- /Images/Diagrams/DatasilkCoreMvc-View.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Datasilk/Core/HEAD/Images/Diagrams/DatasilkCoreMvc-View.jpg -------------------------------------------------------------------------------- /Test/test.html: -------------------------------------------------------------------------------- 1 | This is a test! 2 |

{{title}}

3 | Written by {{author}} 4 | 5 | {{page-list path:"support", "length":"15"}} -------------------------------------------------------------------------------- /Core/Web/IRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Http; 3 | 4 | namespace Datasilk.Core.Web 5 | { 6 | public interface IRequest : IDisposable 7 | { 8 | HttpContext Context { get; set; } 9 | string Path { get; set; } 10 | string[] PathParts { get; set; } 11 | Parameters Parameters { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Core/Web/IService.cs: -------------------------------------------------------------------------------- 1 | namespace Datasilk.Core.Web 2 | { 3 | public interface IService : IRequest 4 | { 5 | void Init(); 6 | string Success(); 7 | string Empty(); 8 | string AccessDenied(string message = "Error 403"); 9 | string Error(string message = "Error 500"); 10 | string BadRequest(string message = "Bad Request 400"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Test/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Core/Attributes/RequestMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Datasilk.Core.Web 4 | { 5 | [AttributeUsage(AttributeTargets.Method)] 6 | public class GETAttribute : Attribute { } 7 | public class POSTAttribute : Attribute { } 8 | public class PUTAttribute : Attribute { } 9 | public class HEADAttribute : Attribute { } 10 | public class DELETEAttribute : Attribute { } 11 | } 12 | -------------------------------------------------------------------------------- /Test/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace Test 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Core/Web/Request.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | 3 | namespace Datasilk.Core.Web 4 | { 5 | public abstract class Request: IRequest 6 | { 7 | public HttpContext Context { get; set; } 8 | public string Path { get; set; } 9 | public string[] PathParts { get; set; } 10 | public Parameters Parameters { get; set; } 11 | public virtual void Dispose() { } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Core/Extensions/Mvc.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | 3 | namespace Datasilk.Core.Extensions 4 | { 5 | public static class Mvc 6 | { 7 | public static IApplicationBuilder UseDatasilkMvc(this IApplicationBuilder builder, MvcOptions options = default) 8 | { 9 | return builder.UseMiddleware(options); 10 | } 11 | } 12 | 13 | public class MvcOptions : Middleware.MvcOptions { } 14 | } 15 | -------------------------------------------------------------------------------- /Core/Web/Routes.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | 3 | namespace Datasilk.Core.Web 4 | { 5 | public class Routes 6 | { 7 | public virtual IController FromControllerRoutes(HttpContext context, Parameters parameters, string name) 8 | { 9 | return null; 10 | } 11 | 12 | public virtual IService FromServiceRoutes(HttpContext context, Parameters parameters, string name) 13 | { 14 | return null; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Test/Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | PreserveNewest 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Test/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Datasilk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Core/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Datasilk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Core/Web/Response.cs: -------------------------------------------------------------------------------- 1 | namespace Datasilk.Core.Web 2 | { 3 | public enum responseType 4 | { 5 | replace = 0, 6 | append = 1, 7 | before = 2, 8 | after = 3, 9 | prepend = 4 10 | } 11 | 12 | //used to send a JSON object back to the client web browser 13 | public class Response 14 | { 15 | public responseType type { get; set; } = responseType.replace; //type of insert command 16 | public string selector { get; set; } = ""; //css selector to insert response HTML into 17 | public string html { get; set; } = ""; //HTML response 18 | public string javascript { get; set; } = ""; //optional javascript to insert onto the page dynamically 19 | public string css { get; set; } = ""; //optional CSS to insert onto the page dynamically 20 | public string json { get; set; } = ""; 21 | 22 | public Response(string html = "", string javascript = "", string css = "", string json = "", string selector = "", responseType type = responseType.replace) 23 | { 24 | this.html = html; 25 | this.javascript = javascript; 26 | this.css = css; 27 | this.selector = selector; 28 | this.json = json; 29 | this.type = type; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Core/Web/Service.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json; 2 | using Microsoft.AspNetCore.Http; 3 | 4 | namespace Datasilk.Core.Web 5 | { 6 | public class Service : Request, IService 7 | { 8 | public virtual void Init() { } 9 | 10 | public string JsonResponse(dynamic obj) 11 | { 12 | Context.Response.ContentType = "text/json"; 13 | return JsonSerializer.Serialize(obj); 14 | } 15 | 16 | public string AccessDenied(string message = "Error 403") 17 | { 18 | Context.Response.StatusCode = 403; 19 | Context.Response.WriteAsync(message); 20 | return message; 21 | } 22 | 23 | public string Error(string message = "Error 500") 24 | { 25 | Context.Response.StatusCode = 500; 26 | Context.Response.WriteAsync(message); 27 | return message; 28 | } 29 | 30 | public string BadRequest(string message = "Bad Request 400") 31 | { 32 | Context.Response.StatusCode = 400; 33 | return "Bad Request"; 34 | } 35 | 36 | public string Success() 37 | { 38 | return "success"; 39 | } 40 | 41 | public string Empty() 42 | { 43 | Context.Response.ContentType = "text/json"; 44 | return "{}"; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Test/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace Test 6 | { 7 | /// 8 | /// Interaction logic for MainWindow.xaml 9 | /// 10 | public partial class MainWindow : Window 11 | { 12 | public MainWindow() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | private void Button_Click(object sender, RoutedEventArgs e) 18 | { 19 | var view = new View(new ViewOptions() 20 | { 21 | Html = txtInput.Text 22 | }); 23 | view.Show("is-block"); 24 | view["insert-adj"] = view.Elements.Where(a => a.Name == "insert-adj").First().Vars["text"]; 25 | var header = view.Child("header"); 26 | var i = header.Fields.Where(a => a.Key == "page-list").First().Value[0]; 27 | header["page-list"] = "This is a page list filtered by path: " + view.Elements[i].Vars["path"]; 28 | txtInput.Text = view.Render(); 29 | txtInput.Text += "\n\n" + view.GetBlock(view.Elements.Where(a => a.Name == "is-block").First()); 30 | btnRender.Visibility = Visibility.Hidden; 31 | } 32 | 33 | private void txtInput_TextChanged(object sender, TextChangedEventArgs e) 34 | { 35 | 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Core/Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 1.0.8.2 6 | Datasilk.Core 7 | Datasilk.Core.Mvc 8 | Mark Entingh 9 | Datasilk 10 | Datasilk Core MVC 11 | An ultra-lightweight MVC framework for the web that handles page requests and RESTful web API calls. 12 | Datasilk 2023 13 | LICENSE 14 | https://mvc.datasilk.io/ 15 | https://mvc.datasilk.io/images/favicon.png 16 | https://github.com/datasilk/core 17 | GitHub 18 | MVC, Web API, ultra-lightweight 19 | Fixed caching issue with View.Partial, fixed issue with partial includes mustache variable parameters disappearing, cleaned up View class by removing unused classes, methods, & vars, and optimized the Render function. 20 | true 21 | 1.0.8.2 22 | 1.0.8.2 23 | en 24 | 25 | 26 | 27 | 28 | True 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Test/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 |