##// END OF EJS Templates
Search duplicates for file, not hash
neko259 -
r1827:bbdc98ff default
parent child Browse files
Show More
@@ -90,10 +90,10 b' class AbstractViewer:'
90 90 return '<div class="image">'\
91 91 '{}'\
92 92 '<div class="image-metadata"><a href="{}" download >{}, {}</a>'\
93 ' <a class="file-menu" href="#" data-type="{}" data-search-url="{}" data-hash="{}">🔍 </a></div>'\
93 ' <a class="file-menu" href="#" data-type="{}" data-search-url="{}" data-filename="{}">🔍 </a></div>'\
94 94 '</div>'.format(self.get_format_view(), self.file.url,
95 95 self.file_type, filesizeformat(self.file.size),
96 self.file_type, search_url, self.hash)
96 self.file_type, search_url, self.file.name)
97 97
98 98 def get_format_view(self):
99 99 image_name = PLAIN_FILE_FORMATS.get(self.file_type, self.file_type)
@@ -165,7 +165,7 b' function addContextMenu() {'
165 165 duplicates: {
166 166 name: gettext('Duplicates search'),
167 167 callback: function(key, opts) {
168 window.location = '/feed/?image_hash=' + $trigger.data('hash');
168 window.location = '/feed/?image=' + $trigger.data('filename');
169 169 }
170 170 },
171 171 google: {
@@ -79,21 +79,21 b' class IpFilter(FeedFilter):'
79 79 return 'IP: {}'.format(ip)
80 80
81 81
82 class HashFilter(FeedFilter):
82 class ImageFilter(FeedFilter):
83 83 @staticmethod
84 84 def get_filtered_posts(request, posts):
85 85 filtered_posts = posts
86 86
87 image_hash = request.GET.get('image_hash', None)
88 if image_hash:
89 filtered_posts = filtered_posts.filter(attachments__hash=image_hash)
87 image = request.GET.get('image', None)
88 if image:
89 filtered_posts = filtered_posts.filter(attachments__file=image)
90 90 return filtered_posts
91 91
92 92 @staticmethod
93 93 def get_query(request):
94 image_hash = request.GET.get('image_hash', None)
95 if image_hash:
96 return 'Hash: {}'.format(image_hash)
94 image = request.GET.get('image', None)
95 if image:
96 return 'File: {}'.format(image)
97 97
98 98
99 99 class FeedView(PostMixin, BaseBoardView):
@@ -101,7 +101,7 b' class FeedView(PostMixin, BaseBoardView)'
101 101 TripcodeFilter,
102 102 FavoritesFilter,
103 103 IpFilter,
104 HashFilter,
104 ImageFilter,
105 105 )
106 106
107 107 def get(self, request):
General Comments 0
You need to be logged in to leave comments. Login now