-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support customrize title and copyright, and split base.html
- Loading branch information
Showing
8 changed files
with
115 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env python | ||
|
||
|
||
from django.conf import settings | ||
|
||
|
||
def pyhn_info(request): | ||
return { | ||
'PYHN_TITLE': settings.PYHN_TITLE, | ||
'PYHN_COPYRIGHT': settings.PYHN_COPYRIGHT, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div id="footer"> | ||
<div class="container"> | ||
<p class="text-muted"> | ||
{% if PYHN_COPYRIGHT %} | ||
{{ PYHN_COPYRIGHT|safe }} | ||
{% else %} | ||
© 2014 <a href="https://github.com/akun">akun</a>. Powered by <a href="https://github.com/akun/PyHackerNews">Python Hacker News</a>. Report <a href="https://github.com/akun/PyHackerNews/issues/new">issue</a> | ||
{% endif %} | ||
</p> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{% load i18n %} | ||
{% load pyhn_extras %} | ||
|
||
<div class="navbar navbar-default navbar-fix-top" role="navigation"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
<a class="navbar-brand" href="{% url 'index' %}">{% if PYHN_TITLE %}{{ PYHN_TITLE }}{% else %}Python Hacker News{% endif %}</a> | ||
</div> | ||
<div class="navbar-collapse collapse"> | ||
<ul class="nav navbar-nav"> | ||
<li><a href="{% url 'news:newest' %}">{% trans 'New' %}</a></li> | ||
{% if perms.can_submit %} | ||
<li><a href="{% url 'news:submit' %}">{% trans 'Submit' %}</a></li> | ||
{% endif %} | ||
</ul> | ||
<ul class="nav navbar-nav navbar-right"> | ||
{% if request.user.is_authenticated %} | ||
<li class="dropdown"> | ||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="{{ request.user.email|gravatar_url }}" /> {{ request.user.username }} <b class="caret"></b></a> | ||
<ul class="dropdown-menu"> | ||
<li><a href="{% url 'account:index' %}">Account</a></li> | ||
<li><a href="{% url 'account:logout' %}">Sign Out</a></li> | ||
</ul> | ||
</li> | ||
{% else %} | ||
<li class="dropdown"> | ||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="{{ request.user.email|gravatar_url }}" /> {{ request.user.username }} <b class="caret"></b></a> | ||
<ul class="dropdown-menu"> | ||
<li><a href="{% url 'social:begin' 'github' %}">{% trans 'Sign in with GitHub' %}</a></li> | ||
<li><a href="{% url 'social:begin' 'weibo' %}">{% trans 'Sign in with Sina Weibo' %}</a></li> | ||
</ul> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
|
||
|
||
from django.test import TestCase | ||
|
||
from pyhn.libs import context_processors | ||
|
||
|
||
class ContextProcessorsTestCase(TestCase): | ||
|
||
def test_pyhn_info_if_default(self): | ||
context = context_processors.pyhn_info(self.client.request) | ||
self.assertEqual('', context['PYHN_TITLE']) | ||
self.assertEqual('', context['PYHN_COPYRIGHT']) | ||
|
||
def test_pyhn_info_if_edit_settings(self): | ||
from django.conf import settings | ||
title = 'test_title' | ||
copyright = 'test_copyright' | ||
settings.PYHN_TITLE = title | ||
settings.PYHN_COPYRIGHT = copyright | ||
|
||
context = context_processors.pyhn_info(self.client.request) | ||
self.assertEqual(title, context['PYHN_TITLE']) | ||
self.assertEqual(copyright, context['PYHN_COPYRIGHT']) | ||
|
||
settings.PYHN_TITLE = '' | ||
settings.PYHN_COPYRIGHT = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters