1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
21 import openobject.templating
23 class BaseTemplateEditor(openobject.templating.TemplateEditor):
24 templates = ['/openobject/controllers/templates/base.mako']
26 def edit(self, template, template_text):
27 output = super(BaseTemplateEditor, self).edit(template, template_text)
29 end_head = output.index('</head>')
31 output = output[:end_head] + """
32 <link rel="stylesheet" type="text/css" href="/web_uservoice/static/css/uservoice.css"/>
33 """ + output[end_head:]
36 end_body = output.index('</body>')
38 # testing forum: 84397
39 output = output[:end_body] + """
40 <script type="text/javascript">
41 var uservoiceOptions = {
43 host: 'feedback.openerp.com',
44 forum: '${getattr(cp.request, 'uservoice_forum', 77459)}',
48 function _loadUserVoice() {
49 var s = document.createElement('script');
50 s.src = ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js";
51 document.getElementsByTagName('head')[0].appendChild(s);
53 _loadSuper = window.onload;
54 window.onload = (typeof window.onload != 'function') ? _loadUserVoice : function() { _loadSuper(); _loadUserVoice(); };
56 """ + output[end_body:]
61 class HeaderTemplateEditor(openobject.templating.TemplateEditor):
62 templates = ['/openerp/controllers/templates/header.mako']
64 def edit(self, template, template_text):
65 output = super(HeaderTemplateEditor, self).edit(template, template_text)
67 PAT = '<ul class="tools">'
69 ul = output.index(PAT)
70 output = output[:ul] + ("""
71 <p class="logout feedback"><a href="#" onclick="UserVoice.Popin.show(uservoiceOptions); return false;"><img src="/web_uservoice/static/images/uv_favicon.png" />%s</a></p>
72 """ % _('feedback')) + output[ul:]