Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example Project #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin
from chessopeningtrainer.models import Opening

admin.site.register(Opening)

# Register your models here.
5 changes: 5 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig

class ChessopeningtrainerConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'chessopeningtrainer'
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import csv
from django.core.management.base import BaseCommand
from django.conf import settings
from chessopeningtrainer.models import Opening

class Command(BaseCommand):
help = 'Populates the database with opening data'

def handle(self, *args, **options):
opening_files = ['a.tsv', 'b.tsv', 'c.tsv', 'd.tsv', 'e.tsv']

for file in opening_files:
file_path = os.path.join(settings.BASE_DIR, 'chessopeningtrainer', 'openings', file)
with open(file_path) as tsvfile:
reader = csv.reader(tsvfile, delimiter='\t')
for row in reader:
opening = Opening()
opening.eco = row[0]
opening.name = row[1]
opening.pgn = row[2]
opening.save()
self.stdout.write(self.style.SUCCESS('Successfully populated database'))
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2 on 2023-04-24 15:08

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Opening',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('pgn', models.TextField()),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2 on 2023-04-24 23:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('chessopeningtrainer', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='opening',
name='eco',
field=models.CharField(default='', max_length=255),
),
]
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.db import models

class Opening(models.Model):
eco = models.CharField(max_length=255, default='')
name = models.CharField(max_length=255)
pgn = models.TextField()

# Create your models here.
705 changes: 705 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/openings/a.tsv

Large diffs are not rendered by default.

732 changes: 732 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/openings/b.tsv

Large diffs are not rendered by default.

1,166 changes: 1,166 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/openings/c.tsv

Large diffs are not rendered by default.

512 changes: 512 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/openings/d.tsv

Large diffs are not rendered by default.

291 changes: 291 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/openings/e.tsv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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/
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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.
82 changes: 82 additions & 0 deletions projectexample/openingtrainer/chessopeningtrainer/static/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*! 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;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.openinglist {
list-style: none;
padding: 0;
margin: 0;
border-collapse: collapse;
border: 2px solid black;
text-align: left;
}

.openinglist li {
margin-bottom: 10px;
}


.openinglist li span {
display: table-cell;
padding: 5px;
border-left: 1px solid black;
}

.searchfilter {
width: 100%; /* Full-width */
font-size: 16px; /* Increase font-size */
padding: 12px 20px 12px 40px; /* Add some padding */
border: 1px solid #ddd; /* Add a grey border */
margin-bottom: 12px; /* Add some space below the input */
}

#reset {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}

#undo {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],

rules: {
// allow while(true) loops
'no-constant-condition': ['error', { checkLoops: false }],
'@typescript-eslint/naming-convention': [
'error',
{
selector: ['default'],
format: ['strictCamelCase'],
leadingUnderscore: 'allow',
},
{
selector: ['variable'],
format: ['strictCamelCase', 'UPPER_CASE'],
},
{
selector: ['objectLiteralProperty'],
format: ['strictCamelCase', 'UPPER_CASE'],
},
{
selector: ['typeLike'],
format: ['PascalCase'],
},
],
'multiline-comment-style': ['error', 'starred-block']
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage/
package-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"semi": false,
"singleQuote": true,
"overrides": [
{
"files": "**/*.md",
"options": {
"parser": "markdown",
"printWidth": 80,
"proseWrap": "always"
}
},
{
"files": "**/*.json",
"options": {
"parser": "json",
"tabWidth": 2
}
}
]
}
Loading