├── .gitignore ├── .gitmodules ├── AUTHORS ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── README.rst ├── setup.py └── twitter_bootstrap ├── __init__.py └── models.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | dist 3 | *.egg-info 4 | build 5 | .python-version 6 | 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "twitter_bootstrap/static"] 2 | path = twitter_bootstrap/static 3 | url = git://github.com/twitter/bootstrap.git 4 | [submodule "twitter_bootstrap/static/twitter_bootstrap"] 5 | path = twitter_bootstrap/static/twitter_bootstrap 6 | url = git@github.com:twbs/bootstrap.git 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Steven Cummings 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | django-twitter-bootstrap is an MIT-licensed, open-source project and welcomes 4 | contributions. 5 | 6 | This being a relatively simple project, contributions would likely take one of 7 | the following forms: 8 | 9 | * Any of the items found in the PLAN 10 | * Backports of this packaging to prior versions of Bootstrap 11 | * Minor bugfixes 12 | * Documentation improvements 13 | * Tests 14 | 15 | I plan to keep up on future releases of Bootstrap myself. 16 | 17 | ## Developing - The Bootstrap git sub-module 18 | 19 | One note of import to would-be contributors is that Bootstrap is included as a 20 | git sub-module so that we don't have the mess of managing *copies* of 21 | Bootstrap's sources. Instead we can just checkout a target release tag of 22 | Bootstrap and go. 23 | 24 | When you first clone the project: 25 | 26 | ```bash 27 | git clone git://github.com/estebistec/django-twitter-bootstrap.git 28 | cd django-twitter-bootstrap 29 | git submodule update --init 30 | ``` 31 | 32 | Then, when you want to update to a different release of Bootstrap: 33 | 34 | ```bash 35 | cd twitter_bootstrap/static/twitter_bootstrap 36 | git tag # See a list of tags 37 | git checkout v3.0.4 # Or some other release tag 38 | cd ../../.. 39 | git add twitter_bootstrap/static/twitter_bootstrap 40 | git commit -m "Upgrade Bootstrap to v3.0.4" 41 | ``` 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 C. Steven Cummings 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHORS 2 | include LICENSE 3 | include PLAN 4 | include *.md 5 | include *.rst 6 | include setup.py 7 | include twitter_bootstrap/*.py 8 | include twitter_bootstrap/static/twitter_bootstrap/fonts/glyphicons-halflings-regular.* 9 | include twitter_bootstrap/static/twitter_bootstrap/js/*.js 10 | recursive-include twitter_bootstrap/static/twitter_bootstrap/less *.less 11 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. image:: https://pypip.in/v/django-twitter-bootstrap/badge.png 2 | :target: https://pypi.python.org/pypi/django-twitter-bootstrap/ 3 | :alt: Latest Version 4 | 5 | .. image:: https://pypip.in/d/django-twitter-bootstrap/badge.png 6 | :target: https://pypi.python.org/pypi/django-twitter-bootstrap/ 7 | :alt: Downloads 8 | 9 | Overview 10 | ======== 11 | 12 | This package provides a `Django `_ app whose static folder contains 13 | the sources of `Bootstrap `_, nothing more and nothing 14 | less. The un-minified `LESS `_ and javascript sources are included to be 15 | integrated into your Django site as you see fit. If you simply want to use the minified CSS and JS 16 | files provided by the Bootstrap project, you probably don't need this anyway. 17 | 18 | Further goals of this project include: 19 | 20 | - To include Bootstrap as a git submodule, so as to include specific release tags and avoid the 21 | mess of managing a copy of Bootstrap. 22 | - To provide versions that mirror Bootstrap releases going forward. 23 | 24 | And that's it! Bootstrap pre-packaged for Django. 25 | 26 | I found that other similar projects: 27 | 28 | - Did not keep up with recent versions of Bootstrap. 29 | - Simply made a copy of the Bootstrap sources, messy and unnecessary. 30 | - Tied the packaging to their own clever template tags or other Django components. You should have 31 | your choice of these things apart from this packaging. 32 | 33 | Setup 34 | ===== 35 | 36 | **NOTE** The paths of the included bootstrap assets have now been namespaced within the app's 37 | ``static`` folder. The ``less`` and ``js`` folders now reside within a ``twitter_bootstrap`` 38 | folder. 39 | 40 | First, install the app:: 41 | 42 | pip install django-twitter-bootstrap==3.3.0 43 | 44 | Then include it in your Django project:: 45 | 46 | # settings.py: 47 | 48 | INSTALLED_APPS = ( 49 | ... 50 | 'twitter_bootstrap', 51 | ... 52 | ) 53 | 54 | This also assumes you haven't removed ``django.contrib.staticfiles.finders.AppDirectoriesFinder`` 55 | from the ``STATICFILES_FINDERS`` config setting. 56 | 57 | Provided staticfiles 58 | ==================== 59 | 60 | Of course what's provided is just Bootstrap, but more specifically... 61 | 62 | glyphicons 63 | ---------- 64 | 65 | These don't need to be specified or configured in your project, but they are included all the 66 | same. 67 | 68 | - ``twitter_bootstrap/fonts/glyphicons-halflings-regular.eot`` 69 | - ``twitter_bootstrap/fonts/glyphicons-halflings-regular.svg`` 70 | - ``twitter_bootstrap/fonts/glyphicons-halflings-regular.ttf`` 71 | - ``twitter_bootstrap/fonts/glyphicons-halflings-regular.woff`` 72 | 73 | LESS 74 | ---- 75 | 76 | - ``twitter_bootstrap/less/bootstrap.less`` 77 | 78 | Also included are lots of other LESS files included by the above that aren't worth listing out. 79 | The above file is the common entry point for usage of Bootstrap styles. 80 | 81 | JavaScript 82 | ---------- 83 | 84 | Unlike the LESS sources, the javascript modules each represent a feature set 85 | that you may or may not want to include in your site. These files are 86 | typically hand-picked based on the needs of your site. Please check the 87 | Bootstrap documentation for info on which of these modules depends on others. 88 | 89 | - ``twitter_bootstrap/js/transition.js`` 90 | - ``twitter_bootstrap/js/modal.js`` 91 | - ``twitter_bootstrap/js/dropdown.js`` 92 | - ``twitter_bootstrap/js/scrollspy.js`` 93 | - ``twitter_bootstrap/js/tab.js`` 94 | - ``twitter_bootstrap/js/tooltip.js`` 95 | - ``twitter_bootstrap/js/popover.js`` 96 | - ``twitter_bootstrap/js/alert.js`` 97 | - ``twitter_bootstrap/js/button.js`` 98 | - ``twitter_bootstrap/js/collapse.js`` 99 | - ``twitter_bootstrap/js/carousel.js`` 100 | - ``twitter_bootstrap/js/affix.js`` 101 | 102 | Plain Usage 103 | =========== 104 | 105 | If you're not using an asset manager, you can just include them as usual in your site templates:: 106 | 107 | {% load staticfiles %} 108 | ... 109 | 110 | ... 111 | 112 | Usage with an asset pipeline 113 | ============================ 114 | 115 | Of course I recommend you not go plain, and instead use an asset manager that helps with the 116 | filtering, concatenating, minification, and other processing of your static assets. One such 117 | manager is `django-pipeline `_. 118 | 119 | - Follow the setup instructions for django-pipeline 120 | - Define asset groups which provide Bootstrap 121 | - Use asset groups in your templates. 122 | 123 | Configuration 124 | ------------- 125 | 126 | Create asset groups including the bootstrap LESS and Javascript you want to include:: 127 | 128 | # settings.py 129 | 130 | PIPELINE_CSS = { 131 | ... 132 | 'bootstrap': { 133 | 'source_filenames': ( 134 | 'twitter_bootstrap/less/bootstrap.less', 135 | ), 136 | 'output_filename': 'css/b.css', 137 | 'extra_context': { 138 | 'media': 'screen,projection', 139 | }, 140 | }, 141 | ... 142 | } 143 | 144 | PIPELINE_JS = { 145 | ... 146 | 'bootstrap': { 147 | 'source_filenames': ( 148 | 'twitter_bootstrap/js/transition.js', 149 | 'twitter_bootstrap/js/modal.js', 150 | 'twitter_bootstrap/js/dropdown.js', 151 | 'twitter_bootstrap/js/scrollspy.js', 152 | 'twitter_bootstrap/js/tab.js', 153 | 'twitter_bootstrap/js/tooltip.js', 154 | 'twitter_bootstrap/js/popover.js', 155 | 'twitter_bootstrap/js/alert.js', 156 | 'twitter_bootstrap/js/button.js', 157 | 'twitter_bootstrap/js/collapse.js', 158 | 'twitter_bootstrap/js/carousel.js', 159 | 'twitter_bootstrap/js/affix.js', 160 | ), 161 | 'output_filename': 'js/b.js', 162 | }, 163 | ... 164 | } 165 | 166 | Of course you need to set up a 167 | `LESS compiler `_ 168 | for pipeline to use when processing the styles:: 169 | 170 | # settings.py 171 | 172 | PIPELINE_COMPILERS = ( 173 | 'pipeline.compilers.less.LessCompiler', 174 | ) 175 | 176 | Then, in the 177 | `PIPELINE_LESS_ARGUMENTS `_ 178 | setting, supply an ``--include`` option which tells ``lessc`` where bootstrap LESS sources and any 179 | of your own live:: 180 | 181 | # settings.py 182 | 183 | import os 184 | 185 | # TODO update this to reflect where your settings live relative to the project root 186 | BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 187 | 188 | my_app_less = os.path.join(BASE_DIR, 'my_app', 'static', 'less') 189 | 190 | # For apps outside of your project, it's simpler to import them to find their root folders 191 | import twitter_bootstrap 192 | bootstrap_less = os.path.join(os.path.dirname(twitter_bootstrap.__file__), 'static', 'less') 193 | 194 | PIPELINE_LESS_ARGUMENTS = u'--include-path={}'.format(os.pathsep.join([bootstrap_less, my_app_less])) 195 | 196 | Please note that for any LESS sources outside of your project root, usually these are installed 197 | Django packages, it is simpler to import the package and determine the package root from the 198 | import module's ``__file__`` attribute. 199 | 200 | Template setup 201 | -------------- 202 | 203 | A sample Django template using the assets:: 204 | 205 | ... 206 | {% load compressed %} 207 | ... 208 | 209 | ... 210 | {% compressed_css 'bootstrap' %} 211 | ... 212 | 213 | 214 | ... 215 | {% compressed_js 'bootstrap' %} 216 | ... 217 | 218 | 219 | 220 | That's it. Enjoy! 221 | 222 | Version ranges matching bootstrap versions 223 | ========================================== 224 | 225 | As stated above in the goals, versions of this package should match versions of Bootstrap, where 226 | available. This presents something of a problem if and when we need to make updates to the 227 | *packaging* here. We can't just upgrade any of the three common components of semantic versioning, 228 | because those map to versions of Bootstrap. So, we'll use revisions when needed. 229 | 230 | E.g., suppose we have django-twitter-bootstrap 3.2.0 which packages Bootstrap 3.2.0. If we 231 | need to enhance or fix the packaging, we release it as revised version 3.2.0-1. 232 | 233 | Therefore, if you're getting a packaging for the first time you could specify it as a very tight 234 | range of that target version or no less than the next patch level version. E.g., target 3.2.0 with 235 | ``>=3.2.0,<3.2.1``. Each of these captures all revisions to packagings targeting a specific version 236 | of Bootstrap. 237 | 238 | Finally, it should be re-iterated that the need for this should be the exception and versions 239 | should generally mirror Bootstrap more directly going forward. 240 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | from setuptools import setup, find_packages 5 | 6 | 7 | setup( 8 | name="django-twitter-bootstrap", 9 | version="3.3.0", 10 | packages=find_packages(), 11 | package_data={ 12 | 'twitter_bootstrap': [ 13 | 'static/twitter_bootstrap/fonts/glyphicons-halflings-regular.*', 14 | 'static/twitter_bootstrap/js/*.js', 15 | 'static/twitter_bootstrap/less/*.less', 16 | 'static/twitter_bootstrap/less/mixins/*.less', 17 | ], 18 | }, 19 | 20 | # metadata for upload to PyPI 21 | author="Steven Cummings", 22 | author_email="cummingscs@gmail.com", 23 | description="Provides a Django app whose static folder contains Bootstrap assets", 24 | license="MIT", 25 | keywords="django app staticfiles twitter bootstrap", 26 | url="https://github.com/estebistec/django-twitter-bootstrap", 27 | download_url="http://pypi.python.org/pypi/django-twitter-bootstrap", 28 | classifiers=[ 29 | 'Development Status :: 4 - Beta', 30 | 'Environment :: Web Environment', 31 | 'Framework :: Django', 32 | 'Intended Audience :: Developers', 33 | 'License :: OSI Approved :: MIT License', 34 | 'Programming Language :: Python', 35 | 'Programming Language :: Python :: 3', 36 | 'Programming Language :: Python :: 2.7', 37 | 'Programming Language :: Python :: 3.3', 38 | 'Topic :: Software Development :: Libraries', 39 | ] 40 | ) 41 | -------------------------------------------------------------------------------- /twitter_bootstrap/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/estebistec/django-twitter-bootstrap/00c69013ff3543515d8409a5508f885d7fe14c48/twitter_bootstrap/__init__.py -------------------------------------------------------------------------------- /twitter_bootstrap/models.py: -------------------------------------------------------------------------------- 1 | # Create your models here. 2 | --------------------------------------------------------------------------------