Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

A small Django app to easily broadcast an announcement across a website.

License

Notifications You must be signed in to change notification settings

natgeosociety/django-broadcasts

 
 

Repository files navigation

django-broadcasts

This version of Django Site Broadcasts was forked to provide a way to schedule client-side messages:

  • Across the whole site or on specific pages
  • For a specified amount of time
  • Uses a cookie to mark that the message was shown
  • For all users, authenticated users only, or unauthenticated users only
  • Retrievable via AJAX to allow for page caching
  • Django 1.5+ compatibility

Installation

  1. Use pip to install the application:

    $ pip install django-site-broadcasts
  2. Then add broadcasts to your INSTALLED_APPS setting:

    INSTALLED_APPS = [
        # ...
        'broadcasts',
    ]
  3. Add this line to your urls.py:

    url(r'^messages/', include('broadcasts.urls')),
    

Usage

If you have this in your HTML somewhere:

<div id="messages"></div>

you can use this simple jQuery snippet to retrieve all available broadcasts:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
    function addMessage(message) {
        $('#messages').append('<div class="alert">' + message + '</div>');
    };
    $.getJSON("{% url 'broadcast_messages' %}", function(data){
        $.each(data, function(index, value) {addMessage(value.message)});
    });
</script>

About

A small Django app to easily broadcast an announcement across a website.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 58.0%
  • CSS 20.5%
  • HTML 11.5%
  • Makefile 4.7%
  • Batchfile 4.6%
  • JavaScript 0.7%