Content View Specification

advertisement
Content View Specification
Overview
The content view is integrated into the WebApp and UI. Thus all code for viewing content is contained
within the WebApp project. Most of that is placed on Controls, which is a “piece” of a webpage that can
be placed on any page. Thus it be possible to add content to any page simply by adding its control,
though in the future there might be differences between content displayed on its own page, and
perhaps a smaller version of that for pages where that content isn’t the focus.
Currently there are three different types of content: Text (markup), Images, and Video. Each of these is
displayed by its own specific renderer, and pages that contain content might look different depending
on the type of content. For details on the video content renderer, see the Video Player Specification.
Content Controls and Abstraction
Most of the content is displayed through a hierarchy of controls. For instance, a page with video
content might contain the video player itself, a list of related videos, a comment box and list of
comments, some metadata (including who authored the video and when), and so on. Each of these
would be its own control, such that the same control for comments could also be placed on, say, a page
with text content, or a user’s profile. These controls can also contain other controls, for instance a list of
related links might have multiple copies of a control that displays a single link. This way, changing the
link in one place changes it everywhere that it is used.
For these to work on any page, the controls need to know exactly what data to show. This is done
through the use of properties. The page, or a higher level control, can set properties on a control that it
contains, and once that control has learned all the information it needs to know, it can display. All
controls that display something that has to do with content inherit from the AContentControl class,
inheriting the Content and ContentId properties. Once the user sets either of these (if ContentId was set,
the database needs to be queried first), then the control goes ahead and displays its information, for
instance the author of that content. If the property is not set in this case, then the control doesn’t know
which content to show the author for, and can’t display anything. It is the responsibility of the
containing page or control to make sure all of the properties are set.
Content Layout Controls and the Visitor
The controls in the ContentLayoutControls folder have a simple purpose: layout the controls that a
content page would contain for the specific type of content. Thus there is exactly one
ContentLayoutControl for each type of content. The VideoContentLayoutControl might have a
VideoContent control (the video player), and controls for comments and related results, and those
would all be laid out differently than the text or image content pages.
With this design, the Content page needs only to add the ContentLayoutControl for the correct type of
content, and the subcontrols will all be added and laid out properly. This selection process is done using
a visitor, the interface for which is defined in the Common project. This visitor automatically decides,
based on the type of content, which ContentLayoutControl the content page should display.
Note that it is important to add both a ContentLayoutControl and the appropriate method in the visitor
when a new type of content is added.
Text (Markup) Content
Markup content is an extension of text content that allows the author to specify formatting. The
formatting is done with XHTML, but we only allow a subset of the tags (script and forms are both out).
This gives the user more control of the look of their content, without exposing our site to attacks. For
users who are unfamiliar with writing markup (which we theorize will be most), a WYSIWYG editor is
provided, that does all markup internally and displays what that content will look like to the user, as he
is working on it.
Using markup we can also add our own functionality. We have setup an embed tag, that allows a user to
embed another content within the markup on his page. Since that tag is not part of standard markup,
then we must parse it and deal with it ourselves, through an XmlDocument. Most of the rest of the
markup can simply be passed to the browser, as the browser should be able display HTML properly.
Image Content
Image content has minimal support, currently, but we are investigating ways to use javascript and have
an interactive display of images, and the ability to hover over and see tags and other information related
to that image. The ImageControl simply displays an image, with the URL of ServeImage.aspx, which
serves the image to the page.
Download