From 42fef3a8657fe778c2295ff40276adbdd0336876 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 14 Feb 2019 10:25:49 +0000
Subject: [PATCH] [erp5_web_render_ui] Allow any external app to download the
 source code

---
 .../portal_skins/erp5_web_renderjs_ui/File_viewAsWeb.py        | 3 +++
 .../portal_skins/erp5_web_renderjs_ui/Image_viewAsWeb.py       | 3 +++
 .../portal_skins/erp5_web_renderjs_ui/WebPage_viewAsWeb.py     | 3 +++
 3 files changed, 9 insertions(+)

diff --git a/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/File_viewAsWeb.py b/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/File_viewAsWeb.py
index 84ec3fe502..9f8bc4c3b8 100644
--- a/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/File_viewAsWeb.py
+++ b/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/File_viewAsWeb.py
@@ -9,6 +9,9 @@ file_content = file.getData()
 # The vanilla HTML is wanted
 response.setBase(None)
 
+# Allow any external app to download the source code
+response.setHeader("Access-Control-Allow-Origin", "*")
+
 if REQUEST.getHeader('If-Modified-Since', '') == file.getModificationDate().rfc822():
   response.setStatus(304)
   return ""
diff --git a/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/Image_viewAsWeb.py b/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/Image_viewAsWeb.py
index 414b379044..9127125d42 100644
--- a/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/Image_viewAsWeb.py
+++ b/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/Image_viewAsWeb.py
@@ -6,6 +6,9 @@ if response is None:
 # The vanilla HTML is wanted
 response.setBase(None)
 
+# Allow any external app to download the source code
+response.setHeader("Access-Control-Allow-Origin", "*")
+
 image = context
 if REQUEST.getHeader('If-Modified-Since', '') == image.getModificationDate().rfc822():
   response.setStatus(304)
diff --git a/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/WebPage_viewAsWeb.py b/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/WebPage_viewAsWeb.py
index 2963e76c4c..7d9d21cd9e 100644
--- a/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/WebPage_viewAsWeb.py
+++ b/bt5/erp5_web_renderjs_ui/SkinTemplateItem/portal_skins/erp5_web_renderjs_ui/WebPage_viewAsWeb.py
@@ -6,6 +6,9 @@ if response is None:
 # The vanilla HTML is wanted
 response.setBase(None)
 
+# Allow any external app to download the source code
+response.setHeader("Access-Control-Allow-Origin", "*")
+
 web_page = context
 web_section = REQUEST.get("current_web_section")
 if web_section is None:
-- 
2.30.9