Nicolas Raoul
Nicolas Raoul

Reputation: 60203

Static HTML page in a Share AMP

I have made an AMP for Alfresco Share.

Now, I want that AMP to also serve a static HTML page when installed.

What is the best way to do that?

I could create an Alfresco Share Web Script, but that would be overkill, right?

Upvotes: 0

Views: 194

Answers (2)

Nicolas Raoul
Nicolas Raoul

Reputation: 60203

Here is the way suggested by @vikash, if you find something better please post a new answer, thanks!

In your Share AMP, add the following 3 files:

  • File src/main/amp/config/alfresco/templates/mypage.ftl containing just the HTML of your static page.
  • File src/main/amp/config/alfresco/web-extension/site-data/template-instances/mypage.xml containing <template-instance><template-type>mypage</template-type></template-instance>.
  • File src/main/amp/config/alfresco/web-extension/site-data/pages/mypage.xml containing this:

 

<page>
    <template-instance>mypage</template-instance>
    <authentication>none</authentication>
</page>

Then compile and redeploy your Share AMP.
The page should be visible at http://localhost:8080/share/page/mypage

Upvotes: 0

Gagravarr
Gagravarr

Reputation: 48326

In your source AMP package, create a folder src/web-resources/

In the file-mapping.properties have an entry for /web-resources=/ eg

/config=/WEB-INF/classes
/web-resources=/

Your AMP's contents should then be something like:

Archive:  build/dist/Custom500.amp
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-04-28 15:28   lib/
      136  2013-07-23 08:50   module.properties
        0  2016-04-01 10:26   web-resources/
    14643  2016-04-01 10:26   web-resources/error500.jsp
     4286  2016-02-03 10:11   web-resources/favicon.ico
       41  2014-08-13 23:37   file-mapping.properties
---------                     -------
    19458                     6 files

When that AMP is installed, the files under the web-resources folder from the AMP (which were in src/web-resources before) will be dropped into the route of the Share webapp and can be served directly by Tomcat

(This example is to override the favicon and 500 error page for Share, but it's much the same for just adding custom web pages instead of overriding built-in web-served resources!)

Upvotes: 1

Related Questions