CMS Program Architecture
This program is mainly used for enterprise website development, can also do blog programs, the program is from the previous article of the. NET blog program improved, the main technology from WebForm to. NET MVC, because it is a very early project, 12 is the MVC3 version, of course, or run under Linux.
Technology stack
- . NET Framework 4.0
- SQLite database
- Mono Linux Runtime environment and the SQLite library under Mono
- Razor template engine
- Dapper Lightweight ORM Framework
- vs2017 Community Version
This time the development tool is relatively new, the last time with vs2010 hair, the span is relatively large, the project was also developed in 10, although with 2017, in fact, there is no impact.
The razor engine is much more user-friendly than nvelocity, and is better than a back-end collection.
And this time the project completely uses dapper ORM, the entire database access layer operation looks also very refreshing.
Code structure
The left is mainly divided into three folders, Jqpress.web is to store the Web routing portal, template skin, static files, upload folders, the background management program through the areas domain management to achieve, the whole project structure is still relatively clear.
Routing Design
Routing portal for homecontroller this file, including the home page, product list, the article list, the article content waits, all is through this controller to route, although the function is more, but the code quantity is less than 300 lines, the business logic processing basically is in the service layer.
The action logic for a list interface is only 20 lines below
Public actionresult Category (string pagename) {var model = new Postlistmodel (); CategoryInfo cate = _categoryservice.getcategory (pagename); Model. Category = Cate; if (cate! = null) {int categoryId = cate. CategoryId; Model. Metakeywords = Cate. Catename; Model. Metadescription = Cate. Description; Viewbag.title = Cate. Catename; Model. URL = Confighelper.siteurl + "category/" + Jqpress.Framework.Utils.StringHelper.SqlEncode (PAGENAME) + "/page/{0}"; const int pageSize = 10; int count = 0; int pageIndex = pressrequest.getint ("page", 1); int Cateid = Pressrequest.getqueryint ("Cateid",-1); int tagid = Pressrequest.getqueryint ("TagID",-1); if (Cateid > 0) pageIndex = pageIndex + 1; var cateids =categoryid+ "," + _categoryservicE.getcategorylist (). FindAll (c = C.parentid = = categoryId). Aggregate (String. Empty, (current, t) = + current + (T.categoryid + ",")). TrimEnd (', '); var postlist = _postservice.getpostpagelist (PageSize, PageIndex, out count, Cateids. TrimEnd (', '), TagID,-1,-1,-1,-1, -1,-1, "", "", ""); Model. Pagelist.loadpagedlist (postlist); Model. Postlist = (list<postinfo>) postlist; } model. IsDefault = 0; return View (model. Category.viewname,model); }
Template engine Design
Template engine with razor, different CMS style templates in the form of folders stored in the Themes folder, through the backend settings can be arbitrary switch template (this feature is still being perfected).
Data storage Design
As a lightweight CMS, of course, will not use MySQL or SQL Server, still firmly use SQLite, the above is through the dapper database operation, although no Microsoft increased ORM powerful, but the readability and maneuverability are very good.
Because Linux is supported, SQLite's operations classes need to beusing Mono.Data.Sqlite;
, of course, you can switch over windows, the above I write the switch is too rough, learning the design pattern of the students should be able to reconstruct in minutes, switching Windows and Linux is simply not too convenient.
Database structure
jq_category
Classification and labeling Table
jq_comments
Comment Form
jq_links
Friend Chain and navigation settings
jq_posts
Article table
jq_sites
Site access statistics and articles, classifications, quantity tables
jq_users
Account Form
The database structure is not different from the previous blog program, except that some table structure fields differ
Run vs2017 Debug Mode preview
CMS Home
Background login, Default user name admin, password 123456
Background Home
Article List
Article editing
How to deploy under Linux mono
For the mono installation information on my server.
Jexus
Linux requires the installation of mono and Jexus to run, mono as the Linux runtime Environment of the. NET Framework, Jexus as a Web server.
Jexus configuration, because my server also has other languages of the site, so there is no direct use of jexus external services.
Nginx
Nginx Proxy Jexus 81 port, this place is not required, but nginx as a regular agent software, you can run on the server. NET, PHP, Java, and so on, and blossom.
Bin folder Description
The deployment of. NET MVC3 under Linux requires that the DLLs referenced under the project need to be uploaded to the bin directory. and also need to upload Microsoft.web.Infrastructure.dll, this is the release of MVC project need to use. Can compare my webform under the Linux blog program site bin as long as the introduction of Mono and nvelocity these 2 third-party DLLs, the others are their own business programs, this. NET CMS is a lot of things, is my blog site under the Bin folder content.
. NET program issues on a Linux server
- Jexus does not support Chinese, so the file upload path must be rewritten as a letter plus a number symbol.
- Jexus Web servers are case-sensitive by default, so be sure to
Just remove the "#" from the "Export mono_iomap= ..." in the script file of JWs, and you can leave it out of case.
Source Access
Https://github.com/robotbird/jqpress.cms
To prevent some students from accessing GitHub, they put Oschina on the gitee.
Https://gitee.com/robotbird/jqpress.cms
Postscript
In the development of this CMS when the. NET core was not born, as Linux under the. NET MVC project is still relatively new, but unfortunately did not write code, run to do the project to do the product, where the open source out of the memory of writing code years, if useful to everyone that the best.
If the source of interest can contact qq:330296409
. NET folios:. NET MVC cms under Linux