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.4.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

django_hockeydata_api-0.0.4-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file django_hockeydata_api-0.0.4.tar.gz.

File metadata

  • Download URL: django_hockeydata_api-0.0.4.tar.gz
  • Upload date:
  • Size: 9.2 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.1 CPython/3.8.7

File hashes

Hashes for django_hockeydata_api-0.0.4.tar.gz
Algorithm Hash digest
SHA256 0f3b68151a341ec725e510cf5fc933e0a41ec6cb354e5a4e7468250abc92df58
MD5 789d82d6e6f5ac8061ab80c2691bbfdf
BLAKE2b-256 ea0b83602029f8a35b253aade6f4ddb781c0fca734e1759fcfe938b3a10e4a7d

See more details on using hashes here.

Provenance

File details

Details for the file django_hockeydata_api-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: django_hockeydata_api-0.0.4-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.1 CPython/3.8.7

File hashes

Hashes for django_hockeydata_api-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 29b19435e44ef26a8cd46dff6eaec8530f877150302d4f29c22a2b9df48c010d
MD5 c04ea04c46c6c196e1cc37eba4b52551
BLAKE2b-256 75802cef7b5b39aa56f93326cc7a0e2a7c6fb6ce956dc70fcf3f12a5ca065010

See more details on using hashes here.

Provenance

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