Coder Social home page Coder Social logo

netcorestack / hisar Goto Github PK

View Code? Open in Web Editor NEW
21.0 10.0 6.0 5.63 MB

:european_castle: Hisar: Cross-Platform Modular Component Development Infrastructure

License: MIT License

C# 52.09% JavaScript 23.72% CSS 13.29% HTML 10.91%
dotnet dotnetcore aspnetcore component-architecture cms-framework application-framework extensibility cross-platform

hisar's Introduction

Hisar

Cross-Platform Modular Component Development Infrastructure

NuGet NuGet

Latest release on Nuget

Why Hisar?

The purpose of this framework is that eliminate the monolithic application challenges and allow us to develop component (module) without main application dependency. Thus the component can be run and test as a standalone web application. When you complete development requirements and ready to deploy the component then just pack it or copy the output to the related directory of the main application.

MsBuild , NuGet or dotnet pack tools can be used for packaging. In this way, the component will be able to part of the main hosting application and available to upload NuGet or MyGet package repositories.

Despite the other framework you don't need to reference any component (module) to main application but if you want the component to act as part of the main application you can copy the output .dll to ExternalComponents folder of main application so the Hisar platform engine resolves all dependencies, controllers, views, contents and then registers the component with convention name.

Controllers

For example; you got a component which is name Hisar.Component.Carousel. For convention, Hisar engine resolves that namespace as a Carousel component when to act as a part of the main application. For this component, the component Controllers will work as an Area with http://<domainname>/carousel URL prefix in main application (Landing Hosting or Admin Hosting apps).

ViewComponents

View components are similar to partial views, but they are much more powerful. Hisar ViewComponents work as follows;

@section styles {
    <link rel="stylesheet" href="@Url.ComponentContent("~/css/carousel.css")" />
}

<h2>Carousel</h2>
@await Component.InvokeAsync(ViewContext.ResolveName("Carousel"))
ViewContext.ResolveName("Carousel")

extension method creates convention name for the executing view component according to running component state. In this way, the Component (module, which has CarouselViewComponent) works on its own and resolve the convenient name for any state. (Standalone app or part of the main application)

Component Contents

<img src="@Url.ComponentContent("~/img/banner1.svg")" alt="ASP.NET Core" class="img-responsive" />
Url.ComponentContent("~/img/banner1.svg")

this extension method makes the content accessible for the specified path for any state.

Startup.cs

Startup.cs is the bootstrap - starter class for the ASP.NET Core web application. We tried to preserve as much as possible in the same way this file except

public static void ConfigureRoutes(IRouteBuilder routes)

for the method mentioned above and

.UseStartup<DefaultHisarStartup<Startup>>()

our custom startup wrapper to handle component and application acts. For more details, you can check the test projects source code in this repository.

Component Development

To develop the component you can fallow these steps;

  • Download the .NET Core SDK 2.2.0 or newer. Once installed, run this command:

     dotnet tool install --global dotnet-hisar --version 2.2.0
    
  • Create a web application with Hisar.Component prefix. (Hisar.Component.YourComponentName)

  • Add NetCoreStack.Hisar package to the project.

     dotnet add package NetCoreStack.Hisar
    
  • Update the line UseStartup<Startup> to UseStartup<DefaultHisarStartup<Startup>> for WebHostBuilder.

  • Add PreBuild event to generate component helper classes with Hisar global tool.

    <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
        <Exec Command="cd $(ProjectDir) &amp; dotnet hisar --build &quot;$(ProjectDir)&quot;" />
    </Target>
  • Add Hisar Web Cli Services (Tooling)

    public void ConfigureServices(IServiceCollection services)
    {
        #if !RELEASE
        /// <param name="webCliAddress">Default is localhost:1444 (WebCli Tools)</param> 
        /// <param name="enableLiveReload">To enable livereload proxy</param>
        services.AddWebCliSocket<Startup>();
        #endif
        
        // ...
    }
    
    public void Configure(IApplicationBuilder app, ...)
    {
        #if !RELEASE
        app.UseCliProxy();
        #endif
        
        // ...
    }
  • Add all the required contents as embedded resources.

    <ItemGroup>
        <EmbeddedResource Include="Views\**\*.cshtml" />
        <EmbeddedResource Include="wwwroot\**\*.*" />
        <None Update="wwwroot\**\*">
            <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        </None>
    </ItemGroup>
  • If you have any templating directory for static serve files or hosting main web application, start the Web Cli tool on project root directory from command line. It will start the Web Cli application on http://localhost:1444 to manage all main application contents or provide _Layout.cshtml if no appdir option specified. (One working Web Cli tool is enough for same templating usage)

     dotnet hisar --appdir <the-path-of-your-hosting-app-relative-or-absolute> 
    

Database

MongoDb Database

docker volume create --name=mongodata

docker run -it -v mongodata:/data/db -p 27017:27017 -d mongo

Tools

Hisar Web Cli tool provides manage extensibility and templating of components. Dotnet global tools extensibility model has various tooling features. Hisar Web Cli is built on top of it.

Components.json (sample nuget package reference)

{
    "components": {
        "Hisar.Component.CoreManagement": {
            "targetFramework": "netcoreapp2.2",
            "version": "2.2.0"
        }
    }
}

TODO

  • Hisar Package Repository
  • Component Marketplace (Upload, search, download and enable)

Contributing to Repository

  • Fork and clone locally.
  • Build the solution with Visual Studio 2017.
  • Create a topic specific branch in git.
  • Send a Pull Request.

Prerequisites

ASP.NET Core

License

The MIT licence

hisar's People

Contributors

gencebay avatar tahaipek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hisar's Issues

New logo for Hisar

I wanted to contribute to Hisar. I designed a logo for Hisar. If you like it, I'll send you the files.

hisar

_Layout.cshtml In Memory File Watcher

Hisar default LayoutFullName is

public static string LayoutFullName => "/Views/Shared/_Layout.cshtml";

so we should provide in memory file watcher feature for component development area. Hisar Web Cli can invoke change event by websocket integration.
@sinanbozkus
@GkhnIpek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.