Commit a4b8ed6705b9f2953f41acdd7052b1e803dba7ec

Authored by Augusto Herrmann
1 parent 1de58c6c
Exists in master

parametrizando o perfil da barra que ser? compilado

app/barrabrasil.py
@@ -14,8 +14,8 @@ def pagina_teste(): @@ -14,8 +14,8 @@ def pagina_teste():
14 return make_response("<h1>403 Forbidden</h1>", 403) 14 return make_response("<h1>403 Forbidden</h1>", 403)
15 15
16 @app.route('/barra.js') 16 @app.route('/barra.js')
17 -def barra():  
18 - with app.open_resource('templates/barra-brasil.js') as f: 17 +def barra(profile='default'):
  18 + with app.open_resource('templates/%s/barra-brasil.js' % profile) as f:
19 conteudo = f.read().decode('utf-8') 19 conteudo = f.read().decode('utf-8')
20 etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest() 20 etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest()
21 if request.if_none_match and \ 21 if request.if_none_match and \
@@ -29,4 +29,9 @@ def barra(): @@ -29,4 +29,9 @@ def barra():
29 return resposta 29 return resposta
30 30
31 if __name__ == '__main__': 31 if __name__ == '__main__':
  32 + from sys import argv
  33 + if len(argv) > 1:
  34 + profile = argv[1]
  35 + else:
  36 + profile = 'default'
32 app.run(debug=False) 37 app.run(debug=False)
assets/barra-brasil.coffee
@@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
1 - divBarra = document.getElementById("barra-brasil")  
2 - divBarra.parentNode.removeChild(divBarra) if divBarra  
3 - head = document.getElementsByTagName("head")[0]  
4 - body = document.getElementsByTagName("body")[0]  
5 -  
6 - link = document.createElement("link")  
7 - href = document.createAttribute("href")  
8 -  
9 - novaDiv = document.createElement("div")  
10 - idNovaDiv = document.createAttribute("id")  
11 - idNovaDiv.nodeValue = "barra-brasil"  
12 - novaDiv.setAttributeNode idNovaDiv  
13 - # conteudoBarra definido no barra-brasil-1.yaml e atribuido pelo assetgen  
14 - novaDiv.innerHTML = conteudoBarra  
15 - body.insertBefore(novaDiv, body.childNodes[0])  
16 -  
17 - # src.nodeValue = "http://barra.brasil.gov.br/estilo-barra.css";  
18 - # href.nodeValue = "http://189.9.137.173/estilo-barra.css";  
19 - # href.nodeValue = "static/estilo-barra.css"  
20 - window._barrabrasil =  
21 - insere_css: (css) ->  
22 - style = document.createElement("style")  
23 - tipo = document.createAttribute("type")  
24 - tipo.nodeValue = "text/css"  
25 - media = document.createAttribute("media")  
26 - media.nodeValue = "all"  
27 - style.setAttributeNode tipo  
28 - style.setAttributeNode media  
29 -  
30 - if style.styleSheet #Hack para IE8  
31 - style.styleSheet.cssText = css  
32 - else  
33 - style.appendChild document.createTextNode(css)  
34 -  
35 - head.appendChild style  
36 -  
assets/conteudo-barra.html
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -<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 &agrave; informa&ccedil;&atilde;o</a></span><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&ccedil;os</a></li><li class="list-item"><a href="http://www.planalto.gov.br/legislacao" class="link-barra">Legisla&ccedil;&atilde;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></ul></div>  
assets/estatisticas.coffee
@@ -1,9 +0,0 @@ @@ -1,9 +0,0 @@
1 - head = document.getElementsByTagName("head")[0]  
2 - novoScript = document.createElement("script")  
3 - tipo = document.createAttribute("type")  
4 - tipo.nodeValue = "text/javascript"  
5 - src = document.createAttribute("src")  
6 - src.nodeValue = "http://coletajavascript.serpro.gov.br/estatistica.js"  
7 - novoScript.setAttributeNode tipo  
8 - novoScript.setAttributeNode src  
9 - head.appendChild novoScript  
assets/estilo-barra.scss
@@ -1,101 +0,0 @@ @@ -1,101 +0,0 @@
1 -/* http://meyerweb.com/eric/tools/css/reset/  
2 - v2.0 | 20110126  
3 - License: none (public domain)  
4 -*/  
5 -  
6 -/* Css reset mínimo */  
7 -#barra-brasil {  
8 - div, a, ul, li {  
9 - margin: 0;  
10 - padding: 0;  
11 - border: 0;  
12 - font-size: 100%;  
13 - font-family: inherit;  
14 - vertical-align: baseline;  
15 - }  
16 -}  
17 -  
18 -#barra-brasil ul {  
19 - list-style: none;  
20 -}  
21 -  
22 -/* Css específico */  
23 -  
24 -/* web font */  
25 -  
26 -@font-face {  
27 - font-family: "Open Sans";  
28 - font-style: normal;  
29 - font-weight: 700;  
30 - src: local("Open Sans Bold"), local("OpenSans-Bold"), url("http://barra.brasil.gov.br/static/opensans-bold.woff") format("woff");  
31 -}  
32 -  
33 -/* fim da web font */  
34 -  
35 -#barra-brasil {  
36 - height: 32px;  
37 - background: #f1f1f1;  
38 - font-weight: bold;  
39 - font-size: 12px;  
40 - line-height: 32px;  
41 - font-family: "Open Sans",Arial,Helvetica,sans-serif;  
42 - a {  
43 - text-decoration: none;  
44 - }  
45 -}  
46 -  
47 -div#wrapper-barra-brasil {  
48 - position: relative;  
49 - overflow: hidden;  
50 - margin: 0 auto;  
51 - width: 100%;  
52 - max-width: 960px;  
53 -}  
54 -  
55 -#barra-brasil .brasil-flag {  
56 - float: left;  
57 - padding: 7px 0 6px;  
58 - width: 115px;  
59 - height: 19px;  
60 - border-right: 2px solid #dfdfdf;  
61 -}  
62 -  
63 -#barra-brasil .brasil-flag .link-barra {  
64 - display: block;  
65 - padding-left: 42px;  
66 - width: 43px;  
67 - background: embed("imagens/bandeira-brasil.png") 8px center no-repeat;  
68 - text-transform: uppercase;  
69 - line-height: 19px;  
70 -}  
71 -  
72 -#barra-brasil .acesso-info {  
73 - position: absolute;  
74 - left: 130px;  
75 -}  
76 -  
77 -#barra-brasil .list {  
78 - position: absolute;  
79 - top: 0;  
80 - right: 0;  
81 -}  
82 -  
83 -#barra-brasil .list .first { border-left: 2px solid #dfdfdf; }  
84 -  
85 -#barra-brasil .list-item {  
86 - display: inline-block;  
87 - padding: 0 15px 0 13px;  
88 - height: 32px;  
89 - border-right: 2px solid #dfdfdf;  
90 -}  
91 -  
92 -#barra-brasil .link-barra { color: #606060; }  
93 -  
94 -@media screen and (max-width: 668px) {  
95 - #barra-brasil .list { top: -100px; }  
96 -}  
97 -  
98 -@media screen and (min-width: 960px) {  
99 - #wrapper-barra-brasil { width: 960px; }  
100 -}  
101 -  
assets/fonts/opensans-bold.woff
No preview for this file type
assets/fonts/opensans-extrabold.woff
No preview for this file type
assets/fonts/opensans.woff
No preview for this file type
assets/imagens/ai.png

