A Django package for simple use of Hockeydata Javascript API
Project description
django_hockeydata_api
A Django package for simple use of Hockeydata Javascript API https://apidocs.hockeydata.net/.
Requirements
- Python 2.7+, 3.6+
- Django >= 1.11 (tested with this, earlier versions might work also)
- For details, see https://docs.djangoproject.com/en/dev/faq/install/#faq-python-version-support
Installation
-
Install using pip (not available at this time, TODO):
pip install git+https://git.wgdnet.de/cwiegand/django_hockeydata_api.git
Alternatively, you can install download or clone this repo and call
pip install -e .
. -
Add to INSTALLED_APPS in your
settings.py
:'hockeydata_api',
-
In your templates, load the
widget_tags
library:{% load widget_tags %}
Example template
{% extends "base.html" %}
{% load widget_tags %}
{% block extra_head_content %}
{{ block.super }}
<!-- Hockeydata css -->
{% hockeydata_css 'los_player_fullpage' %}
<!-- custom widget css -->
<link href="{% static 'js/style.css' %}" rel="stylesheet">
<!-- Hockeydata javascript -->
{% hockeydata_js 'los_player_fullpage' %}
<!-- Hockeydata Widget -->
{% hockeydata_widget domNode='#player' widgetName='hockeydata.los.Player.FullPage'
divisionId='<yourDivisionId>' playerId=playerId %}
{% endblock %}
{% block content %}
<div id='#player'></div>
{% endblock %}
Documentation
The Templatetags can receive almost all hockeydata widget options, just write them down in python syntax (e.g. true --> True). At the moment there is one special option for the game slider widget to get the gameLink parameter from a callback function. This is useful if you want a gameslider for multiple divisions (e.g. for all divsions of an association):
{% hockeydata_widget domNode='#gameslider' widgetName='hockeydata.los.GameSlider'
divisionId='<yourDivisionId>' gameLink='/link_to_game/%G/%D'
gameLinkFromCallback=True %}
%G
will be replaced by Game-ID and %D
by Divsion-ID if gameLinkFromCallback
is true.
Some widgets support a callback function, that is called when all javascript
is done and the widget is rendered. Set this option as simple string (e.g paint
instead of paint()
). If no javascript function with this name exists,
the option is ignored.
hockeydata api documentation: http://apidocs.hockeydata.net/
hockeydata widget reference: https://apidocs.hockeydata.net/javascript-api/
Settings
The django-hockeydata-api requires some pre-configured settings.
They can be modified by adding a dict variable called HOCKEYDATA
in your settings.py
and customizing the values you want;
The HOCKEYDATA
dict variable contains these settings:
# hockeydata_api settings
HOCKEYDATA = {
# Hockeydata Api-Key (you can get it from https://apidocs.hockeydata.net/api-key/)
'API_KEY': '',
# Sport definition key: americanfootball|icehockey
'SPORT': 'icehockey',
# Base-URL to hockeydata static javascript and css
'STATIC': 'https://api.hockeydata.net/',
# Default template: los_template_dark|los_template_glass|los_template_default
'DEFAULT_CSS': 'los_template_dark',
# localization i18n_x_los, where x is the ISO-639-1 language code (de = Germany)
# https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
'I18N': 'i18n_de_los',
}
Example app
The example app is created for running with django 2.0!
-
create virtualenv
-
install django with 'pip install django'. See https://www.djangoproject.com/ for more information.
-
install django_hockeydata_api as described above
-
copy example app to a folder of your choice
-
set the EXAMPLE_DIV and EXAMPLE_DIV in settings.py to suitable division-ids
-
run using 'python manage.py runserver'. No database or user is required, so you can skip 'python manage.py migrate'.
Bugs and suggestions
If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.
https://git.wgdnet.de/cwiegand/django_hockeydata_api/issues
License
You can use this under BSD-License. See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_hockeydata_api-0.0.5.tar.gz
.
File metadata
- Download URL: django_hockeydata_api-0.0.5.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 315bf166186ba51ea044094b0934a4fcf34bb7f9b0fc3f1bc82265974aa43c3c |
|
MD5 | ac73253ec6e1713cf7f08ac12f9b01ad |
|
BLAKE2b-256 | ce4ed154c3b76d8bde970d4317f89d73eb47efc45bf2579542ea390c8520a4d7 |
File details
Details for the file django_hockeydata_api-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: django_hockeydata_api-0.0.5-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04f5534b9baf3750284c0a40faa6cc5e4c9be471ae4060f87b4cc2dab0c1fc89 |
|
MD5 | 1aa8ca8090cfc49a87f0c81fcc035c63 |
|
BLAKE2b-256 | 0c05a1af9e76240f82a16719f71a2ef801737225a41c08283a7d86dd829f0240 |