Skip to content
This repository has been archived by the owner on Sep 30, 2019. It is now read-only.
noogen edited this page Apr 8, 2013 · 26 revisions

Getting Started

PhunCMS is a non-intrusive add-on to your MVC 4+ projects. Adding PhunCMS nuget package only change two files, your web config and a custom PhunCMS bootstrapped file.

PhunCMS is open source and MIT licensed. It is open to bug report, enhancement, and recommendation. Understanding the configuration section

    <configSections>
        <section name="phuncms" type="Phun.Configuration.PhunCmsConfigurationSection, Phun" 
                 requirePermission="false" />
    </configSections>
    <phuncms resourceRoute="~/phuncms" contentRoute="CmsContent" adminRoles="Content Admin, System Admin"
             domainLevel="1">
        <hostAuthorization>
            <add key="clienthost1.com" value="RoleForClient1, System Admin" />
        </hostAuthorization>
        <contentMap>
            <add route="CmsContent" repositoryType="sql" 
                 repositorySource="DefaultConnectionStringName" 
                 repositoryTable="CmsContent" repositoryCache="App_Data\CmsContent" />
            <add route="CmsContent" repositoryType="file" 
                 repositorySource="App_Data\CmsContent" />
        </contentMap>
    </phuncms>

[phuncms] - this element must name as "phuncms"

  1. @resourceRoute: required, configure route for PhunCMS embedded resource.
  2. @contentRoute: required, configure route for your CMS Content storage, see also [contentMap] element.
  3. @adminRoles: optional, comma separated list of roles that are Content Admin. If left blank, all authenticated users are Content Admin.
  4. @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

  1. @route: required, this must be the same as contentRoute in [phuncms] element. It maps the route of our CMS content.
  2. @repositoryType: required, the repository type name: sql, file, or fully qualified assembly name
  3. @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...
  4. @repositoryTable: require, this is the table name for sql repository.
  5. @repositoryCache: optional, allow for local caching of sql repository files. Downloading file to a local directory help improve file transfer performance. If the local file is out-of-date, it will be redownloaded; otherwise, the local file will be serve up as content.
  6. @domainLevel: optional, default to 1 meaning the system will store in separate tenant/host repository for every host, minus "www". So if you have: ftp.phuncms.com, ftp.tom.phuncms.com, tom.phuncms.com, phuncms.com, and www.phuncms.com then the content are separated in four different folders.

[hostAuthorization] [add] - this is for setting up content admin permission for multi-tenant. It gives you the flexibility of hosting for multiple clients and setting up different Content Admin for each client.

  1. @key: hostname, phuncms.com, funcms.com, etc...
  2. @value: comma separate list of roles similar to override phuncms@adminRoles value.

File Content Repository

Sql Content Repository

Convention

  • CMS is just a repository similar to any file system.
  • A page is map to a folder. The content of the page is stored under the "_default" file.
  • Partial content of page is usually stored under the same folder.
  • Folder names are SEO friendly. All lowered case and include dash.
  • Read is allow for all users. Write permission is configurable.

Vash templating/theme engine convention

  • Vash is use as templating engine and ".vash" is the extension. Vash uses razor liked syntax.
  • When referencing vash in the view, you do not need to include the extension.
  • Vash will attempt to search for view in relative path and "/shared" folder or absolute path.

Limitation

  • Must use Visual Studio 2012 to open this solution.
  • Must run as a IIS website and not Virtual Folder. It was not part of the design so we're not sure if it'll work.

Templating with Razor

Since PhunCMS is just a plugin to your new or existing MVC4 project, you are free to use any templating engine you choose. Default Razor? Using with StackExchange Razor Markdown? With Spark? With nHaml? Current version of PhunCMS only extended three HtmlHelper methods: 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 visits the page. You are required to render phun bundles which are client-side JavaScript to handle content editing. See example below.

@Html.PhunPartial("LeftHeader") 

or

@Html.PhunPartialEditable("h2", "LeftHeader", new { @class= "one" })

@section scripts
{
    @Html.PhunBundles()
}

Templating with Vash

Vash was selected as server-side template for PhunCMS because it's based on Razor syntax. Vash is not a replacement for Razor. Again, Vash is not a replacement for Razor! We want the flexibility to support server-side sandbox templating without having to re-invent the wheel with an entirely new language. We added javascriptdotnet engine and vash for server-side templating.

Server-side sandbox is useful in scenario where your client want to dynamically control their own site UI and you only want to give them specific API methods to use with your system. You do not need to support them all the time because your contract does not allow for more than x amount of professional services time. Vash allow your client to make the changes themself. And if they want better performance, you can work on converting Vash into custom Razor pages.

Support for multi-tenant/mobile site separation

By design, different host content are stored in separate folders; thereby, provide multi-tenant support. This is also beneficial 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 was a concious decision not to support content sharing between repositories. This helps 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? Not really. If you custom code the Razor view or template, then you can share that part of the contents. Server-side template is basically the view or theme of your CMS/site.

How-to for PhunCMS extensibility

PhunCMS content repository/connector is of interface base. Therefore, it is user extensible and configures to use the new content repository. See @repositoryType in configuration section.

For now, PhunCMS only provide two repositories: 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 support multiple backend. As a result, it's not very efferent. There is current work in progress to develop a better sql repository and it will just be for SQL Server.

Inherit PhunCmsContentController to create blog, wiki, etc...

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=" WikiController "/> 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.

Multi-tenant host matching, 2nd, 3rd, etc... TLD mapping

See @domainLevel in configuration section above. We currently do not have the capability of parsing top level domain. You want to be conscious about your domain mapping; and so, PhunCMS only other option is to set a depth on domain level mapping. Per the configuration section example above, if you set the @domainLevel value to 2 means that the content will only store under myhost.com location. If you set it to 3, it will be stored under ftp.myhost.com, john.myhost.com, and myhost.com.

Provide your own editor with createjs

To quickly get the project up and running, we adopted createjs as our starter client-side editing tool for the CMS. This is also because PhunCMS follow the same CMS modular movement. Though there is some known issue with createjs such as not supporting all browsers (ie7). Cough, if you're still using IE7 you probably deserved everything else that's coming such as viruses.

Createjs has 4 built in editors. We currently set default to ckeditor because we like all the nice features it provides. The default editor for createjs is Halo. Then there is also Aloha and Redactor. Please see createjs to figure out how to enable these editors: http://createjs.org/

Provide your own filemanager UI

We know that the default FileManager UI is not very pretty, but it does the job. Part of being modular is you can provide your own File Manager UI which should all be in JavaScript. Since you will be writing your site menu with your Razor template, you can link to your own File Manager UI.

Describe different methods of httphandler and module for PhunCMS url route mapping support.

As you will find out, different IIS version may handle route and configuration differently. If you required, PhunCMS provide many different routing implementation. Please see phun project app config for additional example and also see Phun.Routing source for this different routing configuration.