Meek
meek/mēk/
Goal
Usually when you deal with a CMS system you are working within the constraints of what that system allows you to do. For lots of uses this works really well, you create a site full of content and add a plugin for a common feature you want added to the site. Meek takes this approach and reverses it, as developers we commonly create a custom application for a customer, and then they need the ability to manage a limited set of content within it.
Then it is up to you to create a simple way to manage some content and images within you application. Using the Microsoft MVC framework Meek makes this task as simple as adding single assembly reference and a web.config entry.
Capabilities
- Create and maintain pages via wiki style usability
- Create and maintain partial page content
- Upload images
- Built in CKEditor
- web.config setup or code based setup
- Delpoyable via Nuget
- Built-in InMemory, SQL, FileSystem, or custom storage
- Razor or ASPX view engine support
- C# or VB project compatablity
- Works under medium trust
- Uses your own layout
How to use
Create content
To create a new page you can simply type in the browser a url that does not exist and if you are a content admin it will give you a screen to create it.
To create partial content you can follow the same method and then add the code in the view to reference it. Or if you do not have any content to start, when you add the code in the view to the partial content it will give a content admin a link to create it.
To add the code in the view for a partial view you use a Html helper method, either called fully qualified or if you add the namespace for in in the razor view engine/pages section in the View/web.config.
<add namespace="Meek.HtmlHelpers"/>
Then it is as simple as adding @{Html.RenderRoute(“A/Partial/Page”);} right in the view where you want it to show up.
To add images to content it uses the built in features of CKEditor, you can click the image feature and use the upload tab to add images and the browser server button to select images.
Editing content
To edit content you can either go directly to the same url used to create it or by browsing the site as a content admin both full and partial pages will display a link to edit the content. Or to view all content currently defined in Meek go to the url /Meek/List and it will provide you the list of links to edit any content available.
Assumptions (Razor View Engine)
Your MVC3 application is using the _Viewstart file to set the default layout, if not then the custom content will not have your layout. The title property created for full pages populates the ViewBag.Title property so you need to use this in your layout to set the browser page title.
These are the current required assumptions and may be configurable later to support more custom configuration options.
Meek is available from NuGet or by building from source from its GitHub repository.
If installing from NuGet it has a dependency on WebActivator to handle initalization, if you wish to avoid this you can reference the Meek.dll only and place the Meek.BootStrapper.Initialize() inside your own Application_Start (must be post route registration).
Configuration
Meek supports configuration via web.config, directly from code or a combination of both.
Both still require you to call the Meek.BootStrapper.Initialize() method on the application startup.
web.config configuration
To use the web.config you first need to add the section…
<section name="meek" type="Meek.Configuration.MeekConfigurationSection, Meek" requirePermission="false"/>
Below is the most basic configuration possible (and what is used if installed from NuGet)
<meek> <repository type="InMemory" /> </meek>
This enables the InMemory repository which is great for testing but obviously looses state when the application is unloaded.
The other two types of built in repositories are “Sql” and “FileSystem”, when using these two you must also supply a source=”" attribute. In the case of Sql it will expect that to be a connection string name defined in the <connectionStrings>, and if using the FileSystem it will expect an existing folder name.
With this basic setup everybody has access to manage content which is obviously not ideal, so you can define roles to uses.
<meek altManageContentRoute="Missing">
<repository type="InMemory" />
<contentAdmin>
<add role="Content Admin"/>
</contentAdmin>
</meek>
If you are configuring it for use with webforms then there are a few settings for you.
the viewEngine attribute should be added and set to “ASPX”, and if your are using masterpages you will need to tell it what masterpage to use and what content placeholder to put the content into. Below is a sample configuration.
<meek viewEngine="ASPX">
<repository type="InMemory" />
<aspxConfig masterPage="~/Site.master" contentPlaceHolderId="MainContent"/>
</meek>
<meek altManageContentRoute="Missing" notFoundView="NotFound" ckEditorPath="CustomCKEditor">
Two are used for a customized experience when using the wiki style page creation, altManageContentRoute allows to to define an special route that Meek will listen on to manage content and the notFoundView is for displaying a custom 404 view.
ckEditorPath is used if you have a custom CKEditor that you would like to use instead of the built-in.
To enable the wiki style page creating you need to need to configure the 404 custom error page to either /Meek/Manage or to the altManageContentRoute value.
<customErrors mode="On"> <error statusCode="404" redirect="/Missing"/> </customErrors>
To use the notFoundView you can create your custom 404 view in the /Views/Shared folder where the MVC framework will naturally pick it up.
code configuration
If you wish to customize the configuration to your own needs you can use the overloads on the Meek.BootStrapper.Initialize() method.
You can supply the values for altMnageContentRoute, notFoundView, and ckEditorPath.
There are three services you are able to change Repository, Authorization, and ImageResizer.
To override any of these you need to use the MVC3 built in DependencyResolver to supply a implementation for the interface.
If you wish more control then you can use the overload to supply a replacement implementation for the meek service locator.
A basic example of how to use Unity and the MVC3 DependencyResolver you can download the source and look at the test application, It manually defines the InMemory repository so it may create a default state for the automated tests.
Recent Comments