Skip to content

Commit

Permalink
React dependencies, gulp tasks, npm package
Browse files Browse the repository at this point in the history
  • Loading branch information
izdi committed Mar 7, 2015
1 parent ccfc410 commit 1195fd9
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 16 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
*.sqlite3
*.sql

### IntelliJ ###
*.iml
*.ipr
*.iws
.idea/
.idea

node_modules
static/dist/js
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Django/React skeleton 0.0.1
## Realtime Slack integration for Django projects using Tornado and React
1. Install python dependencies `sudo pip install -r requirements.txt`
2. Install `sudo npm install`
3. Run `gulp` to compile React code
4. Run `gulp watch` to recompile on auto update
9 changes: 9 additions & 0 deletions djslack/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{% load i18n %}
{% load static %}

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">

<link rel="stylesheet" href="{% static 'dist/css/main.css' %}"/>

<title>Django Slack Chat</title>
</head>
<body>
Expand All @@ -23,5 +29,8 @@
<a href='{% url 'slack_auth' %}'>Get slacked</a>
{% endif %}
{% endblock %}

<script src="{% static 'dist/js/main.js' %}"></script>

</body>
</html>
11 changes: 1 addition & 10 deletions djslack/templates/slack.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
$(document).ready(function () {
$('#main').on('click', function () {
<div id="slack-container"></div>

}
});
</script>

<textarea></textarea>
<br/>
<a href='{% url '' %}'>Connect</a>
2 changes: 0 additions & 2 deletions djslack/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def dispatch(self, request, *args, **kwargs):
return super(SlackAuthView, self).dispatch(request, *args, **kwargs)

def get(self, request, *args, **kwargs):
import ipdb
ipdb.set_trace()
code = request.GET.get('code')
if not code:
return self.auth_request()
Expand Down
9 changes: 9 additions & 0 deletions frontend/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @jsx React.DOM */

var ChatArea = require('./components/ChatArea');
var React = require('react');

React.renderComponent(
<ChatArea />,
document.getElementById('slack-container')
);
16 changes: 16 additions & 0 deletions frontend/components/ChatArea.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @jsx React.DOM */

var React = require('react');

var ChatArea = React.createClass({
render: function () {
return (
<div className='chat-wrapper'>
<button>Instantiate connection</button>
<textarea className='chat-frame'></textarea>
</div>
)
}
});

module.exports = ChatArea;
16 changes: 16 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');

gulp.task('browserify', function() {
gulp.src('frontend/app.js')
.pipe(browserify({transform: 'reactify'}))
.pipe(concat('main.js'))
.pipe(gulp.dest('static/dist/js'));
});

gulp.task('default', ['browserify']);

gulp.task('watch', function () {
gulp.watch('frontend/**/*.*', ['default']);
});
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings.local")

from django.core.management import execute_from_command_line

Expand Down
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "djslack",
"version": "0.0.1",
"description": "Slack integration for Django projects using ReactJS as a view layer.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/izdi/djslack.git"
},
"keywords": [
"python",
"django",
"react",
"tornado"
],
"author": "izdi",
"license": "ISC",
"bugs": {
"url": "https://github.com/izdi/djslack/issues"
},
"homepage": "https://github.com/izdi/djslack",
"dependencies": {
"gulp": "^3.8.11",
"gulp-browserify": "^0.5.1",
"gulp-concat": "^2.5.2",
"react": "^0.12.2",
"reactify": "^1.0.0"
}
}
1 change: 1 addition & 0 deletions project/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 7 additions & 1 deletion project/settings.py → project/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))


# Quick-start development settings - unsuitable for production
Expand Down Expand Up @@ -86,6 +86,12 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

# slack
SLACK_CLIENT_ID = os.environ.get('SLACK_CLIENT_ID')
Expand Down
6 changes: 6 additions & 0 deletions project/settings/local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .base import *


STATIC_ROOT = ''
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'), )

4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
backports.ssl-match-hostname==3.4.0.2
certifi==14.5.14
Django==1.7.3
ipdb==0.8
ipython==2.3.1
psycopg2==2.5.4
requests==2.5.1
tornado==4.1
3 changes: 3 additions & 0 deletions static/dist/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
textarea {
display: block;
}
Empty file added tornado_server.py
Empty file.

0 comments on commit 1195fd9

Please sign in to comment.