Show More
@@ -0,0 +1,74 b'' | |||||
|
1 | from django.contrib.syndication.views import Feed | |||
|
2 | from django.core.urlresolvers import reverse | |||
|
3 | from django.shortcuts import get_object_or_404 | |||
|
4 | from boards.models import Post, Tag, NO_PARENT | |||
|
5 | from neboard import settings | |||
|
6 | ||||
|
7 | __author__ = 'neko259' | |||
|
8 | ||||
|
9 | ||||
|
10 | class AllThreadsFeed(Feed): | |||
|
11 | title = settings.SITE_NAME + ' - All threads' | |||
|
12 | link = '/' | |||
|
13 | description_template = 'boards/rss/post.html' | |||
|
14 | ||||
|
15 | def items(self): | |||
|
16 | return Post.objects.get_threads(order_by='-pub_time') | |||
|
17 | ||||
|
18 | def item_title(self, item): | |||
|
19 | return item.title | |||
|
20 | ||||
|
21 | def item_link(self, item): | |||
|
22 | return reverse('thread', args={item.id}) | |||
|
23 | ||||
|
24 | def item_pubdate(self, item): | |||
|
25 | return item.pub_time | |||
|
26 | ||||
|
27 | ||||
|
28 | class TagThreadsFeed(Feed): | |||
|
29 | link = '/' | |||
|
30 | description_template = 'boards/rss/post.html' | |||
|
31 | ||||
|
32 | def items(self, obj): | |||
|
33 | return Post.objects.get_threads(tag=obj, order_by='-pub_time') | |||
|
34 | ||||
|
35 | def get_object(self, request, tag_name): | |||
|
36 | return get_object_or_404(Tag, name=tag_name) | |||
|
37 | ||||
|
38 | def item_title(self, item): | |||
|
39 | return item.title | |||
|
40 | ||||
|
41 | def item_link(self, item): | |||
|
42 | return reverse('thread', args={item.id}) | |||
|
43 | ||||
|
44 | def item_pubdate(self, item): | |||
|
45 | return item.pub_time | |||
|
46 | ||||
|
47 | def title(self, obj): | |||
|
48 | return obj.name | |||
|
49 | ||||
|
50 | ||||
|
51 | class ThreadPostsFeed(Feed): | |||
|
52 | link = '/' | |||
|
53 | description_template = 'boards/rss/post.html' | |||
|
54 | ||||
|
55 | def items(self, obj): | |||
|
56 | return Post.objects.get_thread(opening_post_id=obj) | |||
|
57 | ||||
|
58 | def get_object(self, request, post_id): | |||
|
59 | return post_id | |||
|
60 | ||||
|
61 | def item_title(self, item): | |||
|
62 | return item.title | |||
|
63 | ||||
|
64 | def item_link(self, item): | |||
|
65 | if NO_PARENT == item.parent: | |||
|
66 | return reverse('thread', args={item.id}) | |||
|
67 | else: | |||
|
68 | return reverse('thread', args={item.parent}) + "#" + str(item.id) | |||
|
69 | ||||
|
70 | def item_pubdate(self, item): | |||
|
71 | return item.pub_time | |||
|
72 | ||||
|
73 | def title(self, obj): | |||
|
74 | return get_object_or_404(Post, id=obj).title No newline at end of file |
@@ -0,0 +1,15 b'' | |||||
|
1 | {% load i18n %} | |||
|
2 | ||||
|
3 | {% if obj.image %} | |||
|
4 | <img src="{{ obj.image.url_200x150 }}" | |||
|
5 | alt="{% trans 'Post image' %}" /> | |||
|
6 | {% endif %} | |||
|
7 | {{ obj.text.rendered|safe }} | |||
|
8 | {% if obj.tags.all %} | |||
|
9 | <p> | |||
|
10 | {% trans 'Tags' %}: | |||
|
11 | {% for tag in obj.tags.all %} | |||
|
12 | {{ tag.name }} | |||
|
13 | {% endfor %} | |||
|
14 | </p> | |||
|
15 | {% endif %} No newline at end of file |
@@ -2,7 +2,7 b' import markdown' | |||||
2 | from markdown.inlinepatterns import Pattern |
|
2 | from markdown.inlinepatterns import Pattern | |
3 | from markdown.util import etree |
|
3 | from markdown.util import etree | |
4 |
|
4 | |||
5 |
__author__ = ' |
|
5 | __author__ = 'neko259' | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | class AutolinkPattern(Pattern): |
|
8 | class AutolinkPattern(Pattern): |
@@ -38,6 +38,7 b'' | |||||
38 |
|
38 | |||
39 | <div class="navigation_panel"> |
|
39 | <div class="navigation_panel"> | |
40 | {% block metapanel %}{% endblock %} |
|
40 | {% block metapanel %}{% endblock %} | |
|
41 | [<a href="rss/">RSS</a>] | |||
41 | <a class="link" href="#top">{% trans 'Up' %}</a> |
|
42 | <a class="link" href="#top">{% trans 'Up' %}</a> | |
42 | </div> |
|
43 | </div> | |
43 |
|
44 |
@@ -167,7 +167,7 b' class BoardTests(TestCase):' | |||||
167 | 'where it should fail') |
|
167 | 'where it should fail') | |
168 |
|
168 | |||
169 | response = client.post(THREAD_PAGE_ONE, {'text': TEST_TEXT, |
|
169 | response = client.post(THREAD_PAGE_ONE, {'text': TEST_TEXT, | |
170 | 'tags': valid_tags}) |
|
170 | 'tags': valid_tags}) | |
171 | self.assertEqual(HTTP_CODE_REDIRECT, response.status_code, |
|
171 | self.assertEqual(HTTP_CODE_REDIRECT, response.status_code, | |
172 | msg=u'Posting new message failed: got code ' + |
|
172 | msg=u'Posting new message failed: got code ' + | |
173 | str(response.status_code)) |
|
173 | str(response.status_code)) |
@@ -1,5 +1,6 b'' | |||||
1 | from django.conf.urls import patterns, url, include |
|
1 | from django.conf.urls import patterns, url, include | |
2 | from boards import views |
|
2 | from boards import views | |
|
3 | from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed | |||
3 |
|
4 | |||
4 | urlpatterns = patterns('', |
|
5 | urlpatterns = patterns('', | |
5 |
|
6 | |||
@@ -23,4 +24,9 b" urlpatterns = patterns(''," | |||||
23 | url(r'^settings$', views.settings, name='settings'), |
|
24 | url(r'^settings$', views.settings, name='settings'), | |
24 | url(r'^tags$', views.all_tags, name='tags'), |
|
25 | url(r'^tags$', views.all_tags, name='tags'), | |
25 | url(r'^captcha/', include('captcha.urls')), |
|
26 | url(r'^captcha/', include('captcha.urls')), | |
|
27 | ||||
|
28 | # RSS feeds | |||
|
29 | url(r'^rss/$', AllThreadsFeed()), | |||
|
30 | url(r'^tag/(?P<tag_name>\w+)/rss/$', TagThreadsFeed()), | |||
|
31 | url(r'^thread/(?P<post_id>\w+)/rss/$', ThreadPostsFeed()), | |||
26 | ) No newline at end of file |
|
32 | ) |
@@ -128,7 +128,7 b' INSTALLED_APPS = (' | |||||
128 | 'django.contrib.auth', |
|
128 | 'django.contrib.auth', | |
129 | 'django.contrib.contenttypes', |
|
129 | 'django.contrib.contenttypes', | |
130 | 'django.contrib.sessions', |
|
130 | 'django.contrib.sessions', | |
131 | 'django.contrib.sites', |
|
131 | # 'django.contrib.sites', | |
132 | 'django.contrib.messages', |
|
132 | 'django.contrib.messages', | |
133 | 'django.contrib.staticfiles', |
|
133 | 'django.contrib.staticfiles', | |
134 | # Uncomment the next line to enable the admin: |
|
134 | # Uncomment the next line to enable the admin: |
General Comments 0
You need to be logged in to leave comments.
Login now