简体   繁体   English

可以无脑使用CQ5 / Adob​​e Experience Manager吗?

[英]Can CQ5/Adobe Experience Manager be used headless?

No experience with CQ/AEM but been thrown in the deep end. 没有使用CQ / AEM的经验,但是被深深地吸引了。

I have an approach where we'd have a web front end (built using Ember.js/handlebars) making calls to a web service which would in turn join the data (eg how many movies you've watched) with the appropriate content (eg the web service knows to look up node X in the CMS; "Thanks for watching all those movies!") and return the copy, image and data in a single JSON document. 我有一种方法,让我们有一个Web前端(使用Ember.js / handlebars构建)来调用Web服务,该服务将依次将数据(例如,您看过多少部电影)与适当的内容(例如,Web服务知道在CMS中查找节点X;“感谢您观看所有这些电影!”),然后在单个JSON文档中返回副本,图像和数据。

This works really well when I have a RESTful API to the CMS. 当我拥有CMS的RESTful API时,此方法非常有效。

However I've now been asked to make Adobe Experience Manager/CQ5 the CMS, and need to know if the same thing exists. 但是,现在我被要求将Adobe Experience Manager / CQ5设为CMS,并且需要知道是否存在相同的东西。

I don't think it does; 我不认为是这样。 I know that CQ5 uses either JCR/CRX as its content repository but from what I can see these aren't exposed as a web service (only language level APIs available) 我知道CQ5使用JCR / CRX作为其内容存储库,但是据我所知,它们并没有作为Web服务公开(仅提供语言级别的API)

AEM 6.2 uses JCR OAK which promises a RESTful API. AEM 6.2使用JCR OAK并承诺一个RESTful API。

So in short my question is: does JCR OAK provide a RESTful API to the content and if so can anyone provide any examples/pointers please? 简而言之,我的问题是:JCR OAK是否为内容提供RESTful API,请问有人可以提供任何示例/指针吗?

AEM comes with Apache Sling , which allows you to access the contents of the JCR through HTTP requests. AEM附带了Apache Sling ,它使您可以通过HTTP请求访问JCR的内容。

The DefaultGetServlet can allow you to render content in JSON format by using the json extension. DefaultGetServlet允许您使用json扩展名以JSON格式呈现内容。

For example: 例如:

http://localhost:4502/content/geometrixx-outdoors/en/men.infinity.json

Returns the following JSON (shortened for readability): 返回以下JSON(为简化可读性而缩短):

{
    jcr:primaryType: "cq:Page",
    jcr:createdBy: "admin",
    jcr:created: "Mon Jan 09 2017 14:44:46 GMT+1100",
    jcr:content: {
        jcr:primaryType: "cq:PageContent",
        jcr:mixinTypes: [
            "cq:LiveSync"
        ],
    jcr:createdBy: "admin",
    jcr:title: "Men's"
}

As of AEM 6.1, there is also a more user-friendly API based on Siren ; 从AEM 6.1开始,还有一个基于Siren的更加用户友好的API; however it is not fully complete yet. 但是它还没有完全完成。

http://localhost:4502/api.json/content/geometrixx-outdoors/en/men.html

Returns the following JSON (shortened for readability): 返回以下JSON(为简化可读性而缩短):

{
    links: [
    {
        rel: [
            "self"
        ],
         href: "http://localhost:4502/api.json"
    },
    {
        rel: [
            "assets"
        ],
        href: "http://localhost:4502/api/assets.json"
    }
    ],
    class: [
        "core/services"
    ],
    properties: {
        name: "api"
    }
}

These are the OOTB features but you can always create your own Sling Servlet to expose content however you like. 这些是OOTB的功能,但是您始终可以创建自己的Sling Servlet来公开自己喜欢的内容。

If, by headless, you mean whether you can use AEM without using it to host your site then yes it can be used as a Restful content repository as explained by others. 如果无意间表示您是否可以在不使用AEM托管站点的情况下使用AEM,那么可以,它可以用作Restful内容存储库,如其他人所述。 AEM 6.1+ has more support for SPA so you might want to investigate that rather than going down the route of using it as a content repository only. AEM 6.1+对SPA提供了更多支持,因此您可能需要研究一下SPA,而不是仅仅将其用作内容存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM