diff --git a/castle/cms/indexing/configure.zcml b/castle/cms/indexing/configure.zcml index 93f82b9f7..abeb81987 100644 --- a/castle/cms/indexing/configure.zcml +++ b/castle/cms/indexing/configure.zcml @@ -42,5 +42,13 @@ + + + + + + + + diff --git a/castle/cms/indexing/indexers.py b/castle/cms/indexing/indexers.py index faa98ae45..cdb1d1436 100644 --- a/castle/cms/indexing/indexers.py +++ b/castle/cms/indexing/indexers.py @@ -1,10 +1,12 @@ from AccessControl import Unauthorized from Acquisition import aq_base, aq_parent +from bs4 import BeautifulSoup from wildcard.hps.interfaces import IReindexActive from OFS.interfaces import IItem from plone import api from plone.app.uuid.utils import uuidToCatalogBrain as get_brain from plone.app.contenttypes.interfaces import IFile, IImage +from plone.app.textfield import RichTextValue from plone.dexterity.interfaces import IDexterityContent from plone.event.interfaces import IEvent from plone.indexer.decorator import indexer @@ -18,6 +20,12 @@ from castle.cms.interfaces import IHasDefaultImage from castle.cms.interfaces import IReferenceNamedImage from castle.cms.interfaces import ITrashed +import logging +from fbigov.contenttypes.interfaces.pressrelease import IPressRelease +from castle.cms.interfaces import IVideo, IAudio +from fbigov.contenttypes.interfaces.speech import ISpeech +from fbigov.contenttypes.interfaces.story import IStory +from fbigov.contenttypes.interfaces.testimony import ITestimony @indexer(IItem) @@ -220,3 +228,51 @@ def self_or_child_has_title_description_and_image(obj): def has_custom_markup(image): if image.custom_markup: return True + +# full content query indexers + +def get_description(obj, _type): + return obj.Description() + +def get_raw_text(obj, _type): + logging.info('setting display_full_content for {} object'.format(_type)) + text = getattr(obj, 'text', '') + if text is not None: + if type(text) is RichTextValue: + return text.raw + return text + else: + return '' + +@indexer(IPressRelease) +def press_release_body_content(obj): + return get_raw_text(obj, 'Press Release') + +@indexer(IFile) +def file_body_content(obj): + return 'Click here for more information' + +@indexer(IImage) +def image_body_content(obj): + return get_description(obj, 'Image') + +@indexer(IVideo) +def video_body_content(obj): + return get_description(obj, 'Video') + + +@indexer(IAudio) +def audio_body_content(obj): + return get_description(obj, 'Audio') + +@indexer(IStory) +def story_body_content(obj): + return get_description(obj, 'Story') + +@indexer(ISpeech) +def speech_body_content(obj): + return get_raw_text(obj, 'Speech') + +@indexer(ITestimony) +def testimony_body_content(obj): + return get_description(obj, 'Story') diff --git a/castle/cms/profiles/3017/catalog.xml b/castle/cms/profiles/3017/catalog.xml new file mode 100644 index 000000000..2074570e9 --- /dev/null +++ b/castle/cms/profiles/3017/catalog.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/castle/cms/profiles/default/catalog.xml b/castle/cms/profiles/default/catalog.xml index 0aa405de7..60e3ae79f 100644 --- a/castle/cms/profiles/default/catalog.xml +++ b/castle/cms/profiles/default/catalog.xml @@ -51,4 +51,12 @@ + + + + + + + + diff --git a/castle/cms/static/images/previews/querylisting/full-content.png b/castle/cms/static/images/previews/querylisting/full-content.png new file mode 100644 index 000000000..280c3e340 Binary files /dev/null and b/castle/cms/static/images/previews/querylisting/full-content.png differ diff --git a/castle/cms/tiles/configure.zcml b/castle/cms/tiles/configure.zcml index ab0ac0973..d4eae9ad8 100644 --- a/castle/cms/tiles/configure.zcml +++ b/castle/cms/tiles/configure.zcml @@ -434,6 +434,12 @@ for="plone.dexterity.interfaces.IDexterityContent ..interfaces.ICastleLayer" factory=".querylisting.TiledView" /> + + +
+
  • + +
    +
    + +
    +
    +
    +

    + ${item/Title} +

    +
    +

    +

    + + to + + +

    +
    +
    +
    +
    +
  • +
    +
    + \ No newline at end of file diff --git a/castle/cms/upgrades.zcml b/castle/cms/upgrades.zcml index 435d45676..3b4de6864 100644 --- a/castle/cms/upgrades.zcml +++ b/castle/cms/upgrades.zcml @@ -261,4 +261,25 @@ profile="castle.cms:default" /> + + + + + + diff --git a/castle/cms/upgrades/__init__.py b/castle/cms/upgrades/__init__.py index 225cbd95a..538e75c11 100644 --- a/castle/cms/upgrades/__init__.py +++ b/castle/cms/upgrades/__init__.py @@ -9,7 +9,12 @@ from zope.interface import noLongerProvides import plone.api as api - +from fbigov.contenttypes.interfaces.pressrelease import IPressRelease +from castle.cms.interfaces import IVideo, IAudio +from fbigov.contenttypes.interfaces.speech import ISpeech +from fbigov.contenttypes.interfaces.story import IStory +from fbigov.contenttypes.interfaces.testimony import ITestimony +from plone.app.contenttypes.interfaces import IFile, IImage CASTLE_LOGGER = getLogger('castle.cms') PROFILE_ID = 'profile-castle.cms:default' @@ -141,3 +146,14 @@ def upgrade_3011(site, logger=CASTLE_LOGGER): upgrade_3014 = default_upgrade_factory('3014') upgrade_3015 = default_upgrade_factory('3015') upgrade_3016 = default_upgrade_factory('3016') +upgrade_3017a = default_upgrade_factory('3017') + +def upgrade_3017b(site, logger=CASTLE_LOGGER): + logger.info('3017b') + query = api.content.find( + object_provides=[IFile, IPressRelease, IImage, IVideo, IAudio, IStory, ISpeech, ITestimony]) + for item in query: + print('reindexing object {}'.format(item.Title)) + obj = item.getObject() + obj.reindexObject(idxs=['querylist_searchabletext']) + print('upgrade completed') \ No newline at end of file