├── project ├── __init__.py ├── urls.py ├── wsgi.py └── settings.py ├── shp2svg ├── __init__.py ├── management │ ├── __init__.py │ └── commands │ │ └── __init__.py ├── migrations │ ├── __init__.py │ └── 0001_initial.py ├── admin.py ├── tests.py ├── models.py └── views.py ├── templates ├── robots.txt ├── static │ ├── img │ │ ├── glyphicons-halflings.png │ │ └── glyphicons-halflings-white.png │ ├── js │ │ ├── underscore-min.js │ │ ├── json2.js │ │ ├── bootstrap.min.js │ │ └── jquery.form.js │ └── css │ │ ├── bootstrap-responsive.min.css │ │ └── bootstrap-responsive.css ├── header.html ├── 500.html ├── 404.html ├── svg.html ├── base.html ├── setup_form.html ├── shapefilecontainer_detail.html └── index.html ├── requirements.txt ├── .gitignore ├── manage.py ├── README.md └── fabfile.py /project/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shp2svg/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shp2svg/management/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shp2svg/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shp2svg/management/commands/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Sitemap: http://shp2svg.com/sitemap.xml 3 | Disallow: /admin/ -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Django==1.5.4 2 | Fabric==1.5.1 3 | South==0.7.6 4 | paramiko==1.9.0 5 | psycopg2==2.4.5 6 | pycrypto==2.6 7 | wsgiref==0.1.2 -------------------------------------------------------------------------------- /templates/static/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datadesk/django-shp2svg/HEAD/templates/static/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | django.log 2 | django.log.* 3 | settings_local.py 4 | *~ 5 | build/* 6 | media/* 7 | static/* 8 | *.db 9 | *.pyc 10 | *.swp 11 | .DS_Store -------------------------------------------------------------------------------- /templates/static/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/datadesk/django-shp2svg/HEAD/templates/static/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /shp2svg/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib.gis import admin 2 | from shp2svg.models import Shape, ShapefileContainer 3 | 4 | admin.site.register(Shape, admin.GeoModelAdmin) 5 | admin.site.register(ShapefileContainer, admin.GeoModelAdmin) -------------------------------------------------------------------------------- /templates/header.html: -------------------------------------------------------------------------------- 1 |
2 |

shp2svg

3 |

Convert a shapefile into SVG paths easily used with JavaScript libraries like Raphael.

5 |
-------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /shp2svg/tests.py: -------------------------------------------------------------------------------- 1 | """ 2 | This file demonstrates writing tests using the unittest module. These will pass 3 | when you run "manage.py test". 4 | 5 | Replace this with more appropriate tests for your application. 6 | """ 7 | 8 | from django.test import TestCase 9 | 10 | 11 | class SimpleTest(TestCase): 12 | def test_basic_addition(self): 13 | """ 14 | Tests that 1 + 1 always equals 2. 15 | """ 16 | self.assertEqual(1 + 1, 2) 17 | -------------------------------------------------------------------------------- /templates/500.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 |
5 | {% include 'header.html' %} 6 |
7 |

We're sorry.

8 |

There was a mistake loading your page.

9 |

The site administrator has been notified about the problem.

10 |

Please wait a few minutes and try again.

11 |
12 |
13 | {% endblock %} -------------------------------------------------------------------------------- /templates/404.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block content %} 4 |
5 | {% include 'header.html' %} 6 |
7 |

We're sorry.

8 |
9 |

We couldn't find the page you requested.

10 |

There might be a mistake in the URL, or the link could be out of date.

11 |

You could try:

12 |
    13 |
  • Typing the URL again.
  • 14 |
  • Visiting the site index to look for the information you want.
  • 15 |
