Skip to main content

django_hockeydata_api

A Django package for simple use of Hockeydata Javascript API https://apidocs.hockeydata.net/.

Requirements

Installation

  1. 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 ..

  2. Add to INSTALLED_APPS in your settings.py:

    'hockeydata_api',

  3. 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!

  1. create virtualenv

  2. install django with 'pip install django'. See https://www.djangoproject.com/ for more information.

  3. install django_hockeydata_api as described above

  4. copy example app to a folder of your choice

  5. set the EXAMPLE_DIV and EXAMPLE_DIV in settings.py to suitable division-ids

  6. 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.

Metadata

Release files for django-hockeydata-api 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-hockeydata-api 0.0.5
File Size Uploaded
django_hockeydata_api-0.0.5.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-hockeydata-api 0.0.5
File Interpreter ABI Platform
django_hockeydata_api-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / django_hockeydata_api-0.0.5.tar.gz

Download URL django_hockeydata_api-0.0.5.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
315bf166186ba51ea044094b0934a4fcf34bb7f9b0fc3f1bc82265974aa43c3c
BLAKE2b-256 checksum
How to use checksums
ce4ed154c3b76d8bde970d4317f89d73eb47efc45bf2579542ea390c8520a4d7
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / django_hockeydata_api-0.0.5-py3-none-any.whl

Download URL django_hockeydata_api-0.0.5-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04f5534b9baf3750284c0a40faa6cc5e4c9be471ae4060f87b4cc2dab0c1fc89
BLAKE2b-256 checksum
How to use checksums
0c05a1af9e76240f82a16719f71a2ef801737225a41c08283a7d86dd829f0240
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page