Posts
6
Comments
22
Trackbacks
0
December 2009 Entries
Configuration tasks for a new MojoPortal site

In this post, I'm going to list out the configuration tasks that are needed for any new MojoPortal installation. These tasks are listed elsewhere in documentation, but I haven't seen them listed all in one place yet, so here goes.
I'd like to keep this list up to date as possible, so if there is anything you see that I've missed or gotten wrong let me know and I'll update.

This list includes server-side configurations but stops at the point when you must use the admin UI to make additional changes to your portal.

 

Category

Steps

Notes

User.config file settings

In MojoPortal.Web, right click the project root and choose “Add”  >  “New Item”. Choose “Web Configuration File” and rename the new file “user.config”.

 

Under <appSettings> I add the following keys, your requirements may mean you could need a slightly different list of keys than this. See the Web.config master to see what keys are available. 

<add key="MSSQLConnectionString" value="" />

<add key="SMTPServer" value="localhost" />

<add key="SMTPRequiresAuthentication" value="false" />

<add key="SMTPUseSsl" value="false" />

<add key="SMTPPort" value="25" />

<add key="SMTPUser" value="UserName" />

<add key="SMTPPassword" value="UPassword" />

<add key="SMTPTimeoutInMilliseconds" value="30000" />

<add key="PreferredGreenwichMeantimeOffset" value="-5.00" />

<add key="mojoProfileConfigFileName" value="mojoProfile.config" /> (see next item)

<add key="SilverlightClientKey" value="mojoProfile.config" />

Below are changes that I think are pretty specific to my requirements that I have added to my user.config:

<add key="UseRelatedSiteMode" value="false" />

<add key="ShowForumPostsInMemberList" value="true" />

This new “user.config” file will have all your default appSetting override values. See http://www.mojoportal.com/webconfig.aspx for details.

Web.config changes

Update this section (near the end of the web.config file):

<system.net><mailSettings><smtp>…

Settings as appropriate.

Note that upgrades may overwrite these settings since they are in your web.config. Keep a backup handy!

Edit mojoProfile.config

Remove default profile settings that you don’t want, add ones you want. To avoid having your changes overwritten, you can change the appSettings key “mojoProfileConfigFileName” to something else, copy the original file, and edit the copy under a new name.

I use this name: CustomMojoProfile.config

 

See

http://www.mojoportal.com/userprofileconfiguration.aspx

for details about how to configure this

Change permissions for Data folder

ASPNET user (IIS_WPG and NetworkService on Windows 2003) must have write permission to the Data folder beneath the root of the Web. These permissions must be applied to all child objects, too.

Mostly this is used for logging, I believe.

Content changes

Many opportunities for changing content under

mojoPortal.Web/Data/

much of this is localized boilerplate content specific to the portal itself.

 

Registration agreement

If you want to have a custom registration agreement displayed when users register with your site, you need to create a new content file.

See

http://www.mojoportal.com/creatingaregistrationagreement.aspx

for details

Global images

Global images are under mojoPortal.Web/Data/SiteImages

 

Favicon.ico

If you want to change this, replace in in the /Data/skins/ subdirectories as appropriate.

 

Multi-site installations

If you are upgrading, be sure to remove this file after installing:

/Setup/initialcontent/pages/00001homepage.config

See note at the end of this post

http://www.mojoportal.com/configuring-initial-content.aspx

 

Important keys to change for security purposes