5.58 KB

assets/imagens/bandeira-brasil.png

1.22 KB

assets/imagens/barra-brasil-v3-bgx.gif

43 Bytes

assets/imagens/barra-brasil-v3-bgx.png

183 Bytes

assets/imagens/brasil.png

5.6 KB

barra-brasil-1.yaml
@@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
1 -# configuracao do assetgen para:  
2 -# - gerar o script de comportamento, minificado  
3 -# - gerar o css com as imagens incorporadas  
4 -  
5 -generate:  
6 -  
7 -- barra-brasil.js:  
8 - source:  
9 - - assets/conteudo-barra.html  
10 - - assets/barra-brasil.coffee  
11 - - assets/estatisticas.coffee  
12 - - raw: "})();" # fechamento do escopo da funcao anonima (ver template abaixo)  
13 - template: |  
14 - (function(){  
15 - var conteudoBarra = '${source|trim}';  
16 -  
17 -- estilo-barra.css:  
18 - source:  
19 - - assets/estilo-barra.scss  
20 - depends:  
21 - - assets/imagens/*  
22 - embed.path.root: assets  
23 - embed.url.base: imagens/  
24 -  
25 -- barra-brasil-css.js:  
26 - source:  
27 - - build/estilo-barra.css  
28 - template: |  
29 - window._barrabrasil.insere_css('${source|trim}');  
30 -  
31 -css.embed: true  
32 -css.embed.only: true  
33 -css.compress: true  
34 -js.compress: false  
35 -js.uglify.bin: uglifyjs  
36 -output.directory: build  
37 -output.hashed: false  
38 -output.manifest: app/assets.json  
39 -  
40 -profile.dev:  
41 - css.compress: false  
42 - js.compress: false  
barra-brasil-2.yaml
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -# configuracao do assetgen para:  
2 -# - mesclar o css com javascript de comportamento  
3 -  
4 -generate:  
5 -  
6 -- barra-brasil.js:  
7 - source:  
8 - - build/barra-brasil.js # parte de comportamento  
9 - - build/barra-brasil-css.js # codigo de insercao do css  
10 - uglify.bin: uglifyjs  
11 -  
12 -css.embed: true  
13 -css.embed.only: true  
14 -output.directory: app/templates  
15 -output.hashed: false  
16 -output.manifest: assets.json  
17 -  
18 -profile.dev:  
19 - css.compress: false  
20 - js.compress: false  
build.sh 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +#!/bin/sh
  2 +echo .
  3 +echo .
  4 +if test -f recipes/$1
  5 + sh recipes/$1/compile.sh
  6 + cp recipes/$1/build/barra-brasil.js app/templates/$1/
  7 +else
  8 + echo "Error. Profile $1 does not exist."
  9 +fi
recipes/default/assets/barra-brasil.coffee 0 → 100755
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  1 + divBarra = document.getElementById("barra-brasil")
  2 + divBarra.parentNode.removeChild(divBarra) if divBarra
  3 + head = document.getElementsByTagName("head")[0]
  4 + body = document.getElementsByTagName("body")[0]
  5 +
  6 + link = document.createElement("link")
  7 + href = document.createAttribute("href")
  8 +
  9 + novaDiv = document.createElement("div")
  10 + idNovaDiv = document.createAttribute("id")
  11 + idNovaDiv.nodeValue = "barra-brasil"
  12 + novaDiv.setAttributeNode idNovaDiv
  13 + # conteudoBarra definido no barra-brasil-1.yaml e atribuido pelo assetgen
  14 + novaDiv.innerHTML = conteudoBarra
  15 + body.insertBefore(novaDiv, body.childNodes[0])
  16 +
  17 + # src.nodeValue = "http://barra.brasil.gov.br/estilo-barra.css";
  18 + # href.nodeValue = "http://189.9.137.173/estilo-barra.css";
  19 + # href.nodeValue = "static/estilo-barra.css"
  20 + window._barrabrasil =
  21 + insere_css: (css) ->
  22 + style = document.createElement("style")
  23 + tipo = document.createAttribute("type")
  24 + tipo.nodeValue = "text/css"
  25 + media = document.createAttribute("media")
  26 + media.nodeValue = "all"
  27 + style.setAttributeNode tipo
  28 + style.setAttributeNode media
  29 +
  30 + if style.styleSheet #Hack para IE8
  31 + style.styleSheet.cssText = css
  32 + else
  33 + style.appendChild document.createTextNode(css)
  34 +
  35 + head.appendChild style
  36 +
recipes/default/assets/conteudo-barra.html 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<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 &agrave; informa&ccedil;&atilde;o</a></span><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&ccedil;os</a></li><li class="list-item"><a href="http://www.planalto.gov.br/legislacao" class="link-barra">Legisla&ccedil;&atilde;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></ul></div>
recipes/default/assets/estatisticas.coffee 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 + head = document.getElementsByTagName("head")[0]
  2 + novoScript = document.createElement("script")
  3 + tipo = document.createAttribute("type")
  4 + tipo.nodeValue = "text/javascript"
  5 + src = document.createAttribute("src")
  6 + src.nodeValue = "http://coletajavascript.serpro.gov.br/estatistica.js"
  7 + novoScript.setAttributeNode tipo
  8 + novoScript.setAttributeNode src
  9 + head.appendChild novoScript
recipes/default/assets/estilo-barra.scss 0 → 100755
@@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
  1 +/* http://meyerweb.com/eric/tools/css/reset/
  2 + v2.0 | 20110126
  3 + License: none (public domain)
  4 +*/
  5 +
  6 +/* Css reset mínimo */
  7 +#barra-brasil {
  8 + div, a, ul, li {
  9 + margin: 0;
  10 + padding: 0;
  11 + border: 0;
  12 + font-size: 100%;
  13 + font-family: inherit;
  14 + vertical-align: baseline;
  15 + }
  16 +}
  17 +
  18 +#barra-brasil ul {
  19 + list-style: none;
  20 +}
  21 +
  22 +/* Css específico */
  23 +
  24 +/* web font */
  25 +
  26 +@font-face {
  27 + font-family: "Open Sans";
  28 + font-style: normal;
  29 + font-weight: 700;
  30 + src: local("Open Sans Bold"), local("OpenSans-Bold"), url("http://barra.brasil.gov.br/static/opensans-bold.woff") format("woff");
  31 +}
  32 +
  33 +/* fim da web font */
  34 +
  35 +#barra-brasil {
  36 + height: 32px;
  37 + background: #f1f1f1;
  38 + font-weight: bold;
  39 + font-size: 12px;
  40 + line-height: 32px;
  41 + font-family: "Open Sans",Arial,Helvetica,sans-serif;
  42 + a {
  43 + text-decoration: none;
  44 + }
  45 +}
  46 +
  47 +div#wrapper-barra-brasil {
  48 + position: relative;
  49 + overflow: hidden;
  50 + margin: 0 auto;
  51 + width: 100%;
  52 + max-width: 960px;
  53 +}
  54 +
  55 +#barra-brasil .brasil-flag {
  56 + float: left;
  57 + padding: 7px 0 6px;
  58 + width: 115px;
  59 + height: 19px;
  60 + border-right: 2px solid #dfdfdf;
  61 +}
  62 +
  63 +#barra-brasil .brasil-flag .link-barra {
  64 + display: block;
  65 + padding-left: 42px;
  66 + width: 43px;
  67 + background: embed("imagens/bandeira-brasil.png") 8px center no-repeat;
  68 + text-transform: uppercase;
  69 + line-height: 19px;
  70 +}
  71 +
  72 +#barra-brasil .acesso-info {
  73 + position: absolute;
  74 + left: 130px;
  75 +}
  76 +
  77 +#barra-brasil .list {
  78 + position: absolute;
  79 + top: 0;
  80 + right: 0;
  81 +}
  82 +
  83 +#barra-brasil .list .first { border-left: 2px solid #dfdfdf; }
  84 +
  85 +#barra-brasil .list-item {
  86 + display: inline-block;
  87 + padding: 0 15px 0 13px;
  88 + height: 32px;
  89 + border-right: 2px solid #dfdfdf;
  90 +}
  91 +
  92 +#barra-brasil .link-barra { color: #606060; }
  93 +
  94 +@media screen and (max-width: 668px) {
  95 + #barra-brasil .list { top: -100px; }
  96 +}
  97 +
  98 +@media screen and (min-width: 960px) {
  99 + #wrapper-barra-brasil { width: 960px; }
  100 +}
  101 +
