summaryrefslogtreecommitdiff
path: root/indoteknik_custom/controllers
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-03-31 11:05:10 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-03-31 11:05:10 +0700
commit0a0e1774d7ff25dfd6605ce4dfdc7dfdeb45eb5e (patch)
tree5e31bc083e681fd1fb7c66c25d4b3e0a8009723a /indoteknik_custom/controllers
parent4cf422c5b0f687cb33eb7c0851ca2234e36d2b29 (diff)
show content only iframe
Diffstat (limited to 'indoteknik_custom/controllers')
-rw-r--r--indoteknik_custom/controllers/__init__.py1
-rw-r--r--indoteknik_custom/controllers/website.py36
2 files changed, 37 insertions, 0 deletions
diff --git a/indoteknik_custom/controllers/__init__.py b/indoteknik_custom/controllers/__init__.py
new file mode 100644
index 00000000..02ab5287
--- /dev/null
+++ b/indoteknik_custom/controllers/__init__.py
@@ -0,0 +1 @@
+from . import website \ No newline at end of file
diff --git a/indoteknik_custom/controllers/website.py b/indoteknik_custom/controllers/website.py
new file mode 100644
index 00000000..2e3df519
--- /dev/null
+++ b/indoteknik_custom/controllers/website.py
@@ -0,0 +1,36 @@
+from odoo.http import request, Controller
+from odoo import http, _
+
+class Website(Controller):
+ @http.route('/content', auth='public')
+ def content(self, **kw):
+ url = kw.get('url', '')
+ iframe = f"<iframe src='{url}' onload='hideHeader(this)' ></iframe>"
+ style = '''
+ <style>
+ iframe {
+ border: none;
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100vw;
+ height: 100vh;
+ }
+ </style>
+ '''
+ script = '''
+ <script>
+ const hideHeader = (iframe) => {
+ var header = iframe.contentWindow.document.querySelector('header');
+ if (header) {
+ header.style.display = 'none';
+ }
+ var footer = iframe.contentWindow.document.querySelector('footer');
+ if (footer) {
+ footer.style.display = 'none';
+ }
+ }
+ </script>
+ '''
+ content = '<!DOCTYPE html><html>' + '<body>' + iframe + style + script + '</body>' + '</html>'
+ return request.make_response(content, [('Access-Control-Allow-Origin', '*'), ('Access-Control-Allow-Headers', '*')]) \ No newline at end of file