Keys that should be changed in new installations for security (for additional info on security, see http://www.mojoportal.com/security.aspx)

 

appSettings key

Instructions

Notes

SilverlightClientKey

 

Regererate a new GUID

Under appSettings,  so this replacement can be in “user.config”

 

From web.config comments:

SilverlightClientKey is a token used to identify the silverlight app to the server, for logging and other purposes.

    We don't want other people's copy of the app to be able to log to our server.

    Best to generate your own new guid and put it in user.config

Any keys containing PaymentGatewayUseTestMode”

Set to “false” in production!

 

machineKey

This is important for security, you should generate a new one and update <system.web><machineKey validationKey=”…” />

To this new value.

Note: you should save the new value elsewhere because once you encrypt something using your custom machineKey, if you change it you will not be able to decrypt again. Also, because this is not external to the mojoportal web.config file, it may be overwritten, so very important to (securely) keep a 2nd copy!

 

From the Web.config comments:

To generate your own, you can use this nice online utility:

http://www.aspnetresources.com/tools/keycreator.aspx

or this newer one which is more up to date as of 1/4/2007:

http://www.developmentnow.com/articles/machinekey_generator.aspx

 

 Addendum:

I found some error log messages like this:

2010-01-12 10:00:56,315 ERROR mojoPortal.Web.Global - 208.176.36.131-en-US - /HtmlEdit.aspx?mid=4&pageid=12
System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\kn3fdlma.0.cs' could not be found
error CS2008: No inputs specified

To fix, I am assigning read/write privileges to C:\WINDOWS\TEMP for ASPNET user. If anyone knows if this is not necessary or has other solutions, feedback would be appreciated.

 

Posted On Thursday, December 17, 2009 12:38 PM | Feedback (0)
Creating a MojoPortal module

MojoPortal is an open-source content management platform that we have started using at StrongEye because it offers an extensive out of the box starting point for ASP.NET Web applications, and also because it is incredibly developer-friendly.

UPDATE: For most common Web site tasks, you probably can go very far in MojoPortal without having to create custom code. These steps are advanced and for developers who want to create new functionality that cannot be accomplished with the existing feature set that comes out-of-the-box with MojoPortal.

One of the first tasks that a developer needs to do to get started with MojoPortal is to create a module. Basically a module is a starting point for a 100% custom application. The module is the shim that plugs in to MojoPortal proper, and allows you to include a entry point to your application in context of the portal.

I have found the documentation to be great on the MojoPortal site, but there are lots of small details that are hidden inside tutorial videos and elsewhere. This post is an attempt to bring all these things into one place so you can get started.

UPDATE: This post is updated to include a bit more context than before. Before you begin step 1, you must first have a local copy of MojoPortal loaded from SVN per instructions here (note: this links to Windows instructions as that is my bias, Linux SVN instructions are here).

Once you have all the Mojoportal source code loaded locally, you need to set up you VS Solution. The simplest way to do this is to copy an existing .sln file from the code you just got from SVN and rename it so that it will not be overwritten when you do new updates from SVN to get newer versions in the future.

For the purpose of this entry, I am going to make a copy of "mojoportal_mssql_only.sln" and I'll rename it 'mojoportal-localdev_mssql_only.sln'. Then I'll open this file in Visual Studio. Getting the initial project to run locally is beyond the scope of this article, though this is something that you must have working before any of the steps below will work.

How to create a MojoPortal module

Step 1: Create the 3 initial projects

 

 

Category

Steps

Notes

Create UI project

Create a new ASP.NET Web Application [yourProject].UI

 

Delete or rename the auto-generated Default.aspx file so it does not get copied to the portal by mistake.

 

Create subfolders in your Web project for your controls and asp.net pages:

/[yourProject]/

/[yourProject]/Controls/

 

Create a subfolder from the root of your Web project called "Setup:

/Setup/

 NOTE: don't create a new Web Site; what we want is a new Web Application.

 

Right click Solution root > 

Add > 

New Project > 

ASP.NET Web Application

 

Creating contents inside "Setup" is outside the scope of this article. See the developer documentation here for details on how to use the Setup system.

 

Create Business Layer project

Create a new Class Library project [yourProject].Business

 

Create Data Layer project

Create a new Class Library project [yourProject].Data

 

Rename your .Data project to [yourProject].Data.MSSQL (or whatever db you are using). By naming it .Data initially, Visual Studio sets the target assembly name to .Data, renaming the project does not cause this to change, which is the desired behavior.

All the .Data projects that are variants targeting different database technologies should all compile to the same assembly name so they can be swapped at build time.

Add References in your Web UI project

·         Log4net

·         mojoPortal.Business

·         mojoPortal.Business.WebHelpers

·         mojoPortal.Features.UI

·         mojoPortal.Net

·         mojoPortal.Web

·         mojoPortal.Web.Controls

·         mojoPortal.Web.Editor

·         mojoPortal.Web.Framework

·         [yourProject].Business

 

Add Reference in your [yourProject].Business project

·         [yourProject].Data.MSSQL

 

 

Add .resx file for localization

Create a standard ASP.NET folder App_GlobalResources.

In this folder, add a new .resx file by choosing Add > New Item > Resources file. Give the file a name matching your project name so that it is unique.

 

 

Step 2: Make your project mimic mojoPortal.Web enough that it will compile

 

Category

Steps

Notes

Update Web.Config

Open the Web.config file in mojoPortal.Web and copy the entire <pages> section in to your new [myProject].UI web.config

This section (<pages>) lives directly under <system.web> … your project may have an auto-generated section already. You can just overwrite the entire thing.

Copy Master Pages

Create a folder in your [myProject].UI project called “App_MasterPages”

Copy layout.Master from the WebStore.UI subfolder (this is preferable because it is a subset of the entire master page and it’s all that you need to develop). You can also simply copy the entire “App_MasterPages” folder from WebStore.UI (NOTE: NOT mojoPortal.Web! Important to use the folder from WebStore.UI instead!)

This gives your aspx pages the correct content placeholders when you develop your feature.

 

Step 3: Create your Module

The Module is an .ascx control that inherits from SiteModuleControl and creates the instance-specific entry point from the portal into your custom code. From this entry point, you may also have many other pages that are custom aspx pages that use the portal master page.

These steps rely on code generated by CodeSmith, which provides a free version on their site (here)

Category

Steps

Notes

Create Module ascx

In the folder created earlier in [yourProject].UI

/[yourProject]/

Right click and create a new Web User Control (.ascx) called

 [yourProject]Module.ascx

 

Generate ascx from CodeSmith template

Open CodeSmith Studio. In Template Explorer, open the folder “Codesmith4x” found in

\mojoportal\CodeSmith Templates\

 

Find the template called

Mp_UI-starter_ModuleControlGenerator.cst

Right click and choose “Execute”

 

A dialog will open prompting you for values. Here is what to choose:

 

Author: [your name]

BusinessLayerNameSpace: [yourProject].Business

ControlName: [yourModuleControlName]

FeatureName: [yourProject]

UINameSpace: [yourProject].UI

 

Click “Generate”

The result of the generated code includes both control UI code and code-behind c# code. You will need to highlight each section separately to cut and paste.

Cut and paste back into your Module

Select the code beginning with comments

// Author:   [yourname]

To the end. This is the code behind that goes in [yourModule]Module.ascx.cs

 

Open [yourModule]Module.ascx.cs and replace all the code with the copied code. Save.

 

Return to the generated Codesmith resulting code. In the .ascx source section, highlight ONLY the single line beginning with

<%@ Control … %>

Copy that and paste over the Source in your [yourModule]Module.ascx file. Save.

 

Copy the remaining code between

<%@ Control … %> and the code behind c# code comments from CodeSmith into your ascx source.

Save.

 

The sequence and steps are designed here to work around a Visual Studio problem in which the “TitleControl” is not found.

If you simply copy and paste everything all at once instead of following these steps, you may see the error:
“The name ‘TitleControl’ does not exist in the current context” even though the control is there. As long as these conditions are true, you should not see that message:

-          You have the proper MojoPortal references set

-          You have updated the <pages> section in Web.config

-          You copy and paste the CodeSmith output in the correct sequence and Save in between steps.

 

Step 3: Add post-build logic to your Web project

This step integrates your code with mojoPortal with each successful build, so you can run the code and see it in context.

 

 

Category

Steps

Notes

Open the Properties of your .UI project

Right click on [yourProject].UI in Visual Studio Solution Explorer, choose “Properties”. Navigate to the Build Events tab.

 

Add Post-build event command line instructions to your .UI project

The purpose of this section is so that your code from your UI project will be automatically copied into the mojoportal project with each build. If you haven't used these, $(ProjectDir) and $(SolutionDir) are macros that Visual Studio recognizes. For more info about post-build events,see this article.

Copy the commands below into the text box labeled “Post-build event command line:” and replace XXX with your project path names and YYY with your project names:

 

xcopy /s /y "$(ProjectDir)bin\YYY.UI.dll" "$(SolutionDir)Web\bin\"

xcopy /s /y "$(ProjectDir)bin\YYY.Business.dll" "$(SolutionDir)Web\bin\"

xcopy /s /y "$(ProjectDir)bin\YYY.Data.dll" "$(SolutionDir)Web\bin\"

xcopy /s /y "$(ProjectDir)XXX\*.ashx" "$(SolutionDir)Web\XXX\"

xcopy /s /y "$(ProjectDir)XXX\*.ascx" "$(SolutionDir)Web\XXX\"

xcopy /s /y "$(ProjectDir)XXX\*.aspx" "$(SolutionDir)Web\XXX\"

xcopy /s /y "$(ProjectDir)XXX\Controls\*.ascx" "$(SolutionDir)Web\XXX\Controls\"

xcopy /s /y "$(ProjectDir)App_GlobalResources\*.resx" "$(SolutionDir)Web\App_GlobalResources\"

xcopy /s /y "$(ProjectDir)Setup\*" "$(SolutionDir)Web\Setup"

 

Save after you have replaced the paths, right click your Web project and choose Properties. In the Build Events tab, click the Edit Post-build… button and you can paste this there.

Install your feature using the MojoPortal Administration tools

After you build your project, log in to MojoPortal as Administrator and navigate to this location:
Administration > Advanced Tools > Feature Installation / Configuration

You will see a list of all installed features, scroll down and click Add New Feature.

On the new page, enter your module entry point path in Control Source. You may also choose resource files, icons, and other options here. Click Update.

You may now add your new feature to a page.

 

 After the steps above are completed, with my project, here is my solution structure in Visual Studio:

 project structure

 

Posted On Wednesday, December 16, 2009 3:32 PM | Feedback (20)