Hello Jin Lin,
On Tue, Jul 30, 2013 at 8:47 PM, jin lin <
bboyj...@gmail.com> wrote:
> Thanks for the reply, but I still don't get it. Let's say I put <a
> href="/abc" ></a> inside the CMS documents. and this will convert to <a
> href ="site/rest/abc"></a> after the rest call. I read the URL you have
> posted.
> <hst:link var="abc" path="/abc"/>
> <a href="${abc}"></a>
> but this is automatically gone because the htmlcleaner inside the CMS
> documents.
> I do not quite understand how it works.
I'll try to give some general concepts explanation. I think our
documentation is not quite good enough at this moment for general
architectural overview kind of explanations : I am working on this the
coming months every now and then. I will cover rest concepts as well.
I only have started with [1] at this moment which is not about REST or
the HST yet. More will follow.
Any way, in a nutshell :
Hippo CMS is document oriented, not page oriented. This means, in the
CMS when editing documents, you are not creating pages. You might not
even know as an editor where you document ends up as a url...also, it
can be exposed in multiple channels (site, rest, rss). Thus obviously,
since the same document can be exposed in multiple channels (and
multiple environments, for example test, acct, prod all having
different host names and urls), a document in the cms can never have a
'URL'. Also, internal links to other documents are not URLs : They are
just references. So, documents are just plain content, with links to
internal or external documents (the external links are already fully
qualified urls of course)
that is in a very small nutshell the CMS document part.
Now, we have the HST, which is a delivery tier framework, which is
normally used to build sites, rest apis, rss, pdf, etc. The HST is a
framework as it calls the code you write. In the sense, Hippo Site
Toolkit is a confusing name. Hippo Site Framework would be more
accurate. Any way, the HST from birds eye view has two parts:
1) Request matching phase [2] : To which channel should some url
resolve and to which sitemap item
2) Request processing phase [3] : Which component tree to render in
case of normal site generation, or, in case of REST apis, which JAX-RS
endpoint to process [4,5,6].
Now, the HST use the matching phase to map a incoming URL to some
sitemapitem (in case of REST api you can do without a sitemap). The
HST *knows* how to rewrite internal documents links to real URLs. You
can do this by using the <hst:link hippobean="${mybean}"> tag and
inject a hippoBean in it (HippoBean is actually a lightweight wrapper
around a jcr document). The HST will then general a link for that
bean. Rewriting all links in some html blob is done with <hst:html>
tag. Any way, this is all quite site related.
However, you can expose the very same content also over a different
channel than a site, for example over a REST api. You then have to
create a mount or sitemapitem that delegates to either plain rest
pipeline or content rest pipeline. In the rest representations, you
can use the HstLinkCreator. This one will create correct links for jcr
nodes that you expose over REST.
I know the above is a way too short explanation, but it is kind of
difficult to explain the entire cms 7 concept and hst in one mail :).
I can only give you some examples of rest apis you can look at. See
[7]. for this one, svn co the 1.04.xx and start it up locally. On the
site homepage you can see in the content some links to REST endpoints.
The gogreen demo also has examples for it. If you want, I can check
out tomorrow the gogreen code and where to find the examples, that
might help...
Last thing about hst linkrewriting : We normally develop locally on
localhost and deploy the site always as site.war. This means, the
context path is always /site. In production, we normally also deploy
as site,war. Then however we have httpd in front that injects the
/site part of the url, so visitors of course don't see the /site part.
To make sure that in that case the hst does not generate links
containing /site, we set in the repository at /hst:hst/hst:hosts the
boolean 'hst:showcontextpath' to false.
more about hst links can be found at [8,9]
Regards Ard ... hope this already helps a bit
[1]
http://www.onehippo.com/en/resources/blogs/2013/07/hippo-cms-a-birds-eye-architectural-tour.html
[2]
http://www.onehippo.org/7_8/library/concepts/request-handling/hst-2-request-matching.html
[3]
http://www.onehippo.org/7_8/library/concepts/request-handling/hst-2-request-processing.html
[4]
http://www.onehippo.org/7_8/library/concepts/rest/restful-jax-rs-component-support-in-hst-2.html
[5]
http://www.onehippo.org/7_8/library/concepts/rest/restful-api-support---content-context-aware-jax-rs-services.html
[6]
http://www.onehippo.org/7_8/library/concepts/rest/restful-api-support---plain-jax-rs-services.html
[7]
http://svn.onehippo.org/repos/hippo/hippo-cms7/testsuite/branches/hippo-testsuite-1.04.xx/components/src/main/java/org/hippoecm/hst/demo/jaxrs/
[8]
http://www.onehippo.org/7_8/library/concepts/links-and-urls/hst-2-urls.html
[9]
http://www.onehippo.org/7_8/library/concepts/links-and-urls/context-aware-canonical-preferred-and-navigationstateful-urls.html
Boston - 1 Broadway, Cambridge, MA 02142