コード例 #1
0
    def get_search_data(self, post, language, request):
        with switch_language(post, language):
            description = post.get_description()
            abstract = strip_tags(post.safe_translation_getter('abstract', default=''))
            keywords = post.get_keywords()

            text_bits = []
            if abstract:
                text_bits.append(abstract)
            if description:
                text_bits.append(description)
            if keywords:
                text_bits.append(' '.join(keywords))
                self.prepared_data['keywords'] = ','.join(keywords)
            for category in post.categories.all():
                text_bits.append(
                    force_text(category.safe_translation_getter('name')))
            for tag in post.tags.all():
                text_bits.append(force_text(tag.name))

            if get_setting('USE_PLACEHOLDER'):
                plugins = post.content.cmsplugin_set.filter(language=language)
                content_bits = []
                for base_plugin in plugins:
                    content = get_plugin_index_data(base_plugin, request)
                    content_bits.append(' '.join(content))
                post_text = ' '.join(content_bits)
            else:
                post_text = post.safe_translation_getter('post_text')
                if post_text:
                    post_text = strip_tags(post_text)
            self.prepared_data['post_text'] = post_text
            text_bits.append(post_text)

            return ' '.join(text_bits)
コード例 #2
0
    def get_search_data(self, post, language, request):
        with switch_language(post, language):
            description = post.get_description()
            abstract = strip_tags(post.safe_translation_getter('abstract', default=''))
            keywords = post.get_keywords()

            text_bits = []
            if abstract:
                text_bits.append(abstract)
            if description:
                text_bits.append(description)
            if keywords:
                text_bits.append(' '.join(keywords))
                self.prepared_data['keywords'] = ','.join(keywords)
            for category in post.categories.all():
                text_bits.append(
                    force_text(category.safe_translation_getter('name')))
            for tag in post.tags.all():
                text_bits.append(force_text(tag.name))

            if get_setting('USE_PLACEHOLDER'):
                plugins = post.content.cmsplugin_set.filter(language=language)
                content_bits = []
                for base_plugin in plugins:
                    content = get_plugin_index_data(base_plugin, request)
                    content_bits.append(' '.join(content))
                post_text = ' '.join(content_bits)
            else:
                post_text = post.safe_translation_getter('post_text')
                if post_text:
                    post_text = strip_tags(post_text)
            self.prepared_data['post_text'] = post_text
            text_bits.append(post_text)

            return ' '.join(text_bits)
コード例 #3
0
 def get_search_data(self, obj, language, request):
     description = self.get_description(obj)
     text_bits = [strip_tags(description)]
     for category in obj.categories.all():
         text_bits.append(force_text(category.safe_translation_getter('name')))
     for tag in obj.tags.all():
         text_bits.append(force_text(tag.name))
     if obj.content:
         for base_plugin in obj.content.cmsplugin_set.filter(language=language):
             plugin_text_content = ' '.join(get_plugin_index_data(base_plugin, request))
             text_bits.append(plugin_text_content)
     return ' '.join(text_bits)
コード例 #4
0
 def get_search_data(self, post, language, request):
     optional_attributes = []
     abstract = post.safe_translation_getter('abstract')
     text_bits = [post.get_title()]
     text_bits.append(strip_tags(abstract))
     text_bits.append(post.get_description())
     text_bits.append(' '.join(post.get_keywords()))
     for category in post.categories.all():
         text_bits.append(
             force_text(category.safe_translation_getter('name')))
     for tag in post.tags.all():
         text_bits.append(force_text(tag.name))
     if post.content:
         plugins = post.content.cmsplugin_set.filter(language=language)
         for base_plugin in plugins:
             content = get_plugin_index_data(base_plugin, request)
             text_bits.append(' '.join(content))
     for attribute in optional_attributes:
         value = force_text(getattr(post, attribute))
         if value and value not in text_bits:
             text_bits.append(value)
     return ' '.join(text_bits)
コード例 #5
0
 def get_plugin_search_text(self, base_plugin, request):
     plugin_content_bits = get_plugin_index_data(base_plugin, request)
     return clean_join(' ', plugin_content_bits)