diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ff325a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.pyc +*~ +dist +build +django_webpacker.egg-info/ +sample_project/node_modules/ +sample_project/static/webpack_bundles/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6fe59e0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: python + +python: + - "3.4" + +install: + - python setup.py install + - pip install coveralls + +script: + - coverage run --source=testapp sample_project/manage.py test + +after_success: + coveralls \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..462d55a --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include README.rst +recursive-include django_webpacker/management * \ No newline at end of file diff --git a/README.rst b/README.rst index 2bcc558..1d17917 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,23 @@ django-webpacker's documentation: ===================================== -#badges +.. image:: https://readthedocs.org/projects/django-webpacker/badge/?version=latest + :target: http://django-webpacker.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. image:: https://coveralls.io/repos/github/MicroPyramid/django-webpacker/badge.svg?branch=master + :target: https://coveralls.io/github/MicroPyramid/django-webpacker?branch=master + +.. image:: https://travis-ci.org/MicroPyramid/django-webpacker.svg?branch=master + :target: https://travis-ci.org/MicroPyramid/django-webpacker + +.. image:: https://landscape.io/github/MicroPyramid/django-webpacker/master/landscape.svg?style=flat + :target: https://landscape.io/github/MicroPyramid/django-webpacker/master + :alt: Code Health + +.. image:: https://img.shields.io/github/license/micropyramid/django-webpacker.svg + :target: https://pypi.python.org/pypi/django-webpacker/ + Introduction: ============= diff --git a/django_webpacker/management/commands/__init__.py b/django_webpacker/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/index.rst b/docs/source/index.rst index bfde824..2eca6ad 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,8 +1,6 @@ django-webpacker's documentation: ===================================== -#badges - Introduction: ============= diff --git a/sample_project/manage.py b/sample_project/manage.py new file mode 100755 index 0000000..db62fa4 --- /dev/null +++ b/sample_project/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample_project.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/sample_project/package.json b/sample_project/package.json new file mode 100644 index 0000000..2e22c42 --- /dev/null +++ b/sample_project/package.json @@ -0,0 +1,36 @@ +{ + "name": "sample_project", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "babel": "^6.23.0", + "babel-core": "^6.24.0", + "babel-loader": "^6.4.1", + "css-loader": "^0.28.0", + "extract-text-webpack-plugin": "^2.1.0", + "file-loader": "^0.11.1", + "html-webpack-inline-source-plugin": "0.0.7", + "html-webpack-plugin": "^2.28.0", + "image-webpack-loader": "^3.3.0", + "less-loader": "^4.0.3", + "node-sass": "^4.5.2", + "react": "^15.4.2", + "react-hot-loader": "^1.3.1", + "sass-loader": "^6.0.3", + "script-loader": "^0.7.0", + "style-loader": "^0.16.1", + "webpack": "^2.3.3", + "webpack-bundle-tracker": "^0.2.0", + "webpack-dev-server": "^2.4.2" + }, + "dependencies": { + "imports-loader": "^0.7.1", + "jquery": "^3.2.1" + } +} diff --git a/sample_project/requirements.txt b/sample_project/requirements.txt new file mode 100644 index 0000000..6abbe5d --- /dev/null +++ b/sample_project/requirements.txt @@ -0,0 +1,3 @@ +boto==2.46.1 +Django==1.9.13 +django-webpacker==0.1.1 diff --git a/sample_project/sample_project/__init__.py b/sample_project/sample_project/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sample_project/sample_project/settings.py b/sample_project/sample_project/settings.py new file mode 100644 index 0000000..3f34b58 --- /dev/null +++ b/sample_project/sample_project/settings.py @@ -0,0 +1,86 @@ +import os + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +SECRET_KEY = '8&=h22)%v2_ii66p30-6=3_v%(&ujs83q=l1@m^fd6#t&00tr&' + +DEBUG = True + +ALLOWED_HOSTS = [] + + + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django_webpacker', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'sample_project.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'sample_project.wsgi.application' + + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + +STATIC_URL = '/static/' + + +STATIC_URL = '/static/' + +STATICFILES_DIRS = (BASE_DIR + '/static',) + + +STATICFILES_FINDERS = ( + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + # other finders.. +) + +WEB_PACK_FILES = [ + {'html_file_name': 'templates/index.html', + 'webpack_js': 'index', + }, + {'html_file_name': 'templates/login.html', + 'webpack_js': 'login', + }, +] + +ENABLE_DJANGO_WEBPACK_S3_STORAGES = False +AWS_BUCKET_NAME = '' \ No newline at end of file diff --git a/sample_project/sample_project/urls.py b/sample_project/sample_project/urls.py new file mode 100644 index 0000000..907acdd --- /dev/null +++ b/sample_project/sample_project/urls.py @@ -0,0 +1,24 @@ +"""sample_project URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.10/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url +from django.contrib import admin +from testapp.views import * + +urlpatterns = [ + url(r'^admin/', admin.site.urls), + url(r'^$', index), + url(r'^login/$', login_page, name="login_page"), +] diff --git a/sample_project/sample_project/wsgi.py b/sample_project/sample_project/wsgi.py new file mode 100644 index 0000000..4a9ed68 --- /dev/null +++ b/sample_project/sample_project/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for sample_project project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sample_project.settings") + +application = get_wsgi_application() diff --git a/sample_project/static/css/login.css b/sample_project/static/css/login.css new file mode 100644 index 0000000..543eada --- /dev/null +++ b/sample_project/static/css/login.css @@ -0,0 +1,6 @@ +body{ + color: #ddd; +} +a{ + color: blue; +} \ No newline at end of file diff --git a/sample_project/static/css/main.css b/sample_project/static/css/main.css new file mode 100644 index 0000000..bbd9d49 --- /dev/null +++ b/sample_project/static/css/main.css @@ -0,0 +1,6 @@ +body{ + color: #ddd; +} +a{ + color: red; +} \ No newline at end of file diff --git a/sample_project/static/js/login.js b/sample_project/static/js/login.js new file mode 100644 index 0000000..df19f2f --- /dev/null +++ b/sample_project/static/js/login.js @@ -0,0 +1,3 @@ +$('#login').click(function(e){ + alert("click on login 123") +}) \ No newline at end of file diff --git a/sample_project/static/js/main.js b/sample_project/static/js/main.js new file mode 100644 index 0000000..0293c98 --- /dev/null +++ b/sample_project/static/js/main.js @@ -0,0 +1,3 @@ +$('#hello_world').click(function(e){ + alert("click on hello world 123") +}) \ No newline at end of file diff --git a/sample_project/templates/index.html b/sample_project/templates/index.html new file mode 100644 index 0000000..e6e7e18 --- /dev/null +++ b/sample_project/templates/index.html @@ -0,0 +1,11 @@ + + +
+