Commit 306f2ed72340b5ad19d5a02701b4057c433b6948

Authored by Carlos Vieira
1 parent e98295a7
Exists in master

barrabrasil.py: recolocado o etag. Adicionado data de modifica??o pelo build. pr…

…ofile e build.sh: adicionando campo com data de modifica??o.
Showing 3 changed files with 15 additions and 9 deletions   Show diff stats
app/barrabrasil.py
... ... @@ -38,28 +38,32 @@ def barra():
38 38 f = app.open_resource('profile')
39 39 cfg = Config(f)
40 40 profile = cfg.profile
  41 + data = cfg.date
41 42 with app.open_resource('templates/%s/barra-brasil.js' % profile) as f:
42 43 conteudo = f.read().decode('utf-8')
43   - #etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest()
44   - #if request.if_none_match and \
45   - # etag in request.if_none_match:
46   - # resposta = Response(status=304)
47   - #else: # nao esta em cache do navegador
48   - resposta = make_response(conteudo)
49   - # resposta.set_etag(etag)
  44 + etag = hashlib.sha1(conteudo.encode('utf-8')).hexdigest()
  45 + if request.if_none_match and \
  46 + etag in request.if_none_match:
  47 + resposta = Response(status=304)
  48 + else: # nao esta em cache do navegador
  49 + resposta = make_response(conteudo)
  50 + resposta.set_etag(etag)
50 51 resposta.headers['Content-type'] = 'application/x-javascript'
51 52 resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas
52   - resposta.headers['Last-Modified'] = 'Mon, 30 Sep 2013 19:08:30 GMT'
  53 + resposta.headers['Last-Modified'] = data
53 54 return resposta
54 55  
55 56 @app.route('/static/opensans-bold.woff')
56 57 def fonte():
  58 + f = app.open_resource('profile')
  59 + cfg = Config(f)
  60 + data = cfg.date
57 61 f = app.open_resource('static/opensans-bold.woff')
58 62 conteudo = f.read().decode('base64')
59 63 resposta = make_response(conteudo)
60 64 resposta.headers['Content-type'] = 'application/x-font-woff'
61 65 resposta.headers['Cache-control'] = 'public, max-age: 86400' #24 horas
62   - resposta.headers['Last-Modified'] = 'Mon, 30 Sep 2013 19:08:30 GMT'
  66 + resposta.headers['Last-Modified'] = data
63 67 return resposta
64 68  
65 69 if __name__ == '__main__':
... ...
app/profile
1 1 profile : copa2014
  2 +date : " Mon, 12 May 2014 15:04:36 -0300 "
... ...
build.sh
... ... @@ -14,6 +14,7 @@ then
14 14 cd ../../app
15 15 touch profile
16 16 echo 'profile :' $profile > profile
  17 + echo 'date : "' $(date -R) '"'>> profile
17 18 python barrabrasil.py
18 19 else
19 20 echo "Error. Profile $1 does not exist."
... ...