You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Behrang Saeedzadeh <be...@gmail.com> on 2014/03/31 10:30:26 UTC

Trouble with (and a couple of questions regarding) configuring the Sling Resource Resolver

Hi all,

=== Introduction

We are using Adobe CQ 5 (CQ 5.6) project to create and manage different
sites with different domains.

These sites are stored in shards with the following format:

   /content/myapp/a1/b1/c1/uuid-1/
   /content/myapp/a2/b2/c2/uuid-2/
   /content/myapp/a3/b3/c3/uuid-3/
   ...

Each site has a home page that is stored in the root folder of the site.
For example, we have:

   /content/myapp/a1/b1/c1/uuid-1/home

in which home is a cq:Page.

Other pages of the site are children of the home page. For example we have:

   /content/myapp/a1/b1/c1/uuid-1/home/about
   /content/myapp/a1/b1/c1/uuid-1/home/faq
   ...

We want to accomplish the following two objectives:

   1. Serve each CQ site from a distinct domain (no two sites can have the
   same domain)
   2. Serve sites with short URLs. That is, pretending that we want to
   serve the site with uuid-1 from site-1.com
      1. Home page should be accessible via http://site-1.com rather than
      http://site-1.com/content/myapp/a1/b1/c1/uuid-1/
      2. Similarly the about page should be accessible via
      http://site-1.com/about and faq should be accessible via
      http://site-1.com/faq
   3. Rewrite URLs in the generated HTML pages to their short forms. For
   example, if a generated page contains an anchor like <a href="
   /content/myapp/a1/b1/c1/uuid-1/home/faq">FAQ</a>, before being sent to
   the browser, it should be shortened to <a href="/faq">FAQ</a>

To test our implementation in local development environments, we have added
the following entries to our /etc/hosts files:

127.0.0.1       site-1
127.0.0.1       site-2
127.0.0.1       site-3


This allows us to connect to our local CQ5 Publisher instances via
http://site-1:4503 to test these mappings.

It is difficult to find all the information required to implement these two
objectives in one place. One article we are using as a starting point
is Multidomain CQ mappings and Apache configuration:
http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration/

According to this article, we need to define two sling mappings under
/etc/map.publish. With some minor changes, we have implemented these
mappings:

   - Gist: https://gist.github.com/behrangsa/6a8f5682706668eb6942
   - Downloadable:
   https://drive.google.com/file/d/0ByWstmU-AS9GQ2NxNXQzWGNDcjQ/edit?usp=sharing

With this configuration we have achieved our first two objectives. However
we have not managed to achieve our 3rd objective. That is when we view the
source code of an HTML page generated by CQ5, none of the anchor hrefs are
transformed to their shorter forms.

=== Questions

   - Is sling:Mapping thoroughly documented anywhere? I especially want to
   know how sling treats internalRedirect when it contains an array of strings
   rather than a string. There's this page here (
   https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html)
   but it is quite brief and lacks detail.
   - Is there anything wrong with the configuration that I have posted?
   - What else do I have to do to make CQ transform anchors in the
   generated HTML files so that they are shortened? In case it might be
   helpful, output of /system/console/status-slingrewriter is also uploaded to
   here: https://gist.github.com/behrangsa/e50c3131b693e8d06c61
   - Here's a screenshot of our Day CQ Link Checker Transformer's
   configuration: http://i.imgur.com/E4AS3R4.png (Gist here:
   https://gist.github.com/behrangsa/f20189d559408db4a652)



Thanks in advance,
Behrang
http://www.behrang.org

Re: Trouble with (and a couple of questions regarding) configuring the Sling Resource Resolver

Posted by behrangsa <be...@gmail.com>.
We finally managed to pinpoint the issue and fix this.

Somebody had added a
`com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl.xml` under
`/apps/myapp/config.publish` with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
        jcr:primaryType="sling:OsgiConfig"
        service.bad_link_tolerance_interval="{Long}48"
        service.check_override_patterns="[^.]"
        service.special_link_patterns=".*&#xa;"
       
service.special_link_prefix="[javascript:,data:,mailto:,#,&lt;!--,${]"/>

I think the combination of `check_override_patterns` and
`special_link_patterns` had disabled link shortening.

Removing this file made link shortening work again.



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Trouble-with-and-a-couple-of-questions-regarding-configuring-the-Sling-Resource-Resolver-tp4032312p4032346.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Trouble with (and a couple of questions regarding) configuring the Sling Resource Resolver

