{"id":16421134,"url":"https://github.com/kezabelle/django-intercoolerjs-helpers","last_synced_at":"2025-03-23T07:32:01.258Z","repository":{"id":57420490,"uuid":"83018115","full_name":"kezabelle/django-intercoolerjs-helpers","owner":"kezabelle","description":" small reusable app for Django which provides a few improvements for working with Intercooler.js","archived":false,"fork":false,"pushed_at":"2019-08-20T13:26:42.000Z","size":48,"stargazers_count":13,"open_issues_count":7,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T22:07:15.853Z","etag":null,"topics":["ajax","django","django-middleware","intercoolerjs","jquery","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kezabelle.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-24T08:15:03.000Z","updated_at":"2025-02-06T12:54:02.000Z","dependencies_parsed_at":"2022-09-16T09:10:50.796Z","dependency_job_id":null,"html_url":"https://github.com/kezabelle/django-intercoolerjs-helpers","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezabelle%2Fdjango-intercoolerjs-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezabelle%2Fdjango-intercoolerjs-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezabelle%2Fdjango-intercoolerjs-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezabelle%2Fdjango-intercoolerjs-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kezabelle","download_url":"https://codeload.github.com/kezabelle/django-intercoolerjs-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245071927,"owners_count":20556352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ajax","django","django-middleware","intercoolerjs","jquery","python"],"created_at":"2024-10-11T07:30:33.142Z","updated_at":"2025-03-23T07:32:00.965Z","avatar_url":"https://github.com/kezabelle.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-intercooler_helpers\n==========================\n\n:author: Keryn Knight\n:version: 0.2.0\n\n.. |travis_stable| image:: https://travis-ci.org/kezabelle/django-intercoolerjs-helpers.svg?branch=0.2.0\n  :target: https://travis-ci.org/kezabelle/django-intercoolerjs-helpers\n\n.. |travis_master| image:: https://travis-ci.org/kezabelle/django-intercoolerjs-helpers.svg?branch=master\n  :target: https://travis-ci.org/kezabelle/django-intercoolerjs-helpers\n\n==============  ======\nRelease         Status\n==============  ======\nstable (0.2.0)  |travis_stable|\nmaster          |travis_master|\n==============  ======\n\n\n.. contents:: Sections\n   :depth: 2\n\nWhat it does\n------------\n\n``intercooler_helpers`` is a small reusable app for `Django`_ which provides a\nfew improvements for working with `Intercooler.js`_.\n\nIt providea a middleware which extracts relevant `Intercooler.js`_ data from the\nquerystring, and attaches it to the request as a separate ``QueryDict`` (ie: it\nbehaves like ``request.POST`` or ``request.GET``)\n\nIt also provides a small middleware for changing request method based on either the\nquery string (``_method=PUT``) or a request header(``X-HTTP-Method-Override: PUT``)\n\nBetween them, they should capture all the incoming `Intercooler.js`_ data on\nwhich the server may act.\n\nInstallation and usage\n----------------------\n\nThis application depends on `django-intercoolerjs`_ which provides a copy of\n`Intercooler.js`_ bundled up for use with the standard `Django`_ staticfiles\napplication.\n\nInstallation\n^^^^^^^^^^^^\n\nYou can grab ``0.2.0`` from `PyPI`_ like so::\n\n  pip install django-intercooler-helpers==0.2.0\n\nOr you can grab it from  `GitHub`_  like this::\n\n  pip install -e git+https://github.com/kezabelle/django-intercoolerjs-helpers.git#egg=django-intercoolerjs-helpers\n\nConfiguration\n^^^^^^^^^^^^^\nYou need to add ``intercooler_helpers.middleware.IntercoolerData`` to your\n``MIDDLEWARE_CLASSES`` (or ``MIDDLEWARE`` on Django **1.10+**).\n\nYou may optionally want to add ``intercooler_helpers.middleware.HttpMethodOverride``\nas well, if you don't already have a method by which to fake the HTTP Method change.\nIf you're using ``\u003cmeta name=\"intercoolerjs:use-actual-http-method\" content=\"true\"/\u003e``\nthen you don't need ``HttpMethodOverride`` at all.\n\nTo install all the middleware, you want something like::\n\n  # MIDDLEWARE = ... for newer Django\n  MIDDLEWARE_CLASSES = (\n    # ...\n    'intercooler_helpers.middleware.HttpMethodOverride',\n    'intercooler_helpers.middleware.IntercoolerData',\n    'intercooler_helpers.middleware.IntercoolerRedirector',\n    # ...\n  )\n\n``HttpMethodOverride`` and ``IntercoolerData`` ought to be near the top of the iterable, as they both make use of ``process_request(request)``.\n``IntercoolerRedirector`` ought to be near the bottom, as it operates on ``process_response(request, response)`` and you probably want to convert the response to a client-side redirect at the earliest opportunity.\n\nUsage\n^^^^^\n\nA brief overview of the public API provided so far:\n\nIntercoolerData\n***************\n\nFor fully correct detection of `Intercooler.js`_ requests, you can call\n``request.is_intercooler()``.\nBehind the scenes, it uses ``request.maybe_intercooler()`` to\ndetect whether ``ic-request`` was present, indicating it *may* have been a\nvalid `Intercooler.js`_ request, and also checks ``request.is_ajax()``\n\nTo parse the Intercooler-related data out of the query-string, you can use\n``request.intercooler_data`` (not a method!) which is a ``QueryDict`` and should\nbehave exactly like ``request.GET`` - It pulls all of the ``ic-*`` keys out\nof ``request.GET`` and puts them in a separate data structure, leaving\nyour ``request.GET`` cleaned of extraenous data.\n\n``request.intercooler_data`` is a **lazy** data structure, like ``request.user``,\nso will not modify ``request.GET`` until access is attempted.\n\nThe following properties exist, mapping back to the keys mentioned in the\n`Intercooler.js Reference document`_\n\n- ``request.intercooler_data.url`` returns a ``namedtuple`` containing\n\n  - returns the ``ic-current-url`` (converted via ``urlparse``) or ``None``\n  - A `Django`_ ``ResolverMatch`` pointing to the view which made the request (based on ``ic-current-url``) or ``None``\n- ``request.intercooler_data.element`` returns a ``namedtuple`` containing\n\n  -  ``ic-element-name`` or ``None``\n  -  ``ic-element-id`` or ``None``\n- ``request.intercooler_data.id``\n\n  - the ``ic-id`` which made the request. an ever-incrementing integer.\n- ``request.intercooler_data.request``\n\n  - a boolean indicating that it was an `Intercooler.js`_ request. Should always\n    be true if ``request.is_intercooler()`` said so.\n- ``request.intercooler_data.target_id``\n\n  -  ``ic-target-id`` or ``None``\n- ``request.intercooler_data.trigger`` returns a ``namedtuple`` containing\n\n  -  ``ic-trigger-name`` or ``None``\n  -  ``ic-trigger-id`` or ``None``\n- ``request.intercooler_data.prompt_value``\n\n  - If no ``ic-prompt-name`` was given and a prompt was used, this will contain\n    the user's response. Appears to be undocumented?\n\n\nHttpMethodOverride\n******************\n\n- ``request.changed_method`` is a boolean indicating that the request was\n  toggled from being a ``POST`` to something else (one of\n  ``GET``, ``HEAD``, ``POST``, ``PUT``, ``PATCH``, ``DELETE``, ``OPTIONS`` ...\n  though why you'd want to ``POST`` and have it act as a ``GET`` is beyond me.\n  But that's your choice)\n- ``request.original_method`` if either ``_method=X`` or\n  ``X-HTTP-Method-Override: X`` caused the request to change method, then this\n  will contain the original request. It should always be ``POST``\n- ``request.method`` will reflect the desired HTTP method, rather than the one\n  originally used (``POST``)\n\n\nIntercoolerRedirector\n*********************\n\nIf a redirect status code is given (\u003e 300, \u003c 400), and the request originated from `Intercooler.js`_ (assumes ``IntercoolerData`` is installed so that ``request.is_intercooler()`` may be called), remove the ``Location`` header from the response, and create a new ``HttpResponse`` with all the other headers, and also the ``X-IC-Redirect`` header to indicate to `Intercooler.js`_ that it needs to do a client side-redirect.\n\n\nSupported Django versions\n-------------------------\n\nThe tests are run against Django 1.8 through 1.10, and Python 2.7, 3.3, 3.4 and 3.5.\n\nRunning the tests\n^^^^^^^^^^^^^^^^^\n\nIf you have a cloned copy, you can do::\n\n  python setup.py test\n\nIf you have tox, you can just do::\n\n  tox\n\nRunning the demo\n^^^^^^^^^^^^^^^^\n\nA barebones demo is provided. It assumes you're using something like `virtualenv`_ and\n`virtualenvwrapper`_ but you can probably figure it out otherwise::\n\n    mktmpenv --python=`which python3`\n    pip install -e git+https://github.com/kezabelle/django-intercooler-helpers.git#egg=django-intercooler-helpers\n\nThen probably::\n\n    cd src/django-intercooler-helpers\n    python demo_project.py runserver\n\nIt shows off a few of the same demos that the `Intercooler.js`_ website does.\n\nContributing\n------------\n\nPlease do!\n\nThe project is hosted on `GitHub`_ in the `kezabelle/django-intercooler-helpers`_\nrepository.\n\nBug reports and feature requests can be filed on the repository's `issue tracker`_.\n\nIf something can be discussed in 140 character chunks, there's also `my Twitter account`_.\n\nRoadmap\n-------\n\nTODO.\n\nThe license\n-----------\n\nIt's `FreeBSD`_. There's should be a ``LICENSE`` file in the root of the repository, and in any archives.\n\n.. _FreeBSD: http://en.wikipedia.org/wiki/BSD_licenses#2-clause_license_.28.22Simplified_BSD_License.22_or_.22FreeBSD_License.22.29\n.. _Django: https://www.djangoproject.com/\n.. _Intercooler.js: http://intercoolerjs.org/\n.. _django-intercoolerjs: https://github.com/brejoc/django-intercoolerjs\n.. _GitHub: https://github.com/\n.. _PyPI: https://pypi.python.org/pypi\n.. _Intercooler.js Reference document: http://intercoolerjs.org/reference.html\n.. _virtualenvwrapper: https://virtualenvwrapper.readthedocs.io/en/latest/\n.. _virtualenv: https://virtualenv.pypa.io/en/stable/\n.. _kezabelle/django-intercooler-helpers: https://github.com/kezabelle/django-intercooler-helpers/\n.. _issue tracker: https://github.com/kezabelle/django-intercooler-helpers/issues/\n.. _my Twitter account: https://twitter.com/kezabelle/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezabelle%2Fdjango-intercoolerjs-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkezabelle%2Fdjango-intercoolerjs-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezabelle%2Fdjango-intercoolerjs-helpers/lists"}