Giter Site home page Giter Site logo

mydjango-rado / srvup-comments Goto Github PK

View Code? Open in Web Editor NEW

This project forked from srvup/srvup-comments

0.0 2.0 0.0 64 KB

A Re-usable Django Comments App made for Srvup

Home Page: http://www.srvup.com/

License: MIT License

Python 49.44% CSS 1.01% JavaScript 48.96% HTML 0.59%

srvup-comments's Introduction

Srvup Comments

A reusable Django & Javascript app (jQuery) for simply implementing a comments feed on any url.

Quick start

  1. Install Srvup Comments & Dependancies:

    pip install srvup-comments django djangorestframework django-cors-headers
    
  2. Add "comments" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'corsheaders', 
        'rest_framework',
        'comments',
    ]
    
  3. Implement Django Dependancy Settings:

    Such as:

    MIDDLEWARE = [
        ...
        'django.contrib.sessions.middleware.SessionMiddleware',
        'corsheaders.middleware.CorsMiddleware',
        'django.middleware.common.CommonMiddleware',
        ...
    ]
    
    REST_FRAMEWORK = {
        'DEFAULT_PERMISSION_CLASSES': (
            'rest_framework.permissions.IsAuthenticated',
            'rest_framework.permissions.IsAuthenticatedOrReadOnly',
        ),
        'DEFAULT_AUTHENTICATION_CLASSES': (
            'rest_framework.authentication.SessionAuthentication',
        ),
        'DEFAULT_RENDERER_CLASSES': (
            'rest_framework.renderers.JSONRenderer',
            'rest_framework.renderers.BrowsableAPIRenderer',
        )
    }
    
    
    
    CORS_URLS_REGEX = r'^/api.*'
    CORS_ORIGIN_ALLOW_ALL = True
    CORS_ORIGIN_WHITELIST = (
        '*',
    )
    
    
  4. Add the following to ROOT_URLCONF:

    from django.conf.urls import url, include
    urlpatterns = [
        ...
        url(r'^api/comments/', include('comments.api.urls')),
    ]
    
  5. Add jQuery and Bootstrap(recommended):

    <!-- jQuery Required -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    
    <!-- Bootstrap JS Recommeded -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    
    <!-- Bootstrap CSS Recommeded -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    
  6. Add Srvup.Comments.js:

    {% load static %} 
    
    <!-- Primary Static files -->
    <script src='{% static "comments/js/srvup.comments.js" %}'></script>
    
    <!-- CSRF Safe For Ajax -->
    <script src='{% static "comments/js/srvup.safe.js" %}'></script>
    
  7. Run Django Commands:

    python manage.py makemigrations
    
    python manage.py migrate
    
  8. Use!

    <div class='srvup-load-comments' data-url='{{ request.build_absolute_uri }}'></div>
    
  9. Customize:

    <div class='srvup-load-comments' data-url='/any/path/' data-login='/accounts/login/' data-api-endpoint='/api/comments/'></div>
    

    data-url: Any url path you want your comments to load for that path

    data-login: Your default login. Defaults to LOGIN_URL

    data-api-endpoint: Your endoing for the API comments. Change as needed. Defaults to /api/comments/

srvup-comments's People

Contributors

codingforentrepreneurs avatar

Watchers

Radoslaw Tomaszewski avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.