Skip to content

weaver-viii/dealer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dealer

Dealer — SCM revision helper in your projects. Just add SCM revision to your static paths and get automatic control at client browser caches:

Somewhere in templates:

<script src='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/main.js?{{ request.revision }}'

On clientside:

<script src='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/main.js?34jhfd45hd8'

Supported Git, Mercurial and simple revision parse by file.

Note

For Mercurial support install mercurial

Build Status
  • python >= 2.6

Dealer should be installed using pip:

pip install dealer
from dealer.git import git

print git.revision
# Auto parse repository type
from dealer.auto import auto
print auto.revision

path — path to SCM repository (current dir by default)

from dealer.mercurial import Backend

hg = Backend('/path/to/hg/repo')

DEALER_TYPE — Type of SCM repository ('auto', 'git', 'mercurial', 'simple'). By default 'auto' DEALER_PATH — Path to SCM. By default current dir

Append to your settings:

TEMPLATE_CONTEXT_PROCESSORS += 'dealer.contrib.django.staff.context_processor',

And use REVISION variable in your templates:

<link href="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/test.css?{{ REVISION }}" rel="stylesheet" type="text/css" media="screen" />
<script src="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/test.js?{{ REVISION }}"></script>

Append to your settings:

MIDDLEWARE_CLASSES += 'dealer.contrib.django.staff.middleware',

And use in your views:

def view(request):
    return request.revision

Or in your templates by request.revision var.

DEALER_TYPE — Type of SCM repository ('auto', 'git', 'mercurial', 'simple'). By default 'auto' DEALER_PARAMS — Params for backend

In views:

from flask import Flask, g
from dealer.contrib.flask import Dealer

app = Flask('test')
Dealer(app)
assert app.revision

@app.route('/')
def usage_in_view():
    return g.revision

In templates:

<link href="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/test.css?{{ REVISION }}" rel="stylesheet" type="text/css" media="screen" />

If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/Dealer/issues

Development of dealer happens at github: https://github.com/klen/Flask-Mixer

  • klen (Kirill Klenov)

Licensed under a BSD license.

About

Make some staff

Resources

License

Stars

Watchers

Forks

Packages

No packages published