GithubHelp home page GithubHelp logo

dealer's Introduction

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

On clientside:

<script src='/main.js?34jhfd45hd8'

Supported Git, Mercurial and simple revision parse by file.

Note

You should install Mercurial for hg support.

Build Status Coverals Version Downloads Donate

Requirements

  • python (2.6, 2.7, 3.3)

Installation

Dealer should be installed using pip:

pip install dealer

Usage

Basic usage

from dealer.git import git

print git.revision

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

print auto.tag

Manually create backend

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

from dealer.mercurial import Backend

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

Django support

Settings

DEALER_TYPE — Type of SCM repository ('auto', 'git', 'mercurial', 'simple', 'null'). By default 'auto';

DEALER_PATH — Path to SCM. By default current dir;

DEALER_SILENT — Disable log warnings;

DEALER_BACKENDS — Backends for auto search by default ('git', 'mercurial', 'simple', 'null');

Context-processor

Append to your settings:

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

And use the REVISION and TAG variables in your templates:

<link href="/test.css?{{ REVISION }}" rel="stylesheet" type="text/css" media="screen" />
<script src="/test.js?{{ REVISION }}"></script>

Middleware

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.

Flask support

Settings

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

Usage

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

Bug tracker

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

Contributing

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

Contributors

  • klen (Kirill Klenov)

License

Licensed under a BSD license.

dealer's People

Contributors

klen avatar sinanm89 avatar singingwolfboy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.