GithubHelp home page GithubHelp logo

mohamadhussien / django-liveblog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bycoffe/django-liveblog

0.0 2.0 0.0 68 KB

A live-blogging application meant to work alongside an existing blogging application.

License: BSD 3-Clause "New" or "Revised" License

django-liveblog's Introduction

Django live-blogging application
================================

This is a live-blogging application meant to work alongside an existing blogging application.

The main blogging application must have a model for entries that the live-blogging model can use as a foreign key.


Requirements
------------

Django (Tested with 1.1 but should work with 1.0)

Markdown for Python (http://www.freewisdom.org/projects/python-markdown/)

A Django blogging application


Features
------------

The appearance of the live-blogging entries can be customized in the template of the main blog entry (or in a separate template file, using {% include %}). See Usage below.

The live-blogging entries can be ordered newest-to-oldest or oldest-to-newest.


Installation
------------

1. Place the 'liveblog' directory in your Python path.
2. Add 'liveblog' to the INSTALLED_APPS tuple in your Django settings.py file.
3. Add 'liveblog.context_processors.liveblog_order' to the TEMPLATE_CONTEXT_PROCESSORS tuple in your Django settings.py file.
4. Add two other variables to your settings.py file: BLOG_APP and BLOG_ENTRY_MODEL. BLOG_APP should be the main Django blogging module you want to connect this live-blogging application to. BLOG_ENTRY_MODEL should be the name of the model within that module that represents an entry in the blog.

For example, if your main blogging application is called 'blog', and it uses a model called 'Entry' to represent a blog entry, you would add the following to settings.py:
BLOG_APP = 'blog'
BLOG_ENTRY_MODEL = 'Entry'

This allows the live-blogging application to do the equivalent of 'from blog.models import Entry', which allows it to use Entry as a foreign key.

5. Run manage.py syncdb to create the necessary table for the live-blogging application.

6. In the template that's used to display a main blog entry, add the following:

        {% load order_queryset %}

7. Customize the following template code to your liking and add it to the template. 'object' is a main blog entry.

        {# If this entry has associated live-blog entries (i.e., it is a live blog), show them. #}
        {% if object.liveblogentry_set.all %}

        <p>Order:
        {% ifequal liveblog_order 'pub_date' %}
        <a href="{{ object.get_absolute_url }}?order=asc">newest first</a>
        {% else %}
        newest first
        {% endifequal %}
        |
        {% ifequal liveblog_order '-pub_date' %}
        <a href="{{ object.get_absolute_url }}?order=desc">oldest first</a>
        {% else %}
        oldest first
        {% endifequal %}
        </p>

            <ul class="liveblog">
            {% for entry in object.liveblogentry_set.all|order_by:liveblog_order %}
                <li>
                    <p><strong>{{ entry.pub_date|date:"P" }}:</strong>
                    {{ entry.body }}</p>
                </li>
            {% endfor %}
            </ul>
        {% endif %}


Usage
------------

In your admin site, you'll see 'Live Blog Entries' listed. Add, edit or remove a live-blog entry just as you would any other item in the Django admin. Each live-blog entry must be associated with a main-blog entry (the main blog entry is where you would put an introduction, etc.). By default, the associated main-blog entry is the newest entry, but any blog entry can be selected in the admin.


Example site
------------

http://bycoffe.com/blog/2009/jul/15/statknowledge-day-one/


Credits
------------

This application includes an order_by template filter found here: http://www.djangosnippets.org/snippets/741/

django-liveblog's People

Contributors

bycoffe avatar

Watchers

James Cloos avatar Mohamad Hussien 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.