YAF.NET (aka Yet Another Forum.NET) for mojoPortal
Adds a YAF.NET Forum feature to mojoPortal: put it on a page and the forum runs inside that page, with the mojoPortal login, users and roles.
- YAF.NET 3.2.18 (the .NET Framework version,
netfxbranch) - mojoPortal 4.x (.NET Framework 4.8.1)
- all databases of mojoPortal and YAF.NET: SQL Server, MySQL, PostgreSQL, SQLite (the forum tables, prefix
yaf_, go into the mojoPortal database by default; with SQLite the forum gets its own database fileApp_Data\yaf.db)
There is an installation package for each mojoPortal edition (database) - use the one of your mojoPortal:
| mojoPortal edition | package |
|---|---|
SQL Server (mojoportal-mssql) |
YAF-mojoPortal-v<version>-mssql.zip |
MySQL (mojoportal-mysql) |
YAF-mojoPortal-v<version>-mysql.zip |
PostgreSQL (mojoportal-pgsql) |
YAF-mojoPortal-v<version>-pgsql.zip |
SQLite (mojoportal-sqlite) |
YAF-mojoPortal-v<version>-sqlite.zip |
The packages only differ in the YAF data provider and its database client. No source code or build tools are needed: extract the package and run
.\Install-YafMojoPortal.ps1 -MojoPortalWebDir C:\inetpub\mojoportalor copy the files and merge the Web.config changes by hand - see the INSTALL.md in the package.
mojoPortal has no extension installer like DNN, so the package is a zip with the files for the web root
(files\), the install script and the Web.config changes (web.config-changes.xml).
The packages are on the releases page. They are built
by the Release GitHub workflow on every push to master when the YAF.NET version of the YAFNET submodule
(yafsrc\GlobalAssemblyInfo.cs, also the version of the module) is newer than the latest release - so a
submodule update to a new YAF.NET version creates the next release. The module is built against the
assemblies of a mojoPortal release (MOJOPORTAL_VERSION in .github/workflows/release.yml).
This project is dependent upon the parent solution, YAFNET (like the YAFNET-DNN module).
YAFNET-mojoPortal\
YAFNET\ git submodule: https://github.com/YAFNET/YAFNET.git, branch netfx (YAF.NET 3.2.x)
yafsrc\ NTFS junction -> YAFNET\yafsrc (created by init-yafsrc.ps1, not in git)
yaf_mojoportal\ the mojoPortal module (YAF.MojoPortal.slnx)
init-yafsrc.ps1
-
Clone this repository.
-
From a Windows PowerShell prompt in the repo root, run
.\init-yafsrc.ps1. This initializes theYAFNETsubmodule and creates the junctionyafsrc\->YAFNET\yafsrc\. -
Build YAF.NET and the module and install them into a mojoPortal site:
.\yaf_mojoportal\deploy\Deploy-YafMojoPortal.ps1 -MojoPortalWebDir C:\path\to\mojoportal\Web -BuildYaf
-BuildYafrestores the YAF packages and buildsyafsrc\YAF.NET-SqlServer.slnx(needed once and after a submodule update), without it only the module is built. The default-MojoPortalWebDiris a mojoPortal checkout next to the YAFNET folder (..\..\mojoportal\Webfrom the repo root). Use-ConnectionStringfor a separate forum database. The script can be run again for updates.
To later update to a newer commit of the YAFNET netfx branch, run git submodule update --remote YAFNET
(the yafsrc junction does not need to be recreated) and deploy again with -BuildYaf.
To build the installation package:
.\yaf_mojoportal\deploy\Build-Package.ps1 -BuildYafThe zips (one for each database, -Database mssql,mysql,pgsql,sqlite to build only some) are created in
yaf_mojoportal\bin\package\. Deploy-YafMojoPortal.ps1 takes -Database too (default mssql).
Building the module needs the mojoPortal assemblies:
-MojoPortalWebDir can be any mojoPortal 4.x site (only its bin folder is used), not the mojoPortal source.
Script (yaf_mojoportal\deploy\) |
|
|---|---|
Build-Package.ps1 |
builds YAF.NET (-BuildYaf) and the module, creates the package folder and the zip |
Install-YafMojoPortal.ps1 |
installs a package into a site (part of the package) |
Deploy-YafMojoPortal.ps1 |
development: Build-Package.ps1 + Install-YafMojoPortal.ps1 in one step |
- Run the install script of the package or the deploy script (see above).
- Open
/Setup/Default.aspxof the site once - mojoPortal registers the feature ("Configuring YAF.NET Forum"). - Add the YAF.NET Forum feature to a page and open the page as a mojoPortal administrator: the forum database and the board are created on that first visit, the administrator becomes the forum host admin.
- The application pool needs write access to
~/yaf/uploads(attachments, albums, avatars).
| Where | What |
|---|---|
bin |
the YAF assemblies and YAF.MojoPortal.Module.dll. Assemblies that mojoPortal already has are never replaced (a rebuild of mojoPortal would bring them back), the YAF references are redirected to them. Lucene.Net 4.8 is not deployed (see Search). |
~/yaf/ |
the YAF pages, controls, scripts, themes and languages, and its own web.config (YAF control prefixes, UTF-8, handlers) |
~/YafForum/, App_GlobalResources, Setup/applications/yafnet |
the mojoPortal feature |
Web.config (backup Web.config.<date>.bak) |
the YAF.* app settings, the yafnet connection string, owin:AutomaticAppStartup=false and binding redirects to the assembly versions in bin |
Nothing has to be added to global.asax, the module registers itself (PreApplicationStartMethod).
| Setting | |
|---|---|
| Forum Board ID | the YAF board of the module (default 1) |
| Use the language of the site | the forum language follows the mojoPortal culture (when YAF has the language) |
The module title gets a "Forum Administration" link for editors (YAF checks the admin rights itself).
- Login: mojoPortal does the login, the YAF login, registration and logout are turned off
(
YAF.AllowLoginAndLogoff=false). Guests that need to log in are sent to the YAF "custom login redirect url" (host settings), which the module sets to the mojoPortal login page (with a return url to the forum page). - Users: each mojoPortal user gets a YAF login account (
yaf_AspNetUsers, id = mojoPortal user guid) and a forum user. Name, display name and email follow mojoPortal. - Roles: mojoPortal
Adminsare forum host admins and members of the YAFAdministratorsgroup. To map a mojoPortal role, create a YAF group with the same name as the role - the membership then follows mojoPortal (checked every 5 minutes per user). YAF groups without a matching role are managed in the forum only. All users are in the YAF start groups (e.g.Registered Users). - Links: the forum links are the url of the mojoPortal page plus the forum parameters
(
/forum?g=Topics&f=2). The page is saved in the board settings (for links in emails). - Web API: mojoPortal registers the attribute routes (also the ones of the YAF controllers), the module
maps the YAF calls
~/yaf/api/...to them and adds the YAF filters and the session state for these calls only. - Search: mojoPortal needs Lucene.Net 3.0.3, YAF 3.2 uses Lucene.Net 4.8 - both have the same file name, so
the YAF search is replaced by a database search (
MojoPortalSearch). It understands the queries of the YAF search page (topic, author, tags, phrases), no search index is needed. - Upgrades: deploy a newer YAF 3.2.x, the database is upgraded automatically on the next visit.
- Some profile functions of YAF are only hidden for DNN (YAF core checks
Config.IsDotNetNuke), so they are visible inside mojoPortal although mojoPortal manages them: change password, delete account and the user import/sync in the forum admin. They work on the forum login accounts only and have no effect on the mojoPortal login. - The YAF scripts bring Bootstrap 5 (JavaScript); a mojoPortal skin that loads another Bootstrap version can conflict.
- The forum sends its emails with its own mail settings (
system.net/mailSettings), not with the SMTP settings of mojoPortal.
Remove the feature from the pages, delete ~/yaf, ~/YafForum, Setup/applications/yafnet,
App_GlobalResources/YafForumResources.resx and bin/YAF*.dll, and restore Web.config from the backup.
The forum tables (yaf_*, also the login accounts yaf_AspNet*) stay in the database (with SQLite: App_Data\yaf.db).