Repository: jorgebastida/django-dajax
Branch: master
Commit: ce515983e907
Files: 21
Total size: 39.1 KB
Directory structure:
gitextract_pmft9w4e/
├── .gitignore
├── AUTHORS
├── COPYING
├── MANIFEST.in
├── README.rst
├── dajax/
│ ├── __init__.py
│ ├── core.py
│ ├── models.py
│ └── static/
│ └── dajax/
│ ├── dojo.dajax.core.js
│ ├── jquery.dajax.core.js
│ ├── mootools.dajax.core.js
│ └── prototype.dajax.core.js
├── docs/
│ ├── Makefile
│ ├── api.rst
│ ├── changelog.rst
│ ├── conf.py
│ ├── index.rst
│ ├── installation.rst
│ ├── make.bat
│ └── migrating-to-09.rst
└── setup.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.pyc
*.egg-info
dist
build
.DS_Store
docs/_build
================================================
FILE: AUTHORS
================================================
Glue is mainly developed and maintained by Jorge Bastida <me@jorgebastida.com>
A big thanks to all the contributors:
Angel Abad for the Debian and Ubuntu distribution package.
================================================
FILE: COPYING
================================================
Copyright (c) 2009-2012 Benito Jorge Bastida
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
3. Neither the name of the author nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================
FILE: MANIFEST.in
================================================
include *.py
include COPYING
include AUTHORS
recursive-include dajax *
recursive-exclude dajax *.pyc
recursive-include docs *
prune docs/_build
================================================
FILE: README.rst
================================================
django-dajax
============
Dajax is a powerfull tool to easily and super-fastly develop asynchronous presentation logic in web applications using python and almost no lines of JS source code.
It supports up to four of the most popular JS frameworks:
* jQuery
* Prototype
* Dojo
* mootols
Using ``django-dajaxice`` communication core, ``django-dajax`` implements an abstraction layer between the presentation logic managed with JS and your python business logic. With dajax you can modify your ``DOM`` structure directly from python.
For more information about how django-dajax works: https://dajaxproject.com
Official site http://dajaxproject.com
Documentation http://readthedocs.org/projects/django-dajax/
Project status
----------------
From ``v0.9.2`` this project is not going to accept new features. In order to not break existing projects using this library, ``django-dajax`` and ``django-dajaxice`` will be maintained until ``django 1.8`` is released.
Should I use django-dajax or django-dajaxice?
---------------------------------------------
In a word, No. I created these projects 4 years ago as a cool tool in order to solve one specific problems I had at that time.
These days using these projects is a bad idea.
Perhaps I'm more pragmatic now, perhaps my vision of how my django projects should be coupled to libraries like these has change, or perhaps these days I really treasure the purity and simplicity of a vanilla django development.
If you want to use this project, you are probably wrong. You should stop couplig your interface with your backend or... in the long term it will explode in your face.
Forget about adding more unnecessary complexity. Keep things simple.
================================================
FILE: dajax/__init__.py
================================================
__version__ = (0, 9, 2, 'beta')
================================================
FILE: dajax/core.py
================================================
from django.utils import simplejson as json
class Dajax(object):
def __init__(self):
self.calls = []
def json(self):
return json.dumps(self.calls)
def alert(self, message):
self.calls.append({'cmd': 'alert', 'val': message})
def assign(self, id, attribute, value):
self.calls.append({'cmd': 'as', 'id': id, 'prop': attribute, 'val': value})
def add_css_class(self, id, value):
if not hasattr(value, '__iter__'):
value = [value]
self.calls.append({'cmd': 'addcc', 'id': id, 'val': value})
def remove_css_class(self, id, value):
if not hasattr(value, '__iter__'):
value = [value]
self.calls.append({'cmd': 'remcc', 'id': id, 'val': value})
def append(self, id, attribute, value):
self.calls.append({'cmd': 'ap', 'id': id, 'prop': attribute, 'val': value})
def prepend(self, id, attribute, value):
self.calls.append({'cmd': 'pp', 'id': id, 'prop': attribute, 'val': value})
def clear(self, id, attribute):
self.calls.append({'cmd': 'clr', 'id': id, 'prop': attribute})
def redirect(self, url, delay=0):
self.calls.append({'cmd': 'red', 'url': url, 'delay': delay})
def script(self, code): # OK
self.calls.append({'cmd': 'js', 'val': code})
def remove(self, id):
self.calls.append({'cmd': 'rm', 'id': id})
def add_data(self, data, function):
self.calls.append({'cmd': 'data', 'val': data, 'fun': function})
================================================
FILE: dajax/models.py
================================================
# Don't delete me
================================================
FILE: dajax/static/dajax/dojo.dajax.core.js
================================================
var Dajax = {
process: function(data)
{
dojo.forEach(data, function(elem,i){
switch(elem.cmd)
{
case 'alert':
alert(elem.val);
break;
case 'data':
eval( elem.fun+"(elem.val);" );
break;
case 'as':
if(elem.prop === 'innerHTML'){
dojo.forEach(dojo.query(elem.id), function(e){
require(["dojo/html"], function(html){
html.set(e, elem.val);
});
});
}
else{
dojo.forEach(dojo.query(elem.id),function(e){ e[elem.prop] = elem.val; });
}
break;
case 'addcc':
dojo.forEach(elem.val,function(e){
dojo.query(elem.id).addClass(e);
});
break;
case 'remcc':
dojo.forEach(elem.val,function(e){
dojo.query(elem.id).removeClass(e);
});
break;
case 'ap':
dojo.forEach(dojo.query(elem.id),function(e){ e[elem.prop] += elem.val;});
break;
case 'pp':
dojo.forEach(dojo.query(elem.id),function(e){ e[elem.prop] = elem.val + e[elem.prop] ;});
break;
case 'clr':
dojo.forEach(dojo.query(elem.id),function(e){ e[elem.prop] = ""; });
break;
case 'red':
window.setTimeout('window.location="'+elem.url+'";',elem.delay);
break;
case 'js':
eval(elem.val);
break;
case 'rm':
dojo.forEach(dojo.query(elem.id), "dojo.query(item).orphan();");
break;
default:
break;
}
});
}
};
================================================
FILE: dajax/static/dajax/jquery.dajax.core.js
================================================
var Dajax = {
process: function(data)
{
$.each(data, function(i,elem){
switch(elem.cmd)
{
case 'alert':
alert(elem.val);
break;
case 'data':
eval( elem.fun+"(elem.val);" );
break;
case 'as':
if(elem.prop == 'innerHTML'){
$(elem.id).html(elem.val);
}
else{
jQuery.each($(elem.id),function(){ this[elem.prop] = elem.val; });
}
break;
case 'addcc':
jQuery.each(elem.val,function(){
$(elem.id).addClass(String(this));
});
break;
case 'remcc':
jQuery.each(elem.val,function(){
$(elem.id).removeClass(String(this));
});
break;
case 'ap':
jQuery.each($(elem.id),function(){ this[elem.prop] += elem.val; });
break;
case 'pp':
jQuery.each($(elem.id),function(){ this[elem.prop] = elem.val + this[elem.prop]; });
break;
case 'clr':
jQuery.each($(elem.id),function(){ this[elem.prop] = ""; });
break;
case 'red':
window.setTimeout('window.location="'+elem.url+'";',elem.delay);
break;
case 'js':
eval(elem.val);
break;
case 'rm':
$(elem.id).remove();
break;
default:
break;
}
});
}
};
================================================
FILE: dajax/static/dajax/mootools.dajax.core.js
================================================
var Dajax = {
process: function(data)
{
data.each(function(elem){
switch(elem.cmd)
{
case 'alert':
alert(elem.val);
break;
case 'data':
eval( elem.fun+"(elem.val);" );
break;
case 'as':
if(elem.prop === 'innerHTML'){
$$(elem.id).each(function(e){ e.set('html', elem.val); });
}
else{
$$(elem.id).each(function(e){ e[elem.prop] = elem.val; });
}
break;
case 'addcc':
elem.val.each(function(cssclass){
$$(elem.id).each(function(e){ e.addClass(cssclass);});
});
break;
case 'remcc':
elem.val.each(function(cssclass){
$$(elem.id).each(function(e){ e.removeClass(cssclass);});
});
break;
case 'ap':
$$(elem.id).each(function(e){ e[elem.prop] += elem.val; });
break;
case 'pp':
$$(elem.id).each(function(e){ e[elem.prop] = elem.val + e[elem.prop]; });
break;
case 'clr':
$$(elem.id).each(function(e){ e[elem.prop]=""; });
break;
case 'red':
window.setTimeout('window.location="'+elem.url+'";',elem.delay);
break;
case 'js':
eval(elem.val);
break;
case 'rm':
$$(elem.id).each(function(e){ e.destroy(); });
break;
default:
break;
}
});
}
};
================================================
FILE: dajax/static/dajax/prototype.dajax.core.js
================================================
var Dajax = {
process: function(data)
{
data.each(function(elem){
switch(elem.cmd)
{
case 'alert':
alert(elem.val);
break;
case 'data':
eval( elem.fun+"(elem.val);" );
break;
case 'as':
if(elem.prop === 'innerHTML'){
$$(elem.id).each(function(e){Element.update(e, elem.val);});
}
else{
$$(elem.id).each(function(e){e[elem.prop] = elem.val;});
}
break;
case 'addcc':
elem.val.each(function(cssclass){
$$(elem.id).each(function(e){ e.addClassName(cssclass);});
});
break;
case 'remcc':
elem.val.each(function(cssclass){
$$(elem.id).each(function(e){ e.removeClassName(cssclass);});
});
break;
case 'ap':
$$(elem.id).each(function(e){ e[elem.prop] += elem.val;});
break;
case 'pp':
$$(elem.id).each(function(e){ e[elem.prop] = elem.val + e[elem.prop];});
break;
case 'clr':
$$(elem.id).each(function(e){e[elem.prop] = "";});
break;
case 'red':
window.setTimeout('window.location="'+elem.url+'";',elem.delay);
break;
case 'js':
eval(elem.val);
break;
case 'rm':
$$(elem.id).each(function(e){e.remove();});
break;
default:
break;
}
});
}
};
================================================
FILE: docs/Makefile
================================================
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-dajax.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-dajax.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/django-dajax"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/django-dajax"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
make -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
================================================
FILE: docs/api.rst
================================================
API
===
alert(message)
--------------
Alert a ``message``.
* **message**: Any message you want to alert
Usage Example::
from dajax.core import Dajax
def alert_example(request):
dajax = Dajax()
dajax.alert('Hello from python!')
return dajax.json()
assign(selector, attribute, value)
----------------------------------
Assign to all elements that matches with the ``selector`` as `attribute`` the ``value``.
* **selector**: CSS selector.
* **attribute**: Any valid attribute.
* **value**: The value you want to assing.
Usage Example::
from dajax.core import Dajax
def assign_example(request):
dajax = Dajax()
dajax.assign('#button', 'value', 'Click here!')
dajax.assign('div .alert', 'innerHTML', 'This email is invalid')
return dajax.json()
add_css_class(selector, value)
------------------------------
Assign to all elements that matches with the ``selector`` the ``CSS`` class ``value``. ``value`` could be a string or a list of them.
* **selector**: CSS selector.
* **value**: Any CSS class name or a list of them.
Usage Example::
from dajax.core import Dajax
def add_css_example(request):
dajax = Dajax()
dajax.add_css_class('div .alert', 'red')
dajax.add_css_class('div .warning', ['big', 'yellow'])
return dajax.json()
remove_css_class(selector, value)
---------------------------------
Remove to all elements that matches with the ``selector`` the ``CSS`` class ``value``. ``value`` could be a string or a list of them.
* **selector**: CSS selector.
* **value**: Any CSS class name or a list of them.
Usage Example::
from dajax.core import Dajax
def remove_css_example(request):
dajax = Dajax()
dajax.remove_css_class('div .message', 'big-message')
dajax.remove_css_class('div .total', ['big', 'red'])
return dajax.json()
append(selector, attribute, value)
----------------------------------
Append to all elements that matches with the ``selector`` ``value`` to with the desired ``attribute``.
* **selector**: CSS selector.
* **attribute**: Any valid attribute.
* **value**: Any CSS class name or a list of them.
Usage Example::
from dajax.core import Dajax
def append_example(request):
dajax = Dajax()
dajax.append('#message', 'innerHTML', 'Last message')
return dajax.json()
prepend(selector, attribute, value)
-----------------------------------
Prepend to all elements that matches with the ``selector`` ``value`` to with the desired ``attribute``.
* **selector**: CSS selector.
* **attribute**: Any valid attribute.
* **value**: Any CSS class name or a list of them.
Usage Example::
from dajax.core import Dajax
def prepend_example(request):
dajax = Dajax()
dajax.prepend('#message', 'innerHTML', 'First message')
return dajax.json()
clear(selector, attribute)
--------------------------
Clear all elements that matches with the ``selector`` the desired ``attribute``.
* **selector**: CSS selector.
* **attribute**: Any valid attribute.
Usage Example::
from dajax.core import Dajax
def clear_example(request):
dajax = Dajax()
dajax.clear('#message', 'innerHTML')
return dajax.json()
redirect(url, delay=0)
----------------------
Redirect current page to ``url`` with a delay of ``ms``.
* **url**: Destination URL.
* **delay**: Number of ms that the browser should wait before redirecting.
Usage Example::
from dajax.core import Dajax
def redirect_example(request):
dajax = Dajax()
dajax.redirect('http://google.com', delay=2000)
return dajax.json()
script(code)
------------
Executes ``code`` in the browser
* **code**: Code to execute.
Usage Example::
from dajax.core import Dajax
def code_example(request):
dajax = Dajax()
dajax.code('my_function();')
return dajax.json()
remove(selector)
----------------
Remove all elements that matches ``selector``.
* **selector**: CSS selector.
Usage Example::
from dajax.core import Dajax
def code_example(request):
dajax = Dajax()
dajax.remove('.message')
return dajax.json()
add_data(data, callback_function)
---------------------------------
Send ``data`` to the browser and call ``callback_function`` using this ``data``.
* **data**: Data you want to send to your function.
* **callback_function**: Fuction you want to call in the browser.
Usage Example::
from dajax.core import Dajax
def data_example(request):
dajax = Dajax()
dajax.add_data(range(10), 'my_js_function')
return dajax.json()
================================================
FILE: docs/changelog.rst
================================================
Changelog
=========
0.9.2
^^^^
* Fix unicode issues
* Fix Internet Explorer issues modifying element's innerHTML
0.9
^^^
* Move dajaxice core from dajaxice.core.Dajax to dajax.core
* Django 1.3 is now a requirement
* dajaxice 0.5 is now a requirement
* Static files are now located inside static instead of src
0.8.4
^^^^^
* Upgrade to dajaxice 0.1.3 (New Dajaxice.EXCEPTION)
* Dajax PEP8 naming style for addCSSClass and removeCSSClass
* Fixed some bugs in examples
* Fixed unicode problems
0.8.3
^^^^^
* General: New and cleaned setup.py
0.8.2
^^^^^
* General: Upgrade to dajaxice 0.1.1
0.8.0.1
^^^^^^^
* dajaxice released, now dajax use it as communication core
* cleaned all the code
0.7.5
^^^^^
* Added Dojo support
* Cleaned js files
* Ajax functions outside project folder now supported.
* Flickr in place editor example.
0.7.4.1
^^^^^^^
* Typo error importing ajax functions
0.7.4.0
^^^^^^^
* Typo error importing ajax functions
* Examples: Form validation using new utf-8 support.
* Examples: New deserialize method
* Examples: New DAJAX_CACHE_CONTROL usage in dajax.core.js view.
================================================
FILE: docs/conf.py
================================================
# -*- coding: utf-8 -*-
#
# django-dajax documentation build configuration file, created by
# sphinx-quickstart on Sat Jul 14 08:42:53 2012.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'django-dajax'
copyright = u'2012, Jorge Bastida'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
version = '0.9'
release = '0.9'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'nature'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'django-dajaxdoc'
# -- Options for LaTeX output --------------------------------------------------
# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-dajax.tex', u'django-dajax Documentation',
u'Jorge Bastida', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Additional stuff for the LaTeX preamble.
#latex_preamble = ''
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output --------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-dajax', u'django-dajax Documentation',
[u'Jorge Bastida'], 1)
]
================================================
FILE: docs/index.rst
================================================
django-dajax
============
Dajax is a powerful tool to easily and super-quickly develop asynchronous presentation logic in web applications, using Python and almost no JavaScript source code.
It supports four of the most popular JavaScript frameworks: Prototype, jQuery, Dojo and mootols.
Using ``django-dajaxice`` as communication core, Dajax implements an abstraction layer between presentation logic managed with JavaScript and your Python business logic.
With Dajax you can modify your DOM structure directly from Python.
Documentation
-------------
.. toctree::
:maxdepth: 2
installation
api
migrating-to-09
changelog
How does it work?
-----------------
.. image:: img/overview.png
Example
-------
Once you've `installed dajaxice <http://django-dajaxice.readthedocs.org/en/latest/installation.html>`_ and `dajax <http://django-dajax.readthedocs.org/en/latest/installation.html>`_ you can create ajax functions in your Python code::
from dajax.core import Dajax
def assign_test(request):
dajax = Dajax()
dajax.assign('#box', 'innerHTML', 'Hello World!')
dajax.add_css_class('div .alert', 'red')
return dajax.json()
This function will assign to ``#box`` as innerHTML the text ``Hello World!`` and ``Hola!`` to every DOM element that matches ``.btn``.
You can call this function in your html/js code using::
<div onclick="Dajaxice.app.assign_test(Dajax.process);">Click Here!</div>
Supported JS Frameworks
-----------------------
Dajax currently support four of the most popular:
* `jQuery 1.7.2 <http://jquery.com/>`_
* `Prototype 1.7 <http://www.prototypejs.org>`_
* `MooTools 1.4.5 <http://mootools.net/>`_
* `Dojo 1.7 <http://www.dojotoolkit.org/>`_
================================================
FILE: docs/installation.rst
================================================
Installation
============
In order to use ``dajax`` you should install ``django-dajaxice`` before. Please follow these instructions `here <http://django-dajaxice.readthedocs.org/en/latest/installation.html>`_.
Installing Dajax
----------------
Install ``django-dajax`` using ``easy_install`` or ``pip``::
$ pip install django_dajax
$ easy_install django_dajax
Add ``dajax`` in your project settings.py inside ``INSTALLED_APPS``::
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'dajaxice',
'dajax',
...
)
Create a new ``ajax.py`` file inside your app with your own dajax functions::
from dajax.core import Dajax
def multiply(request, a, b):
dajax = Dajax()
result = int(a) * int(b)
dajax.assign('#result','value',str(result))
return dajax.json()
Include dajax in your <head>::
Dajax supports up to four JS libraries. You should add to your project base template the one you need.
* `jQuery 1.7.2 <http://jquery.com/>`_ - ``dajax/jquery.dajax.core.js``
* `Prototype 1.7 <http://www.prototypejs.org>`_ - ``dajax/prototype.dajax.core.js``
* `MooTools 1.4.5 <http://mootools.net/>`_ - ``dajax/mootools.dajax.core.js``
* `Dojo 1.7 <http://www.dojotoolkit.org/>`_ - ``dajax/dojo.dajax.core.js``
For example for jQuery::
{% static "/static/dajax/jquery.dajax.core.js" %}
Use Dajax
---------
Now you can call your ajax methods using Dajaxice.app.function('Dajax.process')::
<button onclick="Dajaxice.example.myexample(Dajax.process);">Click here!</button>
The function _Dajax.process_ will process what the server returns and call the appropriate actions.
If you need your own callback, you can change the callback with a function like::
function my_callback(data){
Dajax.process(data);
/* Your js code */
}
And use it as::
<button onclick="Dajaxice.app.function(my_callback)">Click here!</button>
================================================
FILE: docs/make.bat
================================================
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=_build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
)
if "%1" == "" goto help
if "%1" == "help" (
:help
echo.Please use `make ^<target^>` where ^<target^> is one of
echo. html to make standalone HTML files
echo. dirhtml to make HTML files named index.html in directories
echo. singlehtml to make a single large HTML file
echo. pickle to make pickle files
echo. json to make JSON files
echo. htmlhelp to make HTML files and a HTML help project
echo. qthelp to make HTML files and a qthelp project
echo. devhelp to make HTML files and a Devhelp project
echo. epub to make an epub
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
echo. text to make text files
echo. man to make manual pages
echo. changes to make an overview over all changed/added/deprecated items
echo. linkcheck to check all external links for integrity
echo. doctest to run all doctests embedded in the documentation if enabled
goto end
)
if "%1" == "clean" (
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
del /q /s %BUILDDIR%\*
goto end
)
if "%1" == "html" (
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
goto end
)
if "%1" == "dirhtml" (
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
goto end
)
if "%1" == "singlehtml" (
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
goto end
)
if "%1" == "pickle" (
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the pickle files.
goto end
)
if "%1" == "json" (
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can process the JSON files.
goto end
)
if "%1" == "htmlhelp" (
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run HTML Help Workshop with the ^
.hhp project file in %BUILDDIR%/htmlhelp.
goto end
)
if "%1" == "qthelp" (
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-dajax.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-dajax.ghc
goto end
)
if "%1" == "devhelp" (
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
if errorlevel 1 exit /b 1
echo.
echo.Build finished.
goto end
)
if "%1" == "epub" (
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The epub file is in %BUILDDIR%/epub.
goto end
)
if "%1" == "latex" (
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
if errorlevel 1 exit /b 1
echo.
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
goto end
)
if "%1" == "text" (
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The text files are in %BUILDDIR%/text.
goto end
)
if "%1" == "man" (
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The manual pages are in %BUILDDIR%/man.
goto end
)
if "%1" == "changes" (
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
if errorlevel 1 exit /b 1
echo.
echo.The overview file is in %BUILDDIR%/changes.
goto end
)
if "%1" == "linkcheck" (
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
if errorlevel 1 exit /b 1
echo.
echo.Link check complete; look for any errors in the above output ^
or in %BUILDDIR%/linkcheck/output.txt.
goto end
)
if "%1" == "doctest" (
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
if errorlevel 1 exit /b 1
echo.
echo.Testing of doctests in the sources finished, look at the ^
results in %BUILDDIR%/doctest/output.txt.
goto end
)
:end
================================================
FILE: docs/migrating-to-09.rst
================================================
Migrating to 0.9
================
Static files
------------
Since ``0.9`` dajax takes advantage of ``django.contrib.staticfiles`` so deploying a dajax application live is much easy than in previous versions.
All the ``X.dajax.core.js`` flavoured files (jQuery, Prototype, ...) are inside a new folder named static instead of src.
You need to remember to run ``python manage.py collectstatic`` before deploying your code live. This command will collect all the static files your application need into ``STATIC_ROOT``. For further information, this is the `Django static files docuemntation <https://docs.djangoproject.com/en/dev/howto/static-files/>`_
You should change all you dajax core imports using for example for jQuery::
{% static "dajax/jquery.core.js" %}
Imports
-------
If you was importing ``dajax`` using::
from dajax.core.Dajax import Dajax
you should change it to::
from dajax.core import Dajax
================================================
FILE: setup.py
================================================
from distutils.core import setup
setup(
name='django-dajax',
version='0.9.2',
author='Jorge Bastida',
author_email='me@jorgebastida.com',
description=('Easy to use library to create asynchronous presentation '
'logic with django and dajaxice'),
url='http://dajaxproject.com',
license='BSD',
packages=['dajax'],
package_data={'dajax': ['static/dajax/*']},
long_description=('dajax is a powerful tool to easily and super-quickly '
'develop asynchronous presentation logic in web '
'applications using python and almost no JS code. It '
'supports up to four of the most popular JS frameworks: '
'jQuery, Prototype, Dojo and mootols.'),
install_requires=[
'django-dajaxice>=0.5'
],
classifiers=['Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Utilities']
)
gitextract_pmft9w4e/ ├── .gitignore ├── AUTHORS ├── COPYING ├── MANIFEST.in ├── README.rst ├── dajax/ │ ├── __init__.py │ ├── core.py │ ├── models.py │ └── static/ │ └── dajax/ │ ├── dojo.dajax.core.js │ ├── jquery.dajax.core.js │ ├── mootools.dajax.core.js │ └── prototype.dajax.core.js ├── docs/ │ ├── Makefile │ ├── api.rst │ ├── changelog.rst │ ├── conf.py │ ├── index.rst │ ├── installation.rst │ ├── make.bat │ └── migrating-to-09.rst └── setup.py
SYMBOL INDEX (14 symbols across 1 files)
FILE: dajax/core.py
class Dajax (line 4) | class Dajax(object):
method __init__ (line 6) | def __init__(self):
method json (line 9) | def json(self):
method alert (line 12) | def alert(self, message):
method assign (line 15) | def assign(self, id, attribute, value):
method add_css_class (line 18) | def add_css_class(self, id, value):
method remove_css_class (line 23) | def remove_css_class(self, id, value):
method append (line 28) | def append(self, id, attribute, value):
method prepend (line 31) | def prepend(self, id, attribute, value):
method clear (line 34) | def clear(self, id, attribute):
method redirect (line 37) | def redirect(self, url, delay=0):
method script (line 40) | def script(self, code): # OK
method remove (line 43) | def remove(self, id):
method add_data (line 46) | def add_data(self, data, function):
Condensed preview — 21 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (43K chars).
[
{
"path": ".gitignore",
"chars": 50,
"preview": "*.pyc\n*.egg-info\ndist\nbuild\n.DS_Store\ndocs/_build\n"
},
{
"path": "AUTHORS",
"chars": 177,
"preview": "Glue is mainly developed and maintained by Jorge Bastida <me@jorgebastida.com>\n\nA big thanks to all the contributors:\nAn"
},
{
"path": "COPYING",
"chars": 1513,
"preview": "Copyright (c) 2009-2012 Benito Jorge Bastida\nAll rights reserved.\n\nRedistribution and use in source and binary forms, wi"
},
{
"path": "MANIFEST.in",
"chars": 144,
"preview": "include *.py\ninclude COPYING\ninclude AUTHORS\nrecursive-include dajax *\nrecursive-exclude dajax *.pyc\nrecursive-include d"
},
{
"path": "README.rst",
"chars": 1702,
"preview": "django-dajax\n============\n\nDajax is a powerfull tool to easily and super-fastly develop asynchronous presentation logic "
},
{
"path": "dajax/__init__.py",
"chars": 32,
"preview": "__version__ = (0, 9, 2, 'beta')\n"
},
{
"path": "dajax/core.py",
"chars": 1515,
"preview": "from django.utils import simplejson as json\n\n\nclass Dajax(object):\n\n def __init__(self):\n self.calls = []\n\n "
},
{
"path": "dajax/models.py",
"chars": 18,
"preview": "# Don't delete me\n"
},
{
"path": "dajax/static/dajax/dojo.dajax.core.js",
"chars": 1930,
"preview": "var Dajax = {\n process: function(data)\n {\n dojo.forEach(data, function(elem,i){\n switch(elem.cmd)\n "
},
{
"path": "dajax/static/dajax/jquery.dajax.core.js",
"chars": 1665,
"preview": "var Dajax = {\n process: function(data)\n {\n $.each(data, function(i,elem){\n switch(elem.cmd)\n "
},
{
"path": "dajax/static/dajax/mootools.dajax.core.js",
"chars": 1724,
"preview": "var Dajax = {\n process: function(data)\n {\n data.each(function(elem){\n switch(elem.cmd)\n {\n "
},
{
"path": "dajax/static/dajax/prototype.dajax.core.js",
"chars": 1727,
"preview": "var Dajax = {\n process: function(data)\n {\n data.each(function(elem){\n switch(elem.cmd)\n {\n "
},
{
"path": "docs/Makefile",
"chars": 4614,
"preview": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS =\nSPHINXBUILD "
},
{
"path": "docs/api.rst",
"chars": 4700,
"preview": "API\n===\n\nalert(message)\n--------------\nAlert a ``message``.\n\n* **message**: Any message you want to alert\n\nUsage Example"
},
{
"path": "docs/changelog.rst",
"chars": 1099,
"preview": "Changelog\n=========\n\n0.9.2\n^^^^\n* Fix unicode issues\n* Fix Internet Explorer issues modifying element's innerHTML\n\n0.9\n^"
},
{
"path": "docs/conf.py",
"chars": 6935,
"preview": "# -*- coding: utf-8 -*-\n#\n# django-dajax documentation build configuration file, created by\n# sphinx-quickstart on Sat J"
},
{
"path": "docs/index.rst",
"chars": 1741,
"preview": "django-dajax\n============\n\n\nDajax is a powerful tool to easily and super-quickly develop asynchronous presentation logic"
},
{
"path": "docs/installation.rst",
"chars": 2040,
"preview": "Installation\n============\n\nIn order to use ``dajax`` you should install ``django-dajaxice`` before. Please follow these "
},
{
"path": "docs/make.bat",
"chars": 4523,
"preview": "@ECHO OFF\n\nREM Command file for Sphinx documentation\n\nif \"%SPHINXBUILD%\" == \"\" (\n\tset SPHINXBUILD=sphinx-build\n)\nset BUI"
},
{
"path": "docs/migrating-to-09.rst",
"chars": 930,
"preview": "Migrating to 0.9\n================\n\nStatic files\n------------\n\nSince ``0.9`` dajax takes advantage of ``django.contrib.st"
},
{
"path": "setup.py",
"chars": 1233,
"preview": "from distutils.core import setup\n\nsetup(\n name='django-dajax',\n version='0.9.2',\n author='Jorge Bastida',\n a"
}
]
About this extraction
This page contains the full source code of the jorgebastida/django-dajax GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 21 files (39.1 KB), approximately 10.8k tokens, and a symbol index with 14 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.