DJANGO SOCIAL LAYER
---------------------

django-social-layer - Adds social media features to any website.

FEATURES
-----------
    - easly add a comment section to any webpage
    - users can like comments
    - notifications
    - users have profile page


INSTALATION
-----------

Install django-social-layer:

.. code:: shell

       pip install django-social-layer

Add to urls.py:

.. code:: python

    path('', include(('social_layer.urls', 'social_layer'), namespace="social_layer"))

add to settings.py:

.. code:: python

       INSTALLED_APPS = [
           ...
           'social_layer',
       ]

run migrations:

.. code:: shell

       ./manage.py migrate social_layer


USAGE
-----
Create a SocialProfile for an user:

.. code:: python

    bob = User.objects.create(username="bob")
    social_bob = SocialProfile.objects.create(user=bob)

Create a CommentSection for any purpose. It can, for example, be linked to an \
object with a ForeignKey field, or to a view by it's URL. In our example we will \
use an url, but it's optional. A CommentSection must have an owner.

.. code:: python

    comment_section = CommentSection.objects.create(owner=social_bob,
                                                    url=request.path)


Now inside a view, lets add a commennt section for the page owned by bob:

.. code:: python

    def some_awesome_view(request):
        social_bob = SocialProfile.objects.get(nick='bob')
        # in our example, we use the url to match the page.
        comment_section = CommentSection.objects.get(url=request.path)
        data = {'comment_section': comment_section}
        return render(request, 'awesome_template.html', data)

To finish, add this to the template:

.. code:: html

    <script defer application="javascript" src="{{ STATIC_ROOT }}social_layer/js/social_layer.js"></script>
    <link rel="stylesheet" href="{{ STATIC_ROOT }}social_layer/css/social_layer.css"/>

    <p>A comment section will render below.</p>
    {% include 'comments/comment_section.html' %}