recipes/default/assets/fonts/opensans-bold.woff 0 → 100644
No preview for this file type
recipes/default/assets/fonts/opensans-extrabold.woff 0 → 100644
No preview for this file type
recipes/default/assets/fonts/opensans.woff 0 → 100644
No preview for this file type
recipes/default/assets/imagens/ai.png 0 → 100644

5.58 KB

recipes/default/assets/imagens/bandeira-brasil.png 0 → 100644

1.22 KB

recipes/default/assets/imagens/barra-brasil-v3-bgx.gif 0 → 100644

43 Bytes

recipes/default/assets/imagens/barra-brasil-v3-bgx.png 0 → 100644

183 Bytes

recipes/default/assets/imagens/brasil.png 0 → 100644

5.6 KB

recipes/default/barra-brasil-1.yaml 0 → 100644
@@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
  1 +# configuracao do assetgen para:
  2 +# - gerar o script de comportamento, minificado
  3 +# - gerar o css com as imagens incorporadas
  4 +
  5 +generate:
  6 +
  7 +- barra-brasil.js:
  8 + source:
  9 + - assets/conteudo-barra.html
  10 + - assets/barra-brasil.coffee
  11 + - assets/estatisticas.coffee
  12 + - raw: "})();" # fechamento do escopo da funcao anonima (ver template abaixo)
  13 + template: |
  14 + (function(){
  15 + var conteudoBarra = '${source|trim}';
  16 +
  17 +- estilo-barra.css:
  18 + source:
  19 + - assets/estilo-barra.scss
  20 + depends:
  21 + - assets/imagens/*
  22 + embed.path.root: assets
  23 + embed.url.base: imagens/
  24 +
  25 +- barra-brasil-css.js:
  26 + source:
  27 + - build/estilo-barra.css
  28 + template: |
  29 + window._barrabrasil.insere_css('${source|trim}');
  30 +
  31 +css.embed: true
  32 +css.embed.only: true
  33 +css.compress: true
  34 +js.compress: false
  35 +js.uglify.bin: uglifyjs
  36 +output.directory: build
  37 +output.hashed: false
  38 +output.manifest: app/assets.json
  39 +
  40 +profile.dev:
  41 + css.compress: false
  42 + js.compress: false
recipes/default/barra-brasil-2.yaml 0 → 100644
@@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
  1 +# configuracao do assetgen para:
  2 +# - mesclar o css com javascript de comportamento
  3 +
  4 +generate:
  5 +
  6 +- barra-brasil.js:
  7 + source:
  8 + - build/barra-brasil.js # parte de comportamento
  9 + - build/barra-brasil-css.js # codigo de insercao do css
  10 + uglify.bin: uglifyjs
  11 +
  12 +css.embed: true
  13 +css.embed.only: true
  14 +output.directory: app/templates
  15 +output.hashed: false
  16 +output.manifest: assets.json
  17 +
  18 +profile.dev:
  19 + css.compress: false
  20 + js.compress: false
recipes/default/compile.sh 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +#!/bin/sh
  2 +assetgen ./barra-brasil-1.yaml
  3 +assetgen ./barra-brasil-2.yaml