Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

created template for project

  • Loading branch information...
commit 6d4380972a9e226361200bdd0544465837dc7117 1 parent eab976e
Roman Gladkov authored
1  .gitignore
View
@@ -12,6 +12,7 @@ var
sdist
develop-eggs
.installed.cfg
+.idea
# Installer logs
pip-log.txt
13 README.md
View
@@ -1,4 +1,13 @@
-django-on-rails
+django on rails
===============
-Skeleton of django project with included webassets, south, sass, coffeescript and haml. Inspired Ruby on Rails.
+Skeleton of Django project with included webassets, south, sass, coffeescript and haml. Inspired Ruby on Rails.
+
+
+# Installation
+
+```
+$ curl https://raw.github.com/d1ffuz0r/djrails/master/bootstrap.sh > bootstrap.sh
+$ chmod +x bootstrap.sh
+$ ./bootstrap.sh project
+```
12 bootstrap.sh
View
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+PROJECT_NAME=$1
+PATH_TO_TEMPLATE=https://github.com/d1ffuz0r/djrails/zipball/master
+
+if [ ! -d $PROJECT_NAME ]; then
+ django-admin.py startproject $PROJECT_NAME --template $PATH_TO_TEMPLATE -v 2
+ echo "project $PROJECT_NAME was created"
+ pip install -r $PROJECT_NAME/pipfile
+else
+ echo "project $PROJECT_NAME already exists"
+fi;
1  project_name/apps/__init__.py
View
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
0  project_name/apps/project_name/__init__.py
View
No changes.
14 project_name/apps/project_name/assets.py
View
@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+
+from django_assets import Bundle, register
+
+js = Bundle('js/home.coffee',
+ filters='coffeescript',
+ output='gen/javascript.js')
+
+css = Bundle('css/home.ccss',
+ filters='clevercss',
+ output='gen/all.css')
+
+register('js_all', js)
+register('css_all', css)
3  project_name/apps/project_name/models.py
View
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
6 project_name/apps/project_name/static/css/home.ccss
View
@@ -0,0 +1,6 @@
+body:
+ color: #bbffa2
+
+h2:
+ color: #000
+ font-family: Tahoma
1  project_name/apps/project_name/static/js/home.coffee
View
@@ -0,0 +1 @@
+alert "It works!"
16 project_name/apps/project_name/templates/home.haml
View
@@ -0,0 +1,16 @@
+!!! 5
+%html
+ %head
+ {% load assets %}
+ {% assets "js_all" %}
+ %script{'type': 'text/javascript',
+ 'src': '{{ ASSET_URL }}'}
+ {% endassets %}
+ {% assets "css_all" %}
+ %link{'rel': 'stylesheet', 'href': '{{ ASSET_URL }}',
+ 'type': 'text/css', 'charset': 'utf-8',
+ 'media': 'screen'}
+ {% endassets %}
+ %body
+ %h2
+ It works!
16 project_name/apps/project_name/tests.py
View
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
7 project_name/apps/project_name/views.py
View
@@ -0,0 +1,7 @@
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+
+def home(request):
+ return render_to_response('home.haml',
+ context_instance=RequestContext(request))
10 project_name/manage.py
View
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
+
+ from django.core.management import execute_from_command_line
+
+ execute_from_command_line(sys.argv)
8 project_name/pipfile
View
@@ -0,0 +1,8 @@
+django>=1.4
+djaml
+hamlpy
+pygments
+clevercss
+south
+-e git://github.com/miracle2k/webassets.git#egg=webassets
+-e git://github.com/miracle2k/django-assets.git#egg=django-assets
0  project_name/project_name/__init__.py
View
No changes.
171 project_name/project_name/settings.py
View
@@ -0,0 +1,171 @@
+# Django settings for {{ project_name }} project.
+
+import os
+
+PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__) + "../../")
+
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = (
+ # ('Your Name', 'your_email@example.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+ 'NAME': '{{ project_name }}', # Or path to database file if using sqlite3.
+ 'USER': '', # Not used with sqlite3.
+ 'PASSWORD': '', # Not used with sqlite3.
+ 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
+ 'PORT': '', # Set to empty string for default. Not used with sqlite3.
+ }
+}
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# In a Windows environment this must be set to your system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = True
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = True
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = ''
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = '/static/'
+
+# Additional locations of static files
+STATICFILES_DIRS = (
+ # Put strings here, like "/home/html/static" or "C:/www/django/static".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+ 'django_assets.finders.AssetsFinder',
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+)
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'c4^tm8q0&@#6)uhanpm7sm3xsp=r558f6kse6q+(lr&ca(ds-c'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ '{{ project_name }}.template_loaders.DjamlFilesystemLoader',
+ '{{ project_name }}.template_loaders.DjamlAppDirectoriesLoader',
+ 'django.template.loaders.filesystem.Loader',
+ 'django.template.loaders.app_directories.Loader',
+# 'django.template.loaders.eggs.Loader',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+)
+
+ROOT_URLCONF = '{{ project_name }}.urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = '{{ project_name }}.wsgi.application'
+
+TEMPLATE_DIRS = (
+ os.path.join(PROJECT_ROOT, 'templates'),
+ # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
+ # Always use forward slashes, even on Windows.
+ # Don't forget to use absolute paths, not relative paths.
+)
+
+FIXTURE_DIRS = (
+ os.path.join(PROJECT_ROOT, 'fixtures'),
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+ 'django.contrib.admin',
+ 'south',
+ 'django_assets',
+ 'apps.{{ project_name }}',
+ # Uncomment the next line to enable admin documentation:
+ # 'django.contrib.admindocs',
+)
+
+# Assets config
+
+ASSETS_URL = '/static/'
+ASSETS_DEBUG = True
+ASSETS_AUTO_BUILD = True
+
+
+# A sample logging configuration. The only tangible logging
+# performed by this configuration is to send an email to
+# the site admins on every HTTP 500 error when DEBUG=False.
+# See http://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+LOGGING = {
+ 'version': 1,
+ 'disable_existing_loggers': False,
+ 'filters': {
+ 'require_debug_false': {
+ '()': 'django.utils.log.RequireDebugFalse'
+ }
+ },
+ 'handlers': {
+ 'mail_admins': {
+ 'level': 'ERROR',
+ 'filters': ['require_debug_false'],
+ 'class': 'django.utils.log.AdminEmailHandler'
+ }
+ },
+ 'loggers': {
+ 'django.request': {
+ 'handlers': ['mail_admins'],
+ 'level': 'ERROR',
+ 'propagate': True,
+ },
+ }
+}
10 project_name/project_name/template_loaders.py
View
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+"""
+Hack for djaml, library not supported django 1.4
+"""
+
+from django.template.loaders import filesystem, app_directories
+from djaml.loaders import get_haml_loader
+
+DjamlFilesystemLoader = get_haml_loader(filesystem)
+DjamlAppDirectoriesLoader = get_haml_loader(app_directories)
28 project_name/project_name/urls.py
View
@@ -0,0 +1,28 @@
+from django.conf.urls import patterns, include, url
+from django.contrib import admin
+import settings
+
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+ url(r'^$', 'apps.{{ project_name }}.views.home', name='home'),
+ # url(r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')),
+
+ # Uncomment the admin/doc line below to enable admin documentation:
+ # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
+ # url(r'^admin/', include(admin.site.urls)),
+)
+
+if settings.DEBUG:
+ urlpatterns += patterns('',
+ url(r'^media/(?P<path>.*)$',
+ 'django.views.static.serve',
+ {'document_root': settings.MEDIA_ROOT}
+ ),
+ url(r'^static/(?P<path>.*)$',
+ 'django.views.static.serve',
+ {'document_root': settings.STATIC_ROOT}
+ ),
+
+ )
28 project_name/project_name/wsgi.py
View
@@ -0,0 +1,28 @@
+"""
+WSGI config for project_name project.
+
+This module contains the WSGI application used by Django's development server
+and any production WSGI deployments. It should expose a module-level variable
+named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
+this application via the ``WSGI_APPLICATION`` setting.
+
+Usually you will have the standard Django WSGI application here, but it also
+might make sense to replace the whole Django WSGI application with a custom one
+that later delegates to the Django one. For example, you could introduce WSGI
+middleware here, or combine a Django application with an application of another
+framework.
+
+"""
+import os
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
+
+# This application object is used by any WSGI server configured to use this
+# file. This includes Django's development server, if the WSGI_APPLICATION
+# setting points here.
+from django.core.wsgi import get_wsgi_application
+application = get_wsgi_application()
+
+# Apply WSGI middleware here.
+# from helloworld.wsgi import HelloWorldApplication
+# application = HelloWorldApplication(application)
Please sign in to comment.
Something went wrong with that request. Please try again.