Posted by Behrang Saeedzadeh <be...@gmail.com>.
Hello again,

It seems to me while the article that I had mentioned in my previous email (
http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration/)
implies that the "linkchecker" transformer/rewriter converts longs URLs
into short URLs, it, in fact, only checks for broken links (please correct
me if I am wrong).

I ended up implementing a custom transformer:
https://gist.github.com/behrangsa/9890191

This is basically copied from
https://dev.day.com/docs/en/cq/current/deploying/dispatcher/disp_domains.htmlwith
some minor changes.





Best regards,
Behrang
http://www.behrang.org


On Mon, Mar 31, 2014 at 7:30 PM, Behrang Saeedzadeh <be...@gmail.com>wrote:

> Hi all,
>
> === Introduction
>
> We are using Adobe CQ 5 (CQ 5.6) project to create and manage different
> sites with different domains.
>
> These sites are stored in shards with the following format:
>
>    /content/myapp/a1/b1/c1/uuid-1/
>    /content/myapp/a2/b2/c2/uuid-2/
>    /content/myapp/a3/b3/c3/uuid-3/
>    ...
>
> Each site has a home page that is stored in the root folder of the site.
> For example, we have:
>
>    /content/myapp/a1/b1/c1/uuid-1/home
>
> in which home is a cq:Page.
>
> Other pages of the site are children of the home page. For example we have:
>
>    /content/myapp/a1/b1/c1/uuid-1/home/about
>    /content/myapp/a1/b1/c1/uuid-1/home/faq
>    ...
>
> We want to accomplish the following two objectives:
>
>    1. Serve each CQ site from a distinct domain (no two sites can have
>    the same domain)
>    2. Serve sites with short URLs. That is, pretending that we want to
>    serve the site with uuid-1 from site-1.com
>       1. Home page should be accessible via http://site-1.com rather than
>       http://site-1.com/content/myapp/a1/b1/c1/uuid-1/
>       2. Similarly the about page should be accessible via
>       http://site-1.com/about and faq should be accessible via
>       http://site-1.com/faq
>    3. Rewrite URLs in the generated HTML pages to their short forms. For
>    example, if a generated page contains an anchor like <a href="
>    /content/myapp/a1/b1/c1/uuid-1/home/faq">FAQ</a>, before being sent to
>    the browser, it should be shortened to <a href="/faq">FAQ</a>
>
> To test our implementation in local development environments, we have
> added the following entries to our /etc/hosts files:
>
> 127.0.0.1       site-1
> 127.0.0.1       site-2
> 127.0.0.1       site-3
>
>
> This allows us to connect to our local CQ5 Publisher instances via
> http://site-1:4503 to test these mappings.
>
> It is difficult to find all the information required to implement these
> two objectives in one place. One article we are using as a starting point
> is Multidomain CQ mappings and Apache configuration:
> http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration/
>
> According to this article, we need to define two sling mappings under
> /etc/map.publish. With some minor changes, we have implemented these
> mappings:
>
>    - Gist: https://gist.github.com/behrangsa/6a8f5682706668eb6942
>    - Downloadable:
>    https://drive.google.com/file/d/0ByWstmU-AS9GQ2NxNXQzWGNDcjQ/edit?usp=sharing
>
> With this configuration we have achieved our first two objectives. However
> we have not managed to achieve our 3rd objective. That is when we view the
> source code of an HTML page generated by CQ5, none of the anchor hrefs are
> transformed to their shorter forms.
>
> === Questions
>
>    - Is sling:Mapping thoroughly documented anywhere? I especially want
>    to know how sling treats internalRedirect when it contains an array of
>    strings rather than a string. There's this page here (
>    https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html)
>    but it is quite brief and lacks detail.
>    - Is there anything wrong with the configuration that I have posted?
>    - What else do I have to do to make CQ transform anchors in the
>    generated HTML files so that they are shortened? In case it might be
>    helpful, output of /system/console/status-slingrewriter is also uploaded to
>    here: https://gist.github.com/behrangsa/e50c3131b693e8d06c61
>    - Here's a screenshot of our Day CQ Link Checker Transformer's
>    configuration: http://i.imgur.com/E4AS3R4.png (Gist here:
>    https://gist.github.com/behrangsa/f20189d559408db4a652)
>
>
>
> Thanks in advance,
> Behrang
> http://www.behrang.org
>