-
Notifications
You must be signed in to change notification settings - Fork 1
How to
PhunCMS is simple. It is a non-intrusive addon to your MVC 4+ projects. Adding PhunCMS nuget package only change two files, your web config and a custom PhunCMS bootstrapper file.
PhunCMS is open source. It is open to bug report, enhancement, and recommendation. This project is build for DotNET Entrepreneur. Every project these days seem to require some form of CMS. The original vision is to provide regular DotNET MVC developer the ability to quickly launch/demo a competitive site with CMS support.
<configSections>
<section name="phuncms" type="Phun.Configuration.PhunCmsConfigurationSection, Phun" requirePermission="false"/>
</configSections>
<phuncms resourceRoute="~/phuncms" contentRoute="CmsContent" adminRoles="Content Admin, System Admin">
<contentMap>
<add route="CmsContent" repositoryType="Sql" repositorySource="DefaultConnectionStringName" repositoryStorage="CmsContent" />
</contentMap>
</phuncms>
[phuncms] - this element must name as "phuncms"
- @resourceRoute: required, configure route for PhunCMS embedded resource.
- @contentRoute: required, configure route for your CMS Content storage, see also [contentMap] element.
- @adminRoles: optional, comma separated list of roles that are Content Admin. If left blank, all authenticated users are Content Admin.
- @disableResourceCache: optional, if false or not set, embedded resources response with HTTP 304 based on the last modified date of the Phun assembly.
[contentMap] [add] - this is just a wrapper element for content routes
- @route: required, this must be the same as contentRoute in [phuncms] element. It map the route of our CMS content.
- @repositoryType: required, the repository type name: sql, file, or fully qualified assembly name
- @repositorySource: required, this is connection string name for sql. For file, it is the base folder name, if there is no colon in the path, it is assume to be a relative path. "App_Data", "C:\MyContentStore", etc...
- @repositoryStorage: required, this is the table name for sql repository. It is optional for file repository. This represent a subfolder for file repository, example "[repositorySource][repositoryStorage]".
[hostAuthorization] [add] - this is for setting up content admin permission for multi-tenant. It give you the flexibility of hosting for multiple client and setting up different Content Admin for each client.
- @key: hostname, phuncms.com, funcms.com, etc..
- @value: comma separate list of roles similar to override phuncms@adminRoles value.
Do not manually map your route. It is best to use the default MVC or similar route mapping for maintenance free routing.
Since PhunCMS is just a plugin to your new or existing MVC4 project, you are free to use any templating engine you choose. Defualt Razor? StackExchange Razor MarkDown? Spark? nHaml? Current version of PhunCMS only extended three HtmlHelper method: PhunRenderPartialContent, PhunRenderPartialForInlineEdit, and PhunRenderBundles. Verbosely, they are exactly what they're named. You may want to render just the content on a page. You can render content that inline editable when a Content Admin visit the page. You are required to render phun bundles which are client-side javascript to handle content editing. See example below.
@Html.PhunRenderPartialContent("LeftHeader")
or
@Html.PhunRenderPartialForInlineEdit("h2", "LeftHeader", new { @class= "one" })
@section scripts
{
@Html.PhunRenderBundles()
}
PhunCMS support full page templating. You can use file manager to create a page. A page basically map or represent a url path. "/Your/Page1" or "/Your/Page2" which is actually physically map to a default file on that path: "/Your/Page1/_default" and "/Your/Page2/_default". Anything under this path are consider partial content. So you can also template inside of "_default" file. "_defualt" file is required to have both the html and head elements. You should also provide page metadata and title for SEO purposes. Example below show how template work:
<div data-cmscontent="LeftHeader"></div><div data-cmscontent="RightHeader"></div>
- The two contents are ajax loaded and will become inline editable for content admin.
<div data-contentcms>%LeftHeader%</div><div data-cmscontent="RightHeader"></div>
<div>%SomeOtherContent%</div>
- Example will render LeftHeader and SomeOtherContent on server-side, while RightHeader get ajax load. Both LeftHeader and RightHeader will become inline editable.
- Example above utilize the current path or relative path to store it's data. So all partial data will be store in "/Your/Page1/" folder. Let say you're inside of "/Your/Page2/_default" then Absolute path can also be use.
<div data-contentcms>%LeftHeader%</div><div data-cmscontent="RightHeader"></div>
<div>%/Your/Page1/SomeOtherContent%</div>
By design, different host content are stored in separate folders; thereby, provide multi-tenant support. This is also benefitial for let say mobile support. If you map your DNS to somesite.com and m.somesite.com, then contents are stored separately for mobile site.
And if you're wondering if you can share content between CMS tenants, the answer is no. To keep the system simple, it is decided that we do not provide content sharing between repositories. This help decouple the content; and thereby, prevent sudden changes of one tenant content to affect other tenants. Entire folder can be downloaded as a zip file so it's easy to make a copy from one tenant to another.
Did I say the answer is no? It's not an absolute no. If you custom code the Razor view or template, then you can share that part of the contents. That's sort of like the view or theme of your site.
PhunCMS content repository/connector is of interface base. Therefore, it is user extensible and configure to use the new content repository. See @repositoryType in configuration section.
For now, PhunCMS only provide two repository: file and sql. Both should be sufficient for now especially the file repository. We attempt to design the sql repository to be more ANSI SQL so it would suport multiple backend. As a result, it's not very effient. There is current work in progress to develop a better sql repository and it will just be for SQL Server.
Since many CMS modules can just file based storage, PhunCMS can also be extended as backend storage for future module.
// map route ~/Wiki
public class WikiController : PhunCmsContentController {
/// <summary>
/// <add route="Wiki" repositoryType="Sql" ... />
/// Initializes a new instance of the <see cref="PhunCmsContentController"/> class.
/// </summary>
public WikiController () : base()
{
this.MyContentConfig =
this.Config.ContentMaps.FirstOrDefault(
c =>
string.Compare(c.RouteNormalized, "Wiki", StringComparison.OrdinalIgnoreCase)
== 0);
}
}
All the basic server/connector methods are there. You don't even have to map the route, just use the configuration. Remember [contentMap] element is a collection. So you just need to add a configuration and PhunCMS automatically map you route. You should define a different repository location. Security will be the same as your @contentRoute security.
Although not tested and not recommended, we do provide micro-security by path or route. Let say you templated a page and only want a specific user access to that page. You can inject IContentPathPermissionHandler. PhunCmsContentController also defined a greedy constructor that allow for injection of this interface.
/// <summary>
/// Initializes a new instance of the <see cref="PhunCmsContentController" /> class.
/// </summary>
/// <param name="contentPathAdminHandler">The content path admin handler.</param>
public PhunCmsContentController(IContentPathPermissionHandler contentPathAdminHandler)
: this()
{
this.ContentPathPermissionHandler = contentPathAdminHandler;
}
Please review source code for more additional info. One additional benefit is you can store your permission in a database somewhere; where by, you can have a UI to setup this configuration. Your IContentPathPermissionHandler implementation is just a cache access to this permission database.
c) provide your own editor with createjs d) provide your own filemanager UI 8) Describe different methods of httphandler and module for PhunCMS url route mapping support. 9) TBD... Maybe promoting user questions to How-to wiki?