Code Monkey home page Code Monkey logo

django-coldbrew's Introduction

ColdBrew

django-coldbrew started as a fork of Django Coffeescript.

ColdBrew provides template tags to compile CoffeeScript into JavaScript from templates. It works with both inline code and external files.

Installation

  1. Add "coldbrew" to INSTALLED_APPS setting.
  2. Make sure that you have coffee executable installed. See CoffeeScript official site for details.
  3. Optionally, you can specify the full path to coffee executable with COFFEESCRIPT_EXECUTABLE setting. By default it's set to coffee.

Example Usage

External file

{% load coldbrew %}

<script type="text/javascript"
        src="{{ STATIC_URL}}{% coffeescript "path/to/script.coffee" %}">
</script>

renders to

<script type="text/javascript"
        src="/media/COFFEESCRIPT_CACHE/path/to/script-91ce1f66f583.js">
</script>

Inline

{% load coldbrew %}

<script type="text/javascript">
  {% inlinecoffeescript %}
    console.log "Hello, World!"
  {% endinlinecoffeescript %}
</script>

renders to

<script type="text/javascript">
  (function() {
console.log("Hello, World!");

}).call(this);

</script>

Note that by default compiled files are saved into COFFEESCRIPT_CACHE folder under your STATIC_ROOT (or MEDIA_ROOT if you have no STATIC_ROOT in your settings). You can change this folder name with COLDBREW_CUP setting.

Settings

COFFEESCRIPT_EXECUTABLE

Path to CoffeeScript compiler executable. Default: "coffee".

COLDBREW_CUP

The "cup" in which to place the brewed coffee, ie, compiled javascript. This location is relative to STATIC_ROOT. Default: "COFFEESCRIPT_CACHE".

COFFEESCRIPT_USE_CACHE

Whether to use cache for inline scripts. Default: True.

COFFEESCRIPT_CACHE_TIMEOUT

Cache timeout for inline scripts (in seconds). Default: 30 days.

COFFEESCRIPT_MTIME_DELAY

Cache timeout for reading the modification time of external scripts (in seconds). Default: 10 seconds.

COLDBREW_FAIL_LOUD

If True, raise ColdBrewCompileError upon encountering compiling error. Otherwise, records to error log. Defaults to same as DEBUG.

django-coldbrew's People

Contributors

etos avatar jmyles avatar vorushin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-coldbrew's Issues

global name 'logger' is not defined

Hi!

It's grate application!

I got error:
NameError at /

global name 'logger' is not defined

Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.4
Exception Type: NameError
Exception Value:

global name 'logger' is not defined

Exception Location: /path/to/env/src/package/coldbrew/init.py in compile, line 25
Python Executable: /path/to/env/bin/python
Python Version: 2.7.2

File path output is not always correct (uses STATIC_ROOT)

If STATIC_ROOT is not a parent of COFFEESCRIPT_OUTPUT_DIR, coldbrew.py line 67 no longer makes sense.

One way or another, a URL needs to be developed that accurately reflects the URL structure of both a runserver setup and a production server after collectstatic has been run.

Provide rudimentary server-side AJAX support

There are really two avenues to pursue here - we can go with either or both.

The first is to build support for dajaxice in coffeescript syntax that causes the whole thing to feel like a django view. See http://www.dajaxproject.com/.

The other way forward is to package some simple tools from the WHAT (such as submit_generic_partial()) and provide a framework in coffeescript to access them.

Write git commit ref at top of compiled js during collect_coldbrew

If collect_coldbrew is run on a project which is tracked by a git repository, let's write the commit ref of the most recent revision of each coffee file to the top of the respective javascript.

For example,

"Brewed from my-script-file.coffee 39fdf3fjew9fwe0fwej33f23fwef"

Status Change Button

On clicking the button, a snippet of coffeescript via AJAX, changes the status from one type of thing to another. Coldbrew will need its own dispatch urls to communicate the change in status.

The button has text indicating a status or state of being that is one of two such as "open" and "closed" or "dead" and "alive" .

Each status has an associated color.

Another model shows and records that change plus time date author.

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.