16 |
17 |
18 |
19 | {% endblock %} -------------------------------------------------------------------------------- /project/urls.py: -------------------------------------------------------------------------------- 1 | from shp2svg import views 2 | from django.contrib import admin 3 | from django.conf.urls import patterns, include, url 4 | admin.autodiscover() 5 | 6 | sitemaps = { 7 | 'home': views.Sitemap(['index',]), 8 | 'shapefiles': views.ShapefileContainerSitemap, 9 | } 10 | 11 | urlpatterns = patterns('', 12 | url(r'^$', views.index, name='index'), 13 | url(r'^admin/', include(admin.site.urls)), 14 | url(r'^upload_shape/', views.upload_shapefile), 15 | url(r'^setup/', views.GenerateSVG.as_view()), 16 | # url(r'^robots\.txt$', direct_to_template, { 17 | # 'template': 'robots.txt', 'mimetype': 'text/plain'}), 18 | # url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', { 19 | # 'sitemaps': sitemaps}), 20 | url(r'^(?P[-\d\w]+)/$', views.shapefile_detail, name="shapefile detail"), 21 | ) -------------------------------------------------------------------------------- /templates/svg.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | {% if centroid %} 8 | {% for key, value in paths.items %} 9 | 10 | 11 | 12 | 13 | {% endfor %} 14 | {% else %} 15 | {% for key, value in paths.items %} 16 | 17 | {% endfor %} 18 | {% endif %} 19 | -------------------------------------------------------------------------------- /project/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for project project. 3 | 4 | This module contains the WSGI application used by Django's development server 5 | and any production WSGI deployments. It should expose a module-level variable 6 | named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover 7 | this application via the ``WSGI_APPLICATION`` setting. 8 | 9 | Usually you will have the standard Django WSGI application here, but it also 10 | might make sense to replace the whole Django WSGI application with a custom one 11 | that later delegates to the Django one. For example, you could introduce WSGI 12 | middleware here, or combine a Django application with an application of another 13 | framework. 14 | 15 | """ 16 | import os 17 | 18 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings") 19 | 20 | # This application object is used by any WSGI server configured to use this 21 | # file. This includes Django's development server, if the WSGI_APPLICATION 22 | # setting points here. 23 | from django.core.wsgi import get_wsgi_application 24 | application = get_wsgi_application() 25 | 26 | # Apply WSGI middleware here. 27 | # from helloworld.wsgi import HelloWorldApplication 28 | # application = HelloWorldApplication(application) 29 | -------------------------------------------------------------------------------- /templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | {% block extra-css %}{% endblock %} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {% block extra-js %}{% endblock %} 27 | 28 | 29 | {% block content %}{% endblock %} 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
 2 | 
 3 |          dP                d8888b.                            
 4 |          88                    `88                            
 5 | .d8888b. 88d888b. 88d888b. .aaadP' .d8888b. dP   .dP .d8888b. 
 6 | Y8ooooo. 88'  `88 88'  `88 88'     Y8ooooo. 88   d8' 88'  `88 
 7 |       88 88    88 88.  .88 88.           88 88 .88'  88.  .88 
 8 | `88888P' dP    dP 88Y888P' Y88888P `88888P' 8888P'   `8888P88 
 9 |                   88                                      .88 
10 |                   dP                                  d8888P  
11 | 
12 | 
13 | 14 | django-shp2svg 15 | ============== 16 | 17 | For more information check out our post on The Times' Data Desk blog: [Introducing shp2svg](http://datadesk.latimes.com/posts/2012/12/introducing-shp2svg/) 18 | 19 | Convert a shapefile into an SVG you can use with JavaScript drawing libraries. 20 | 21 | Features 22 | -------- 23 | 24 | * Convert GIS shapefiles to SVG paths at any size 25 | * Get the SVG as JSON or an SVG file editable in Adobe Illustrator 26 | * Use any PostGIS supported projection 27 | * Calculate the centroids for each shape, useable in a proportional symbol map 28 | 29 | Setup 30 | ----- 31 | 32 | Make sure to have your computer [configured for GeoDjango](https://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/). We also suggest using PostgreSQL with a [spatial database template](https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/postgis/#spatialdb-template). 33 | 34 | If you go that route, you can set up a database using: 35 | 36 | $ createdb -T template_postgis shp2svg 37 | 38 | Then, create a virtualenv to store the codebase: 39 | 40 | $ virtualenv --no-site-packages shp2svg 41 | 42 | Clone down the repo: 43 | 44 | $ cd shp2svg 45 | $ git clone git@github.com:datadesk/django-shp2svg.git project 46 | 47 | And install the requirements: 48 | 49 | $ . bin/activate 50 | $ cd project 51 | $ pip install -r requirements.txt 52 | 53 | Sync up the database (we're using South, though you're welcome to drop it locally) and create the cache table: 54 | 55 | $ python manage.py syncdb 56 | $ python manage.py migrate shp2svg 57 | $ python manage.py createcachetable my_cache_table 58 | 59 | Finally, update your settings.py file with your database name and local settings. Start the local server: 60 | 61 | $ fab rs 62 | 63 | You're good to go! Check out [http://localhost:8000](http://localhost:8000). -------------------------------------------------------------------------------- /fabfile.py: -------------------------------------------------------------------------------- 1 | from __future__ import with_statement 2 | from fabric.api import * 3 | import os 4 | import random 5 | 6 | 7 | def rmpyc(): 8 | """ 9 | Erases pyc files from current directory. 10 | 11 | Example usage: 12 | 13 | $ fab rmpyc 14 | 15 | """ 16 | print("Removing .pyc files") 17 | with hide('everything'): 18 | local("find . -name '*.pyc' -print0|xargs -0 rm", capture=False) 19 | 20 | 21 | def rs(port=8000): 22 | """ 23 | Fire up the Django test server, after cleaning out any .pyc files. 24 | 25 | Example usage: 26 | 27 | $ fab rs 28 | $ fab rs:port=9000 29 | 30 | """ 31 | with settings(warn_only=True): 32 | rmpyc() 33 | local("python manage.py runserver 0.0.0.0:%s" % port, capture=False) 34 | 35 | 36 | def sh(): 37 | """ 38 | Fire up the Django shell, after cleaning out any .pyc files. 39 | 40 | Example usage: 41 | 42 | $ fab sh 43 | 44 | """ 45 | rmpyc() 46 | local("python manage.py shell", capture=False) 47 | 48 | 49 | def makesecret( 50 | length=50, 51 | allowed_chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' 52 | ): 53 | """ 54 | Generates secret key for use in Django settings. 55 | """ 56 | key = ''.join(random.choice(allowed_chars) for i in range(length)) 57 | print 'SECRET_KEY = "%s"' % key 58 | 59 | 60 | def load(): 61 | """ 62 | Prints the current load values. 63 | 64 | Example usage: 65 | 66 | $ fab stage load 67 | $ fab prod load 68 | 69 | """ 70 | def _set_color(load): 71 | """ 72 | Sets the terminal color for an load average value depending on how 73 | high it is. 74 | 75 | Accepts a string formatted floating point. 76 | 77 | Returns a formatted string you can print. 78 | """ 79 | value = float(load) 80 | template = "\033[1m\x1b[%sm%s\x1b[0m\033[0m" 81 | if value < 1: 82 | # Return green 83 | return template % (32, value) 84 | elif value < 3: 85 | # Return yellow 86 | return template % (33, value) 87 | else: 88 | # Return red 89 | return template % (31, value) 90 | 91 | with hide('everything'): 92 | # Fetch the data 93 | uptime = run("uptime") 94 | # Whittle it down to only the load averages 95 | load = uptime.split(":")[-1] 96 | # Split up the load averages and apply a color code to each depending 97 | # on how high it is. 98 | one, five, fifteen = [_set_color(i.strip()) for i in load.split(',')] 99 | # Get the name of the host that is currently being tested 100 | host = env['host'] 101 | # Combine the two things and print out the results 102 | output = u'%s: %s' % (host, ", ".join([one, five, fifteen])) 103 | print(output) 104 | 105 | -------------------------------------------------------------------------------- /shp2svg/models.py: -------------------------------------------------------------------------------- 1 | import os 2 | import math 3 | import subprocess 4 | from django.conf import settings 5 | from django.contrib.gis.db import models 6 | 7 | 8 | def get_dbf_path(instance, filename): 9 | return os.path.join('shapes', instance.slug, instance.slug + '.dbf') 10 | 11 | def get_prj_path(instance, filename): 12 | return os.path.join('shapes', instance.slug, instance.slug + '.prj') 13 | 14 | def get_shp_path(instance, filename): 15 | return os.path.join('shapes', instance.slug, instance.slug + '.shp') 16 | 17 | def get_shx_path(instance, filename): 18 | return os.path.join('shapes', instance.slug, instance.slug + '.shx') 19 | 20 | 21 | class ShapefileContainer(models.Model): 22 | """ 23 | A model for grouping multiple shapes. Allows 24 | you to group U.S. States, for example, then export them as 25 | a Dict of SVG paths with the same projection. 26 | """ 27 | name = models.CharField(max_length=500) 28 | source = models.CharField(max_length=500, blank=True) 29 | slug = models.CharField(max_length=500, unique=True) 30 | dbf = models.FileField(upload_to=get_dbf_path, max_length=500) 31 | prj = models.FileField(upload_to=get_prj_path, max_length=500) 32 | shp = models.FileField(upload_to=get_shp_path, max_length=500) 33 | shx = models.FileField(upload_to=get_shx_path, max_length=500) 34 | objects = models.GeoManager() 35 | 36 | def __unicode__(self): 37 | return self.name 38 | 39 | def get_shapefile_folder(self): 40 | """ 41 | returns the path to the folder containing the shapefile 42 | """ 43 | return os.path.join(settings.ROOT_PATH, 'media', 'shapes', self.slug) 44 | 45 | def get_projected_shapes(self, srid): 46 | """ 47 | Returns a projected geoqueryset of all of the Shape objects 48 | in the collection 49 | """ 50 | return self.shape_set.all().transform(srid) 51 | 52 | def get_absolute_url(self): 53 | return '/%s/' % self.slug 54 | 55 | def delete(self, *args, **kwargs): 56 | """ 57 | A custom delete method that also kills the associated files 58 | """ 59 | # kill off the files individually 60 | self.dbf.delete() 61 | self.prj.delete() 62 | self.shp.delete() 63 | self.shx.delete() 64 | # get rid of the directory 65 | path = self.get_shapefile_folder() 66 | subprocess.call(['rm', '-rf', path]) 67 | # and kill off the object 68 | super(ShapefileContainer, self).delete(*args, **kwargs) 69 | 70 | 71 | class Shape(models.Model): 72 | """ 73 | An individual MultiPolygon 74 | """ 75 | poly = models.MultiPolygonField() 76 | # Will store the attributes here as JSON 77 | attributes = models.TextField(blank=True, null=True) 78 | shapefile = models.ForeignKey("ShapefileContainer", null=True, blank=True) 79 | objects = models.GeoManager() 80 | 81 | def get_extracted_coords(self): 82 | """ 83 | Extracts the nested multigeometry coordinates into a nicer list 84 | """ 85 | coords = self.poly.coords 86 | geom_list = [] 87 | for i in coords: 88 | for coord in i: 89 | geom_list.append(list(coord)) 90 | return geom_list -------------------------------------------------------------------------------- /shp2svg/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import datetime 3 | from south.db import db 4 | from south.v2 import SchemaMigration 5 | from django.db import models 6 | 7 | 8 | class Migration(SchemaMigration): 9 | 10 | def forwards(self, orm): 11 | # Adding model 'ShapefileContainer' 12 | db.create_table('shp2svg_shapefilecontainer', ( 13 | ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), 14 | ('name', self.gf('django.db.models.fields.CharField')(max_length=500)), 15 | ('source', self.gf('django.db.models.fields.CharField')(max_length=500, blank=True)), 16 | ('slug', self.gf('django.db.models.fields.CharField')(unique=True, max_length=500)), 17 | ('dbf', self.gf('django.db.models.fields.files.FileField')(max_length=500)), 18 | ('prj', self.gf('django.db.models.fields.files.FileField')(max_length=500)), 19 | ('shp', self.gf('django.db.models.fields.files.FileField')(max_length=500)), 20 | ('shx', self.gf('django.db.models.fields.files.FileField')(max_length=500)), 21 | )) 22 | db.send_create_signal('shp2svg', ['ShapefileContainer']) 23 | 24 | # Adding model 'Shape' 25 | db.create_table('shp2svg_shape', ( 26 | ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), 27 | ('poly', self.gf('django.contrib.gis.db.models.fields.MultiPolygonField')()), 28 | ('attributes', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), 29 | ('shapefile', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['shp2svg.ShapefileContainer'], null=True, blank=True)), 30 | )) 31 | db.send_create_signal('shp2svg', ['Shape']) 32 | 33 | 34 | def backwards(self, orm): 35 | # Deleting model 'ShapefileContainer' 36 | db.delete_table('shp2svg_shapefilecontainer') 37 | 38 | # Deleting model 'Shape' 39 | db.delete_table('shp2svg_shape') 40 | 41 | 42 | models = { 43 | 'shp2svg.shape': { 44 | 'Meta': {'object_name': 'Shape'}, 45 | 'attributes': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), 46 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 47 | 'poly': ('django.contrib.gis.db.models.fields.MultiPolygonField', [], {}), 48 | 'shapefile': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['shp2svg.ShapefileContainer']", 'null': 'True', 'blank': 'True'}) 49 | }, 50 | 'shp2svg.shapefilecontainer': { 51 | 'Meta': {'object_name': 'ShapefileContainer'}, 52 | 'dbf': ('django.db.models.fields.files.FileField', [], {'max_length': '500'}), 53 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 54 | 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'}), 55 | 'prj': ('django.db.models.fields.files.FileField', [], {'max_length': '500'}), 56 | 'shp': ('django.db.models.fields.files.FileField', [], {'max_length': '500'}), 57 | 'shx': ('django.db.models.fields.files.FileField', [], {'max_length': '500'}), 58 | 'slug': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '500'}), 59 | 'source': ('django.db.models.fields.CharField', [], {'max_length': '500', 'blank': 'True'}) 60 | } 61 | } 62 | 63 | complete_apps = ['shp2svg'] -------------------------------------------------------------------------------- /project/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | ROOT_PATH = os.path.split(os.path.dirname(__file__))[0] 3 | 4 | DEBUG = True 5 | TEMPLATE_DEBUG = DEBUG 6 | 7 | # Fill in your admins here 8 | ADMINS = ( 9 | # ('Sample Admin', 'admin@example.com'), 10 | ) 11 | 12 | MANAGERS = ADMINS 13 | 14 | DATABASES = { 15 | 'default': { 16 | 'ENGINE': 'django.contrib.gis.db.backends.postgis', 17 | 'NAME': 'shp2svg', 18 | 'USER': 'postgres', 19 | 'PASSWORD': 'postgres', 20 | 'HOST': 'localhost', 21 | 'PORT': '5432', 22 | } 23 | } 24 | 25 | CACHES = { 26 | 'default': { 27 | 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', 28 | 'LOCATION': 'my_cache_table', 29 | # 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', 30 | } 31 | } 32 | 33 | TIME_ZONE = 'America/Los_Angeles' 34 | LANGUAGE_CODE = 'en-us' 35 | 36 | SITE_ID = 1 37 | USE_I18N = True 38 | USE_L10N = True 39 | USE_TZ = True 40 | 41 | MEDIA_ROOT = os.path.join(ROOT_PATH, 'media') 42 | MEDIA_URL = '/media/' 43 | STATIC_ROOT = os.path.join(ROOT_PATH, 'static') 44 | ADMIN_MEDIA_PREFIX = '/static/admin/' 45 | STATICFILES_DIRS = ( 46 | os.path.join(ROOT_PATH, 'templates', 'static'), 47 | ) 48 | 49 | STATIC_URL = '/static/' 50 | STATICFILES_FINDERS = ( 51 | 'django.contrib.staticfiles.finders.FileSystemFinder', 52 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 53 | ) 54 | 55 | # Make this unique, and don't share it with anybody. 56 | SECRET_KEY = '' 57 | 58 | # List of callables that know how to import templates from various sources. 59 | TEMPLATE_LOADERS = ( 60 | 'django.template.loaders.filesystem.Loader', 61 | 'django.template.loaders.app_directories.Loader', 62 | ) 63 | 64 | MIDDLEWARE_CLASSES = ( 65 | 'django.middleware.gzip.GZipMiddleware', 66 | 'django.middleware.cache.UpdateCacheMiddleware', 67 | 'django.middleware.common.CommonMiddleware', 68 | 'django.contrib.sessions.middleware.SessionMiddleware', 69 | 'django.middleware.csrf.CsrfViewMiddleware', 70 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 71 | 'django.contrib.messages.middleware.MessageMiddleware', 72 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 73 | 'django.middleware.cache.FetchFromCacheMiddleware', 74 | ) 75 | 76 | CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True 77 | 78 | ROOT_URLCONF = 'project.urls' 79 | WSGI_APPLICATION = 'project.wsgi.application' 80 | TEMPLATE_DIRS = ( 81 | os.path.join(ROOT_PATH, 'templates'), 82 | ) 83 | 84 | INSTALLED_APPS = ( 85 | 'django.contrib.auth', 86 | 'django.contrib.contenttypes', 87 | 'django.contrib.sessions', 88 | 'django.contrib.sites', 89 | 'django.contrib.messages', 90 | 'django.contrib.staticfiles', 91 | 'django.contrib.sitemaps', 92 | 'django.contrib.gis', 93 | 'django.contrib.admin', 94 | 'shp2svg', 95 | 'south', 96 | ) 97 | 98 | LOGGING = { 99 | 'version': 1, 100 | 'disable_existing_loggers': False, 101 | 'filters': { 102 | 'require_debug_false': { 103 | '()': 'django.utils.log.RequireDebugFalse' 104 | } 105 | }, 106 | 'handlers': { 107 | 'mail_admins': { 108 | 'level': 'ERROR', 109 | 'filters': ['require_debug_false'], 110 | 'class': 'django.utils.log.AdminEmailHandler' 111 | } 112 | }, 113 | 'loggers': { 114 | 'django.request': { 115 | 'handlers': ['mail_admins'], 116 | 'level': 'ERROR', 117 | 'propagate': True, 118 | }, 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /templates/setup_form.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 | 6 |

First, choose which attribute field you want to use to name your paths. Then, choose a size and projection for the output. If you need more information about shapefiles, Wikipedia has a great entry you should check out. For help choosing an appropriate SRID you can start at spatialreference.org or the Wikipedia entry on map projections.

7 | 8 |
9 | 10 |
11 | 18 |
19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 |
27 |
28 | 29 |
30 | 33 |
34 |
35 |
36 | 37 |
38 |
39 | X 40 |
41 |
42 | Y 43 |
44 |
45 |
46 |
47 |
48 | 51 |
52 |
53 |
54 | 55 | 58 |
59 |
-------------------------------------------------------------------------------- /templates/shapefilecontainer_detail.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block extra-css %} 4 | 7 | {% endblock %} 8 | 9 | {% block extra-js %} 10 | 11 | 12 | {% endblock %} 13 | 14 | {% block content %} 15 |
16 | {% include 'header.html' %} 17 | 18 |

{{ name }}

19 | {% if source %} 20 |

Source: {{ source }}

21 | {% endif %} 22 | 23 |
24 |
25 |
26 |
1
27 |
28 |
29 |

Choose your options

30 | {% include 'setup_form.html' %} 31 |
32 |
33 |
34 | 35 |
36 |
37 |
38 |
2
39 |
40 |
41 |

Preview your shapes

42 |
43 |
44 |
45 |
46 | 47 |
48 |
49 |
50 |
3
51 |
52 |
53 |

Get the paths

54 | 55 | Download SVG 56 |
57 |
58 |
59 |
60 |
61 |

Warning

62 | 63 |
64 |
65 |
66 | 67 | 148 | {% endblock %} 149 | -------------------------------------------------------------------------------- /templates/static/js/underscore-min.js: -------------------------------------------------------------------------------- 1 | (function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,j=i.bind,w=function(n){return n instanceof w?n:this instanceof w?(this._wrapped=n,void 0):new w(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=w),exports._=w):n._=w,w.VERSION="1.4.3";var A=w.each=w.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(w.has(n,a)&&t.call(e,n[a],a,n)===r)return};w.map=w.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e[e.length]=t.call(r,n,u,i)}),e)};var O="Reduce of empty array with no initial value";w.reduce=w.foldl=w.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=w.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},w.reduceRight=w.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=w.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=w.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},w.find=w.detect=function(n,t,r){var e;return E(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},w.filter=w.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&(e[e.length]=n)}),e)},w.reject=function(n,t,r){return w.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},w.every=w.all=function(n,t,e){t||(t=w.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var E=w.some=w.any=function(n,t,e){t||(t=w.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};w.contains=w.include=function(n,t){return null==n?!1:y&&n.indexOf===y?-1!=n.indexOf(t):E(n,function(n){return n===t})},w.invoke=function(n,t){var r=o.call(arguments,2);return w.map(n,function(n){return(w.isFunction(t)?t:n[t]).apply(n,r)})},w.pluck=function(n,t){return w.map(n,function(n){return n[t]})},w.where=function(n,t){return w.isEmpty(t)?[]:w.filter(n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},w.max=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.max.apply(Math,n);if(!t&&w.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>=e.computed&&(e={value:n,computed:a})}),e.value},w.min=function(n,t,r){if(!t&&w.isArray(n)&&n[0]===+n[0]&&65535>n.length)return Math.min.apply(Math,n);if(!t&&w.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;e.computed>a&&(e={value:n,computed:a})}),e.value},w.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=w.random(r++),e[r-1]=e[t],e[t]=n}),e};var F=function(n){return w.isFunction(n)?n:function(t){return t[n]}};w.sortBy=function(n,t,r){var e=F(t);return w.pluck(w.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||void 0===r)return 1;if(e>r||void 0===e)return-1}return n.indexi;){var o=i+a>>>1;u>r.call(e,n[o])?i=o+1:a=o}return i},w.toArray=function(n){return n?w.isArray(n)?o.call(n):n.length===+n.length?w.map(n,w.identity):w.values(n):[]},w.size=function(n){return null==n?0:n.length===+n.length?n.length:w.keys(n).length},w.first=w.head=w.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},w.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},w.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},w.rest=w.tail=w.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},w.compact=function(n){return w.filter(n,w.identity)};var R=function(n,t,r){return A(n,function(n){w.isArray(n)?t?a.apply(r,n):R(n,t,r):r.push(n)}),r};w.flatten=function(n,t){return R(n,t,[])},w.without=function(n){return w.difference(n,o.call(arguments,1))},w.uniq=w.unique=function(n,t,r,e){w.isFunction(t)&&(e=r,r=t,t=!1);var u=r?w.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:w.contains(a,r))||(a.push(r),i.push(n[e]))}),i},w.union=function(){return w.uniq(c.apply(e,arguments))},w.intersection=function(n){var t=o.call(arguments,1);return w.filter(w.uniq(n),function(n){return w.every(t,function(t){return w.indexOf(t,n)>=0})})},w.difference=function(n){var t=c.apply(e,o.call(arguments,1));return w.filter(n,function(n){return!w.contains(t,n)})},w.zip=function(){for(var n=o.call(arguments),t=w.max(w.pluck(n,"length")),r=Array(t),e=0;t>e;e++)r[e]=w.pluck(n,""+e);return r},w.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},w.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=w.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},w.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},w.range=function(n,t,r){1>=arguments.length&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=Array(e);e>u;)i[u++]=n,n+=r;return i};var I=function(){};w.bind=function(n,t){var r,e;if(n.bind===j&&j)return j.apply(n,o.call(arguments,1));if(!w.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));I.prototype=n.prototype;var u=new I;I.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},w.bindAll=function(n){var t=o.call(arguments,1);return 0==t.length&&(t=w.functions(n)),A(t,function(t){n[t]=w.bind(n[t],n)}),n},w.memoize=function(n,t){var r={};return t||(t=w.identity),function(){var e=t.apply(this,arguments);return w.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},w.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},w.defer=function(n){return w.delay.apply(w,[n,1].concat(o.call(arguments,1)))},w.throttle=function(n,t){var r,e,u,i,a=0,o=function(){a=new Date,u=null,i=n.apply(r,e)};return function(){var c=new Date,l=t-(c-a);return r=this,e=arguments,0>=l?(clearTimeout(u),u=null,a=c,i=n.apply(r,e)):u||(u=setTimeout(o,l)),i}},w.debounce=function(n,t,r){var e,u;return function(){var i=this,a=arguments,o=function(){e=null,r||(u=n.apply(i,a))},c=r&&!e;return clearTimeout(e),e=setTimeout(o,t),c&&(u=n.apply(i,a)),u}},w.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},w.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},w.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},w.after=function(n,t){return 0>=n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},w.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)w.has(n,r)&&(t[t.length]=r);return t},w.values=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push(n[r]);return t},w.pairs=function(n){var t=[];for(var r in n)w.has(n,r)&&t.push([r,n[r]]);return t},w.invert=function(n){var t={};for(var r in n)w.has(n,r)&&(t[n[r]]=r);return t},w.functions=w.methods=function(n){var t=[];for(var r in n)w.isFunction(n[r])&&t.push(r);return t.sort()},w.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},w.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},w.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)w.contains(r,u)||(t[u]=n[u]);return t},w.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)null==n[r]&&(n[r]=t[r])}),n},w.clone=function(n){return w.isObject(n)?w.isArray(n)?n.slice():w.extend({},n):n},w.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof w&&(n=n._wrapped),t instanceof w&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==t+"";case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;r.push(n),e.push(t);var a=0,o=!0;if("[object Array]"==u){if(a=n.length,o=a==t.length)for(;a--&&(o=S(n[a],t[a],r,e)););}else{var c=n.constructor,f=t.constructor;if(c!==f&&!(w.isFunction(c)&&c instanceof c&&w.isFunction(f)&&f instanceof f))return!1;for(var s in n)if(w.has(n,s)&&(a++,!(o=w.has(t,s)&&S(n[s],t[s],r,e))))break;if(o){for(s in t)if(w.has(t,s)&&!a--)break;o=!a}}return r.pop(),e.pop(),o};w.isEqual=function(n,t){return S(n,t,[],[])},w.isEmpty=function(n){if(null==n)return!0;if(w.isArray(n)||w.isString(n))return 0===n.length;for(var t in n)if(w.has(n,t))return!1;return!0},w.isElement=function(n){return!(!n||1!==n.nodeType)},w.isArray=x||function(n){return"[object Array]"==l.call(n)},w.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){w["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),w.isArguments(arguments)||(w.isArguments=function(n){return!(!n||!w.has(n,"callee"))}),w.isFunction=function(n){return"function"==typeof n},w.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},w.isNaN=function(n){return w.isNumber(n)&&n!=+n},w.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},w.isNull=function(n){return null===n},w.isUndefined=function(n){return void 0===n},w.has=function(n,t){return f.call(n,t)},w.noConflict=function(){return n._=t,this},w.identity=function(n){return n},w.times=function(n,t,r){for(var e=Array(n),u=0;n>u;u++)e[u]=t.call(r,u);return e},w.random=function(n,t){return null==t&&(t=n,n=0),n+(0|Math.random()*(t-n+1))};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};T.unescape=w.invert(T.escape);var M={escape:RegExp("["+w.keys(T.escape).join("")+"]","g"),unescape:RegExp("("+w.keys(T.unescape).join("|")+")","g")};w.each(["escape","unescape"],function(n){w[n]=function(t){return null==t?"":(""+t).replace(M[n],function(t){return T[n][t]})}}),w.result=function(n,t){if(null==n)return null;var r=n[t];return w.isFunction(r)?r.call(n):r},w.mixin=function(n){A(w.functions(n),function(t){var r=w[t]=n[t];w.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(w,n))}})};var N=0;w.uniqueId=function(n){var t=""+ ++N;return n?n+t:t},w.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;w.template=function(n,t,r){r=w.defaults({},r,w.templateSettings);var e=RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,a,o){return i+=n.slice(u,o).replace(D,function(n){return"\\"+B[n]}),r&&(i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(i+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),a&&(i+="';\n"+a+"\n__p+='"),u=o+t.length,t}),i+="';\n",r.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var a=Function(r.variable||"obj","_",i)}catch(o){throw o.source=i,o}if(t)return a(t,w);var c=function(n){return a.call(this,n,w)};return c.source="function("+(r.variable||"obj")+"){\n"+i+"}",c},w.chain=function(n){return w(n).chain()};var z=function(n){return this._chain?w(n).chain():n};w.mixin(w),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];w.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];w.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),w.extend(w.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | 3 | {% block extra-css %} 4 | 7 | {% endblock %} 8 | 9 | {% block extra-js %} 10 | 15 | {% endblock %} 16 | 17 | {% block content %} 18 |
19 | {% include 'header.html' %} 20 | 21 | {% if shapefiles %} 22 |
23 |

Choose a shapefile from the database

24 |
25 | {% for i in shapefiles %} 26 | 31 | {% endfor %} 32 |
33 |

Or, upload your own:

34 |
35 | {% endif %} 36 |
37 |
38 |
39 |
1
40 |
41 |
42 |

Upload your shapefile

43 | 44 |
45 | {% csrf_token %} 46 | 47 |

Shapefiles come in four parts. Make sure to include the .dbf, .prj, .shp and .shx files. If you need help finding a shapefile Natural Earth and the US Census Bureau are great places to start. To preview or edit a shapefile you need to install GIS software like Quantum GIS or use a web-based solution like MapShaper.

48 | 49 |

Note: Currently shp2svg only supports the conversion of polygons and multipolygons.

50 | 51 |
52 | 53 |
54 | 55 |
56 |
57 |
58 | 59 |
60 | 61 |
62 |
63 |
64 | 65 |
66 | 67 |
68 |
69 |
70 | 71 |
72 | 73 |
74 |
75 |
76 | 77 |
78 | 79 |
80 |
81 |
82 | 83 |
84 | 85 |
86 |
87 | 88 | 89 |
90 |
91 |
— OR —
92 |
93 |
94 | 95 |
96 | 97 |
98 | 99 |
100 |
101 | 102 | 103 |
104 | 105 |
106 |
107 | 110 |
111 |
112 |
113 | 114 |
115 |
116 |
117 |
2
118 |
119 |
120 |

Choose your options

121 | {% include 'setup_form.html' %} 122 |
123 |
124 |
125 | 126 |
127 |
128 |
129 |
3
130 |
131 |
132 |

Preview your SVG

133 |
134 |
135 |
136 |
137 | 138 |
139 |
140 |
141 |
4
142 |
143 |
144 |

Get the paths

145 | 146 | Download SVG 147 |
148 |
149 |
150 |
151 |
152 |

Warning

153 | 154 |
155 |
156 |
157 | 158 | 346 | {% endblock %} 347 | -------------------------------------------------------------------------------- /shp2svg/views.py: -------------------------------------------------------------------------------- 1 | import math 2 | import base64 3 | import zipfile 4 | from zipfile import ZipFile 5 | from django.conf import settings 6 | from django.core.cache import cache 7 | from django.shortcuts import render 8 | from django.shortcuts import redirect 9 | from django.contrib.gis.gdal import * 10 | from django.template import RequestContext 11 | from django.views.generic.base import View 12 | from django.contrib.sitemaps import Sitemap 13 | from django.utils import simplejson as json 14 | from django.core.urlresolvers import reverse 15 | from django.core.files.base import ContentFile 16 | from django.template.loader import get_template 17 | from django.template.defaultfilters import slugify 18 | from shp2svg.models import Shape, ShapefileContainer 19 | from django.contrib.gis.geos import MultiPolygon, Polygon 20 | from django.http import Http404, HttpResponse, HttpResponseBadRequest 21 | 22 | # 23 | # Sitemaps 24 | # 25 | 26 | class ShapefileContainerSitemap(Sitemap): 27 | changefreq = "daily" 28 | 29 | def items(self): 30 | return ShapefileContainer.objects.all() 31 | 32 | 33 | class Sitemap(Sitemap): 34 | def __init__(self, names): 35 | self.names = names 36 | 37 | def items(self): 38 | return self.names 39 | 40 | def changefreq(self, obj): 41 | return 'daily' 42 | 43 | def location(self, obj): 44 | return reverse(obj) 45 | 46 | # 47 | # Content 48 | # 49 | 50 | def index(request): 51 | context = { 52 | 'shapefiles': ShapefileContainer.objects.all() 53 | } 54 | return render(request, 'index.html', context) 55 | 56 | def shapefile_detail(request, slug): 57 | try: 58 | shapefile = ShapefileContainer.objects.get(slug=slug) 59 | except ShapefileContainer.DoesNotExist: 60 | raise Http404 61 | 62 | ds = DataSource(shapefile.shp.path) 63 | layer = ds[0] 64 | context = { 65 | 'name': shapefile.name, 66 | 'slug': shapefile.slug, 67 | 'fields': layer.fields, 68 | 'source': shapefile.source, 69 | } 70 | return render(request, 'shapefilecontainer_detail.html', context) 71 | 72 | def upload_shapefile(request): 73 | if request.method == 'POST': 74 | name = request.POST.get('name') 75 | # Check to see if we already have an object with that name 76 | try: 77 | ShapefileContainer.objects.get(slug=slugify(name)) 78 | return HttpResponseBadRequest("The name you chose is already taken.") 79 | except ShapefileContainer.DoesNotExist: 80 | pass 81 | 82 | # Do we have a zip file? 83 | z = request.FILES.get('zipfile', False) 84 | if z: 85 | if not zipfile.is_zipfile(z): 86 | return HttpResponseBadRequest("You have uploaded an invalid zip file.") 87 | zipped = ZipFile(z) 88 | filenames = [i.filename for i in zipped.filelist] 89 | dbf, prj, shp, shx = False, False, False, False 90 | for i in filenames: 91 | if '.dbf' in i.lower()[-4:]: 92 | dbf = ContentFile(zipped.read(i)) 93 | elif '.prj' in i.lower()[-4:]: 94 | prj = ContentFile(zipped.read(i)) 95 | elif '.shp' in i.lower()[-4:]: 96 | shp = ContentFile(zipped.read(i)) 97 | elif '.shx' in i.lower()[-4:]: 98 | shx = ContentFile(zipped.read(i)) 99 | # make our new container object 100 | if dbf and prj and shp and shx: 101 | new_shapefile = ShapefileContainer.objects.create( 102 | name=name, 103 | slug=slugify(name), 104 | ) 105 | new_shapefile.dbf.save('dbf', dbf) 106 | new_shapefile.prj.save('prj', prj) 107 | new_shapefile.shp.save('shp', shp) 108 | new_shapefile.shx.save('shx', shx) 109 | else: 110 | return HttpResponseBadRequest("Your zip file must contain a .dbf, a .prj, a .shp and a .shx file.") 111 | else: 112 | # Make the new shape container from the individually uploaded files 113 | new_shapefile = ShapefileContainer.objects.create( 114 | name=name, 115 | slug=slugify(name), 116 | dbf=request.FILES.get('dbf'), 117 | prj=request.FILES.get('prj'), 118 | shp=request.FILES.get('shp'), 119 | shx=request.FILES.get('shx'), 120 | ) 121 | source = request.POST.get('source', False) 122 | if source: 123 | new_shapefile.source = source 124 | new_shapefile.save() 125 | # See if we can import the shapefile. 126 | try: 127 | ds = DataSource(new_shapefile.shp.path) 128 | except: 129 | new_shapefile.delete() 130 | return HttpResponseBadRequest("There was a problem processing your shapefile.") 131 | 132 | layer = ds[0] 133 | attribute_fields = layer.fields 134 | for feature in layer: 135 | if feature.geom.geom_type in ['Polygon', 'MultiPolygon']: 136 | # Grab a dict of all the attributes 137 | attribute_dict = dict( (attr, str(feature[attr].value).decode('latin-1')) for attr in attribute_fields ) 138 | # convert to multipolygon if necessary 139 | if feature.geom.geom_type == 'Polygon': 140 | mp = MultiPolygon(feature.geom.geos) 141 | else: 142 | mp = feature.geom.geos 143 | # load in the shape 144 | try: 145 | shape = Shape.objects.create( 146 | poly = mp, 147 | attributes = json.dumps(attribute_dict), 148 | shapefile = new_shapefile, 149 | ) 150 | except: 151 | return HttpResponseBadRequest("There was a problem processing your shapefile.") 152 | else: 153 | continue 154 | 155 | data = { 156 | 'name': new_shapefile.name, 157 | 'slug': new_shapefile.slug, 158 | 'fields': attribute_fields, 159 | } 160 | return HttpResponse(json.dumps(data), content_type='text/html') 161 | 162 | 163 | class SVGResponseMixin(object): 164 | """ 165 | A mixin that can be used to render an SVG response. 166 | """ 167 | def render_to_response(self, context, **response_kwargs): 168 | """ 169 | Returns a CSV file response, transforming 'context' to make the payload. 170 | """ 171 | template = get_template('svg.html') 172 | context = RequestContext(self.request, context) 173 | svg = template.render(context) 174 | response = HttpResponse(svg, mimetype='image/svg+xml') 175 | response['Content-Disposition'] = 'attachment; filename=shp2svg.svg' 176 | return response 177 | 178 | 179 | class JSONResponseMixin(object): 180 | """ 181 | A mixin for rendering a JSON as an AJAX response. Where the 'JSON' is actually 182 | sent as a text/html mimetype to avoid an awkward bug in IE. 183 | """ 184 | def render_to_response(self, context, **response_kwargs): 185 | return HttpResponse(json.dumps(context), content_type='text/html') 186 | 187 | 188 | class GenerateSVG(SVGResponseMixin, JSONResponseMixin, View): 189 | 190 | def translate_coords(self, coord_list, extent): 191 | """ 192 | Takes a list of coordinates and translates them to [0, 0] 193 | """ 194 | x_min = extent[0] 195 | y_min = extent[1] 196 | y_translated_max = abs(extent[3] - extent[1]) 197 | translated_coords = [] 198 | for i in coord_list: 199 | new_coords = (i[0] - x_min, y_translated_max - (i[1] - y_min)) 200 | translated_coords.append(new_coords) 201 | return translated_coords 202 | 203 | def coords_2_path(self, coord_list): 204 | """ 205 | Takes a list of coordinates and returns an SVG path 206 | """ 207 | if len(coord_list) == 1: 208 | path = 'M%s,%sZ' % (coord_list[0][0], coord_list[0][1]) 209 | else: 210 | path = 'M%s,%s' % (coord_list[0][0], coord_list[0][1]) 211 | for i in coord_list[1:]: 212 | path += 'L%s,%s' % (i[0], i[1]) 213 | path += 'Z' 214 | return path.replace('-0.0', '0').replace('0.0', '0').replace('.0', '') 215 | 216 | def get_cache_key(self, obj, srid): 217 | """ 218 | Create a unique cache key for the projected geoqueryset 219 | using the object slug and SRID 220 | """ 221 | id_string = '&'.join([obj.slug, str(srid)]) 222 | obj_hash = base64.b64encode(id_string) 223 | return 'shp2svg:queryset|%s' % obj_hash 224 | 225 | def get(self, request, *args, **kwargs): 226 | self.format = self.request.GET.get('format', 'json') 227 | slug = self.request.GET.get('slug') 228 | try: 229 | shapefile = ShapefileContainer.objects.get(slug=slug) 230 | except ShapefileContainer.DoesNotExist: 231 | raise Http404 232 | 233 | translate = [0, 0] 234 | # some validation on the user input 235 | invalid_int_response = HttpResponseBadRequest("Please enter a valid integer.") 236 | 237 | if self.request.GET.get('translate_x'): 238 | try: 239 | translate[0] = int(self.request.GET.get('translate_x')) 240 | except ValueError: 241 | return invalid_int_response 242 | 243 | if self.request.GET.get('translate_y'): 244 | try: 245 | translate[1] = int(self.request.GET.get('translate_y')) 246 | except ValueError: 247 | return invalid_int_response 248 | 249 | try: 250 | max_size = int(self.request.GET.get('max_size')) 251 | srid = int(self.request.GET.get('srid')) 252 | except ValueError: 253 | return invalid_int_response 254 | 255 | key = self.request.GET.get('key') 256 | centroid = self.request.GET.get('centroid', False) 257 | if centroid == 'on': 258 | centroid = True 259 | 260 | # get a projected geoqueryset 261 | cache_key = self.get_cache_key(shapefile, srid) 262 | projected_shapes = cache.get(cache_key, None) 263 | if not projected_shapes: 264 | projected_shapes = shapefile.get_projected_shapes(srid) 265 | cache.set(cache_key, projected_shapes) 266 | 267 | # get the projected extent of the geoqueryset 268 | x_coords = [] 269 | y_coords = [] 270 | # Wrap this in a try/except to return any errors we hit with the projection 271 | try: 272 | for i in projected_shapes: 273 | coords = i.poly.extent 274 | x_coords.append(coords[0]) 275 | x_coords.append(coords[2]) 276 | y_coords.append(coords[1]) 277 | y_coords.append(coords[3]) 278 | except: 279 | return HttpResponseBadRequest("There was a problem projecting your shapefile. Please try a different SRID.") 280 | 281 | extent = (min(x_coords), min(y_coords), max(x_coords), max(y_coords)) 282 | 283 | # get a constant to scale the coords to the provided max_size 284 | max_translated_x = abs(extent[2] - extent[0]) 285 | max_translated_y = abs(extent[3] - extent[1]) 286 | 287 | if max_translated_x > max_translated_y: 288 | scale_factor = max_size / max_translated_x 289 | else: 290 | scale_factor = max_size / max_translated_y 291 | 292 | # Determine our new max X and Y values 293 | max_coords = [int(math.ceil(max_translated_x * scale_factor)), int(math.ceil(max_translated_y * scale_factor))] 294 | 295 | # generate all the paths 296 | paths = {} 297 | for i in projected_shapes: 298 | # load in the attribute dict 299 | attrs = json.loads(i.attributes) 300 | k = attrs.get(key) 301 | # First grab the coordinates to play with 302 | coords = i.get_extracted_coords() 303 | # Loop through each set and translate them 304 | translated_coords = [] 305 | for c in coords: 306 | translated_coords.append(self.translate_coords(c, extent)) 307 | 308 | # Then loop through our translated coords and scale them 309 | scaled_coords = [] 310 | for t in translated_coords: 311 | scaled_list = [] 312 | for coord_set in t: 313 | scaled_set = (format(( coord_set[0] * scale_factor) + translate[0], '.1f'), format(( coord_set[1] * scale_factor) + translate[1], '.1f')) 314 | scaled_list.append(scaled_set) 315 | scaled_coords.append(scaled_list) 316 | 317 | # Now to grab a translated/scaled centroid for each shape 318 | if centroid: 319 | centroid = i.poly.centroid.coords 320 | translated_centroid = self.translate_coords([centroid], extent) 321 | translated_centroid = translated_centroid[0] 322 | scaled_centroid = [int(translated_centroid[0] * scale_factor) + translate[0], int(translated_centroid[1] * scale_factor) + translate[1]] 323 | 324 | path = '' 325 | for i in scaled_coords: 326 | path += self.coords_2_path(i) 327 | 328 | paths[k] = { 329 | 'path': path, 330 | 'centroid': scaled_centroid, 331 | } 332 | else: 333 | path = '' 334 | for i in scaled_coords: 335 | path += self.coords_2_path(i) 336 | 337 | paths[k] = path 338 | 339 | context = { 340 | 'paths': paths, 341 | 'url': self.request.get_full_path(), 342 | 'centroid': centroid, 343 | 'max_coords': [max_coords[0] + translate[0], max_coords[1] + translate[1]], 344 | } 345 | return self.render_to_response(context) 346 | 347 | def render_to_response(self, context, **response_kwargs): 348 | """ 349 | Figures out what type of response is necessary and pulls the trigger. 350 | """ 351 | if self.format == 'json': 352 | return JSONResponseMixin.render_to_response(self, context) 353 | elif self.format == 'svg': 354 | return SVGResponseMixin.render_to_response(self, context) 355 | else: 356 | return Http404 357 | 358 | -------------------------------------------------------------------------------- /templates/static/css/bootstrap-responsive.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Responsive v2.2.1 3 | * 4 | * Copyright 2012 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.564102564102564%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*margin-left:16.98763411529369%}.row-fluid .offset1{margin-left:11.11111111111111%;*margin-left:11.004728132387708%}.row-fluid .offset1:first-child{margin-left:8.547008547008547%;*margin-left:8.440625568285142%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:30px}input.span12,textarea.span12,.uneditable-input.span12{width:1156px}input.span11,textarea.span11,.uneditable-input.span11{width:1056px}input.span10,textarea.span10,.uneditable-input.span10{width:956px}input.span9,textarea.span9,.uneditable-input.span9{width:856px}input.span8,textarea.span8,.uneditable-input.span8{width:756px}input.span7,textarea.span7,.uneditable-input.span7{width:656px}input.span6,textarea.span6,.uneditable-input.span6{width:556px}input.span5,textarea.span5,.uneditable-input.span5{width:456px}input.span4,textarea.span4,.uneditable-input.span4{width:356px}input.span3,textarea.span3,.uneditable-input.span3{width:256px}input.span2,textarea.span2,.uneditable-input.span2{width:156px}input.span1,textarea.span1,.uneditable-input.span1{width:56px}.thumbnails{margin-left:-30px}.thumbnails>li{margin-left:30px}.row-fluid .thumbnails{margin-left:0}}@media(min-width:768px) and (max-width:979px){.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:724px}.span12{width:724px}.span11{width:662px}.span10{width:600px}.span9{width:538px}.span8{width:476px}.span7{width:414px}.span6{width:352px}.span5{width:290px}.span4{width:228px}.span3{width:166px}.span2{width:104px}.span1{width:42px}.offset12{margin-left:764px}.offset11{margin-left:702px}.offset10{margin-left:640px}.offset9{margin-left:578px}.offset8{margin-left:516px}.offset7{margin-left:454px}.offset6{margin-left:392px}.offset5{margin-left:330px}.offset4{margin-left:268px}.offset3{margin-left:206px}.offset2{margin-left:144px}.offset1{margin-left:82px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.7624309392265194%;*margin-left:2.709239449864817%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.7624309392265194%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.43646408839778%;*width:91.38327259903608%}.row-fluid .span10{width:82.87292817679558%;*width:82.81973668743387%}.row-fluid .span9{width:74.30939226519337%;*width:74.25620077583166%}.row-fluid .span8{width:65.74585635359117%;*width:65.69266486422946%}.row-fluid .span7{width:57.18232044198895%;*width:57.12912895262725%}.row-fluid .span6{width:48.61878453038674%;*width:48.56559304102504%}.row-fluid .span5{width:40.05524861878453%;*width:40.00205712942283%}.row-fluid .span4{width:31.491712707182323%;*width:31.43852121782062%}.row-fluid .span3{width:22.92817679558011%;*width:22.87498530621841%}.row-fluid .span2{width:14.3646408839779%;*width:14.311449394616199%}.row-fluid .span1{width:5.801104972375691%;*width:5.747913483013988%}.row-fluid .offset12{margin-left:105.52486187845304%;*margin-left:105.41847889972962%}.row-fluid .offset12:first-child{margin-left:102.76243093922652%;*margin-left:102.6560479605031%}.row-fluid .offset11{margin-left:96.96132596685082%;*margin-left:96.8549429881274%}.row-fluid .offset11:first-child{margin-left:94.1988950276243%;*margin-left:94.09251204890089%}.row-fluid .offset10{margin-left:88.39779005524862%;*margin-left:88.2914070765252%}.row-fluid .offset10:first-child{margin-left:85.6353591160221%;*margin-left:85.52897613729868%}.row-fluid .offset9{margin-left:79.8342541436464%;*margin-left:79.72787116492299%}.row-fluid .offset9:first-child{margin-left:77.07182320441989%;*margin-left:76.96544022569647%}.row-fluid .offset8{margin-left:71.2707182320442%;*margin-left:71.16433525332079%}.row-fluid .offset8:first-child{margin-left:68.50828729281768%;*margin-left:68.40190431409427%}.row-fluid .offset7{margin-left:62.70718232044199%;*margin-left:62.600799341718584%}.row-fluid .offset7:first-child{margin-left:59.94475138121547%;*margin-left:59.838368402492065%}.row-fluid .offset6{margin-left:54.14364640883978%;*margin-left:54.037263430116376%}.row-fluid .offset6:first-child{margin-left:51.38121546961326%;*margin-left:51.27483249088986%}.row-fluid .offset5{margin-left:45.58011049723757%;*margin-left:45.47372751851417%}.row-fluid .offset5:first-child{margin-left:42.81767955801105%;*margin-left:42.71129657928765%}.row-fluid .offset4{margin-left:37.01657458563536%;*margin-left:36.91019160691196%}.row-fluid .offset4:first-child{margin-left:34.25414364640884%;*margin-left:34.14776066768544%}.row-fluid .offset3{margin-left:28.45303867403315%;*margin-left:28.346655695309746%}.row-fluid .offset3:first-child{margin-left:25.69060773480663%;*margin-left:25.584224756083227%}.row-fluid .offset2{margin-left:19.88950276243094%;*margin-left:19.783119783707537%}.row-fluid .offset2:first-child{margin-left:17.12707182320442%;*margin-left:17.02068884448102%}.row-fluid .offset1{margin-left:11.32596685082873%;*margin-left:11.219583872105325%}.row-fluid .offset1:first-child{margin-left:8.56353591160221%;*margin-left:8.457152932878806%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:710px}input.span11,textarea.span11,.uneditable-input.span11{width:648px}input.span10,textarea.span10,.uneditable-input.span10{width:586px}input.span9,textarea.span9,.uneditable-input.span9{width:524px}input.span8,textarea.span8,.uneditable-input.span8{width:462px}input.span7,textarea.span7,.uneditable-input.span7{width:400px}input.span6,textarea.span6,.uneditable-input.span6{width:338px}input.span5,textarea.span5,.uneditable-input.span5{width:276px}input.span4,textarea.span4,.uneditable-input.span4{width:214px}input.span3,textarea.span3,.uneditable-input.span3{width:152px}input.span2,textarea.span2,.uneditable-input.span2{width:90px}input.span1,textarea.span1,.uneditable-input.span1{width:28px}}@media(max-width:767px){body{padding-right:20px;padding-left:20px}.navbar-fixed-top,.navbar-fixed-bottom,.navbar-static-top{margin-right:-20px;margin-left:-20px}.container-fluid{padding:0}.dl-horizontal dt{float:none;width:auto;clear:none;text-align:left}.dl-horizontal dd{margin-left:0}.container{width:auto}.row-fluid{width:100%}.row,.thumbnails{margin-left:0}.thumbnails>li{float:none;margin-left:0}[class*="span"],.uneditable-input[class*="span"],.row-fluid [class*="span"]{display:block;float:none;width:100%;margin-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.span12,.row-fluid .span12{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="offset"]:first-child{margin-left:0}.input-large,.input-xlarge,.input-xxlarge,input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.input-prepend input,.input-append input,.input-prepend input[class*="span"],.input-append input[class*="span"]{display:inline-block;width:auto}.controls-row [class*="span"]+[class*="span"]{margin-left:0}.modal{position:fixed;top:20px;right:20px;left:20px;width:auto;margin:0}.modal.fade{top:-100px}.modal.fade.in{top:20px}}@media(max-width:480px){.nav-collapse{-webkit-transform:translate3d(0,0,0)}.page-header h1 small{display:block;line-height:20px}input[type="checkbox"],input[type="radio"]{border:1px solid #ccc}.form-horizontal .control-label{float:none;width:auto;padding-top:0;text-align:left}.form-horizontal .controls{margin-left:0}.form-horizontal .control-list{padding-top:0}.form-horizontal .form-actions{padding-right:10px;padding-left:10px}.media .pull-left,.media .pull-right{display:block;float:none;margin-bottom:10px}.media-object{margin-right:0;margin-left:0}.modal{top:10px;right:10px;left:10px}.modal-header .close{padding:10px;margin:-10px}.carousel-caption{position:static}}@media(max-width:979px){body{padding-top:0}.navbar-fixed-top,.navbar-fixed-bottom{position:static}.navbar-fixed-top{margin-bottom:20px}.navbar-fixed-bottom{margin-top:20px}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding:5px}.navbar .container{width:auto;padding:0}.navbar .brand{padding-right:10px;padding-left:10px;margin:0 0 0 -5px}.nav-collapse{clear:both}.nav-collapse .nav{float:none;margin:0 0 10px}.nav-collapse .nav>li{float:none}.nav-collapse .nav>li>a{margin-bottom:2px}.nav-collapse .nav>.divider-vertical{display:none}.nav-collapse .nav .nav-header{color:#777;text-shadow:none}.nav-collapse .nav>li>a,.nav-collapse .dropdown-menu a{padding:9px 15px;font-weight:bold;color:#777;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.nav-collapse .btn{padding:4px 10px 4px;font-weight:normal;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-collapse .dropdown-menu li+li a{margin-bottom:2px}.nav-collapse .nav>li>a:hover,.nav-collapse .dropdown-menu a:hover{background-color:#f2f2f2}.navbar-inverse .nav-collapse .nav>li>a,.navbar-inverse .nav-collapse .dropdown-menu a{color:#999}.navbar-inverse .nav-collapse .nav>li>a:hover,.navbar-inverse .nav-collapse .dropdown-menu a:hover{background-color:#111}.nav-collapse.in .btn-group{padding:0;margin-top:5px}.nav-collapse .dropdown-menu{position:static;top:auto;left:auto;display:none;float:none;max-width:none;padding:0;margin:0 15px;background-color:transparent;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.nav-collapse .open>.dropdown-menu{display:block}.nav-collapse .dropdown-menu:before,.nav-collapse .dropdown-menu:after{display:none}.nav-collapse .dropdown-menu .divider{display:none}.nav-collapse .nav>li>.dropdown-menu:before,.nav-collapse .nav>li>.dropdown-menu:after{display:none}.nav-collapse .navbar-form,.nav-collapse .navbar-search{float:none;padding:10px 15px;margin:10px 0;border-top:1px solid #f2f2f2;border-bottom:1px solid #f2f2f2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}.navbar-inverse .nav-collapse .navbar-form,.navbar-inverse .nav-collapse .navbar-search{border-top-color:#111;border-bottom-color:#111}.navbar .nav-collapse .nav.pull-right{float:none;margin-left:0}.nav-collapse,.nav-collapse.collapse{height:0;overflow:hidden}.navbar .btn-navbar{display:block}.navbar-static .navbar-inner{padding-right:10px;padding-left:10px}}@media(min-width:980px){.nav-collapse.collapse{height:auto!important;overflow:visible!important}} 10 | -------------------------------------------------------------------------------- /templates/static/js/json2.js: -------------------------------------------------------------------------------- 1 | /* 2 | json2.js 3 | 2012-10-08 4 | 5 | Public Domain. 6 | 7 | NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 8 | 9 | See http://www.JSON.org/js.html 10 | 11 | 12 | This code should be minified before deployment. 13 | See http://javascript.crockford.com/jsmin.html 14 | 15 | USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO 16 | NOT CONTROL. 17 | 18 | 19 | This file creates a global JSON object containing two methods: stringify 20 | and parse. 21 | 22 | JSON.stringify(value, replacer, space) 23 | value any JavaScript value, usually an object or array. 24 | 25 | replacer an optional parameter that determines how object 26 | values are stringified for objects. It can be a 27 | function or an array of strings. 28 | 29 | space an optional parameter that specifies the indentation 30 | of nested structures. If it is omitted, the text will 31 | be packed without extra whitespace. If it is a number, 32 | it will specify the number of spaces to indent at each 33 | level. If it is a string (such as '\t' or ' '), 34 | it contains the characters used to indent at each level. 35 | 36 | This method produces a JSON text from a JavaScript value. 37 | 38 | When an object value is found, if the object contains a toJSON 39 | method, its toJSON method will be called and the result will be 40 | stringified. A toJSON method does not serialize: it returns the 41 | value represented by the name/value pair that should be serialized, 42 | or undefined if nothing should be serialized. The toJSON method 43 | will be passed the key associated with the value, and this will be 44 | bound to the value 45 | 46 | For example, this would serialize Dates as ISO strings. 47 | 48 | Date.prototype.toJSON = function (key) { 49 | function f(n) { 50 | // Format integers to have at least two digits. 51 | return n < 10 ? '0' + n : n; 52 | } 53 | 54 | return this.getUTCFullYear() + '-' + 55 | f(this.getUTCMonth() + 1) + '-' + 56 | f(this.getUTCDate()) + 'T' + 57 | f(this.getUTCHours()) + ':' + 58 | f(this.getUTCMinutes()) + ':' + 59 | f(this.getUTCSeconds()) + 'Z'; 60 | }; 61 | 62 | You can provide an optional replacer method. It will be passed the 63 | key and value of each member, with this bound to the containing 64 | object. The value that is returned from your method will be 65 | serialized. If your method returns undefined, then the member will 66 | be excluded from the serialization. 67 | 68 | If the replacer parameter is an array of strings, then it will be 69 | used to select the members to be serialized. It filters the results 70 | such that only members with keys listed in the replacer array are 71 | stringified. 72 | 73 | Values that do not have JSON representations, such as undefined or 74 | functions, will not be serialized. Such values in objects will be 75 | dropped; in arrays they will be replaced with null. You can use 76 | a replacer function to replace those with JSON values. 77 | JSON.stringify(undefined) returns undefined. 78 | 79 | The optional space parameter produces a stringification of the 80 | value that is filled with line breaks and indentation to make it 81 | easier to read. 82 | 83 | If the space parameter is a non-empty string, then that string will 84 | be used for indentation. If the space parameter is a number, then 85 | the indentation will be that many spaces. 86 | 87 | Example: 88 | 89 | text = JSON.stringify(['e', {pluribus: 'unum'}]); 90 | // text is '["e",{"pluribus":"unum"}]' 91 | 92 | 93 | text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); 94 | // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' 95 | 96 | text = JSON.stringify([new Date()], function (key, value) { 97 | return this[key] instanceof Date ? 98 | 'Date(' + this[key] + ')' : value; 99 | }); 100 | // text is '["Date(---current time---)"]' 101 | 102 | 103 | JSON.parse(text, reviver) 104 | This method parses a JSON text to produce an object or array. 105 | It can throw a SyntaxError exception. 106 | 107 | The optional reviver parameter is a function that can filter and 108 | transform the results. It receives each of the keys and values, 109 | and its return value is used instead of the original value. 110 | If it returns what it received, then the structure is not modified. 111 | If it returns undefined then the member is deleted. 112 | 113 | Example: 114 | 115 | // Parse the text. Values that look like ISO date strings will 116 | // be converted to Date objects. 117 | 118 | myData = JSON.parse(text, function (key, value) { 119 | var a; 120 | if (typeof value === 'string') { 121 | a = 122 | /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); 123 | if (a) { 124 | return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], 125 | +a[5], +a[6])); 126 | } 127 | } 128 | return value; 129 | }); 130 | 131 | myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { 132 | var d; 133 | if (typeof value === 'string' && 134 | value.slice(0, 5) === 'Date(' && 135 | value.slice(-1) === ')') { 136 | d = new Date(value.slice(5, -1)); 137 | if (d) { 138 | return d; 139 | } 140 | } 141 | return value; 142 | }); 143 | 144 | 145 | This is a reference implementation. You are free to copy, modify, or 146 | redistribute. 147 | */ 148 | 149 | /*jslint evil: true, regexp: true */ 150 | 151 | /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, 152 | call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, 153 | getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, 154 | lastIndex, length, parse, prototype, push, replace, slice, stringify, 155 | test, toJSON, toString, valueOf 156 | */ 157 | 158 | 159 | // Create a JSON object only if one does not already exist. We create the 160 | // methods in a closure to avoid creating global variables. 161 | 162 | if (typeof JSON !== 'object') { 163 | JSON = {}; 164 | } 165 | 166 | (function () { 167 | 'use strict'; 168 | 169 | function f(n) { 170 | // Format integers to have at least two digits. 171 | return n < 10 ? '0' + n : n; 172 | } 173 | 174 | if (typeof Date.prototype.toJSON !== 'function') { 175 | 176 | Date.prototype.toJSON = function (key) { 177 | 178 | return isFinite(this.valueOf()) 179 | ? this.getUTCFullYear() + '-' + 180 | f(this.getUTCMonth() + 1) + '-' + 181 | f(this.getUTCDate()) + 'T' + 182 | f(this.getUTCHours()) + ':' + 183 | f(this.getUTCMinutes()) + ':' + 184 | f(this.getUTCSeconds()) + 'Z' 185 | : null; 186 | }; 187 | 188 | String.prototype.toJSON = 189 | Number.prototype.toJSON = 190 | Boolean.prototype.toJSON = function (key) { 191 | return this.valueOf(); 192 | }; 193 | } 194 | 195 | var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 196 | escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 197 | gap, 198 | indent, 199 | meta = { // table of character substitutions 200 | '\b': '\\b', 201 | '\t': '\\t', 202 | '\n': '\\n', 203 | '\f': '\\f', 204 | '\r': '\\r', 205 | '"' : '\\"', 206 | '\\': '\\\\' 207 | }, 208 | rep; 209 | 210 | 211 | function quote(string) { 212 | 213 | // If the string contains no control characters, no quote characters, and no 214 | // backslash characters, then we can safely slap some quotes around it. 215 | // Otherwise we must also replace the offending characters with safe escape 216 | // sequences. 217 | 218 | escapable.lastIndex = 0; 219 | return escapable.test(string) ? '"' + string.replace(escapable, function (a) { 220 | var c = meta[a]; 221 | return typeof c === 'string' 222 | ? c 223 | : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 224 | }) + '"' : '"' + string + '"'; 225 | } 226 | 227 | 228 | function str(key, holder) { 229 | 230 | // Produce a string from holder[key]. 231 | 232 | var i, // The loop counter. 233 | k, // The member key. 234 | v, // The member value. 235 | length, 236 | mind = gap, 237 | partial, 238 | value = holder[key]; 239 | 240 | // If the value has a toJSON method, call it to obtain a replacement value. 241 | 242 | if (value && typeof value === 'object' && 243 | typeof value.toJSON === 'function') { 244 | value = value.toJSON(key); 245 | } 246 | 247 | // If we were called with a replacer function, then call the replacer to 248 | // obtain a replacement value. 249 | 250 | if (typeof rep === 'function') { 251 | value = rep.call(holder, key, value); 252 | } 253 | 254 | // What happens next depends on the value's type. 255 | 256 | switch (typeof value) { 257 | case 'string': 258 | return quote(value); 259 | 260 | case 'number': 261 | 262 | // JSON numbers must be finite. Encode non-finite numbers as null. 263 | 264 | return isFinite(value) ? String(value) : 'null'; 265 | 266 | case 'boolean': 267 | case 'null': 268 | 269 | // If the value is a boolean or null, convert it to a string. Note: 270 | // typeof null does not produce 'null'. The case is included here in 271 | // the remote chance that this gets fixed someday. 272 | 273 | return String(value); 274 | 275 | // If the type is 'object', we might be dealing with an object or an array or 276 | // null. 277 | 278 | case 'object': 279 | 280 | // Due to a specification blunder in ECMAScript, typeof null is 'object', 281 | // so watch out for that case. 282 | 283 | if (!value) { 284 | return 'null'; 285 | } 286 | 287 | // Make an array to hold the partial results of stringifying this object value. 288 | 289 | gap += indent; 290 | partial = []; 291 | 292 | // Is the value an array? 293 | 294 | if (Object.prototype.toString.apply(value) === '[object Array]') { 295 | 296 | // The value is an array. Stringify every element. Use null as a placeholder 297 | // for non-JSON values. 298 | 299 | length = value.length; 300 | for (i = 0; i < length; i += 1) { 301 | partial[i] = str(i, value) || 'null'; 302 | } 303 | 304 | // Join all of the elements together, separated with commas, and wrap them in 305 | // brackets. 306 | 307 | v = partial.length === 0 308 | ? '[]' 309 | : gap 310 | ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' 311 | : '[' + partial.join(',') + ']'; 312 | gap = mind; 313 | return v; 314 | } 315 | 316 | // If the replacer is an array, use it to select the members to be stringified. 317 | 318 | if (rep && typeof rep === 'object') { 319 | length = rep.length; 320 | for (i = 0; i < length; i += 1) { 321 | if (typeof rep[i] === 'string') { 322 | k = rep[i]; 323 | v = str(k, value); 324 | if (v) { 325 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 326 | } 327 | } 328 | } 329 | } else { 330 | 331 | // Otherwise, iterate through all of the keys in the object. 332 | 333 | for (k in value) { 334 | if (Object.prototype.hasOwnProperty.call(value, k)) { 335 | v = str(k, value); 336 | if (v) { 337 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 338 | } 339 | } 340 | } 341 | } 342 | 343 | // Join all of the member texts together, separated with commas, 344 | // and wrap them in braces. 345 | 346 | v = partial.length === 0 347 | ? '{}' 348 | : gap 349 | ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' 350 | : '{' + partial.join(',') + '}'; 351 | gap = mind; 352 | return v; 353 | } 354 | } 355 | 356 | // If the JSON object does not yet have a stringify method, give it one. 357 | 358 | if (typeof JSON.stringify !== 'function') { 359 | JSON.stringify = function (value, replacer, space) { 360 | 361 | // The stringify method takes a value and an optional replacer, and an optional 362 | // space parameter, and returns a JSON text. The replacer can be a function 363 | // that can replace values, or an array of strings that will select the keys. 364 | // A default replacer method can be provided. Use of the space parameter can 365 | // produce text that is more easily readable. 366 | 367 | var i; 368 | gap = ''; 369 | indent = ''; 370 | 371 | // If the space parameter is a number, make an indent string containing that 372 | // many spaces. 373 | 374 | if (typeof space === 'number') { 375 | for (i = 0; i < space; i += 1) { 376 | indent += ' '; 377 | } 378 | 379 | // If the space parameter is a string, it will be used as the indent string. 380 | 381 | } else if (typeof space === 'string') { 382 | indent = space; 383 | } 384 | 385 | // If there is a replacer, it must be a function or an array. 386 | // Otherwise, throw an error. 387 | 388 | rep = replacer; 389 | if (replacer && typeof replacer !== 'function' && 390 | (typeof replacer !== 'object' || 391 | typeof replacer.length !== 'number')) { 392 | throw new Error('JSON.stringify'); 393 | } 394 | 395 | // Make a fake root object containing our value under the key of ''. 396 | // Return the result of stringifying the value. 397 | 398 | return str('', {'': value}); 399 | }; 400 | } 401 | 402 | 403 | // If the JSON object does not yet have a parse method, give it one. 404 | 405 | if (typeof JSON.parse !== 'function') { 406 | JSON.parse = function (text, reviver) { 407 | 408 | // The parse method takes a text and an optional reviver function, and returns 409 | // a JavaScript value if the text is a valid JSON text. 410 | 411 | var j; 412 | 413 | function walk(holder, key) { 414 | 415 | // The walk method is used to recursively walk the resulting structure so 416 | // that modifications can be made. 417 | 418 | var k, v, value = holder[key]; 419 | if (value && typeof value === 'object') { 420 | for (k in value) { 421 | if (Object.prototype.hasOwnProperty.call(value, k)) { 422 | v = walk(value, k); 423 | if (v !== undefined) { 424 | value[k] = v; 425 | } else { 426 | delete value[k]; 427 | } 428 | } 429 | } 430 | } 431 | return reviver.call(holder, key, value); 432 | } 433 | 434 | 435 | // Parsing happens in four stages. In the first stage, we replace certain 436 | // Unicode characters with escape sequences. JavaScript handles many characters 437 | // incorrectly, either silently deleting them, or treating them as line endings. 438 | 439 | text = String(text); 440 | cx.lastIndex = 0; 441 | if (cx.test(text)) { 442 | text = text.replace(cx, function (a) { 443 | return '\\u' + 444 | ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 445 | }); 446 | } 447 | 448 | // In the second stage, we run the text against regular expressions that look 449 | // for non-JSON patterns. We are especially concerned with '()' and 'new' 450 | // because they can cause invocation, and '=' because it can cause mutation. 451 | // But just to be safe, we want to reject all unexpected forms. 452 | 453 | // We split the second stage into 4 regexp operations in order to work around 454 | // crippling inefficiencies in IE's and Safari's regexp engines. First we 455 | // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we 456 | // replace all simple value tokens with ']' characters. Third, we delete all 457 | // open brackets that follow a colon or comma or that begin the text. Finally, 458 | // we look to see that the remaining characters are only whitespace or ']' or 459 | // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. 460 | 461 | if (/^[\],:{}\s]*$/ 462 | .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@') 463 | .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']') 464 | .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { 465 | 466 | // In the third stage we use the eval function to compile the text into a 467 | // JavaScript structure. The '{' operator is subject to a syntactic ambiguity 468 | // in JavaScript: it can begin a block or an object literal. We wrap the text 469 | // in parens to eliminate the ambiguity. 470 | 471 | j = eval('(' + text + ')'); 472 | 473 | // In the optional fourth stage, we recursively walk the new structure, passing 474 | // each name/value pair to a reviver function for possible transformation. 475 | 476 | return typeof reviver === 'function' 477 | ? walk({'': j}, '') 478 | : j; 479 | } 480 | 481 | // If the text is not JSON parseable, then a SyntaxError is thrown. 482 | 483 | throw new SyntaxError('JSON.parse'); 484 | }; 485 | } 486 | }()); 487 | -------------------------------------------------------------------------------- /templates/static/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap.js by @fat & @mdo 3 | * Copyright 2012 Twitter, Inc. 4 | * http://www.apache.org/licenses/LICENSE-2.0.txt 5 | */ 6 | !function(e){"use strict";e(function(){e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()},e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e(document).on("click.alert.data-api",t,n.prototype.close)}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")},e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e(document).on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=n,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){s.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f;this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u](),f=e.Event("slide",{relatedTarget:i[0]});if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}},e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e(document).on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=e.extend({},i.data(),n.data());i.carousel(s),t.preventDefault()})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hasClass("width");return e?"width":"height"},show:function(){var t,n,r,i;if(this.transitioning)return;t=this.dimension(),n=e.camelCase(["scroll",t].join("-")),r=this.$parent&&this.$parent.find("> .accordion-group > .in");if(r&&r.length){i=r.data("collapse");if(i&&i.transitioning)return;r.collapse("hide"),i||r.data("collapse",null)}this.$element[t](0),this.transition("addClass",e.Event("show"),"shown"),e.support.transition&&this.$element[t](this.$element[0][n])},hide:function(){var t;if(this.transitioning)return;t=this.dimension(),this.reset(this.$element[t]()),this.transition("removeClass",e.Event("hide"),"hidden"),this.$element[t](0)},reset:function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this},transition:function(t,n,r){var i=this,s=function(){n.type=="show"&&i.reset(),i.transitioning=0,i.$element.trigger(r)};this.$element.trigger(n);if(n.isDefaultPrevented())return;this.transitioning=1,this.$element[t]("in"),e.support.transition&&this.$element.hasClass("collapse")?this.$element.one(e.support.transition.end,s):s()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},e.fn.collapse=function(n){return this.each(function(){var r=e(this),i=r.data("collapse"),s=typeof n=="object"&&n;i||r.data("collapse",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.collapse.defaults={toggle:!0},e.fn.collapse.Constructor=t,e(document).on("click.collapse.data-api","[data-toggle=collapse]",function(t){var n=e(this),r,i=n.attr("data-target")||t.preventDefault()||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,""),s=e(i).data("collapse")?"toggle":n.data();n[e(i).hasClass("in")?"addClass":"removeClass"]("collapsed"),e(i).collapse(s)})}(window.jQuery),!function(e){"use strict";function r(){e(t).each(function(){i(e(this)).removeClass("open")})}function i(t){var n=t.attr("data-target"),r;return n||(n=t.attr("href"),n=n&&/#/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,"")),r=e(n),r.length||(r=t.parent()),r}var t="[data-toggle=dropdown]",n=function(t){var n=e(t).on("click.dropdown.data-api",this.toggle);e("html").on("click.dropdown.data-api",function(){n.parent().removeClass("open")})};n.prototype={constructor:n,toggle:function(t){var n=e(this),s,o;if(n.is(".disabled, :disabled"))return;return s=i(n),o=s.hasClass("open"),r(),o||(s.toggleClass("open"),n.focus()),!1},keydown:function(t){var n,r,s,o,u,a;if(!/(38|40|27)/.test(t.keyCode))return;n=e(this),t.preventDefault(),t.stopPropagation();if(n.is(".disabled, :disabled"))return;o=i(n),u=o.hasClass("open");if(!u||u&&t.keyCode==27)return n.click();r=e("[role=menu] li:not(.divider) a",o);if(!r.length)return;a=r.index(r.filter(":focus")),t.keyCode==38&&a>0&&a--,t.keyCode==40&&a').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,e.proxy(this.removeBackdrop,this)):this.removeBackdrop()):t&&t()}},e.fn.modal=function(n){return this.each(function(){var r=e(this),i=r.data("modal"),s=e.extend({},e.fn.modal.defaults,r.data(),typeof n=="object"&&n);i||r.data("modal",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},e.fn.modal.Constructor=t,e(document).on("click.modal.data-api",'[data-toggle="modal"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("modal")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data());t.preventDefault(),i.modal(s).one("hide",function(){n.focus()})})}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("tooltip",e,t)};t.prototype={constructor:t,init:function(t,n,r){var i,s;this.type=t,this.$element=e(n),this.options=this.getOptions(r),this.enabled=!0,this.options.trigger=="click"?this.$element.on("click."+this.type,this.options.selector,e.proxy(this.toggle,this)):this.options.trigger!="manual"&&(i=this.options.trigger=="hover"?"mouseenter":"focus",s=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(i+"."+this.type,this.options.selector,e.proxy(this.enter,this)),this.$element.on(s+"."+this.type,this.options.selector,e.proxy(this.leave,this))),this.options.selector?this._options=e.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(t){return t=e.extend({},e.fn[this.type].defaults,t,this.$element.data()),t.delay&&typeof t.delay=="number"&&(t.delay={show:t.delay,hide:t.delay}),t},enter:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);if(!n.options.delay||!n.options.delay.show)return n.show();clearTimeout(this.timeout),n.hoverState="in",this.timeout=setTimeout(function(){n.hoverState=="in"&&n.show()},n.options.delay.show)},leave:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);this.timeout&&clearTimeout(this.timeout);if(!n.options.delay||!n.options.delay.hide)return n.hide();n.hoverState="out",this.timeout=setTimeout(function(){n.hoverState=="out"&&n.hide()},n.options.delay.hide)},show:function(){var e,t,n,r,i,s,o;if(this.hasContent()&&this.enabled){e=this.tip(),this.setContent(),this.options.animation&&e.addClass("fade"),s=typeof this.options.placement=="function"?this.options.placement.call(this,e[0],this.$element[0]):this.options.placement,t=/in/.test(s),e.detach().css({top:0,left:0,display:"block"}).insertAfter(this.$element),n=this.getPosition(t),r=e[0].offsetWidth,i=e[0].offsetHeight;switch(t?s.split(" ")[1]:s){case"bottom":o={top:n.top+n.height,left:n.left+n.width/2-r/2};break;case"top":o={top:n.top-i,left:n.left+n.width/2-r/2};break;case"left":o={top:n.top+n.height/2-i/2,left:n.left-r};break;case"right":o={top:n.top+n.height/2-i/2,left:n.left+n.width}}e.offset(o).addClass(s).addClass("in")}},setContent:function(){var e=this.tip(),t=this.getTitle();e.find(".tooltip-inner")[this.options.html?"html":"text"](t),e.removeClass("fade in top bottom left right")},hide:function(){function r(){var t=setTimeout(function(){n.off(e.support.transition.end).detach()},500);n.one(e.support.transition.end,function(){clearTimeout(t),n.detach()})}var t=this,n=this.tip();return n.removeClass("in"),e.support.transition&&this.$tip.hasClass("fade")?r():n.detach(),this},fixTitle:function(){var e=this.$element;(e.attr("title")||typeof e.attr("data-original-title")!="string")&&e.attr("data-original-title",e.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(t){return e.extend({},t?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var e,t=this.$element,n=this.options;return e=t.attr("data-original-title")||(typeof n.title=="function"?n.title.call(t[0]):n.title),e},tip:function(){return this.$tip=this.$tip||e(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);n[n.tip().hasClass("in")?"hide":"show"]()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}},e.fn.tooltip=function(n){return this.each(function(){var r=e(this),i=r.data("tooltip"),s=typeof n=="object"&&n;i||r.data("tooltip",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.tooltip.Constructor=t,e.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'
',trigger:"hover",title:"",delay:0,html:!1}}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("popover",e,t)};t.prototype=e.extend({},e.fn.tooltip.Constructor.prototype,{constructor:t,setContent:function(){var e=this.tip(),t=this.getTitle(),n=this.getContent();e.find(".popover-title")[this.options.html?"html":"text"](t),e.find(".popover-content > *")[this.options.html?"html":"text"](n),e.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var e,t=this.$element,n=this.options;return e=t.attr("data-content")||(typeof n.content=="function"?n.content.call(t[0]):n.content),e},tip:function(){return this.$tip||(this.$tip=e(this.options.template)),this.$tip},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}}),e.fn.popover=function(n){return this.each(function(){var r=e(this),i=r.data("popover"),s=typeof n=="object"&&n;i||r.data("popover",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.popover.Constructor=t,e.fn.popover.defaults=e.extend({},e.fn.tooltip.defaults,{placement:"right",trigger:"click",content:"",template:'

'})}(window.jQuery),!function(e){"use strict";function t(t,n){var r=e.proxy(this.process,this),i=e(t).is("body")?e(window):e(t),s;this.options=e.extend({},e.fn.scrollspy.defaults,n),this.$scrollElement=i.on("scroll.scroll-spy.data-api",r),this.selector=(this.options.target||(s=e(t).attr("href"))&&s.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=e("body"),this.refresh(),this.process()}t.prototype={constructor:t,refresh:function(){var t=this,n;this.offsets=e([]),this.targets=e([]),n=this.$body.find(this.selector).map(function(){var t=e(this),n=t.data("target")||t.attr("href"),r=/^#\w/.test(n)&&e(n);return r&&r.length&&[[r.position().top,n]]||null}).sort(function(e,t){return e[0]-t[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},process:function(){var e=this.$scrollElement.scrollTop()+this.options.offset,t=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,n=t-this.$scrollElement.height(),r=this.offsets,i=this.targets,s=this.activeTarget,o;if(e>=n)return s!=(o=i.last()[0])&&this.activate(o);for(o=r.length;o--;)s!=i[o]&&e>=r[o]&&(!r[o+1]||e<=r[o+1])&&this.activate(i[o])},activate:function(t){var n,r;this.activeTarget=t,e(this.selector).parent(".active").removeClass("active"),r=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',n=e(r).parent("li").addClass("active"),n.parent(".dropdown-menu").length&&(n=n.closest("li.dropdown").addClass("active")),n.trigger("activate")}},e.fn.scrollspy=function(n){return this.each(function(){var r=e(this),i=r.data("scrollspy"),s=typeof n=="object"&&n;i||r.data("scrollspy",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.scrollspy.Constructor=t,e.fn.scrollspy.defaults={offset:10},e(window).on("load",function(){e('[data-spy="scroll"]').each(function(){var t=e(this);t.scrollspy(t.data())})})}(window.jQuery),!function(e){"use strict";var t=function(t){this.element=e(t)};t.prototype={constructor:t,show:function(){var t=this.element,n=t.closest("ul:not(.dropdown-menu)"),r=t.attr("data-target"),i,s,o;r||(r=t.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,""));if(t.parent("li").hasClass("active"))return;i=n.find(".active:last a")[0],o=e.Event("show",{relatedTarget:i}),t.trigger(o);if(o.isDefaultPrevented())return;s=e(r),this.activate(t.parent("li"),n),this.activate(s,s.parent(),function(){t.trigger({type:"shown",relatedTarget:i})})},activate:function(t,n,r){function o(){i.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),t.addClass("active"),s?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu")&&t.closest("li.dropdown").addClass("active"),r&&r()}var i=n.find("> .active"),s=r&&e.support.transition&&i.hasClass("fade");s?i.one(e.support.transition.end,o):o(),i.removeClass("in")}},e.fn.tab=function(n){return this.each(function(){var r=e(this),i=r.data("tab");i||r.data("tab",i=new t(this)),typeof n=="string"&&i[n]()})},e.fn.tab.Constructor=t,e(document).on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(t){t.preventDefault(),e(this).tab("show")})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.typeahead.defaults,n),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.$menu=e(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};t.prototype={constructor:t,select:function(){var e=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(e)).change(),this.hide()},updater:function(e){return e},show:function(){var t=e.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:t.top+t.height,left:t.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(t){var n;return this.query=this.$element.val(),!this.query||this.query.length"+t+""})},render:function(t){var n=this;return t=e(t).map(function(t,r){return t=e(n.options.item).attr("data-value",r),t.find("a").html(n.highlighter(r)),t[0]}),t.first().addClass("active"),this.$menu.html(t),this},next:function(t){var n=this.$menu.find(".active").removeClass("active"),r=n.next();r.length||(r=e(this.$menu.find("li")[0])),r.addClass("active")},prev:function(e){var t=this.$menu.find(".active").removeClass("active"),n=t.prev();n.length||(n=this.$menu.find("li").last()),n.addClass("active")},listen:function(){this.$element.on("blur",e.proxy(this.blur,this)).on("keypress",e.proxy(this.keypress,this)).on("keyup",e.proxy(this.keyup,this)),this.eventSupported("keydown")&&this.$element.on("keydown",e.proxy(this.keydown,this)),this.$menu.on("click",e.proxy(this.click,this)).on("mouseenter","li",e.proxy(this.mouseenter,this))},eventSupported:function(e){var t=e in this.$element;return t||(this.$element.setAttribute(e,"return;"),t=typeof this.$element[e]=="function"),t},move:function(e){if(!this.shown)return;switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),this.prev();break;case 40:e.preventDefault(),this.next()}e.stopPropagation()},keydown:function(t){this.suppressKeyPressRepeat=!~e.inArray(t.keyCode,[40,38,9,13,27]),this.move(t)},keypress:function(e){if(this.suppressKeyPressRepeat)return;this.move(e)},keyup:function(e){switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}e.stopPropagation(),e.preventDefault()},blur:function(e){var t=this;setTimeout(function(){t.hide()},150)},click:function(e){e.stopPropagation(),e.preventDefault(),this.select()},mouseenter:function(t){this.$menu.find(".active").removeClass("active"),e(t.currentTarget).addClass("active")}},e.fn.typeahead=function(n){return this.each(function(){var r=e(this),i=r.data("typeahead"),s=typeof n=="object"&&n;i||r.data("typeahead",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.typeahead.defaults={source:[],items:8,menu:'',item:'
  • ',minLength:1},e.fn.typeahead.Constructor=t,e(document).on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(t){var n=e(this);if(n.data("typeahead"))return;t.preventDefault(),n.typeahead(n.data())})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.options=e.extend({},e.fn.affix.defaults,n),this.$window=e(window).on("scroll.affix.data-api",e.proxy(this.checkPosition,this)).on("click.affix.data-api",e.proxy(function(){setTimeout(e.proxy(this.checkPosition,this),1)},this)),this.$element=e(t),this.checkPosition()};t.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var t=e(document).height(),n=this.$window.scrollTop(),r=this.$element.offset(),i=this.options.offset,s=i.bottom,o=i.top,u="affix affix-top affix-bottom",a;typeof i!="object"&&(s=o=i),typeof o=="function"&&(o=i.top()),typeof s=="function"&&(s=i.bottom()),a=this.unpin!=null&&n+this.unpin<=r.top?!1:s!=null&&r.top+this.$element.height()>=t-s?"bottom":o!=null&&n<=o?"top":!1;if(this.affixed===a)return;this.affixed=a,this.unpin=a=="bottom"?r.top-n:null,this.$element.removeClass(u).addClass("affix"+(a?"-"+a:""))},e.fn.affix=function(n){return this.each(function(){var r=e(this),i=r.data("affix"),s=typeof n=="object"&&n;i||r.data("affix",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.affix.Constructor=t,e.fn.affix.defaults={offset:0},e(window).on("load",function(){e('[data-spy="affix"]').each(function(){var t=e(this),n=t.data();n.offset=n.offset||{},n.offsetBottom&&(n.offset.bottom=n.offsetBottom),n.offsetTop&&(n.offset.top=n.offsetTop),t.affix(n)})})}(window.jQuery); -------------------------------------------------------------------------------- /templates/static/css/bootstrap-responsive.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Responsive v2.2.1 3 | * 4 | * Copyright 2012 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | */ 10 | 11 | .clearfix { 12 | *zoom: 1; 13 | } 14 | 15 | .clearfix:before, 16 | .clearfix:after { 17 | display: table; 18 | line-height: 0; 19 | content: ""; 20 | } 21 | 22 | .clearfix:after { 23 | clear: both; 24 | } 25 | 26 | .hide-text { 27 | font: 0/0 a; 28 | color: transparent; 29 | text-shadow: none; 30 | background-color: transparent; 31 | border: 0; 32 | } 33 | 34 | .input-block-level { 35 | display: block; 36 | width: 100%; 37 | min-height: 30px; 38 | -webkit-box-sizing: border-box; 39 | -moz-box-sizing: border-box; 40 | box-sizing: border-box; 41 | } 42 | 43 | .hidden { 44 | display: none; 45 | visibility: hidden; 46 | } 47 | 48 | .visible-phone { 49 | display: none !important; 50 | } 51 | 52 | .visible-tablet { 53 | display: none !important; 54 | } 55 | 56 | .hidden-desktop { 57 | display: none !important; 58 | } 59 | 60 | .visible-desktop { 61 | display: inherit !important; 62 | } 63 | 64 | @media (min-width: 768px) and (max-width: 979px) { 65 | .hidden-desktop { 66 | display: inherit !important; 67 | } 68 | .visible-desktop { 69 | display: none !important ; 70 | } 71 | .visible-tablet { 72 | display: inherit !important; 73 | } 74 | .hidden-tablet { 75 | display: none !important; 76 | } 77 | } 78 | 79 | @media (max-width: 767px) { 80 | .hidden-desktop { 81 | display: inherit !important; 82 | } 83 | .visible-desktop { 84 | display: none !important; 85 | } 86 | .visible-phone { 87 | display: inherit !important; 88 | } 89 | .hidden-phone { 90 | display: none !important; 91 | } 92 | } 93 | 94 | @media (min-width: 1200px) { 95 | .row { 96 | margin-left: -30px; 97 | *zoom: 1; 98 | } 99 | .row:before, 100 | .row:after { 101 | display: table; 102 | line-height: 0; 103 | content: ""; 104 | } 105 | .row:after { 106 | clear: both; 107 | } 108 | [class*="span"] { 109 | float: left; 110 | min-height: 1px; 111 | margin-left: 30px; 112 | } 113 | .container, 114 | .navbar-static-top .container, 115 | .navbar-fixed-top .container, 116 | .navbar-fixed-bottom .container { 117 | width: 1170px; 118 | } 119 | .span12 { 120 | width: 1170px; 121 | } 122 | .span11 { 123 | width: 1070px; 124 | } 125 | .span10 { 126 | width: 970px; 127 | } 128 | .span9 { 129 | width: 870px; 130 | } 131 | .span8 { 132 | width: 770px; 133 | } 134 | .span7 { 135 | width: 670px; 136 | } 137 | .span6 { 138 | width: 570px; 139 | } 140 | .span5 { 141 | width: 470px; 142 | } 143 | .span4 { 144 | width: 370px; 145 | } 146 | .span3 { 147 | width: 270px; 148 | } 149 | .span2 { 150 | width: 170px; 151 | } 152 | .span1 { 153 | width: 70px; 154 | } 155 | .offset12 { 156 | margin-left: 1230px; 157 | } 158 | .offset11 { 159 | margin-left: 1130px; 160 | } 161 | .offset10 { 162 | margin-left: 1030px; 163 | } 164 | .offset9 { 165 | margin-left: 930px; 166 | } 167 | .offset8 { 168 | margin-left: 830px; 169 | } 170 | .offset7 { 171 | margin-left: 730px; 172 | } 173 | .offset6 { 174 | margin-left: 630px; 175 | } 176 | .offset5 { 177 | margin-left: 530px; 178 | } 179 | .offset4 { 180 | margin-left: 430px; 181 | } 182 | .offset3 { 183 | margin-left: 330px; 184 | } 185 | .offset2 { 186 | margin-left: 230px; 187 | } 188 | .offset1 { 189 | margin-left: 130px; 190 | } 191 | .row-fluid { 192 | width: 100%; 193 | *zoom: 1; 194 | } 195 | .row-fluid:before, 196 | .row-fluid:after { 197 | display: table; 198 | line-height: 0; 199 | content: ""; 200 | } 201 | .row-fluid:after { 202 | clear: both; 203 | } 204 | .row-fluid [class*="span"] { 205 | display: block; 206 | float: left; 207 | width: 100%; 208 | min-height: 30px; 209 | margin-left: 2.564102564102564%; 210 | *margin-left: 2.5109110747408616%; 211 | -webkit-box-sizing: border-box; 212 | -moz-box-sizing: border-box; 213 | box-sizing: border-box; 214 | } 215 | .row-fluid [class*="span"]:first-child { 216 | margin-left: 0; 217 | } 218 | .row-fluid .controls-row [class*="span"] + [class*="span"] { 219 | margin-left: 2.564102564102564%; 220 | } 221 | .row-fluid .span12 { 222 | width: 100%; 223 | *width: 99.94680851063829%; 224 | } 225 | .row-fluid .span11 { 226 | width: 91.45299145299145%; 227 | *width: 91.39979996362975%; 228 | } 229 | .row-fluid .span10 { 230 | width: 82.90598290598291%; 231 | *width: 82.8527914166212%; 232 | } 233 | .row-fluid .span9 { 234 | width: 74.35897435897436%; 235 | *width: 74.30578286961266%; 236 | } 237 | .row-fluid .span8 { 238 | width: 65.81196581196582%; 239 | *width: 65.75877432260411%; 240 | } 241 | .row-fluid .span7 { 242 | width: 57.26495726495726%; 243 | *width: 57.21176577559556%; 244 | } 245 | .row-fluid .span6 { 246 | width: 48.717948717948715%; 247 | *width: 48.664757228587014%; 248 | } 249 | .row-fluid .span5 { 250 | width: 40.17094017094017%; 251 | *width: 40.11774868157847%; 252 | } 253 | .row-fluid .span4 { 254 | width: 31.623931623931625%; 255 | *width: 31.570740134569924%; 256 | } 257 | .row-fluid .span3 { 258 | width: 23.076923076923077%; 259 | *width: 23.023731587561375%; 260 | } 261 | .row-fluid .span2 { 262 | width: 14.52991452991453%; 263 | *width: 14.476723040552828%; 264 | } 265 | .row-fluid .span1 { 266 | width: 5.982905982905983%; 267 | *width: 5.929714493544281%; 268 | } 269 | .row-fluid .offset12 { 270 | margin-left: 105.12820512820512%; 271 | *margin-left: 105.02182214948171%; 272 | } 273 | .row-fluid .offset12:first-child { 274 | margin-left: 102.56410256410257%; 275 | *margin-left: 102.45771958537915%; 276 | } 277 | .row-fluid .offset11 { 278 | margin-left: 96.58119658119658%; 279 | *margin-left: 96.47481360247316%; 280 | } 281 | .row-fluid .offset11:first-child { 282 | margin-left: 94.01709401709402%; 283 | *margin-left: 93.91071103837061%; 284 | } 285 | .row-fluid .offset10 { 286 | margin-left: 88.03418803418803%; 287 | *margin-left: 87.92780505546462%; 288 | } 289 | .row-fluid .offset10:first-child { 290 | margin-left: 85.47008547008548%; 291 | *margin-left: 85.36370249136206%; 292 | } 293 | .row-fluid .offset9 { 294 | margin-left: 79.48717948717949%; 295 | *margin-left: 79.38079650845607%; 296 | } 297 | .row-fluid .offset9:first-child { 298 | margin-left: 76.92307692307693%; 299 | *margin-left: 76.81669394435352%; 300 | } 301 | .row-fluid .offset8 { 302 | margin-left: 70.94017094017094%; 303 | *margin-left: 70.83378796144753%; 304 | } 305 | .row-fluid .offset8:first-child { 306 | margin-left: 68.37606837606839%; 307 | *margin-left: 68.26968539734497%; 308 | } 309 | .row-fluid .offset7 { 310 | margin-left: 62.393162393162385%; 311 | *margin-left: 62.28677941443899%; 312 | } 313 | .row-fluid .offset7:first-child { 314 | margin-left: 59.82905982905982%; 315 | *margin-left: 59.72267685033642%; 316 | } 317 | .row-fluid .offset6 { 318 | margin-left: 53.84615384615384%; 319 | *margin-left: 53.739770867430444%; 320 | } 321 | .row-fluid .offset6:first-child { 322 | margin-left: 51.28205128205128%; 323 | *margin-left: 51.175668303327875%; 324 | } 325 | .row-fluid .offset5 { 326 | margin-left: 45.299145299145295%; 327 | *margin-left: 45.1927623204219%; 328 | } 329 | .row-fluid .offset5:first-child { 330 | margin-left: 42.73504273504273%; 331 | *margin-left: 42.62865975631933%; 332 | } 333 | .row-fluid .offset4 { 334 | margin-left: 36.75213675213675%; 335 | *margin-left: 36.645753773413354%; 336 | } 337 | .row-fluid .offset4:first-child { 338 | margin-left: 34.18803418803419%; 339 | *margin-left: 34.081651209310785%; 340 | } 341 | .row-fluid .offset3 { 342 | margin-left: 28.205128205128204%; 343 | *margin-left: 28.0987452264048%; 344 | } 345 | .row-fluid .offset3:first-child { 346 | margin-left: 25.641025641025642%; 347 | *margin-left: 25.53464266230224%; 348 | } 349 | .row-fluid .offset2 { 350 | margin-left: 19.65811965811966%; 351 | *margin-left: 19.551736679396257%; 352 | } 353 | .row-fluid .offset2:first-child { 354 | margin-left: 17.094017094017094%; 355 | *margin-left: 16.98763411529369%; 356 | } 357 | .row-fluid .offset1 { 358 | margin-left: 11.11111111111111%; 359 | *margin-left: 11.004728132387708%; 360 | } 361 | .row-fluid .offset1:first-child { 362 | margin-left: 8.547008547008547%; 363 | *margin-left: 8.440625568285142%; 364 | } 365 | input, 366 | textarea, 367 | .uneditable-input { 368 | margin-left: 0; 369 | } 370 | .controls-row [class*="span"] + [class*="span"] { 371 | margin-left: 30px; 372 | } 373 | input.span12, 374 | textarea.span12, 375 | .uneditable-input.span12 { 376 | width: 1156px; 377 | } 378 | input.span11, 379 | textarea.span11, 380 | .uneditable-input.span11 { 381 | width: 1056px; 382 | } 383 | input.span10, 384 | textarea.span10, 385 | .uneditable-input.span10 { 386 | width: 956px; 387 | } 388 | input.span9, 389 | textarea.span9, 390 | .uneditable-input.span9 { 391 | width: 856px; 392 | } 393 | input.span8, 394 | textarea.span8, 395 | .uneditable-input.span8 { 396 | width: 756px; 397 | } 398 | input.span7, 399 | textarea.span7, 400 | .uneditable-input.span7 { 401 | width: 656px; 402 | } 403 | input.span6, 404 | textarea.span6, 405 | .uneditable-input.span6 { 406 | width: 556px; 407 | } 408 | input.span5, 409 | textarea.span5, 410 | .uneditable-input.span5 { 411 | width: 456px; 412 | } 413 | input.span4, 414 | textarea.span4, 415 | .uneditable-input.span4 { 416 | width: 356px; 417 | } 418 | input.span3, 419 | textarea.span3, 420 | .uneditable-input.span3 { 421 | width: 256px; 422 | } 423 | input.span2, 424 | textarea.span2, 425 | .uneditable-input.span2 { 426 | width: 156px; 427 | } 428 | input.span1, 429 | textarea.span1, 430 | .uneditable-input.span1 { 431 | width: 56px; 432 | } 433 | .thumbnails { 434 | margin-left: -30px; 435 | } 436 | .thumbnails > li { 437 | margin-left: 30px; 438 | } 439 | .row-fluid .thumbnails { 440 | margin-left: 0; 441 | } 442 | } 443 | 444 | @media (min-width: 768px) and (max-width: 979px) { 445 | .row { 446 | margin-left: -20px; 447 | *zoom: 1; 448 | } 449 | .row:before, 450 | .row:after { 451 | display: table; 452 | line-height: 0; 453 | content: ""; 454 | } 455 | .row:after { 456 | clear: both; 457 | } 458 | [class*="span"] { 459 | float: left; 460 | min-height: 1px; 461 | margin-left: 20px; 462 | } 463 | .container, 464 | .navbar-static-top .container, 465 | .navbar-fixed-top .container, 466 | .navbar-fixed-bottom .container { 467 | width: 724px; 468 | } 469 | .span12 { 470 | width: 724px; 471 | } 472 | .span11 { 473 | width: 662px; 474 | } 475 | .span10 { 476 | width: 600px; 477 | } 478 | .span9 { 479 | width: 538px; 480 | } 481 | .span8 { 482 | width: 476px; 483 | } 484 | .span7 { 485 | width: 414px; 486 | } 487 | .span6 { 488 | width: 352px; 489 | } 490 | .span5 { 491 | width: 290px; 492 | } 493 | .span4 { 494 | width: 228px; 495 | } 496 | .span3 { 497 | width: 166px; 498 | } 499 | .span2 { 500 | width: 104px; 501 | } 502 | .span1 { 503 | width: 42px; 504 | } 505 | .offset12 { 506 | margin-left: 764px; 507 | } 508 | .offset11 { 509 | margin-left: 702px; 510 | } 511 | .offset10 { 512 | margin-left: 640px; 513 | } 514 | .offset9 { 515 | margin-left: 578px; 516 | } 517 | .offset8 { 518 | margin-left: 516px; 519 | } 520 | .offset7 { 521 | margin-left: 454px; 522 | } 523 | .offset6 { 524 | margin-left: 392px; 525 | } 526 | .offset5 { 527 | margin-left: 330px; 528 | } 529 | .offset4 { 530 | margin-left: 268px; 531 | } 532 | .offset3 { 533 | margin-left: 206px; 534 | } 535 | .offset2 { 536 | margin-left: 144px; 537 | } 538 | .offset1 { 539 | margin-left: 82px; 540 | } 541 | .row-fluid { 542 | width: 100%; 543 | *zoom: 1; 544 | } 545 | .row-fluid:before, 546 | .row-fluid:after { 547 | display: table; 548 | line-height: 0; 549 | content: ""; 550 | } 551 | .row-fluid:after { 552 | clear: both; 553 | } 554 | .row-fluid [class*="span"] { 555 | display: block; 556 | float: left; 557 | width: 100%; 558 | min-height: 30px; 559 | margin-left: 2.7624309392265194%; 560 | *margin-left: 2.709239449864817%; 561 | -webkit-box-sizing: border-box; 562 | -moz-box-sizing: border-box; 563 | box-sizing: border-box; 564 | } 565 | .row-fluid [class*="span"]:first-child { 566 | margin-left: 0; 567 | } 568 | .row-fluid .controls-row [class*="span"] + [class*="span"] { 569 | margin-left: 2.7624309392265194%; 570 | } 571 | .row-fluid .span12 { 572 | width: 100%; 573 | *width: 99.94680851063829%; 574 | } 575 | .row-fluid .span11 { 576 | width: 91.43646408839778%; 577 | *width: 91.38327259903608%; 578 | } 579 | .row-fluid .span10 { 580 | width: 82.87292817679558%; 581 | *width: 82.81973668743387%; 582 | } 583 | .row-fluid .span9 { 584 | width: 74.30939226519337%; 585 | *width: 74.25620077583166%; 586 | } 587 | .row-fluid .span8 { 588 | width: 65.74585635359117%; 589 | *width: 65.69266486422946%; 590 | } 591 | .row-fluid .span7 { 592 | width: 57.18232044198895%; 593 | *width: 57.12912895262725%; 594 | } 595 | .row-fluid .span6 { 596 | width: 48.61878453038674%; 597 | *width: 48.56559304102504%; 598 | } 599 | .row-fluid .span5 { 600 | width: 40.05524861878453%; 601 | *width: 40.00205712942283%; 602 | } 603 | .row-fluid .span4 { 604 | width: 31.491712707182323%; 605 | *width: 31.43852121782062%; 606 | } 607 | .row-fluid .span3 { 608 | width: 22.92817679558011%; 609 | *width: 22.87498530621841%; 610 | } 611 | .row-fluid .span2 { 612 | width: 14.3646408839779%; 613 | *width: 14.311449394616199%; 614 | } 615 | .row-fluid .span1 { 616 | width: 5.801104972375691%; 617 | *width: 5.747913483013988%; 618 | } 619 | .row-fluid .offset12 { 620 | margin-left: 105.52486187845304%; 621 | *margin-left: 105.41847889972962%; 622 | } 623 | .row-fluid .offset12:first-child { 624 | margin-left: 102.76243093922652%; 625 | *margin-left: 102.6560479605031%; 626 | } 627 | .row-fluid .offset11 { 628 | margin-left: 96.96132596685082%; 629 | *margin-left: 96.8549429881274%; 630 | } 631 | .row-fluid .offset11:first-child { 632 | margin-left: 94.1988950276243%; 633 | *margin-left: 94.09251204890089%; 634 | } 635 | .row-fluid .offset10 { 636 | margin-left: 88.39779005524862%; 637 | *margin-left: 88.2914070765252%; 638 | } 639 | .row-fluid .offset10:first-child { 640 | margin-left: 85.6353591160221%; 641 | *margin-left: 85.52897613729868%; 642 | } 643 | .row-fluid .offset9 { 644 | margin-left: 79.8342541436464%; 645 | *margin-left: 79.72787116492299%; 646 | } 647 | .row-fluid .offset9:first-child { 648 | margin-left: 77.07182320441989%; 649 | *margin-left: 76.96544022569647%; 650 | } 651 | .row-fluid .offset8 { 652 | margin-left: 71.2707182320442%; 653 | *margin-left: 71.16433525332079%; 654 | } 655 | .row-fluid .offset8:first-child { 656 | margin-left: 68.50828729281768%; 657 | *margin-left: 68.40190431409427%; 658 | } 659 | .row-fluid .offset7 { 660 | margin-left: 62.70718232044199%; 661 | *margin-left: 62.600799341718584%; 662 | } 663 | .row-fluid .offset7:first-child { 664 | margin-left: 59.94475138121547%; 665 | *margin-left: 59.838368402492065%; 666 | } 667 | .row-fluid .offset6 { 668 | margin-left: 54.14364640883978%; 669 | *margin-left: 54.037263430116376%; 670 | } 671 | .row-fluid .offset6:first-child { 672 | margin-left: 51.38121546961326%; 673 | *margin-left: 51.27483249088986%; 674 | } 675 | .row-fluid .offset5 { 676 | margin-left: 45.58011049723757%; 677 | *margin-left: 45.47372751851417%; 678 | } 679 | .row-fluid .offset5:first-child { 680 | margin-left: 42.81767955801105%; 681 | *margin-left: 42.71129657928765%; 682 | } 683 | .row-fluid .offset4 { 684 | margin-left: 37.01657458563536%; 685 | *margin-left: 36.91019160691196%; 686 | } 687 | .row-fluid .offset4:first-child { 688 | margin-left: 34.25414364640884%; 689 | *margin-left: 34.14776066768544%; 690 | } 691 | .row-fluid .offset3 { 692 | margin-left: 28.45303867403315%; 693 | *margin-left: 28.346655695309746%; 694 | } 695 | .row-fluid .offset3:first-child { 696 | margin-left: 25.69060773480663%; 697 | *margin-left: 25.584224756083227%; 698 | } 699 | .row-fluid .offset2 { 700 | margin-left: 19.88950276243094%; 701 | *margin-left: 19.783119783707537%; 702 | } 703 | .row-fluid .offset2:first-child { 704 | margin-left: 17.12707182320442%; 705 | *margin-left: 17.02068884448102%; 706 | } 707 | .row-fluid .offset1 { 708 | margin-left: 11.32596685082873%; 709 | *margin-left: 11.219583872105325%; 710 | } 711 | .row-fluid .offset1:first-child { 712 | margin-left: 8.56353591160221%; 713 | *margin-left: 8.457152932878806%; 714 | } 715 | input, 716 | textarea, 717 | .uneditable-input { 718 | margin-left: 0; 719 | } 720 | .controls-row [class*="span"] + [class*="span"] { 721 | margin-left: 20px; 722 | } 723 | input.span12, 724 | textarea.span12, 725 | .uneditable-input.span12 { 726 | width: 710px; 727 | } 728 | input.span11, 729 | textarea.span11, 730 | .uneditable-input.span11 { 731 | width: 648px; 732 | } 733 | input.span10, 734 | textarea.span10, 735 | .uneditable-input.span10 { 736 | width: 586px; 737 | } 738 | input.span9, 739 | textarea.span9, 740 | .uneditable-input.span9 { 741 | width: 524px; 742 | } 743 | input.span8, 744 | textarea.span8, 745 | .uneditable-input.span8 { 746 | width: 462px; 747 | } 748 | input.span7, 749 | textarea.span7, 750 | .uneditable-input.span7 { 751 | width: 400px; 752 | } 753 | input.span6, 754 | textarea.span6, 755 | .uneditable-input.span6 { 756 | width: 338px; 757 | } 758 | input.span5, 759 | textarea.span5, 760 | .uneditable-input.span5 { 761 | width: 276px; 762 | } 763 | input.span4, 764 | textarea.span4, 765 | .uneditable-input.span4 { 766 | width: 214px; 767 | } 768 | input.span3, 769 | textarea.span3, 770 | .uneditable-input.span3 { 771 | width: 152px; 772 | } 773 | input.span2, 774 | textarea.span2, 775 | .uneditable-input.span2 { 776 | width: 90px; 777 | } 778 | input.span1, 779 | textarea.span1, 780 | .uneditable-input.span1 { 781 | width: 28px; 782 | } 783 | } 784 | 785 | @media (max-width: 767px) { 786 | body { 787 | padding-right: 20px; 788 | padding-left: 20px; 789 | } 790 | .navbar-fixed-top, 791 | .navbar-fixed-bottom, 792 | .navbar-static-top { 793 | margin-right: -20px; 794 | margin-left: -20px; 795 | } 796 | .container-fluid { 797 | padding: 0; 798 | } 799 | .dl-horizontal dt { 800 | float: none; 801 | width: auto; 802 | clear: none; 803 | text-align: left; 804 | } 805 | .dl-horizontal dd { 806 | margin-left: 0; 807 | } 808 | .container { 809 | width: auto; 810 | } 811 | .row-fluid { 812 | width: 100%; 813 | } 814 | .row, 815 | .thumbnails { 816 | margin-left: 0; 817 | } 818 | .thumbnails > li { 819 | float: none; 820 | margin-left: 0; 821 | } 822 | [class*="span"], 823 | .uneditable-input[class*="span"], 824 | .row-fluid [class*="span"] { 825 | display: block; 826 | float: none; 827 | width: 100%; 828 | margin-left: 0; 829 | -webkit-box-sizing: border-box; 830 | -moz-box-sizing: border-box; 831 | box-sizing: border-box; 832 | } 833 | .span12, 834 | .row-fluid .span12 { 835 | width: 100%; 836 | -webkit-box-sizing: border-box; 837 | -moz-box-sizing: border-box; 838 | box-sizing: border-box; 839 | } 840 | .row-fluid [class*="offset"]:first-child { 841 | margin-left: 0; 842 | } 843 | .input-large, 844 | .input-xlarge, 845 | .input-xxlarge, 846 | input[class*="span"], 847 | select[class*="span"], 848 | textarea[class*="span"], 849 | .uneditable-input { 850 | display: block; 851 | width: 100%; 852 | min-height: 30px; 853 | -webkit-box-sizing: border-box; 854 | -moz-box-sizing: border-box; 855 | box-sizing: border-box; 856 | } 857 | .input-prepend input, 858 | .input-append input, 859 | .input-prepend input[class*="span"], 860 | .input-append input[class*="span"] { 861 | display: inline-block; 862 | width: auto; 863 | } 864 | .controls-row [class*="span"] + [class*="span"] { 865 | margin-left: 0; 866 | } 867 | .modal { 868 | position: fixed; 869 | top: 20px; 870 | right: 20px; 871 | left: 20px; 872 | width: auto; 873 | margin: 0; 874 | } 875 | .modal.fade { 876 | top: -100px; 877 | } 878 | .modal.fade.in { 879 | top: 20px; 880 | } 881 | } 882 | 883 | @media (max-width: 480px) { 884 | .nav-collapse { 885 | -webkit-transform: translate3d(0, 0, 0); 886 | } 887 | .page-header h1 small { 888 | display: block; 889 | line-height: 20px; 890 | } 891 | input[type="checkbox"], 892 | input[type="radio"] { 893 | border: 1px solid #ccc; 894 | } 895 | .form-horizontal .control-label { 896 | float: none; 897 | width: auto; 898 | padding-top: 0; 899 | text-align: left; 900 | } 901 | .form-horizontal .controls { 902 | margin-left: 0; 903 | } 904 | .form-horizontal .control-list { 905 | padding-top: 0; 906 | } 907 | .form-horizontal .form-actions { 908 | padding-right: 10px; 909 | padding-left: 10px; 910 | } 911 | .media .pull-left, 912 | .media .pull-right { 913 | display: block; 914 | float: none; 915 | margin-bottom: 10px; 916 | } 917 | .media-object { 918 | margin-right: 0; 919 | margin-left: 0; 920 | } 921 | .modal { 922 | top: 10px; 923 | right: 10px; 924 | left: 10px; 925 | } 926 | .modal-header .close { 927 | padding: 10px; 928 | margin: -10px; 929 | } 930 | .carousel-caption { 931 | position: static; 932 | } 933 | } 934 | 935 | @media (max-width: 979px) { 936 | body { 937 | padding-top: 0; 938 | } 939 | .navbar-fixed-top, 940 | .navbar-fixed-bottom { 941 | position: static; 942 | } 943 | .navbar-fixed-top { 944 | margin-bottom: 20px; 945 | } 946 | .navbar-fixed-bottom { 947 | margin-top: 20px; 948 | } 949 | .navbar-fixed-top .navbar-inner, 950 | .navbar-fixed-bottom .navbar-inner { 951 | padding: 5px; 952 | } 953 | .navbar .container { 954 | width: auto; 955 | padding: 0; 956 | } 957 | .navbar .brand { 958 | padding-right: 10px; 959 | padding-left: 10px; 960 | margin: 0 0 0 -5px; 961 | } 962 | .nav-collapse { 963 | clear: both; 964 | } 965 | .nav-collapse .nav { 966 | float: none; 967 | margin: 0 0 10px; 968 | } 969 | .nav-collapse .nav > li { 970 | float: none; 971 | } 972 | .nav-collapse .nav > li > a { 973 | margin-bottom: 2px; 974 | } 975 | .nav-collapse .nav > .divider-vertical { 976 | display: none; 977 | } 978 | .nav-collapse .nav .nav-header { 979 | color: #777777; 980 | text-shadow: none; 981 | } 982 | .nav-collapse .nav > li > a, 983 | .nav-collapse .dropdown-menu a { 984 | padding: 9px 15px; 985 | font-weight: bold; 986 | color: #777777; 987 | -webkit-border-radius: 3px; 988 | -moz-border-radius: 3px; 989 | border-radius: 3px; 990 | } 991 | .nav-collapse .btn { 992 | padding: 4px 10px 4px; 993 | font-weight: normal; 994 | -webkit-border-radius: 4px; 995 | -moz-border-radius: 4px; 996 | border-radius: 4px; 997 | } 998 | .nav-collapse .dropdown-menu li + li a { 999 | margin-bottom: 2px; 1000 | } 1001 | .nav-collapse .nav > li > a:hover, 1002 | .nav-collapse .dropdown-menu a:hover { 1003 | background-color: #f2f2f2; 1004 | } 1005 | .navbar-inverse .nav-collapse .nav > li > a, 1006 | .navbar-inverse .nav-collapse .dropdown-menu a { 1007 | color: #999999; 1008 | } 1009 | .navbar-inverse .nav-collapse .nav > li > a:hover, 1010 | .navbar-inverse .nav-collapse .dropdown-menu a:hover { 1011 | background-color: #111111; 1012 | } 1013 | .nav-collapse.in .btn-group { 1014 | padding: 0; 1015 | margin-top: 5px; 1016 | } 1017 | .nav-collapse .dropdown-menu { 1018 | position: static; 1019 | top: auto; 1020 | left: auto; 1021 | display: none; 1022 | float: none; 1023 | max-width: none; 1024 | padding: 0; 1025 | margin: 0 15px; 1026 | background-color: transparent; 1027 | border: none; 1028 | -webkit-border-radius: 0; 1029 | -moz-border-radius: 0; 1030 | border-radius: 0; 1031 | -webkit-box-shadow: none; 1032 | -moz-box-shadow: none; 1033 | box-shadow: none; 1034 | } 1035 | .nav-collapse .open > .dropdown-menu { 1036 | display: block; 1037 | } 1038 | .nav-collapse .dropdown-menu:before, 1039 | .nav-collapse .dropdown-menu:after { 1040 | display: none; 1041 | } 1042 | .nav-collapse .dropdown-menu .divider { 1043 | display: none; 1044 | } 1045 | .nav-collapse .nav > li > .dropdown-menu:before, 1046 | .nav-collapse .nav > li > .dropdown-menu:after { 1047 | display: none; 1048 | } 1049 | .nav-collapse .navbar-form, 1050 | .nav-collapse .navbar-search { 1051 | float: none; 1052 | padding: 10px 15px; 1053 | margin: 10px 0; 1054 | border-top: 1px solid #f2f2f2; 1055 | border-bottom: 1px solid #f2f2f2; 1056 | -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); 1057 | -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); 1058 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); 1059 | } 1060 | .navbar-inverse .nav-collapse .navbar-form, 1061 | .navbar-inverse .nav-collapse .navbar-search { 1062 | border-top-color: #111111; 1063 | border-bottom-color: #111111; 1064 | } 1065 | .navbar .nav-collapse .nav.pull-right { 1066 | float: none; 1067 | margin-left: 0; 1068 | } 1069 | .nav-collapse, 1070 | .nav-collapse.collapse { 1071 | height: 0; 1072 | overflow: hidden; 1073 | } 1074 | .navbar .btn-navbar { 1075 | display: block; 1076 | } 1077 | .navbar-static .navbar-inner { 1078 | padding-right: 10px; 1079 | padding-left: 10px; 1080 | } 1081 | } 1082 | 1083 | @media (min-width: 980px) { 1084 | .nav-collapse.collapse { 1085 | height: auto !important; 1086 | overflow: visible !important; 1087 | } 1088 | } 1089 | -------------------------------------------------------------------------------- /templates/static/js/jquery.form.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery Form Plugin 3 | * version: 3.10 (20-JUL-2012) 4 | * @requires jQuery v1.3.2 or later 5 | * 6 | * Examples and documentation at: http://malsup.com/jquery/form/ 7 | * Project repository: https://github.com/malsup/form 8 | * Dual licensed under the MIT and GPL licenses: 9 | * http://malsup.github.com/mit-license.txt 10 | * http://malsup.github.com/gpl-license-v2.txt 11 | */ 12 | /*global ActiveXObject alert */ 13 | ;(function($) { 14 | "use strict"; 15 | 16 | /* 17 | Usage Note: 18 | ----------- 19 | Do not use both ajaxSubmit and ajaxForm on the same form. These 20 | functions are mutually exclusive. Use ajaxSubmit if you want 21 | to bind your own submit handler to the form. For example, 22 | 23 | $(document).ready(function() { 24 | $('#myForm').on('submit', function(e) { 25 | e.preventDefault(); // <-- important 26 | $(this).ajaxSubmit({ 27 | target: '#output' 28 | }); 29 | }); 30 | }); 31 | 32 | Use ajaxForm when you want the plugin to manage all the event binding 33 | for you. For example, 34 | 35 | $(document).ready(function() { 36 | $('#myForm').ajaxForm({ 37 | target: '#output' 38 | }); 39 | }); 40 | 41 | You can also use ajaxForm with delegation (requires jQuery v1.7+), so the 42 | form does not have to exist when you invoke ajaxForm: 43 | 44 | $('#myForm').ajaxForm({ 45 | delegation: true, 46 | target: '#output' 47 | }); 48 | 49 | When using ajaxForm, the ajaxSubmit function will be invoked for you 50 | at the appropriate time. 51 | */ 52 | 53 | /** 54 | * Feature detection 55 | */ 56 | var feature = {}; 57 | feature.fileapi = $("").get(0).files !== undefined; 58 | feature.formdata = window.FormData !== undefined; 59 | 60 | /** 61 | * ajaxSubmit() provides a mechanism for immediately submitting 62 | * an HTML form using AJAX. 63 | */ 64 | $.fn.ajaxSubmit = function(options) { 65 | /*jshint scripturl:true */ 66 | 67 | // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) 68 | if (!this.length) { 69 | log('ajaxSubmit: skipping submit process - no element selected'); 70 | return this; 71 | } 72 | 73 | var method, action, url, $form = this; 74 | 75 | if (typeof options == 'function') { 76 | options = { success: options }; 77 | } 78 | 79 | method = this.attr('method'); 80 | action = this.attr('action'); 81 | url = (typeof action === 'string') ? $.trim(action) : ''; 82 | url = url || window.location.href || ''; 83 | if (url) { 84 | // clean url (don't include hash vaue) 85 | url = (url.match(/^([^#]+)/)||[])[1]; 86 | } 87 | 88 | options = $.extend(true, { 89 | url: url, 90 | success: $.ajaxSettings.success, 91 | type: method || 'GET', 92 | iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' 93 | }, options); 94 | 95 | // hook for manipulating the form data before it is extracted; 96 | // convenient for use with rich editors like tinyMCE or FCKEditor 97 | var veto = {}; 98 | this.trigger('form-pre-serialize', [this, options, veto]); 99 | if (veto.veto) { 100 | log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); 101 | return this; 102 | } 103 | 104 | // provide opportunity to alter form data before it is serialized 105 | if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { 106 | log('ajaxSubmit: submit aborted via beforeSerialize callback'); 107 | return this; 108 | } 109 | 110 | var traditional = options.traditional; 111 | if ( traditional === undefined ) { 112 | traditional = $.ajaxSettings.traditional; 113 | } 114 | 115 | var elements = []; 116 | var qx, a = this.formToArray(options.semantic, elements); 117 | if (options.data) { 118 | options.extraData = options.data; 119 | qx = $.param(options.data, traditional); 120 | } 121 | 122 | // give pre-submit callback an opportunity to abort the submit 123 | if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { 124 | log('ajaxSubmit: submit aborted via beforeSubmit callback'); 125 | return this; 126 | } 127 | 128 | // fire vetoable 'validate' event 129 | this.trigger('form-submit-validate', [a, this, options, veto]); 130 | if (veto.veto) { 131 | log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); 132 | return this; 133 | } 134 | 135 | var q = $.param(a, traditional); 136 | if (qx) { 137 | q = ( q ? (q + '&' + qx) : qx ); 138 | } 139 | if (options.type.toUpperCase() == 'GET') { 140 | options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; 141 | options.data = null; // data is null for 'get' 142 | } 143 | else { 144 | options.data = q; // data is the query string for 'post' 145 | } 146 | 147 | var callbacks = []; 148 | if (options.resetForm) { 149 | callbacks.push(function() { $form.resetForm(); }); 150 | } 151 | if (options.clearForm) { 152 | callbacks.push(function() { $form.clearForm(options.includeHidden); }); 153 | } 154 | 155 | // perform a load on the target only if dataType is not provided 156 | if (!options.dataType && options.target) { 157 | var oldSuccess = options.success || function(){}; 158 | callbacks.push(function(data) { 159 | var fn = options.replaceTarget ? 'replaceWith' : 'html'; 160 | $(options.target)[fn](data).each(oldSuccess, arguments); 161 | }); 162 | } 163 | else if (options.success) { 164 | callbacks.push(options.success); 165 | } 166 | 167 | options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg 168 | var context = options.context || options; // jQuery 1.4+ supports scope context 169 | for (var i=0, max=callbacks.length; i < max; i++) { 170 | callbacks[i].apply(context, [data, status, xhr || $form, $form]); 171 | } 172 | }; 173 | 174 | // are there files to upload? 175 | var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113) 176 | var hasFileInputs = fileInputs.length > 0; 177 | var mp = 'multipart/form-data'; 178 | var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); 179 | 180 | var fileAPI = feature.fileapi && feature.formdata; 181 | log("fileAPI :" + fileAPI); 182 | var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; 183 | 184 | // options.iframe allows user to force iframe mode 185 | // 06-NOV-09: now defaulting to iframe mode if file input is detected 186 | if (options.iframe !== false && (options.iframe || shouldUseFrame)) { 187 | // hack to fix Safari hang (thanks to Tim Molendijk for this) 188 | // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d 189 | if (options.closeKeepAlive) { 190 | $.get(options.closeKeepAlive, function() { 191 | fileUploadIframe(a); 192 | }); 193 | } 194 | else { 195 | fileUploadIframe(a); 196 | } 197 | } 198 | else if ((hasFileInputs || multipart) && fileAPI) { 199 | fileUploadXhr(a); 200 | } 201 | else { 202 | $.ajax(options); 203 | } 204 | 205 | // clear element array 206 | for (var k=0; k < elements.length; k++) 207 | elements[k] = null; 208 | 209 | // fire 'notify' event 210 | this.trigger('form-submit-notify', [this, options]); 211 | return this; 212 | 213 | // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) 214 | function fileUploadXhr(a) { 215 | var formdata = new FormData(); 216 | 217 | for (var i=0; i < a.length; i++) { 218 | formdata.append(a[i].name, a[i].value); 219 | } 220 | 221 | if (options.extraData) { 222 | for (var p in options.extraData) 223 | if (options.extraData.hasOwnProperty(p)) 224 | formdata.append(p, options.extraData[p]); 225 | } 226 | 227 | options.data = null; 228 | 229 | var s = $.extend(true, {}, $.ajaxSettings, options, { 230 | contentType: false, 231 | processData: false, 232 | cache: false, 233 | type: 'POST' 234 | }); 235 | 236 | if (options.uploadProgress) { 237 | // workaround because jqXHR does not expose upload property 238 | s.xhr = function() { 239 | var xhr = jQuery.ajaxSettings.xhr(); 240 | if (xhr.upload) { 241 | xhr.upload.onprogress = function(event) { 242 | var percent = 0; 243 | var position = event.loaded || event.position; /*event.position is deprecated*/ 244 | var total = event.total; 245 | if (event.lengthComputable) { 246 | percent = Math.ceil(position / total * 100); 247 | } 248 | options.uploadProgress(event, position, total, percent); 249 | }; 250 | } 251 | return xhr; 252 | }; 253 | } 254 | 255 | s.data = null; 256 | var beforeSend = s.beforeSend; 257 | s.beforeSend = function(xhr, o) { 258 | o.data = formdata; 259 | if(beforeSend) 260 | beforeSend.call(this, xhr, o); 261 | }; 262 | $.ajax(s); 263 | } 264 | 265 | // private function for handling file uploads (hat tip to YAHOO!) 266 | function fileUploadIframe(a) { 267 | var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; 268 | var useProp = !!$.fn.prop; 269 | 270 | if ($(':input[name=submit],:input[id=submit]', form).length) { 271 | // if there is an input with a name or id of 'submit' then we won't be 272 | // able to invoke the submit fn on the form (at least not x-browser) 273 | alert('Error: Form elements must not have name or id of "submit".'); 274 | return; 275 | } 276 | 277 | if (a) { 278 | // ensure that every serialized input is still enabled 279 | for (i=0; i < elements.length; i++) { 280 | el = $(elements[i]); 281 | if ( useProp ) 282 | el.prop('disabled', false); 283 | else 284 | el.removeAttr('disabled'); 285 | } 286 | } 287 | 288 | s = $.extend(true, {}, $.ajaxSettings, options); 289 | s.context = s.context || s; 290 | id = 'jqFormIO' + (new Date().getTime()); 291 | if (s.iframeTarget) { 292 | $io = $(s.iframeTarget); 293 | n = $io.attr('name'); 294 | if (!n) 295 | $io.attr('name', id); 296 | else 297 | id = n; 298 | } 299 | else { 300 | $io = $('