finally split games up; allow websockets from <app>/urls.py

master
Tait Hoyem 2 years ago
parent 1ce91b1871
commit 577c59d4cf

@ -1,7 +1,12 @@
from django.urls import path
from django.urls import path, re_path
from . import views
from . import consumers
urlpatterns = [
path('', views.index, name='chat')
]
]
websocket_urlpatterns = [
re_path(r'ws/chat/(?P<room_name>\w+)/$', consumers.ChatConsumer.as_asgi ()),
]

@ -1,3 +0,0 @@
from django.contrib import admin
# Register your models here.

@ -1,5 +0,0 @@
from django.apps import AppConfig
class ChessConfig(AppConfig):
name = 'chess'

@ -1,32 +0,0 @@
# chessboard.js Change Log
All notable changes to this project will be documented in this file.
## [1.0.0] - 2019-06-11
- Orientation methods now return current orientation. [Issue #64]
- Drop support for IE8
- Do not check for `window.JSON` (Error #1004)
- Rename `ChessBoard` to `Chessboard` (`ChessBoard` is still supported, however)
- id query selectors are now supported as the first argument to `Chessboard()`
- Remove Error #1002
- Format code according to [StandardJS]
- Bump minimum jQuery version to 1.8.3
- Throttle piece drag functions
## [0.3.0] - 2013-08-10
- Added `appearSpeed` animation config property
- Added `onSnapbackEnd` event
- Added `onMoveEnd` event
## [0.2.0] - 2013-08-05
- Added `onMouseoverSquare` and `onMouseoutSquare` events
- Added `onSnapEnd` event
- Added square code as CSS class on the squares
- Added [chess.js] integration examples
## [0.1.0] - 2013-05-21
- Initial release
[chess.js]:https://github.com/jhlywa/chess.js
[Issue #64]:https://github.com/oakmac/chessboardjs/issues/64
[StandardJS]:https://standardjs.com/

@ -1,20 +0,0 @@
Copyright 2019 Chris Oakman
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1,82 +0,0 @@
# chessboard.js
chessboard.js is a JavaScript chessboard component. It depends on [jQuery].
Please see [chessboardjs.com] for documentation and examples.
## What is chessboard.js?
chessboard.js is a JavaScript chessboard component with a flexible "just a
board" API that
chessboard.js is a standalone JavaScript Chess Board. It is designed to be "just
a board" and expose a powerful API so that it can be used in different ways.
Here's a non-exhaustive list of things you can do with chessboard.js:
- Use chessboard.js to show game positions alongside your expert commentary.
- Use chessboard.js to have a tactics website where users have to guess the best
move.
- Integrate chessboard.js and [chess.js] with a PGN database and allow people to
search and playback games (see [Example 5000])
- Build a chess server and have users play their games out using the
chessboard.js board.
chessboard.js is flexible enough to handle any of these situations with relative
ease.
## What can chessboard.js **not** do?
The scope of chessboard.js is limited to "just a board." This is intentional and
makes chessboard.js flexible for handling a multitude of chess-related problems.
This is a common source of confusion for new users. [remove?]
Specifically, chessboard.js does not understand anything about how the game of
chess is played: how a knight moves, who's turn is it, is White in check?, etc.
Fortunately, the powerful [chess.js] library deals with exactly this sort of
problem domain and plays nicely with chessboard.js's flexible API. Some examples
of chessboard.js combined with chess.js: 5000, 5001, 5002
Please see the powerful [chess.js] library for an API to deal with these sorts
of questions.
This logic is distinct from the logic of the board. Please see the powerful
[chess.js] library for this aspect of your application.
Here is a list of things that chessboard.js is **not**:
- A chess engine
- A legal move validator
- A PGN parser
chessboard.js is designed to work well with any of those things, but the idea
behind chessboard.js is that the logic that controls the board should be
independent of those other problems.
## Docs and Examples
- Docs - <http://chessboardjs.com/docs>
- Examples - <http://chessboardjs.com/examples>
## Developer Tools
```sh
# create a build in the build/ directory
npm run build
# re-build the website
npm run website
```
## License
[MIT License](LICENSE.md)
[jQuery]:https://jquery.com/
[chessboardjs.com]:http://chessboardjs.com
[chess.js]:https://github.com/jhlywa/chess.js
[Example 5000]:http://chessboardjs.com/examples#5000

@ -1,54 +0,0 @@
/*! chessboard.js v1.0.0 | (c) 2019 Chris Oakman | MIT License chessboardjs.com/license */
.clearfix-7da63 {
clear: both;
}
.board-b72b1 {
border: 2px solid #404040;
box-sizing: content-box;
}
.square-55d63 {
float: left;
position: relative;
/* disable any native browser highlighting */
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.white-1e1d7 {
background-color: #f0d9b5;
color: #b58863;
}
.black-3c85d {
background-color: #b58863;
color: #f0d9b5;
}
.highlight1-32417, .highlight2-9c5d2 {
box-shadow: inset 0 0 3px 3px yellow;
}
.notation-322f9 {
cursor: default;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
position: absolute;
}
.alpha-d2270 {
bottom: 1px;
right: 3px;
}
.numeric-fc462 {
top: 2px;
left: 2px;
}

@ -1,2 +0,0 @@
/*! chessboard.js v1.0.0 | (c) 2019 Chris Oakman | MIT License chessboardjs.com/license */
.clearfix-7da63{clear:both}.board-b72b1{border:2px solid #404040;box-sizing:content-box}.square-55d63{float:left;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.white-1e1d7{background-color:#f0d9b5;color:#b58863}.black-3c85d{background-color:#b58863;color:#f0d9b5}.highlight1-32417,.highlight2-9c5d2{box-shadow:inset 0 0 3px 3px #ff0}.notation-322f9{cursor:default;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;position:absolute}.alpha-d2270{bottom:1px;right:3px}.numeric-fc462{top:2px;left:2px}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -1,29 +0,0 @@
{
"author": "Chris Oakman <chris@oakmac.com> (http://chrisoakman.com/)",
"name": "@chrisoakman/chessboardjs",
"description": "JavaScript chessboard widget",
"homepage": "https://chessboardjs.com",
"license": "MIT",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "git://github.com/oakmac/chessboardjs.git"
},
"files": ["dist/"],
"dependencies": {
"jquery": ">=3.4.1"
},
"devDependencies": {
"csso": "3.5.1",
"fs-plus": "3.1.1",
"kidif": "1.1.0",
"mustache": "2.3.0",
"standard": "10.0.2",
"uglify-js": "3.6.0"
},
"scripts": {
"build": "standard lib/chessboard.js && node scripts/build.js",
"standard": "standard --fix lib/*.js website/js/*.js",
"website": "node scripts/website.js"
}
}

@ -1,4 +0,0 @@
from django.db import models
from common.models import LameUser
# Create your models here.

File diff suppressed because it is too large Load Diff

@ -1,2 +0,0 @@
/*! chessboard.js v1.0.0 | (c) 2019 Chris Oakman | MIT License chessboardjs.com/license */
.clearfix-7da63{clear:both}.board-b72b1{border:2px solid #404040;box-sizing:content-box}.square-55d63{float:left;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.white-1e1d7{background-color:#f0d9b5;color:#b58863}.black-3c85d{background-color:#b58863;color:#f0d9b5}.highlight1-32417,.highlight2-9c5d2{box-shadow:inset 0 0 3px 3px #ff0}.notation-322f9{cursor:default;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;position:absolute}.alpha-d2270{bottom:1px;right:3px}.numeric-fc462{top:2px;left:2px}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

@ -1,25 +0,0 @@
{% extends 'common/master.html' %}
{% load static %}
{% block body %}
<link rel="stylesheet" href="{% static 'chess/css/chessboard.css' %}">
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"></script>
<script src="{% static 'chess/chessboard.js' %}"></script>
<style>
</style>
<div id="test">Here is some text</div>
<div id="board" style="width: 800px">
</div>
<script>
var config = {
pieceTheme: "{% static 'chess/img/' %}{piece}.png",
position: 'start',
draggable: true
};
var board = Chessboard('board', config);
</script>
{% endblock %}

@ -1 +0,0 @@
{% extends 'common/master.html' %}

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

@ -1,6 +0,0 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='chess')
]

@ -1,5 +0,0 @@
from django.shortcuts import render
# Create your views here.
def index(request):
return render(request, 'chess/board.html', {})

@ -6,7 +6,7 @@
<ul>
{% for game in games %}
<li>
<a href="{% url game.url %}">{{ game.name }}</a>
<a href="{% url game.url_name %}">{{ game.name }}</a>
</li>
{% endfor %}
</ul>

@ -20,7 +20,7 @@ from .models import LameUser
def index(request):
if request.user.is_authenticated:
return render(request, "signed_in.html", {
"games": settings.VISIBLE_GAME_LINKS,
"games": settings.GAMES,
})
else:
return render(request, "index.html")

@ -10,4 +10,4 @@ application = ProtocolTypeRouter({
lamegames.urls.websocket_urlpatterns
)
),
})
})

