Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored templates to make them slightly cleaner.
- Loading branch information
Showing
10 changed files
with
94 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
{{ block.super }} | ||
<h1> {{ chat.name }} </h1> | ||
<textarea name="term" id="inputbox" cols="40" rows="4"></textarea> | ||
<div id="message_list"> | ||
<ul> | ||
</ul> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,8 @@ | ||
{% extends "chats/base_chat.html" %} | ||
{% load staticfiles %} | ||
<html> | ||
<head> | ||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | ||
<script type="text/javascript" src="{% static "long_poll.js" %}"></script> | ||
</head> | ||
{% block header %} | ||
{{ block.super }} | ||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | ||
<script type="text/javascript" src="{% static "long_poll.js" %}"></script> | ||
{% endblock %} | ||
|
||
<h1>{{ chat.name }}</h1> | ||
<textarea name="term" id="inputbox" cols="40" rows="4"></textarea> | ||
<div id="message_list"> | ||
<ul> | ||
</ul> | ||
</div> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
from django.http import HttpResponse | ||
from django.shortcuts import render, get_object_or_404 | ||
from django.contrib.auth.decorators import login_required | ||
|
||
from chat.models import ChatRoom | ||
|
||
@login_required | ||
def index(request): | ||
chat_rooms = ChatRoom.objects.order_by('name')[:5] | ||
context = { | ||
'chat_list': chat_rooms, | ||
} | ||
return render(request,'chats/index.html', context) | ||
|
||
@login_required | ||
def chat_room(request, chat_room_id): | ||
chat = get_object_or_404(ChatRoom, pk=chat_room_id) | ||
return render(request, 'chats/chat_room.html', {'chat': chat}) | ||
|
||
@login_required | ||
def longpoll_chat_room(request, chat_room_id): | ||
chat = get_object_or_404(ChatRoom, pk=chat_room_id) | ||
return render(request, 'chats/longpoll_chat_room.html', {'chat': chat}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "base_generic.html" %} | ||
|
||
{% block title %} | ||
Some Chat App | ||
{% endblock %} | ||
|
||
{% block header %} | ||
Welcome {{ user.username }}! Chat to your heart's content :) <br/><a href="/accounts/logout">logout</a> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<head> | ||
{% block header %} | ||
{% endblock %} | ||
<title>{% block title %}{% endblock %}</title> | ||
</head> | ||
<body> | ||
<!-- header, etc --> | ||
{% block content %} | ||
{% endblock %} | ||
<!-- footer --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "base_generic.html" %} | ||
|
||
{% block content %} | ||
|
||
{% if form.errors %} | ||
<p>Your username and password didn't match. Please try again.</p> | ||
{% endif %} | ||
|
||
<form method="post" action="{% url 'django.contrib.auth.views.login' %}"> | ||
{% csrf_token %} | ||
<table> | ||
<tr> | ||
<td>{{ form.username.label_tag }}</td> | ||
<td>{{ form.username }}</td> | ||
</tr> | ||
<tr> | ||
<td>{{ form.password.label_tag }}</td> | ||
<td>{{ form.password }}</td> | ||
</tr> | ||
</table> | ||
|
||
<input type="submit" value="login" /> | ||
<input type="hidden" name="next" value="{{ next }}" /> | ||
</form> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% extends "base_generic.html" %} | ||
{% block header %} | ||
<script> | ||
function redirect(){ | ||
window.location.href = "/"; | ||
} | ||
|
||
setTimeout(redirect, 2000); | ||
</script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<h2> Logging out ... </h2> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters