├── .gitignore ├── .travis.yml ├── BUILD_INSTRUCTIONS.md ├── CHANGELOG.md ├── LICENSE ├── MANIFEST.in ├── README.markdown ├── bin └── build-jquery.sh ├── js ├── custom-jquery.js └── octopus.js ├── octopus ├── __init__.py ├── apps.py ├── settings.py ├── static │ ├── __init__.py │ └── octopus │ │ ├── custom-jquery.js │ │ └── octopus.js ├── templates │ └── octopus │ │ ├── ajax.html │ │ ├── clear.html │ │ ├── form.html │ │ └── link.html ├── templatetags │ ├── __init__.py │ └── tentacles.py ├── tools │ └── __init__.py └── views.py ├── package-lock.json ├── package.json ├── requirements.txt ├── setup.cfg ├── setup.py ├── tests ├── manage.py ├── octopus ├── settings.py ├── static │ └── __init__.py ├── test_app │ ├── __init__.py │ ├── apps.py │ ├── models.py │ ├── templates │ │ ├── 404.html │ │ ├── __init__.py │ │ ├── base.html │ │ ├── full_list_new.html │ │ ├── full_new.html │ │ └── test_app │ │ │ ├── form.html │ │ │ └── full_form.html │ ├── urls.py │ └── views.py └── tests │ ├── __init__.py │ ├── test-requirements.txt │ ├── test_tags.py │ └── test_views.py └── tox.ini /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | build/ 3 | dist/ 4 | *.egg-info/ 5 | *.pyc 6 | CACHE/ 7 | migrations/ 8 | .pypirc 9 | .tox/ 10 | __pycache__/ 11 | node_modules/ 12 | tests/static 13 | *.db 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | install: 5 | - pip install tox 6 | script: 7 | - tox 8 | env: 9 | - TOXENV=django18 10 | - TOXENV=django19 11 | - TOXENV=django110 12 | - TOXENV=django111 13 | -------------------------------------------------------------------------------- /BUILD_INSTRUCTIONS.md: -------------------------------------------------------------------------------- 1 | # Instructions for building the javascript libraries 2 | 3 | Any js development should be done in `js/` rather than directly in 4 | `octopus/static/octopus`. The build commands should be used to install 5 | it in the appropriate places. 6 | 7 | ## Dependencies: 8 | 9 | * node 10 | * npm 11 | * browserify 12 | * jquery-builder 13 | 14 | ### For the lazy: 15 | (debian-flavored linux only) 16 | 17 | sudo apt-get install nodejs nodejs-legacy npm 18 | sudo npm install n 19 | sudo n stable 20 | sudo npm install browserify jquery-builder 21 | 22 | ## Build commands 23 | 24 | Look in package.json for the most up-to-date list 25 | 26 | |command |purpose| 27 | |:--|:--| 28 | | build | installs the js library into the python package | 29 | | build-test | runs `collectstatic` from within `tests` | 30 | | build-all | runs `build` and `build-test` | 31 | | build-jquery | custom builds jquery with the minimum required components: ajax, css, effects, and events | 32 | | install-jquery | installs jquery into the python package | 33 | 34 | #### tip: set up a file watcher to automatically run build-all as you 35 | code 36 | 37 | For pycharm users: https://www.jetbrains.com/help/pycharm/2016.3/file-watchers.html -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v0.4.1 4 | 5 | New Features 6 | 7 | * Added tag to clear certain elements when clicked 8 | 9 | Bug fixes 10 | 11 | * Fixed title insertion and HTML parsin 12 | * Stopped propagation on clicks 13 | * Fixed fadeout conflict when insert=self 14 | 15 | ## v0.4 16 | 17 | This is an aggressive update that breaks backwards compatibility in 18 | just about every way, but seeing that no one really uses it, the fallout 19 | should be minimal :) 20 | 21 | ### New features 22 | 23 | * Proxy templates are no longer used to switch between full and ajax 24 | requests. You now just define blocks named `fragment` in your 25 | templates. 26 | * Titles are included directly in the response. Before, titles were 27 | defined on the link itself. Now a `title` block is supported to define 28 | title content 29 | * While loading, the target element fades to 30% opacity 30 | 31 | ### Changes 32 | 33 | * removed support for python < 3.6 34 | * due to changes in django, new installed apps are required: 35 | 36 | INSTALLED_APPS = ( 37 | ... 38 | 'django.contrib.auth', 39 | 'django.contrib.contenttypes' 40 | ... 41 | ) 42 | 43 | * changed the template tags' signatures to resemble the typical order of 44 | html tag attributes: 45 | 46 | \text\ 47 | 48 | {% a '/home' target='#main' text='text' %} 49 | 50 | * Changed default value for `multi` to `True` 51 | * Switched to using data-* html attributes 52 | 53 | ### Javascript changes 54 | 55 | * Added javascript build commands: see `BUILD_INSTRUCTIONS.md` for details 56 | * Includes custom build of jQuery to use only the required components 57 | * Trivial javascript improvements, still needs a lot of work before a 58 | 1.0 release. Jasmine tests are still missing 59 | 60 | 61 | ## v0.3.2 62 | 63 | * removed deprecated 'a' tag 64 | 65 | ## v0.3.1 66 | 67 | * officially added support for django 1.8, 1.9, and 1.10 and python 3.5. 68 | * removed support for EOL versions 69 | 70 | ## v0.3 71 | 72 | ### Bug fixes 73 | 74 | * fixed bug in the javascript that prevented replaceState() from being called 75 | in FireFox 76 | 77 | ### Changes 78 | 79 | * a `title` is now required to engaged the forward/back behavior 80 | 81 | * `multi` default value for forms changed to `True` 82 | 83 | * the behavior of `self` was modified to fully replace the containing element, 84 | so be sure a single node encapsulates your template fragments if using 85 | `self` 86 | 87 | ## v0.2 88 | 89 | ### Changes 90 | 91 | * `action` attribute in the template tags was changed to `insert` to avoid 92 | conflicts with form attributes. This is not backwards compatible. 93 | 94 | * Changed the name of the file in the template tag from `a.py` to 95 | `tentacles.py`. `{% load a %}` is deprecated. Change it to 96 | `{% load tentacles %}` 97 | 98 | 99 | ### New Features 100 | 101 | * Create-, Update-, and DeleteViews support added and tested. 102 | 103 | * New template tag to create forms 104 | 105 | * Added `self` to allowed `insert` methods. This is similar to `replace` but 106 | in case several nodes have been appended or prepended, it only replaces the 107 | exact node in question rather than overwriting the contents of the entire 108 | `target`. This allows for creating, editing, or deleting multiple models in 109 | place and saving them individually. If `insert="self"` is set, `target` is 110 | ignored. 111 | 112 | ## v0.1 113 | 114 | ### Features 115 | 116 | * New generic class-based views that correspond to DetailView, ListView, 117 | ArchiveIndexView, DayArchiveView, TodayArchiveView, DateDetailView, 118 | WeekArchiveView, MonthArchiveView, and YearArchiveView 119 | 120 | * A mixin(AjaxResponseMixin) to be used on pre-existing CBVs 121 | 122 | * A template tag to generate octopus-compatible links -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Brian McClure 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.markdown 2 | include LICENSE 3 | include tox.ini 4 | include .travis.yml 5 | recursive-include octopus *.py *.html *.css *.js -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/brmc/django-octopus.svg?branch=master)](https://travis-ci.org/brmc/django-octopus) 2 | 3 | # **django-octopus** # 4 | 5 | Octopus is a lightweight AJAX pull framework for django that uses a 6 | purely declarative syntax to load or refresh pages modularly. 7 | 8 | [Click here to see a full-featured demo.](http://mcclure.pw/demo). 9 | The content of the demo hasn't been updated to match the changes with 10 | version 0.4. It behaves the same from the end-user perspective, 11 | but the information is no longer accurate 12 | 13 | ## Contents 14 | 15 | * [Quick start](#quick-start) 16 | * [Changelog (Recent changes only)](#changelog-recent-changes) 17 | * [How does it work?](#how-does-it-work) 18 | * [Requirements](#requirements) 19 | * [Installation](#installation) 20 | * [Usage](#usage) 21 | * [Views](#views) 22 | * [Creating Class Based Views](#creating-class-based-views) 23 | * [Creating function Based Views](#creating-function-based-views) 24 | * [Template Tags](#template-tags) 25 | * [a (links)](#a) 26 | * [form](#form) 27 | * [Manually Creating Elements](#manually-creating-elements) 28 | * [Creating Links](#creating-links) 29 | * [Creating forms](#creating-forms) 30 | * [Creating Templates](#creating-templates) 31 | * [Configuration](#configuration) 32 | * [Todo](#todo) 33 | 34 | 35 | ## Quick start ## 36 | 37 | 1\. `pip install django-octopus` 38 | 39 | 2\. `settings.py` 40 | 41 | INSTALLED_APPS = ( 42 | 'django.contrib.auth', 43 | 'django.contrib.contenttypes', 44 | ... 45 | 'octopus', 46 | ... 47 | ) 48 | 49 | You may need to restart your development server to detect the template 50 | tags. 51 | 52 | 3\. Add javascript: 53 | 54 | 55 | 56 | 57 | 4\. Define your views: 58 | 59 | from octopus.views import OctopusDetailView, OctopusListView 60 | 61 | def YourDetailView(OctopusDetailView): 62 | model = YourModel 63 | template_name = "