Commits

Ryan Wilcox committed a749551

can now bootstrap Django apps with mobile support

Comments (0)

Files changed (3)

setups/__init__.py

 from setups.project.project_level_templates_folder import do_project_level_template_folder
 from setups.project.add_django_utils import add_project_level_django_utils
 from setups.project.add_hoptoad import add_django_hoptoad
+from setups.project.mobile_views import mobile_views
 
 project_setup_task_list = [( "setup project relative template paths", do_sane_template_path, dict(optional=False) ),
         ( "user database setup switch", do_user_setup_switch, dict(optional=False) ),
         #("pull in html5 for django and set it up", setup_django_html5),
         ( "setup folder for project wide templates", do_project_level_template_folder, dict(optional=False) ),
         ( "add personal django utils", add_project_level_django_utils, dict(optional=False) ),
-        ( "Hoptoad for error reporting", add_django_hoptoad, dict(optional=True) )
+        ( "Hoptoad for error reporting", add_django_hoptoad, dict(optional=True) ),
+        ( "Support for templates for mobile browsers", mobile_views, dict(optional=True) )
 ]
 
 #from setups.app.

setups/project/mobile_views.py

+import os
+from setup_helpers import applypatch, filecopy, install_python_module
+
+def mobile_views(base_path, project_path):
+    install_python_module("django-user-agent-detector")
+    
+    applypatch( os.path.join( base_path, "supporting", "mobile_views.patch"),
+        os.path.join(project_path, "settings.py") )
+    
+    print " *** TODO ITEM: you're on your own to install minidetector"

supporting/mobile_views.patch

+--- settings copy.py	2010-12-29 17:12:05.000000000 -0500
++++ settings.py	2010-12-29 17:12:17.000000000 -0500
+@@ -76,6 +76,7 @@
+     'django.middleware.csrf.CsrfViewMiddleware',
+     'django.contrib.auth.middleware.AuthenticationMiddleware',
+     'django.contrib.messages.middleware.MessageMiddleware',
++    'minidetector.Middleware',
+ )
+ 
+ ROOT_URLCONF = 'testproject.urls'