The GroupSitemapBuild project. included in version 5.5 of the Telligent Evolution Platform SDK, was developed as a reference application for the Groups endpoint of the Platform APIs. It is a console application that builds an XML sitemap for a Telligent Evolution platform site showing the groups, subgroups and applications in groups (blogs, forums, galleries, and wikis). It is not meant to build a complete sitemap of every page in your site but only serve as sample code for working with the Groups endpoint.
Platform API Groups Endpoint
The Groups Sitemap Builder makes use of the Platform API Groups Endpoint. See the Groups endpoint documentation for details.
Platform API Search Endpoint
The Groups Sitemap Builder makes use of the REST v2 Search Endpoint. See the Search endpoint documentation for details.
The GroupSitemapBuilder.Console sample is a console application that builds two versions of sitemap, based on your site's groups and applications (blogs, forums, galleries, wikis). One sitemap is a sitemap.xml file that uses the Sitemaps.org 0.9 schema for web site sitemaps, which is the format recommended by Google. The second sitemap, sitemap.html, is a simple HTML document that displays your site's groups hierarchy in an unnumbered list (<ul>) format.
The GroupSitemapBuilder consists of several thin layers: the console program itself, a Service layer, a Repository layer, and helper functionality like Mappers and extension methods.
The two classes in the Entities folder, Group and App, are lightweight objects that are local representations of the Telligent Evolution Platform's Group and application (Blog, Forum, Gallery, and Wiki) classes.
The RestRepository class makes requests to the proper REST endpoint and returns the resulting XML.
The Mappers class includes methods for mapping the API's returned XML to an entity, Group or App.
The RestService class performs the majority of the work of the application. It provides a simple interface for requesting a group or groups, calls to the RestRepository to get the returned XML from the API, converts the XML to entities using the Mapper functions and then returns the entities to the calling code.
SitemapExtensions.cs contains extension methods for the Group and App entities for formatting output.
Program.cs is the console application itself. It sets up the RestService passing in the site url, username, and API key to use for the API calls, gets the group hierarchy, and then prints the results to two files using the ToHtml() and ToSiteMap() extension methods for the Group entity.
To create a sitemap of your site:
- Set your site Url, username (of a user with permission to access web services and impersonate other users), and the REST Token for that user in the Main method of the Program.cs file.
- Build the GroupSitemapBuilder.Console project
- Hit F5 to run the console app (or browse to the output .exe file and run it via the command line).
- Two files will be created in your current folder (which is your /bin/Debug or /bin/Release folder in Visual Studio) a sitemap.xml file, your sitemap file, and a sitemap.html file which is a simple HTML document that shows your Group structure in a simple <ul> list format.
- For this sample project to work properly your Telligent Evolution platform site must have the REST API enabled. You can enable the REST API via the control panel: Site Administration > Site Configuration > Manage REST API.
- For this sample project to work properly the user that you specify in step one above must have permissions that allow them to access the REST API. The "Site - Access Web Services" and "Site - Impersonate Users" permissions must be assigned to a role that the user is assigned to. You can manage permissions via the control Panel: Membership Administration > Members and Roles > Manage Site Roles.
- The accessing user, set in step #1 above must have an API Key created. You can create an API key by editing your Settings, clicking the Site Options tab, clicking on the Create and Edit Application Keys link at the bottom of the page, and adding an API Key if you do not already have one.
- This sample application uses the admin user to impersonate the "Anonymous" user so that the sitemap that is created is what a non-logged in user (having the same permissions as the "Everyone" role) would see when accessing your site. The Anonymous user normally does not have permissions to access web services. You will have to temporarily assign the Anonymous user to a role that does have the "Site - Access Web Services" permission to run this sample application. We do not recommend that you do so for your live site. We recommend only running this sample application on a local or staging site. Should you decide to give the Anonymous user elevated privileges to run the sample application you should remember to remove those elevated privileges as soon as possible.