yewang / besogo

Embeddable SGF editor/viewer for the game of Go (aka Weiqi, Baduk)
http://yewang.github.io/besogo/
MIT License
101 stars 29 forks source link
baduk board-game boardgame go goban igo javascript sgf sgf-editor weiqi

BesoGo

Embeddable SGF player for the game of Go (aka Weiqi, Baduk)

Written in JavaScript, CSS, and HTML5, with no dependencies on other libraries

Free software released under the MIT License. Some bundled assets are copyright by other authors and available under Creative Commons licensing terms. See "Copying and License" section for further details.

User Notes

BesoGo can be used as a web-based SGF editor, an embeddable SGF viewer, or a board diagram renderer

Online usage

SGF editor based on the latest code snapshot at https://yewang.github.io/besogo/testing.html

With realistic board rendering https://yewang.github.io/besogo/testing.html?theme=wood&realstones=on

Other experimental themes include:

SGF editor based on the latest release (lagging behind the latest snapshot) at https://yewang.github.io/besogo/stable.html

Offline usage

Download the source distribution and open testing.html

Navigation key bindings

Shift-clicking with the auto-move/navigate tool will jump to the move that plays at that point

When entering moves, overwrite, suicide, and basic ko moves are not allowed, but can be enabled by holding down ctrl while clicking

BesoGo supports the SGF standard for Go game records. BesoGo should always output SGF files that comply with the standard (besides the exceptions listed below). BesoGo permissively imports SGF file input, allowing many common SGF syntax errors, while attempting to fix any issues and converting to valid SGF on output.

Exceptions in SGF standard support

Web Dev Guide

See https://yewang.github.io/besogo/ and https://yewang.github.io/besogo/fixedSize.html for some examples of how to embed BesoGo. See https://yewang.github.io/besogo/testing.html for an example full window interface for the editor.

To embed BesoGo editor/viewer in your website

  1. Link the style sheet css/besogo.css and one of the css/board-*.css sheets, which select different board themes (simple, flat, book, dark, wood, etc.). These sheets provide essential rendering parameters and can be modified to customize the layout and style.
  2. Include the combined and minified javascript file besogo-all-min.js.
  3. Add divs with the class besogo-editor, besogo-viewer, or besogo-diagram, e.g.,
    <div class="besogo-editor"></div>
    <div class="besogo-viewer" sgf="gameRecord.sgf"></div>
    <div class="besogo-diagram" panels="comment">
    (;FF[4]GM[1]SZ[9]AB[bb:dd]AW[ee][ff][gg]
    C[This diagram shows a 9x9 board with 9 black stones and 3 white stones placed on it.
    Be sure to properly escape HTML special characters such as &gt;, &lt;, etc.])</div>
  4. Call the auto-initialization function besogo.autoInit() to create widgets for the above divs.

The contents of the div should either be empty or contain SGF text. If SGF text is detected (by starting with "(;", ignoring whitespace), it will be loaded into BesoGo. BesoGo will remove all children from the div and then insert sub-divs building up the GUI.

Security Warning: If your site inserts user-input SGF text directly into the inner HTML of a div, remember to escape any HTML special characters ("<", ">", "&") to avoid XSS vulnerabilities. BesoGo will properly load the intended characters. This is not a security vulnerability within BesoGo, but rather a reminder to use secure practices in your surrounding code.

Options settable via div attributes

Code Doc

Everything is (or at least should be) encapsulated within the name space object besogo

Combining and minifying the JavaScript

./build.sh automatically generates the combined and minified versions (requires shell, cat, curl, and internet access)

Alternatively, you can manually combine and minify as follows

  1. Cobmine the js files into a single file (just ensure that besogo.js is first), e.g., with cat js/* > besogo.all.js
  2. Use the Google Closure Compiler to minify the combined file

JavaScript files in js/ folder

CSS files in css/ folder

Graphical assets in img/ folder

These images are used for realistic board and stone rendering

Change Log

0.0.2-alpha

0.0.1-alpha

0.0.0-alpha

Copying and License

Software Code

The following copyright and license terms only apply to the software code, which consists of all of the files excluding the contents of the img/ directory.

MIT License

Copyright (c) 2015-2018 Ye Wang yewang15@gmail.com

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.

Graphical Assets

The contents of the img/ directory are copyright by other authors and available under the license terms specified below

The following images are from the go-assets repository, available under a Creative Commons Attribution-ShareAlike 4.0 International license. Copyright (C) 2016 Andreas Tarnowsky andreas.tarnowsky@googlemail.com

The following images are from (or derived from) the jgoboard repository, available under a Creative Commons Attribution-NonCommercial 4.0 International license. Copyright (C) 2013 Joonas Pihlajamaa github@joonaspihlajamaa.com

The following images are courtesy of tozgrec (OGS user).