Skip to main content

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_hockeydata_api-0.0.5.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

django_hockeydata_api-0.0.5-py3-none-any.whl (11.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page