class SearchExtender(object): """Adapter that adds search metadata.""" implements(ISchemaExtender) _fields = [ extender.ExtensionBooleanField( 'showinsearch', languageIndependent=True, schemata='settings', default=True, write_permission='ftw.solr: Edit search settings', widget=BooleanWidget( label=_(u'label_showinsearch', default=u'Show in search'), visible={ "edit": "visible", "view": "invisible" }, description="", )), extender.ExtentionTextField( 'searchwords', searchable=False, schemata='settings', languageIndependent=False, write_permission='ftw.solr: Edit search settings', allowable_content_types='text/plain', widget=TextAreaWidget( label=_(u'label_searchwords', default=u'Search words'), description=_( u'help_searchwords', default=u'Specify words for which this item will show up ' 'as the first search result. Multiple words can be ' 'specified on new lines.'), visible={ "edit": "visible", "view": "invisible" }, )), ] def __init__(self, context): self.context = context def getFields(self): return self._fields
class ISearchSettings(Interface): path_based_breadcrumbs = schema.Bool( title=_(u'Use Path for Breadcrumbs'), default=False, ) max_breadcrumbs = schema.Int( title=_(u'Max. Breadcrumbs'), default=3, ) respect_navroot = schema.Bool( title=_(u'Respect Navigation Root'), description=_(u'Constrain searches to navigation root'), default=False, )
class ILiveSearchSettings(Interface): grouping = schema.Bool( title=_(u'Enable Grouping in LiveSearch'), description=_(u'If enabled, livesearch results are grouped by portal ' 'type.'), default=False, ) group_by = schema.List( title=_(u'Groups'), description=_(u'Specify a list of portal types by which livesearch ' 'results are grouped. Groups are shown in the provided ' 'order. Results that do not match a portal type in the ' 'given list are shown at the bottom.'), default=[ u'Folder', u'Document', u'News Item', u'Event', u'File', u'Image' ], value_type=schema.TextLine(), required=False, ) group_search_limit = schema.Int( title=_(u'Group Search Limit'), description=_(u'The maximum number of search results to consider for' 'grouping.'), default=1000, ) group_limit = schema.Int( title=_(u'Group Limit'), description=_(u'The maximum number of search results per group.'), default=7, required=False, ) max_title = schema.Int( title=_(u'Maximum Title Length'), default=40, ) max_description = schema.Int( title=_(u'Maximum Description Length'), default=100, )
def get_search_help_item(self): label_search_help = _('label_search_help', default='Search help') search_help_obj = api.portal.get_navigation_root( self.context).restrictedTraverse('searchhelp', None) if search_help_obj is None: return None return { 'url': search_help_obj.absolute_url(), 'title': translate(label_search_help, context=self.request), 'first_of_group': False, 'cssclass': 'no-result' }
def get_show_more_item(self): label_show_all = _('label_show_all', default='Show all items') params = self.facet_params params += '&SearchableText=' + self.searchterms path = self.request.form.get('path', None) if path: params += '&path=' + url_quote_plus(path) url = '@@search?{0}'.format(params) return { 'url': url, 'title': translate(label_show_all, context=self.request), 'first_of_group': False, 'cssclass': 'no-result' }
class IWordCloudPortlet(IPortletDataProvider): """A WordCloud portlet. It inherits from IPortletDataProvider because for this portlet, the data that is being rendered and the portlet assignment itself are the same. """ portlet_title = schema.TextLine(title=_(u'label_portlet_title', default=u"Title"), description=_(u'help_portlet_title', default=u"Portlet title"), required=False, default=u"Word Cloud") num_words = schema.Int( title=_(u'label_num_words', default=u"Number of words"), description=_(u'help_num_words', default=u"Maximum number of words to be displayed"), required=True, default=10) num_sizes = schema.Int( title=_(u'label_num_sizes', u"Number of sizes"), description=_(u'help_num_sizes', default=u"Number of different sizes to represent term " "weight"), required=True, default=5) scale_factor = schema.Float( title=_(u'label_scale_factor', default=u"Scale factor"), description=_( u'help_scale_factor', default=u"Constant scaling factor to scale font size by"), required=True, default=2.0)