cmsplugin-googlesearch / cmsplugin_googlesearch /

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
#from cms.models import CMSPlugin
from cmsplugin_googlesearch.models import GoogleSearchPlugin
from cmsplugin_googlesearch.forms import GoogleSearchForm
from django.utils.translation import ugettext as _
from cms.models.titlemodels import Title

class CMSGoogleSearchPlugin(CMSPluginBase):
    model = GoogleSearchPlugin
    name = _("Google Search")
    render_template = "plugins/cmsplugin_googlesearch/"

    def render(self, context, instance, placeholder):

        #set plugin template from plugin model
        self.render_template = "plugins/cmsplugin_googlesearch/%s" % instance.get_template_display()

        #get the first page that has an apphook to cmsplugin_googlesearch; use it as the form redirect value
        redirect = Title.objects.filter(application_urls='cmsplugin_googlesearch.urls').filter(publisher_is_draft=False)[0].page.get_absolute_url()

#        import ipdb; ipdb.set_trace()

        form = GoogleSearchForm()

        #if a query is defined in the plugin
        if instance.query:
            form.initial.update({'query': instance.query.strip(), })

            'object':       instance,
            'placeholder':  placeholder,
            'css':          instance.get_css_display(),
            'form':         form,
            'redirect':     redirect,
        return context

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.