@ -36,7 +36,6 @@ INSTALLED_APPS = [
"common",
"channels",
"chat",
"chess",
"minesweeper",
"rps",
"games",
@ -48,27 +47,22 @@ INSTALLED_APPS = [
"django.contrib.staticfiles",
]
VISIBLE_GAME_LINKS = [
GAMES = [
{
"urls": "minesweeper.urls",
"url": "minesweeper",
"module": "minesweeper",
"url_name": "minesweeper",
"name": "Minesweeper (Single-Player)",
},
{
"urls": "rps.urls",
"url": "rps",
"module": "rps",
"url_name": "rps",
"name": "Rock, Paper, Scissors",
},
{
"urls": "chat.urls",
"url": "chat",
"module": "chat",
"url_name": "chat",
"name": "Chat",
},
{
"urls": "chess.urls",
"url": "chess",
"name": "Chess",
},
]
MIDDLEWARE = [

@ -28,11 +28,12 @@ urlpatterns = [
#path('chat/', include('chat.urls')),
#path('games/', include('games.urls')),
#path('chess/', include('chess.urls'))
*[path(game["url"] + "/", include(game["urls"])) for game in settings.VISIBLE_GAME_LINKS]
*[path(game["url_name"], include(game["module"] + ".urls")) for game in settings.GAMES]
]
websocket_urlpatterns = [
re_path(r'ws/chat/(?P<room_name>\w+)/$', chat.consumers.ChatConsumer.as_asgi()),
path('rps/<id>', rps.consumers.RPSConsumer.as_asgi()),
path('minesweeper/', minesweeper.consumers.MinesweeperConsumer.as_asgi())
*[x for game in settings.GAMES for x in __import__(game["module"] + ".urls").urls.websocket_urlpatterns],
#re_path(r'ws/chat/(?P<room_name>\w+)/$', chat.consumers.ChatConsumer.as_asgi()),
#path('rps/<id>', rps.consumers.RPSConsumer.as_asgi()),
#path('minesweeper/', minesweeper.consumers.MinesweeperConsumer.as_asgi()),
]

@ -1,6 +1,11 @@
from django.urls import path
from . import views
from . import consumers
urlpatterns = [
path('minesweeper/', views.minesweeper, name='minesweeper')
]
websocket_urlpatterns = [
path('minesweeper/', consumers.MinesweeperConsumer.as_asgi()),
]

@ -1,10 +1,14 @@
from django.urls import path
from . import views
from . import consumers
urlpatterns = [
path('rps/', views.rps, name="rps"),
path('rps/select', views.rps_select, name="rps/select"),
path('rps/create', views.rps_create, name="rps/create"),
path('rps/join/<room_id>', views.rps_join, name='rps/join'),
path('minesweeper/', views.minesweeper, name='minesweeper')
]
]
websocket_urlpatterns = [
path("rps/<id>", consumers.RPSConsumer.as_asgi()),
]

Loading…
Cancel
Save