provide quicksearch input field as top action

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3217 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2009-02-08 16:30:12 +00:00
parent 3589363264
commit 6acfec47f4
8 changed files with 173 additions and 9 deletions

View file

@ -27,9 +27,9 @@
<a name="top" <a name="top"
tal:content="item/title">Title</a> tal:content="item/title">Title</a>
</h1> </h1>
<p tal:define="description description|item/description" <p tal:define="description description|item/renderedDescription"
tal:condition="description"> tal:condition="description">
<i tal:content="description">Description</i></p> <i tal:content="structure description">Description</i></p>
</metal:title> </metal:title>

View file

@ -160,6 +160,22 @@ fieldset.box td {
top: 1em; top: 1em;
} }
.quicksearch {
position: absolute;
right: 2em;
top: 1em;
}
.quicksearch input {
font-size: 80%;
}
.language-switch {
position: absolute;
right: 2em;
top: 3em;
}
.top image { .top image {
margin-top: -1px; margin-top: -1px;
} }

View file

@ -104,6 +104,10 @@ class NodeView(BaseView):
cm.register('js', 'loops.js', resourceName='loops.js', priority=60) cm.register('js', 'loops.js', resourceName='loops.js', priority=60)
cm.register('top_actions', 'top_actions', name='multi_actions', cm.register('top_actions', 'top_actions', name='multi_actions',
subMacros=[i18n_macros.macros['language_switch']]) subMacros=[i18n_macros.macros['language_switch']])
if self.globalOptions('expert.quicksearch'):
from loops.expert.browser.search import search_macros
cm.register('top_actions', 'top_quicksearch', name='multi_actions',
subMacros=[search_macros.macros['quicksearch']], priority=20)
cm.register('portlet_left', 'navigation', title='Navigation', cm.register('portlet_left', 'navigation', title='Navigation',
subMacro=node_macros.macros['menu']) subMacro=node_macros.macros['menu'])
if canWrite(self.context, 'title') or ( if canWrite(self.context, 'title') or (

View file

@ -13,4 +13,10 @@
factory="loops.expert.browser.base.BaseQueryView" factory="loops.expert.browser.base.BaseQueryView"
permission="zope.View" /> permission="zope.View" />
<browser:page
name="search.html"
for="loops.interfaces.INode"
class="loops.expert.browser.search.SearchResults"
permission="zope.View" />
</configure> </configure>

80
expert/browser/search.pt Normal file
View file

@ -0,0 +1,80 @@
<html i18n:domain="loops">
<!-- $Id$ -->
<div metal:define-macro="quicksearch"
class="top-actions quicksearch">
<form method="get" action="search.html">
<input type="text" name="search.text" />
</form>
</div>
<div metal:define-macro="search_results" id="search.results"
tal:define="item nocall:view">
<fieldset class="box">
<metal:results define-macro="results">
<h2 i18n:translate="">Search results</h2>
<table class="listing" summary="Search results"
i18n:attributes="summary">
<thead>
<tr>
<th i18n:translate="">Title</th>
<th i18n:translate="">Type</th>
<th i18n:translate=""
tal:condition="view/useVersioning">V</th>
<th i18n:translate="">Size</th>
<th i18n:translate="">Modification Date</th>
<th i18n:translate="">Author(s)</th>
<th i18n:translate=""
tal:condition="view/showObjectActions">Info</th>
</tr>
</thead>
<tbody>
<tal:items tal:repeat="row item/results">
<tal:item define="class python: repeat['row'].odd() and 'even' or 'odd';
description row/description">
<tr tal:attributes="class class">
<td>
<a tal:attributes="href
string:${view/url}/.target${row/uniqueId}?version=this;
title description">
<img tal:define="icon row/icon"
tal:condition="icon"
tal:attributes="src icon/src" />
<div tal:content="row/title" /></a>
</td>
<td i18n:translate="" class="center"
tal:content="row/longTypeTitle|row/typeTitle">Type</td>
<tal:version condition="view/useVersioning">
<td class="center"
tal:define="versionId row/versionId|string:">
<a href="#"
tal:content="versionId"
tal:omit-tag="python: versionId and versionId=='1.1'"
tal:attributes="href string:${view/url}/.target${row/uniqueId}?loops.viewName=listversions">1.1</a>
</td>
</tal:version>
<td class="nowrap number">
<span tal:replace="row/context/sizeForDisplay|string:">Size</span>
</td>
<td><span tal:replace="row/modified">modified</span></td>
<td><span tal:replace="row/creators">John</span></td>
<td class="nowrap center"
tal:define="target nocall:row;
style nothing"
tal:condition="view/showObjectActions">
<div metal:use-macro="views/node_macros/object_actions" />
</td>
</tr>
</tal:item>
</tal:items>
</tbody>
</table>
</metal:results>
</fieldset>
</div>
</html>

58
expert/browser/search.py Normal file
View file

@ -0,0 +1,58 @@
#
# Copyright (c) 2009 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
"""
Definition of basic view classes and other browser related stuff for the
loops.expert package.
$Id$
"""
from zope import interface, component
from zope.app.pagetemplate import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy
from zope.traversing.api import getName, getParent
from loops.browser.node import NodeView
from loops.expert.concept import ConceptQuery, FullQuery
from loops import util
from loops.util import _
search_macros = ViewPageTemplateFile('search.pt')
class SearchResults(NodeView):
""" Provides results listing """
@Lazy
def macro(self):
return search_macros.macros['search_results']
@Lazy
def item(self):
return self
@Lazy
def results(self):
form = self.request.form
text = form.get('search.text')
type = self.globalOptions('expert.quicksearch')[0]
result = FullQuery(self).query(text=text, type=type,
useTitle=True, useFull=True,)
return self.viewIterator(result)

View file

@ -1,6 +1,7 @@
<!-- $Id$ --> <!-- $Id$ -->
<metal:actions define-macro="language_switch" <div metal:define-macro="language_switch"
class="top-actions language-switch"
tal:define="langInfo view/languageInfo; tal:define="langInfo view/languageInfo;
available langInfo/availableLanguages" available langInfo/availableLanguages"
tal:condition="python: len(available) > 1"> tal:condition="python: len(available) > 1">
@ -13,4 +14,4 @@
class python: langInfo.language == lang class python: langInfo.language == lang
and 'selected' or 'notselected'" /></a> and 'selected' or 'notselected'" /></a>
</tal:lang> </tal:lang>
</metal:actions> </div>

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de # Copyright (c) 2009 Helmut Merz helmutm@cy55.de
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -36,7 +36,6 @@ from cybertools.typology.interfaces import ITypeManager
from loops.browser.common import BaseView from loops.browser.common import BaseView
from loops.browser.node import NodeView from loops.browser.node import NodeView
from loops.common import adapted from loops.common import adapted
#from loops.query import ConceptQuery, FullQuery
from loops.expert.concept import ConceptQuery, FullQuery from loops.expert.concept import ConceptQuery, FullQuery
from loops import util from loops import util
from loops.util import _ from loops.util import _