Skip to content

Commit 1195fd9

Browse files
committed
React dependencies, gulp tasks, npm package
1 parent ccfc410 commit 1195fd9

File tree

16 files changed

+115
-16
lines changed

16 files changed

+115
-16
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
*.sqlite3
44
*.sql
55

6-
### IntelliJ ###
76
*.iml
87
*.ipr
98
*.iws
10-
.idea/
9+
.idea
10+
11+
node_modules
12+
static/dist/js

README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Django/React skeleton 0.0.1
2+
## Realtime Slack integration for Django projects using Tornado and React
3+
1. Install python dependencies `sudo pip install -r requirements.txt`
4+
2. Install `sudo npm install`
5+
3. Run `gulp` to compile React code
6+
4. Run `gulp watch` to recompile on auto update

djslack/templates/base.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
{% load i18n %}
2+
{% load static %}
3+
14
<!DOCTYPE html>
25
<html>
36
<head lang="en">
47
<meta charset="UTF-8">
8+
9+
<link rel="stylesheet" href="{% static 'dist/css/main.css' %}"/>
10+
511
<title>Django Slack Chat</title>
612
</head>
713
<body>
@@ -23,5 +29,8 @@
2329
<a href='{% url 'slack_auth' %}'>Get slacked</a>
2430
{% endif %}
2531
{% endblock %}
32+
33+
<script src="{% static 'dist/js/main.js' %}"></script>
34+
2635
</body>
2736
</html>

djslack/templates/slack.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
2-
<script>
3-
$(document).ready(function () {
4-
$('#main').on('click', function () {
1+
<div id="slack-container"></div>
52

6-
}
7-
});
8-
</script>
93

10-
<textarea></textarea>
11-
<br/>
12-
<a href='{% url '' %}'>Connect</a>

djslack/views.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ def dispatch(self, request, *args, **kwargs):
2525
return super(SlackAuthView, self).dispatch(request, *args, **kwargs)
2626

2727
def get(self, request, *args, **kwargs):
28-
import ipdb
29-
ipdb.set_trace()
3028
code = request.GET.get('code')
3129
if not code:
3230
return self.auth_request()

frontend/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @jsx React.DOM */
2+
3+
var ChatArea = require('./components/ChatArea');
4+
var React = require('react');
5+
6+
React.renderComponent(
7+
<ChatArea />,
8+
document.getElementById('slack-container')
9+
);

frontend/components/ChatArea.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/** @jsx React.DOM */
2+
3+
var React = require('react');
4+
5+
var ChatArea = React.createClass({
6+
render: function () {
7+
return (
8+
<div className='chat-wrapper'>
9+
<button>Instantiate connection</button>
10+
<textarea className='chat-frame'></textarea>
11+
</div>
12+
)
13+
}
14+
});
15+
16+
module.exports = ChatArea;

gulpfile.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var gulp = require('gulp');
2+
var browserify = require('gulp-browserify');
3+
var concat = require('gulp-concat');
4+
5+
gulp.task('browserify', function() {
6+
gulp.src('frontend/app.js')
7+
.pipe(browserify({transform: 'reactify'}))
8+
.pipe(concat('main.js'))
9+
.pipe(gulp.dest('static/dist/js'));
10+
});
11+
12+
gulp.task('default', ['browserify']);
13+
14+
gulp.task('watch', function () {
15+
gulp.watch('frontend/**/*.*', ['default']);
16+
});

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55
if __name__ == "__main__":
6-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings.local")
77

88
from django.core.management import execute_from_command_line
99

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "djslack",
3+
"version": "0.0.1",
4+
"description": "Slack integration for Django projects using ReactJS as a view layer.",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/izdi/djslack.git"
12+
},
13+
"keywords": [
14+
"python",
15+
"django",
16+
"react",
17+
"tornado"
18+
],
19+
"author": "izdi",
20+
"license": "ISC",
21+
"bugs": {
22+
"url": "https://github.com/izdi/djslack/issues"
23+
},
24+
"homepage": "https://github.com/izdi/djslack",
25+
"dependencies": {
26+
"gulp": "^3.8.11",
27+
"gulp-browserify": "^0.5.1",
28+
"gulp-concat": "^2.5.2",
29+
"react": "^0.12.2",
30+
"reactify": "^1.0.0"
31+
}
32+
}

0 commit comments

Comments
 (0)