.NET 企业库 知识分享--知识产生力量,成功源于分享!
RSS

导航







专业.NET技术社区

专业.NET技术社区


快速搜索

高级搜索 »

Architectural Documentation

修改时间: 2007/11/04 03:03 由 admin - 编目为: ScrewTurn Wiki
This page presents an overview of the architecture of the ScrewTurn Wiki engine.




编辑

1 - Functionalities and Architecture Overview

The ScrewTurn Wiki engine is a server-side application whose purpose is to run a wiki-style website. The software is based on Microsoft ASP.NET 2.0, and written in C#.

The main functionalities that the wiki engine presents are:

  • Page management: allows to create and modify wiki pages using a particular markup language called WikiMarkup. Standard XHTML is also allowed. Every time a page is modified, a new revision is created so that a full change history is always available. Pages can be categorized as needed.
  • User management: allows to manage user accounts, with the possibility to flag some of them as administrators. In such case, the users are able to perform administration tasks such as deleting pages, managing user accounts, etc.
  • File management: allows to upload, delete and rename files to be used in the wiki (images, documents, compressed archives, and so on).
  • Snippet management: allows to manage WikiMarkup snippets, i.e. small chunks of text that can be inserted anywhere in the wiki by reference.
  • Navigation path management: allow to define lists of pages that can be browsed sequentially, so that it’s possible to illustrate procedures or processes step-by-step.
  • "Meta" information management: allows to edit parts of the web interface such as the global header and footer, the sidebar/menu, the page header and footer, etc. All the content is written in WikiMarkup or XHTML.

编辑

1.1 - Data Management

The wiki engine manages several kinds of data:

  • User accounts
  • Pages and related data
  • Uploaded files
  • Snippets
  • "Meta" information

编辑

1.1.1 - User Accounts

A user account has the following properties:

  • Username
  • Email address
  • Creation date/time
  • Active flag
  • Admin flag

When the "active" flag is true, the user account is active and can be used to login to the wiki. When the "admin" flag is true, the user account has administration rights. All user accounts have a password, but the wiki does not have direct access to it: Users Storage Providers are demanded to authenticate users directly.

编辑

1.1.2 - Pages and Related Data

A wiki page has the following properties:

  • Name
  • Status
  • Non-Cached flag
  • Creation date/time
  • Title
  • Content

The name of the page is used for handling HTTP requests and for storage purposes. The status indicates the access status of the page:

  • Normal: authenticated users can edit the page
  • Public: anonymous users can edit the page
  • Locked: only administrators can edit the page

When the "non-cached" flag is true, the page content is never cached and every time the page is requested, its content is loaded from the Provider.

1.1.2.1 - Page Discussion

Every page has a discussion associated to it. A discussion is a tree-structured set of messages written by users. Each message has the following properties:

  • ID
  • Username of the author
  • Subject
  • Creation date/time
  • Body (WikiMarkup or XHTML)
  • Replies

1.1.2.2 - Categories

Each page can be bound to zero or more categories, which only have a name.

1.1.2.3 - Navigation Paths

Navigation paths only have two properties:

  • Name
  • List of pages

编辑

1.1.3 - File Management

The wiki engine allows to upload, delete and rename files, which are all managed internally. All files are stored in a local directory.

编辑

1.1.4 - "Meta" Information

The wiki engine allows to customize the following parts of the web interface:

  • Global header
  • Sidebar or menu
  • Global footer
  • Page-level header
  • Page-level footer

编辑

1.2 - Provider-Based Architecture

Two main parts of the wiki engine are based on providers:

  • Data storage
    • User accounts
    • Pages and related data
  • Content formatting

编辑

1.2.1 - Users Storage Providers

A Users Storage Provider is responsible of storing and retrieving account data from a persistent storage medium.

The functions of a Users Storage Provider are:

  • Retrieve all user accounts
  • Test an account with username/password for authentication
  • Add new accounts
  • Edit existing accounts data
  • Removing existing accounts

User account objects have a reference to their provider.

The wiki engine internally uses a standard Users Storage Provider to store account data in local text files.

编辑

1.2.2 - Pages Storage Providers

A Pages Storage Provider is responsible of storing and retrieving page data from a persistent storage medium.

The functions of a Pages Storage Provider are:

  • Retrieve/add/remove/rename/merge categories
  • Retrieve a list of all pages
  • Retrieve the list of revisions of a page
  • Retrieve the content of a page revision
  • Add new pages
  • Modify existing pages, creating backups of the current content
  • Rename/remove existing page
  • Rollback existing pages to a previous revision
  • Bind a page with zero or more categories
  • Retrieve/add/modify/delete messages for a page
  • Retrieve/add/modify/delete navigation paths
  • Retrieve/add/modify/delete snippets

It's important to note that objects (such as pages, categories, navigation paths) can be bound together only if they are managed by the same provider.

Pages, categories, snippets and navigation paths object have a reference to their provider.

The wiki engine internally uses a standard Pages Storage Provider to store pages data in local text files.

编辑

1.2.3 - Formatting Providers

In order to allow more flexibility, the wiki engine can load Formatting Providers, i.e. objects that can alter the content of a page or "meta" file before the user sees it.

In particular, a Formatting Provider can alter the content of a page or "meta" file during three different phases:

  1. Phase 1: executed after the content is retrieved from storage. The wiki engine has not yet converted the WikiMarkup to XHTML.
  2. Phase 2: executed after the wiki engine has converted WikiMarkup to XHTML.
  3. Phase 3: executed before rendering the content to the browser.

A Formatting Provider can declare which phase(s) it needs to execute.

The wiki engine does not use a Formatting Provider to perform WikiMarkup - XHTML conversion.

编辑

1.3 - Data Caching

The wiki engine implements different types of data caching, in order to improve performance.

A full sorted list of pages is always kept in memory: every time a page is requested, a binary search is performed on the list. Note: this list does not contain the content of page, but only the auxiliary information.

A full sorted list of user accounts is always kept in memory: every time a user tries to login, a binary search is performed on the list, and the proper provider is demanded to authenticate the account.

Retrieving the pages content from disk and converting it to XHTML is an onerous operation, so there the engine also has a content cache, which contains both the raw page content and the partially formatted (Phase 1 + Phase 2) content. Every time a page is requested, its content is searched in the cache: in case of cache hit, Phase 3 is executed and the content is rendered. In case of cache miss, the content is loaded from the proper provider, Phase 1 and 2 are executed and the partially formatted content is cached. The cache adopts a least-recently-used paradigm to discard old data and free space for new content.

Partially formatted "meta" information is also cached in a dictionary object.

编辑

2 - Architecture Detail

System Architecture

System Architecture

The engine is partitioned in two main blocks, as displayed in the diagram.

The Core Assembly contains all the business logic, such as data management and caching, content formatting, providers configuration and loading and system configuration.

Access control is directly performed by the ASP.NET pages, which also take care of the content presentation and user interaction.

To get detailed information about the Core Assembly and the single ASP.NET pages, please follow these links:

.NET 藏经阁 | | 版权所有 ©2008 entlib.net.cn