##// END OF EJS Templates
Show header in the feed
neko259 -
r1823:ce41b3a5 default
parent child Browse files
Show More
@@ -24,6 +24,10 b''
24 {% get_current_language as LANGUAGE_CODE %}
24 {% get_current_language as LANGUAGE_CODE %}
25 {% get_current_timezone as TIME_ZONE %}
25 {% get_current_timezone as TIME_ZONE %}
26
26
27 {% for query in queries %}
28 <div class="image-mode-tab">{{ query }}</div>
29 {% endfor %}
30
27 {% if posts %}
31 {% if posts %}
28 {% if prev_page_link %}
32 {% if prev_page_link %}
29 <div class="page_link">
33 <div class="page_link">
@@ -13,6 +13,7 b" POSTS_PER_PAGE = settings.get_int('View'"
13 PARAMETER_CURRENT_PAGE = 'current_page'
13 PARAMETER_CURRENT_PAGE = 'current_page'
14 PARAMETER_PAGINATOR = 'paginator'
14 PARAMETER_PAGINATOR = 'paginator'
15 PARAMETER_POSTS = 'posts'
15 PARAMETER_POSTS = 'posts'
16 PARAMETER_QUERIES = 'queries'
16
17
17 PARAMETER_PREV_LINK = 'prev_page_link'
18 PARAMETER_PREV_LINK = 'prev_page_link'
18 PARAMETER_NEXT_LINK = 'next_page_link'
19 PARAMETER_NEXT_LINK = 'next_page_link'
@@ -26,6 +27,10 b' class FeedFilter:'
26 def get_filtered_posts(request, posts):
27 def get_filtered_posts(request, posts):
27 return posts
28 return posts
28
29
30 @staticmethod
31 def get_query(request):
32 return None
33
29
34
30 class TripcodeFilter(FeedFilter):
35 class TripcodeFilter(FeedFilter):
31 @staticmethod
36 @staticmethod
@@ -36,6 +41,12 b' class TripcodeFilter(FeedFilter):'
36 filtered_posts = filtered_posts.filter(tripcode=tripcode)
41 filtered_posts = filtered_posts.filter(tripcode=tripcode)
37 return filtered_posts
42 return filtered_posts
38
43
44 @staticmethod
45 def get_query(request):
46 tripcode = request.GET.get('tripcode', None)
47 if tripcode:
48 return 'Tripcode: {}'.format(tripcode)
49
39
50
40 class FavoritesFilter(FeedFilter):
51 class FavoritesFilter(FeedFilter):
41 @staticmethod
52 @staticmethod
@@ -61,6 +72,12 b' class IpFilter(FeedFilter):'
61 filtered_posts = filtered_posts.filter(poster_ip=ip)
72 filtered_posts = filtered_posts.filter(poster_ip=ip)
62 return filtered_posts
73 return filtered_posts
63
74
75 @staticmethod
76 def get_query(request):
77 ip = request.GET.get('ip', None)
78 if ip:
79 return 'IP: {}'.format(ip)
80
64
81
65 class HashFilter(FeedFilter):
82 class HashFilter(FeedFilter):
66 @staticmethod
83 @staticmethod
@@ -72,6 +89,12 b' class HashFilter(FeedFilter):'
72 filtered_posts = filtered_posts.filter(attachments__hash=image_hash)
89 filtered_posts = filtered_posts.filter(attachments__hash=image_hash)
73 return filtered_posts
90 return filtered_posts
74
91
92 @staticmethod
93 def get_query(request):
94 image_hash = request.GET.get('image_hash', None)
95 if image_hash:
96 return 'Hash: {}'.format(image_hash)
97
75
98
76 class FeedView(PostMixin, BaseBoardView):
99 class FeedView(PostMixin, BaseBoardView):
77 filters = (
100 filters = (
@@ -91,8 +114,13 b' class FeedView(PostMixin, BaseBoardView)'
91 posts = Post.objects.exclude(
114 posts = Post.objects.exclude(
92 thread__tags__in=settings_manager.get_hidden_tags()).order_by(
115 thread__tags__in=settings_manager.get_hidden_tags()).order_by(
93 '-pub_time').prefetch_related('attachments', 'thread')
116 '-pub_time').prefetch_related('attachments', 'thread')
117 queries = []
94 for filter in self.filters:
118 for filter in self.filters:
95 posts = filter.get_filtered_posts(request, posts)
119 posts = filter.get_filtered_posts(request, posts)
120 query = filter.get_query(request)
121 if query:
122 queries.append(query)
123 params[PARAMETER_QUERIES] = queries
96
124
97 paginator = get_paginator(posts, POSTS_PER_PAGE)
125 paginator = get_paginator(posts, POSTS_PER_PAGE)
98 paginator.current_page = int(page)
126 paginator.current_page = int(page)
General Comments 0
You need to be logged in to leave comments. Login now