Commits

Hector Garcia committed b4353f7

Made some modifications to append python code from files instead of harcoded strings in setup.py. Reorganized files and folders structures. Added README in extras folder. And more stuff.

Comments (0)

Files changed (21)

TODO

-* Create fixture to populate django.contrib.sites with project domain name, substituting example.com
-

conf/first_deploy

 # This file aims to be a quick list of cmds to deploy a project without
-# any deployment system e.g. Fabric. I reccommend using systems like
-# Fabric, though.
+# any deployment system. I reccommend using systems like Fabric, though.
 # You probably will need to replace these cmds to yours. Just keep the
 # paths like, for instance, /path/to/apache/available-sites/, as these
 # are automatically replaced by django-nbskel during the setup.py process,

conf/localsettings.py

-import os
-from settings import *
-
-# Static media
-MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media')
-MEDIA_URL = '/media/'
-ADMIN_MEDIA_PREFIX = '/media/admin/'
-
-# Flags that enable/disable other settings
-DEBUG = True
-USE_LOCALIZATION = False
-
-# Database
-DATABASES = {
-    'default': {
-        'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': os.path.join(os.path.dirname(__file__), 'dev.db'),
-    }
-}
-
-# Template settings
-TEMPLATE_DEBUG = DEBUG
-TEMPLATE_DIRS = (
-    os.path.join(os.path.dirname(__file__), 'templates'),
-)
-
-# Localization
-if USE_LOCALIZATION:
-    ugettext = lambda s: s
-    # Replace with your languages
-    LANGUAGES = (
-        ('en', ugettext('English')),
-        ('es', ugettext('Spanish')),
-        ('it', ugettext('Italian')),
-    )
-    MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + \
-        ('django.middleware.locale.LocaleMiddleware',)
-
-# Debug Toolbar
-INTERNAL_IPS = ('127.0.0.1')
-INSTALLED_APPS = INSTALLED_APPS + ('debug_toolbar',)
-MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + \
-    ('debug_toolbar.middleware.DebugToolbarMiddleware',)
-DEBUG_TOOLBAR_CONFIG = {
-    'INTERCEPT_REDIRECTS': False,
-}
-

conf/requirements.txt

-Django>=1.1
+Django>=1.2
 http://effbot.org/downloads/Imaging-1.1.7.tar.gz
 ipdb
 django-extensions
     nbskel_dir = os.path.join(root_dir, 'nbskel')
     prj_dir = os.path.join(root_dir, PROJECT)
 
-    # Copy initial data fixture and localsettings
-    fixt_src = os.path.join(nbskel_dir, 'initial_data.json')
-    shutil.copy(fixt_src, prj_dir)
-    local_settings = os.path.join(conf_dir, 'localsettings.py')
+    # Copy localsettings
+    #fixt_src = os.path.join(nbskel_dir, 'initial_data.json')
+    #shutil.copy(fixt_src, prj_dir)
+    #local_settings = os.path.join(conf_dir, 'localsettings.py')
+    local_settings = os.path.join(nbskel_dir, 'localsettings.py')
     shutil.copy(local_settings, prj_dir)
 
     # Append static serve to urls
     global_urls = os.path.join(prj_dir, 'urls.py')
+    fd = open(os.path.join(nbskel_dir, 'static_urls.py'))
+    data = fd.read()
+    fd.close()
     with open(global_urls, 'a') as prj_file:
-        prj_file.write("""
-from django.conf import settings
-if settings.DEBUG:
-    import os
-    urlpatterns += patterns('',
-        url(
-            regex=r'^media/(?P<path>.*)$',
-            view='django.views.static.serve',
-            kwargs={'document_root': os.path.join(os.path.dirname(__file__),
-                    'media')},
-        )
-    )
-""")
+        prj_file.write(data)
+
+    # Append local settings import in global settings file
+    global_settings = os.path.join(prj_dir, 'settings.py')
+    fd = open(os.path.join(nbskel_dir, 'settings_import.py'))
+    data = fd.read()
+    fd.close()
+    with open(global_settings, 'a') as prj_file:
+        prj_file.write(data)
 
     # List of files to modify
     old_files = [

nbskel/extras/README

+======
+Extras
+======
+
+initial_data.json
+=================
+
+It helps the tedious process of creating a django admin user
+and setting the Site to localhost:8000.
+
+Usage
+-----
+
+From the root project directory::
+
+    python manage.py loaddata ../nbskel/extras/initial_data.json
+
+``templates``
+=============
+
+Copy this folder to your project to get your base template.
+
+Usage
+-----
+
+From the root project directory::
+
+    cp -R ../nbskel/extras/templates/ templates
+
+``website``
+===========
+
+A django app I use to quickly test stuff, or as a start point
+to something like the app that will hold stuff not related to anything
+in particular, but to the project website.
+
+Usage
+-----
+
+From the root project directory::
+
+    cp -R ../nbskel/extras/website/ website
+
+
+Add the app to your ``INSTALLED_APPS`` setting::
+
+    INSTALLED_APPS = (
+        ...
+        'website',
+    )
+
+Include the ``website/urls.py`` to your base ``urls.py``::
+
+    (r'^website/', include('website.urls')),
+    

nbskel/extras/initial_data.json

+[
+  {
+    "pk": 1, 
+    "model": "auth.user", 
+    "fields": {
+      "username": "admin", 
+      "first_name": "", 
+      "last_name": "", 
+      "is_active": true, 
+      "is_superuser": true, 
+      "is_staff": true, 
+      "last_login": "2010-07-12 11:01:13", 
+      "groups": [], 
+      "user_permissions": [], 
+      "password": "sha1$855a7$72dda34565675a5f6639630468aade6418e8751c", 
+      "email": "a@a.com", 
+      "date_joined": "2010-07-12 11:01:13"
+    }
+  },
+  {
+    "pk": 1, 
+    "model": "sites.site", 
+    "fields": {
+      "domain": "localhost:8000", 
+      "name": "localhost:8000"
+    }
+  }
+]

nbskel/extras/templates/base.html

+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+
+<html>
+
+<head>
+    <title>Hello World</title>
+</head>
+
+<body>
+
+<form action="/i18n/setlang/" method="post">
+    <input name="next" type="hidden" value="{{ request.path }}" />
+    <select name="language">
+        {% for lang in LANGUAGES %}
+        <option value="{{ lang.0 }}" {% ifequal request.LANGUAGE_CODE lang.0 %}selected="selected"{% endifequal %}>{{ lang.1 }}</option>
+        {% endfor %}
+    </select>
+    <input type="submit" value="Go" />
+</form>
+
+{% block content %}<h1>Hello world</h1>{% endblock content %}
+
+</body>
+
+</html>

nbskel/extras/website/__init__.py

Empty file added.

nbskel/extras/website/templates/website_home.html

+{% extends 'base.html' %}
+
+{% block content %}
+    <h1>Hello world</h1>
+{% endblock %}

nbskel/extras/website/urls.py

+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('website.views',
+    url(
+        regex=r'^$',
+        view='home',
+        name='home',
+        kwargs={'template': 'website_home.html'},
+    ),
+)

nbskel/extras/website/views.py

+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+
+def home(request, template):
+    ctxt = RequestContext(request)
+    return render_to_response(template, context_instance=ctxt)

nbskel/initial_data.json

-[
-  {
-    "pk": 1, 
-    "model": "auth.user", 
-    "fields": {
-      "username": "admin", 
-      "first_name": "", 
-      "last_name": "", 
-      "is_active": true, 
-      "is_superuser": true, 
-      "is_staff": true, 
-      "last_login": "2010-07-12 11:01:13", 
-      "groups": [], 
-      "user_permissions": [], 
-      "password": "sha1$855a7$72dda34565675a5f6639630468aade6418e8751c", 
-      "email": "a@a.com", 
-      "date_joined": "2010-07-12 11:01:13"
-    }
-  },
-  {
-    "pk": 1, 
-    "model": "sites.site", 
-    "fields": {
-      "domain": "localhost:8000", 
-      "name": "localhost:8000"
-    }
-  }
-]

nbskel/localsettings.py

+import os
+from settings import *
+
+# Static media
+MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media')
+MEDIA_URL = '/media/'
+ADMIN_MEDIA_PREFIX = '/media/admin/'
+
+# Flags that enable/disable other settings
+DEBUG = True
+USE_LOCALIZATION = False
+
+# Database
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': os.path.join(os.path.dirname(__file__), 'dev.db'),
+    }
+}
+
+# Template settings
+TEMPLATE_DEBUG = DEBUG
+TEMPLATE_DIRS = (
+    os.path.join(os.path.dirname(__file__), 'templates'),
+)
+
+# Localization
+if USE_LOCALIZATION:
+    ugettext = lambda s: s
+    # Replace with your languages
+    LANGUAGES = (
+        ('en', ugettext('English')),
+        ('es', ugettext('Spanish')),
+        ('it', ugettext('Italian')),
+    )
+    MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + \
+        ('django.middleware.locale.LocaleMiddleware',)
+
+# Debug Toolbar
+INTERNAL_IPS = ('127.0.0.1')
+INSTALLED_APPS = INSTALLED_APPS + ('debug_toolbar',)
+MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + \
+    ('debug_toolbar.middleware.DebugToolbarMiddleware',)
+DEBUG_TOOLBAR_CONFIG = {
+    'INTERCEPT_REDIRECTS': False,
+}
+

nbskel/settings_import.py

+
+# Try to use local settings, fail silently
+# if file does not exist
+try:
+    from localsettings import *
+except ImportError:
+    pass
+

nbskel/static_urls.py

+
+# Serve static media in debug mode
+from django.conf import settings
+if settings.DEBUG:
+    import os
+    urlpatterns += patterns('',
+        (r'^%s/(?P<path>.*)$' % settings.MEDIA_URL.strip(os.sep),
+            'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
+    )
+

nbskel/templates/base.html

-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
-"http://www.w3.org/TR/html4/strict.dtd">
-
-<html>
-
-<head>
-    <title>Hello World</title>
-</head>
-
-<body>
-
-<form action="/i18n/setlang/" method="post">
-    <input name="next" type="hidden" value="{{ request.path }}" />
-    <select name="language">
-        {% for lang in LANGUAGES %}
-        <option value="{{ lang.0 }}" {% ifequal request.LANGUAGE_CODE lang.0 %}selected="selected"{% endifequal %}>{{ lang.1 }}</option>
-        {% endfor %}
-    </select>
-    <input type="submit" value="Go" />
-</form>
-
-{% block content %}
-{% endblock content %}
-</body>
-
-</html>

nbskel/website/__init__.py

Empty file removed.

nbskel/website/templates/website_home.html

-{% extends 'base.html' %}
-
-{% block content %}
-    <h1>Hello world</h1>
-{% endblock %}

nbskel/website/urls.py

-from django.conf.urls.defaults import *
-
-urlpatterns = patterns('website.views',
-    url(
-        regex=r'^$',
-        view='home',
-        name='home',
-        kwargs={'template': 'website_home.html'},
-    ),
-)

nbskel/website/views.py

-from django.shortcuts import render_to_response
-from django.template import RequestContext
-
-
-def home(request, template):
-    ctxt = RequestContext(request)
-    return render_to_response(template, context_instance=ctxt)