diff options
| -rwxr-xr-x | indoteknik_custom/__init__.py | 3 | ||||
| -rw-r--r-- | indoteknik_custom/controllers/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/controllers/website.py | 36 |
3 files changed, 39 insertions, 1 deletions
diff --git a/indoteknik_custom/__init__.py b/indoteknik_custom/__init__.py index 0650744f..19240f4e 100755 --- a/indoteknik_custom/__init__.py +++ b/indoteknik_custom/__init__.py @@ -1 +1,2 @@ -from . import models +from . import controllers +from . import models
\ No newline at end of file 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 |
