Skip to content

Commit

Permalink
Barra local é agora barra.js no pacote.
Browse files Browse the repository at this point in the history
Atende #30

A idéia é sempre baixar o barra.js oficial se quiser usar uma barra
local, ao invés de reimplementá-la aqui nesse pacote como era feito no
passado.
  • Loading branch information
idgserpro committed Oct 24, 2016
1 parent 5276291 commit 07feea2
Show file tree
Hide file tree
Showing 22 changed files with 184 additions and 404 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Histórico de Alterações
1.1.2 (unreleased)
^^^^^^^^^^^^^^^^^^

- Barra local passa a ser o barra.js mas agora dentro do pacote. Foi feita uma
estrutura na lógica de testes que avisa se a versão do pacote estiver
desatualizada com relação à barra externa. (closes `#30`_).
[idgserpro]

- Barra agora é chamada no fim da tag body; Mostra mensagem html, como no
padrão estabelecido pelo Ministério do Planejamento, se o javascript não
puder ser carregado (closes `#12`_).
Expand Down Expand Up @@ -92,3 +97,4 @@ Histórico de Alterações
.. _`#10`: https://github.com/plonegovbr/brasil.gov.barra/issues/10
.. _`#12`: https://github.com/plonegovbr/brasil.gov.barra/issues/12
.. _`#25`: https://github.com/plonegovbr/brasil.gov.barra/issues/25
.. _`#30`: https://github.com/plonegovbr/brasil.gov.barra/issues/30
18 changes: 9 additions & 9 deletions src/brasil/gov/barra/browser/barra.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile


