ASP.NET MVC 開源建站系統 ZKEACMS 推薦,從此網站“拼”起來


一個挺有意思的項目,跟拼圖一樣的創建網站,先來幾張GIF感受一下:

官方地址:http://www.zkea.net/zkeacms

下載地址:https://github.com/SeriaWei/ASP.NET-MVC-CMS/releases

GitHub:https://github.com/SeriaWei/ASP.NET-MVC-CMS

開源中國社區:http://git.oschina.net/seriawei/ASP.NET-MVC-CMS


演示地址:http://demo.zkea.net/  

后台:http://demo.zkea.net/admin 

用戶名,密碼:admin


 ZKEACMS是基於EasyFrameWork,使用ASP.NET MVC4開發的開源CMS。

ZKEACMS一個內容管理軟件(網站)。ZKEACMS不僅只是管理內容,更是重新定義了布局、頁面和組件,讓用戶可以自由規划頁面的布局,頁面和內容。

ZKEACMS使用可視化編輯設計,真正做到所見即所得,可直接在預覽頁面上設計頁面。

ZKEACMS采用插件式設計,支持擴展新插件。

架設環境:

Windows server 2003,IIS 6 或以上

MsSql 2005 或以上

.Net FrameWork 4.0,MVC 4

開發環境

Microsoft VisualStudio 2013

Microsoft Sql Server 2005 以上

關於項目的特性大家到官網去看看就好了,這里主要講講Code:

資源管理與應用(JS/CSS):

資源定義

script("jQuery").Include("~/Scripts/jquery-1.11.2.min.js", "~/Scripts/jquery-1.11.2.min.js").RequiredAtHead();
script("bootStrap").Include("~/Content/bootstrap/js/bootstrap.js", "~/Content/bootstrap/js/bootstrap.min.js").RequiredAtFoot();
script("jQueryUi").Include("~/Scripts/jquery-ui/jquery-ui.js", "~/Scripts/jquery-ui/jquery-ui.min.js");
style("bootStrap").Include("~/Content/bootstrap/css/bootstrap.css", "~/Content/bootstrap/css/bootstrap.min.css").RequiredAtHead();
style("bootStrapTheme").Include("~/Content/bootstrap/css/bootstrap-theme.css", "~/Content/bootstrap/css/bootstrap-theme.min.css").RequiredAtHead();
style("Site").Include("~/Content/Site.css", "~/Content/Site.min.css").RequiredAtFoot();

這里是對腳本和樣式文件的定義,顯示調用RequiredAtHead()/RequiredAtFoot(),則無需主動加到頁面中,默認都會使用該資源文件,加到頁面的開頭或者結尾。

資源的使用(.cshtml):

Style.Reqiured("Site").AtHead();
Script.Reqiured("jQueryUi").AtFoot();
@using (Script.AtFoot())
{
    <script type="text/javascript">
        function Create(xxx) {
           
        }
    </script>
}

為什么需要這樣管理資源?因為ZKEACMS的頁面是由不同的組件構成的,完全由用戶選擇在頁面中顯示什么組件,而不同的組件會需要不同的JS或CSS,因此需要動態加載這些資源文件。

簡單的數據和視圖配置(元數據注冊):

    [DataConfigure(typeof(CarouselEntityMetaData))]
    public class CarouselEntity : EditorEntity
    {
        public long? ID { get; set; }

        public int? Height { get; set; }

        public List<CarouselItemEntity> CarouselItems { get; set; }

    }
    class CarouselEntityMetaData : DataViewMetaData<CarouselEntity>
    {
        protected override void DataConfigure()
        {
            DataTable("Carousel");
            DataConfig(m => m.ID).AsIncreasePrimaryKey();
            DataConfig(m => m.CarouselItems).Ignore();
        }

        protected override void ViewConfigure()
        {
            ViewConfig(m => m.ID).AsHidden();
            ViewConfig(m => m.CarouselItems).AsListEditor();
            ViewConfig(m => m.Height).AsHidden();
        }
    }

編輯頁面直接使用EditorForModel:

在視圖配置完以后(.AsTextBox(),.AsDropDownList()...) 直接調用EditorForModel即可自動生成表單:

@Html.EditorForModel()

列表頁面:

@(
 Html.Grid<ArticleEntity>().SetColumnTemplate(col => {
     col.Add(m => m.Title, "<a href='"+Url.Action("Edit")+"?ID={ID}'>{Title}</a>");
 }).SetAsToolBar("#toolBar").ShowCheckbox(m=>m.ID).OrderBy(m=>m.PublishDate, OrderType.Descending)
)

FilterConfig:

以前我們這樣寫:

[ViewDataArticleType]
public override ActionResult Edit(ArticleEntity entity)

現在我們這樣寫:

Registry.Register<ArticleController, ViewDataArticleTypeAttribute>(m => m.Edit(null));

靈活的Service

Service.Add(entity);
Service.Count(m=>m.Id=1);
Service.Delete(primaryKey);
Service.Delete(m=>m.Id=1);
Service.Get(primaryKey);
Service.Get(m=>m.Id=1);
...

實現卻如此簡單:

public class CarouselService : ServiceBase<CarouselEntity>
{
}

。。。。。。

寫得很簡單,可是還有很多,有興趣加入的就到GitHub上面Fork,並加入我們。https://github.com/SeriaWei/ASP.NET-MVC-CMS

盡情的發揮你的想象力吧。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM