public
Description: A full featured and opinionated blogging solution using Django
Homepage: http://lethain.com/projects/lifeflow/
Clone URL: git://github.com/lethain/lifeflow.git
lifeflow / context.py
100644 51 lines (47 sloc) 2.195 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from lifeflow.models import Entry, Flow, RecommendedSite, Author, Flow, Language
from django.contrib.sites.models import Site
from django.conf import settings
 
 
def blog(request):
    def make_slug(str):
        return str.lower().replace(" ","-")
    recent = Entry.current.all()[:5]
    random = Entry.current.all().order_by('?')[:5]
    blog_roll = RecommendedSite.objects.all()
    flows = Flow.objects.all()
    site = Site.objects.get(pk=settings.SITE_ID)
    analytics_id = getattr(settings, 'LIFEFLOW_GOOGLE_ANALYTICS_ID', None)
    use_projects = getattr(settings, 'LIFEFLOW_USE_PROJECTS', True)
    keywords = getattr(settings, 'LIFEFLOW_KEYWORDS', "blog")
    description = getattr(settings, 'LIFEFLOW_DESCRIPTION', "blog")
    author = getattr(settings, 'LIFEFLOW_AUTHOR_NAME', None)
    template_author = getattr(settings, 'LIFEFLOW_TEMPLATE_AUTHOR', "Will Larson")
    template_author_url = getattr(settings, 'LIFEFLOW_TEMPLATE_AUTHOR_URL', "http://www.lethain.com/")
    if author is None:
        try:
            author = Author.objects.get(pk=1).name
        except:
            author = "Anonymous"
 
    author_slug = make_slug(author)
    blog_name = getattr(settings, 'LIFEFLOW_BLOG_NAME', "Unconfigured LifeFlow")
    custom_css = getattr(settings, 'LIFEFLOW_CUSTOM_CSS', None)
    custom_js_header = getattr(settings, 'LIFEFLOW_CUSTOM_JS_HEADER', None)
    custom_js_footer = getattr(settings, 'LIFEFLOW_CUSTOM_JS_FOOTER', None)
    return {
        'blog_roll' : blog_roll,
        'lifeflow_google_analytics_id':analytics_id,
        'lifeflow_blog_name':blog_name,
        'lifeflow_custom_css':custom_css,
        'lifeflow_custom_js_header':custom_js_header,
        'lifeflow_custom_js_footer':custom_js_footer,
        'lifeflow_flows':flows,
        'lifeflow_keywords':keywords,
        'lifeflow_description':description,
        'lifeflow_author':author,
        'lifeflow_author_slug':author_slug,
        'lifeflow_use_projects':use_projects,
        'lifeflow_template_author':template_author,
        'lifeflow_template_author_url':template_author_url,
        'recent_entries' : recent,
        'random_entries' : random,
        'site' : site,
        }