In Juvia, comments are contained in two hierarchical layers. Comments are contained within topics. Topics are are contained within sites. A site is owned by exactly one user who can administer everything within it. This is similar to how many web forums works.
Sites must be registered (created) manually, but topics are automatically created upon posting a comment to a particular topic.
Embedding a Juvia comments page only involves embedding some JavaScript code. Embedding happens entirely in the browser: the page in which Juvia comments are embedded does not require any server-side modifications. Juvia uses various cross-domain request techniques in order to pull this off.
Juvia does not use any iframe
s. The HTML for displaying the comments
and the form is directly embedded inside the page. In order to work well with AJAX
web pages, Juvia never reloads the current page, nor does it ever redirect to another
page.
The beginning of the JavaScript is where the options are. Some of them must be set before the JavaScript works properly.
#comments
or .main .comment-container > div
.The topic_key. This is a unique identifier within the context of a site (it is allowed for another topic within another site to have the same topic key). Unlike the site key, the topic key is not pre-generated: you can pick one yourself, but it must not be longer than 255 characters.
When a comment is posted it is automatically stored within the topic that is referred to by the given site key and the topic key. If there is no topic with such a topic key within the site, then the topic is created.
The site key and the topic key are merely identifiers necessary for Juvia to work. They are never shown to the visitor.
Fetching from and posting to on other domains is usually forbidden by the browser's same origin policy. Newer browsers support a mechanism called Cross-Origin Resource Sharing (CORS) which allows browsers to perform AJAX calls to other domains, and Juvia uses this whenever possible.
On older browsers that don't support CORS, Juvia falls back to a
JSONP-like technique that
involves injecting script
tags to perform cross-domain requests.
Request parameters are embedded in the tag's URL. However, because browsers
impose a limit
on the maximum size of URLs, only a limited amount of data can be posted.
The lowest common denominator seems to be Internet Explorer which imposes
a limit of 2083 characters. This means that on non-CORS capable browsers,
the user will be unable to post large comments. In order to reduce the
impact of this problem, Juvia compresses the comment text with zlib.
Juvia has full support for AJAX web pages, i.e. web pages that are dynamically updated without reloading the page itself or redirecting to another page. Simply execute the Juvia embedding code again (with possibly different options) and everything will work as expected. It is even possible to embed multiple Juvia comment pages on a single web page.
However the second time you load a Juvia comment page may result in some things to be redundantly loaded again. To see what's redundant, let's consider what a Juvia comment page consists of:
Items 1 and 2 are already loaded the first time you load a Juvia comment page. You can omit them by setting the include_base and include_css options to false.
It is possible to embed multiple Juvia comment pages on a single web page. Just specify different container paths for each of them. And just as described in AJAX support, the base runtime code and the CSS are redundantly loaded the second time, so you can omit them by settings include_base and include_css to false.