Show More
@@ -1,6 +1,8 b'' | |||||
|
1 | from django.core.urlresolvers import reverse | |||
1 | import markdown |
|
2 | import markdown | |
2 | from markdown.inlinepatterns import Pattern |
|
3 | from markdown.inlinepatterns import Pattern | |
3 | from markdown.util import etree |
|
4 | from markdown.util import etree | |
|
5 | import boards | |||
4 |
|
6 | |||
5 | __author__ = 'neko259' |
|
7 | __author__ = 'neko259' | |
6 |
|
8 | |||
@@ -28,7 +30,8 b' class ReflinkPattern(Pattern):' | |||||
28 | def handleMatch(self, m): |
|
30 | def handleMatch(self, m): | |
29 | ref_element = etree.Element('a') |
|
31 | ref_element = etree.Element('a') | |
30 | post_id = m.group(4) |
|
32 | post_id = m.group(4) | |
31 |
ref_element.set('href', |
|
33 | ref_element.set('href', reverse(boards.views.jump_to_post, | |
|
34 | kwargs={'post_id': post_id})) | |||
32 | ref_element.text = m.group(2) |
|
35 | ref_element.text = m.group(2) | |
33 |
|
36 | |||
34 | return ref_element |
|
37 | return ref_element |
@@ -24,6 +24,7 b" urlpatterns = patterns(''," | |||||
24 | url(r'^settings$', views.settings, name='settings'), |
|
24 | url(r'^settings$', views.settings, name='settings'), | |
25 | url(r'^tags$', views.all_tags, name='tags'), |
|
25 | url(r'^tags$', views.all_tags, name='tags'), | |
26 | url(r'^captcha/', include('captcha.urls')), |
|
26 | url(r'^captcha/', include('captcha.urls')), | |
|
27 | url(r'^jump/(?P<post_id>\w+)', views.jump_to_post, name='jumper'), | |||
27 |
|
28 | |||
28 | # RSS feeds |
|
29 | # RSS feeds | |
29 | url(r'^rss/$', AllThreadsFeed()), |
|
30 | url(r'^rss/$', AllThreadsFeed()), |
@@ -206,6 +206,17 b' def all_tags(request):' | |||||
206 | return render(request, 'boards/tags.html', context) |
|
206 | return render(request, 'boards/tags.html', context) | |
207 |
|
207 | |||
208 |
|
208 | |||
|
209 | def jump_to_post(request, post_id): | |||
|
210 | post = get_object_or_404(Post, id=post_id) | |||
|
211 | ||||
|
212 | if boards.models.NO_PARENT == post.parent: | |||
|
213 | return redirect(thread, post_id=post.id) | |||
|
214 | else: | |||
|
215 | parent_thread = get_object_or_404(Post, id=post.parent) | |||
|
216 | return redirect(reverse(thread, kwargs={'post_id': parent_thread.id}) | |||
|
217 | + '#' + str(post.id)) | |||
|
218 | ||||
|
219 | ||||
209 | def _get_theme(request): |
|
220 | def _get_theme(request): | |
210 | return request.session.get('theme', neboard.settings.DEFAULT_THEME) |
|
221 | return request.session.get('theme', neboard.settings.DEFAULT_THEME) | |
211 |
|
222 |
General Comments 0
You need to be logged in to leave comments.
Login now