class BarraViewlet(ViewletBase):
"""Implementacao do viewlet da Barra de Identidade do Governo
Este viewlet eh registrado como no arquivo browser/configure.zcml
e habilitado no arquivo profiles/default/viewlets.xml
class BarraViewletJs(ViewletBase):
"""
Viewlet que faz a chamada para o javascript da barra do Ministério do
Planejamento.
Se o usuário marcar a opção para usar barra local, utiliza um barra.js que
está no pacote.
"""
# Indica qual o template sera usado por este viewlet
index = ViewPageTemplateFile('templates/barra.pt')
index = ViewPageTemplateFile('templates/barra_js.pt')

def update(self):
"""Prepara/Atualiza os valores utilizados pelo Viewlet"""
super(BarraViewlet, self).update()
# Disponibiliza uma variavel site_url que retorna a raiz do
# site Plone. No template ela pode ser chamada como view/site_url
super(BarraViewletJs, self).update()
portal = api.portal.get()
helper = api.content.get_view(
name='barra_helper',
context=portal,
request=self.request,
)
self.local = helper.local
self.site_url = portal.absolute_url()
30 changes: 0 additions & 30 deletions src/brasil/gov/barra/browser/barra_js.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/brasil/gov/barra/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<browser:viewlet
name="brasil.gov.barra"
manager="plone.app.layout.viewlets.interfaces.IPortalTop"
class=".barra.BarraViewlet"
template="templates/barra.pt"
layer="brasil.gov.barra.interfaces.IBarraInstalada"
permission="zope.Public"
/>
Expand All @@ -18,7 +18,7 @@
<browser:viewlet
name="brasil.gov.barra.js"
manager="plone.app.layout.viewlets.interfaces.IPortalFooter"
class=".barra_js.BarraViewlet"
class=".barra.BarraViewletJs"
layer="brasil.gov.barra.interfaces.IBarraInstalada"
permission="zope.Public"
/>
Expand Down
30 changes: 4 additions & 26 deletions src/brasil/gov/barra/browser/templates/barra.pt
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
<metal:barra xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<div id="barra-identidade">
<metal:local tal:condition="view/local">
<div id="barra-brasil" tal:condition="view/local">
<div id="wrapper-barra-brasil">
<div class="brasil-flag">
<a href="http://brasil.gov.br" class="link-barra">Brasil</a>
</div>
<span class="acesso-info">
<a href="http://brasil.gov.br/barra#acesso-informacao" class="link-barra">Acesso à informação</a>
</span>
<nav>
<ul class="list">
<li class="list-item first"><a href="http://brasil.gov.br/barra#participe" class="link-barra">Participe</a></li>
<li class="list-item"><a href="http://www.servicos.gov.br/" class="link-barra">Serviços</a></li>
<li class="list-item"><a href="http://www.planalto.gov.br/legislacao" class="link-barra">Legislação</a></li>
<li class="list-item last last-item"><a href="http://brasil.gov.br/barra#orgaos-atuacao-canais" class="link-barra">Canais</a></li>
<div id="barra-brasil" style="background:#7F7F7F; height: 20px; padding:0 0 0 10px;display:block;">
<ul id="menu-barra-temp" style="list-style:none;">
<li style="display:inline; float:left;padding-right:10px; margin-right:10px; border-right:1px solid #EDEDED"><a href="http://brasil.gov.br" style="font-family:sans,sans-serif; text-decoration:none; color:white;">Portal do Governo Brasileiro</a></li>
<li><a style="font-family:sans,sans-serif; text-decoration:none; color:white;" href="http://epwg.governoeletronico.gov.br/barra/atualize.html">Atualize sua Barra de Governo</a></li>
</ul>
</nav>
</div>
</div>
</metal:local>
<metal:remote tal:condition="not:view/local">
<div id="barra-brasil" style="background:#7F7F7F; height: 20px; padding:0 0 0 10px;display:block;">
<ul id="menu-barra-temp" style="list-style:none;">
<li style="display:inline; float:left;padding-right:10px; margin-right:10px; border-right:1px solid #EDEDED"><a href="http://brasil.gov.br" style="font-family:sans,sans-serif; text-decoration:none; color:white;">Portal do Governo Brasileiro</a></li>
<li><a style="font-family:sans,sans-serif; text-decoration:none; color:white;" href="http://epwg.governoeletronico.gov.br/barra/atualize.html">Atualize sua Barra de Governo</a></li>
</ul>
</div>
</metal:remote>
</div>
</metal:barra>
8 changes: 8 additions & 0 deletions src/brasil/gov/barra/browser/templates/barra_js.pt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<metal:barra xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<div id="barra_brasil_js">
<metal:local tal:condition="view/local">
<script defer="defer" src="++resource++brasil.gov.barra/barra.js" type="text/javascript"></script>
</metal:local>
<metal:remote tal:condition="not:view/local">
<script defer="defer" src="//barra.brasil.gov.br/barra.js" type="text/javascript"></script>
</metal:remote>
</div>
</metal:barra>
16 changes: 14 additions & 2 deletions src/brasil/gov/barra/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
from Products.CMFPlone import interfaces as plone_interfaces
from Products.CMFQuickInstallerTool import interfaces as qi_interfaces
from zope.interface import implementer
import os

BARRA_JS_URL = 'http://barra.brasil.gov.br/barra.js'
BARRA_JS_FILE = BARRA_JS_URL.split('/')[-1]
BARRA_JS_STATIC_FILE_LOCATION = os.path.join(
os.path.dirname(__file__),
'static',
BARRA_JS_FILE
)
BARRA_JS_DEFAULT_LANGUAGE = 'pt-BR'

PROJECTNAME = 'brasil.gov.barra'

Expand All @@ -15,6 +25,7 @@ def getNonInstallableProducts(self):
'brasil.gov.barra.upgrades.v1000',
'brasil.gov.barra.upgrades.v1002',
'brasil.gov.barra.upgrades.v1010',
'brasil.gov.barra.upgrades.v1013',
]


Expand All @@ -25,6 +36,7 @@ class HiddenProfiles(object):
def getNonInstallableProfiles(self):
return [
'brasil.gov.barra:uninstall',
'brasil.gov.barra.upgrades.v1002:default'
'brasil.gov.barra.upgrades.v1010:default'
'brasil.gov.barra.upgrades.v1002:default',
'brasil.gov.barra.upgrades.v1010:default',
'brasil.gov.barra.upgrades.v1013:default'
]
13 changes: 0 additions & 13 deletions src/brasil/gov/barra/profiles/default/cssregistry.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/brasil/gov/barra/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<metadata>
<version>1012</version>
<version>1013</version>
</metadata>
2 changes: 2 additions & 0 deletions src/brasil/gov/barra/static/barra.js

Large diffs are not rendered by default.

Loading

0 comments on commit 07feea2

Please sign in to comment.