implemented the first baby steps of "Find"...a "Find Categories" function

This commit is contained in:
Eric J. Bowersox 2003-05-26 09:58:35 +00:00
parent 0ffd03e38b
commit 25569583ea
13 changed files with 306 additions and 27 deletions

View File

@ -165,7 +165,7 @@
<object name="venice-auditor" classname="com.silverwrist.venice.app.StartupShutdownAuditor" priority="100"/>
<object name="categories" classname="com.silverwrist.venice.community.CategoryManager" priority="100"/>
<object name="categories" classname="com.silverwrist.venice.community.CategoryManager" priority="100">
<database connection="data"/>
</object>

View File

@ -164,7 +164,7 @@
<object name="venice-auditor" classname="com.silverwrist.venice.app.StartupShutdownAuditor" priority="100"/>
<object name="categories" classname="com.silverwrist.venice.community.CategoryManager" priority="100"/>
<object name="categories" classname="com.silverwrist.venice.community.CategoryManager" priority="100">
<database connection="data"/>
</object>

View File

@ -323,6 +323,8 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
(6, 'subdir.buttons', '!buttons/classic' ),
(6, 'std.button.width', 'I80' ),
(6, 'std.button.height', 'I24' ),
(6, 'bn.0transparent', '!transparent.gif' ),
(6, 'bnc.0transparent', '!' ),
(6, 'bn.cancel', '!cancel.jpg' ),
(6, 'bnc.cancel', '!Cancel' ),
(6, 'bn.configure', '!configure.jpg' ),
@ -335,10 +337,16 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
(6, 'bnc.i.decline', '!I Decline' ),
(6, 'bn.login', '!login.jpg' ),
(6, 'bnc.login', '!Log In' ),
(6, 'bn.next', '!arrow_next.jpg' ),
(6, 'bnc.next', '!Next' ),
(6, 'bn.ok', '!ok.jpg' ),
(6, 'bnc.ok', '!OK' ),
(6, 'bn.previous', '!arrow_previous.jpg' ),
(6, 'bnc.previous', '!Previous' ),
(6, 'bn.reminder', '!reminder.jpg' ),
(6, 'bnc.reminder', '!Reminder' ),
(6, 'bn.search', '!search.jpg' ),
(6, 'bnc.search', '!Search' ),
(6, 'bn.send.again', '!send_again.jpg' ),
(6, 'bnc.send.again', '!Send Again' ),
(6, 'bn.send.email', '!send_email.jpg' ),
@ -359,6 +367,7 @@ INSERT INTO globalprop (nsid, prop_name, prop_value) VALUES
(10, 'timezone', '_TZ:UTC' ),
(10, 'locale', '_LOC:en_US' ),
(10, 'admin.flags', '_OS:' ),
(10, 'search.result.count', 'I20' ),
(11, 'privacy', '_OS:' ),
(12, 'confirm.message.title', '!Venice E-Mail Confirmation' ),
(12, 'password.change.message.title', '!Venice Password Changed' ),
@ -462,16 +471,17 @@ INSERT INTO users (uid, username, email, is_anon, nospam, created) VALUES
# Set up properties for Anonymous_Honyak.
INSERT INTO userprop (uid, nsid, prop_name, prop_value) VALUES
(1, 10, 'timezone', '_TZ:UTC' ),
(1, 10, 'locale', '_LOC:en_US'),
(1, 10, 'admin.flags', '_OS:A' ),
(1, 11, 'privacy', '_OS:' ),
(1, 11, 'name.given', '!Anonymous'),
(1, 11, 'name.family', '!Honyak' ),
(1, 11, 'locality', '!Nowhere' ),
(1, 11, 'region', '!XX' ),
(1, 11, 'postal.code', '!00000' ),
(1, 11, 'country', '_CTRY:US' );
(1, 10, 'timezone', '_TZ:UTC' ),
(1, 10, 'locale', '_LOC:en_US'),
(1, 10, 'admin.flags', '_OS:A' ),
(1, 10, 'search.result.count', 'I20' ),
(1, 11, 'privacy', '_OS:' ),
(1, 11, 'name.given', '!Anonymous'),
(1, 11, 'name.family', '!Honyak' ),
(1, 11, 'locality', '!Nowhere' ),
(1, 11, 'region', '!XX' ),
(1, 11, 'postal.code', '!00000' ),
(1, 11, 'country', '_CTRY:US' );
# Add authentication for Administrator (no password by default)
INSERT INTO userauth (uid, nsid, method, source_data, auth_data) VALUES
@ -479,16 +489,17 @@ INSERT INTO userauth (uid, nsid, method, source_data, auth_data) VALUES
# Set up properties for Administrator.
INSERT INTO userprop (uid, nsid, prop_name, prop_value) VALUES
(2, 10, 'timezone', '_TZ:UTC' ),
(2, 10, 'locale', '_LOC:en_US' ),
(2, 10, 'admin.flags', '_OS:' ),
(2, 11, 'privacy', '_OS:' ),
(2, 11, 'name.given', '!System' ),
(2, 11, 'name.family', '!Administrator'),
(2, 11, 'locality', '!Nowhere' ),
(2, 11, 'region', '!XX' ),
(2, 11, 'postal.code', '!00000' ),
(2, 11, 'country', '_CTRY:US' );
(2, 10, 'timezone', '_TZ:UTC' ),
(2, 10, 'locale', '_LOC:en_US' ),
(2, 10, 'admin.flags', '_OS:' ),
(2, 10, 'search.result.count', 'I20' ),
(2, 11, 'privacy', '_OS:' ),
(2, 11, 'name.given', '!System' ),
(2, 11, 'name.family', '!Administrator'),
(2, 11, 'locality', '!Nowhere' ),
(2, 11, 'region', '!XX' ),
(2, 11, 'postal.code', '!00000' ),
(2, 11, 'country', '_CTRY:US' );
# Create a group for site administrators.
# (GID 1)
@ -985,3 +996,9 @@ INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_ns
'set.property'),
(3, 5, 'TEXT', 'Edit Password Reminder E-Mail Message', 'SERVLET', 'sysadmin/pwremind_email.js.vs', 12,
'set.property');
# Create the find submenu. (ID #4)
INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle)
VALUES (4, 6, 'find.menu', 'Find', NULL);
INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link) VALUES
(4, 0, 'TEXT', 'Categories', 'SERVLET', 'find_categories.js.vs');

View File

@ -392,10 +392,17 @@ public class ButtonSupplier
// get the full URL of the image
String image_url = rewrite.rewriteURL("IMAGE",m_subdir + "/" + token.getImageName());
// render as <image/> tag
if (ButtonType.IMAGE.equals(token.getType()))
wr.write("<img src=\"" + image_url + "\" alt=\"[" + token.getCaption() + "]\" width = \"" + m_width
+ "\" height=\"" + m_height + "\" border=\"0\" />");
{ // render as <image/> tag
String xcapt;
if (token.getName().startsWith("0"))
xcapt = token.getCaption();
else
xcapt = "[" + token.getCaption() + "]";
wr.write("<img src=\"" + image_url + "\" alt=\"" + xcapt + "\" width = \"" + m_width + "\" height=\""
+ m_height + "\" border=\"0\" />");
} // end if
// render as <input type="image"/> tag
if (ButtonType.INPUT.equals(token.getType()))

View File

@ -71,6 +71,12 @@ public class StandardContentSupplier
} // end header1
public Object bullet() throws DatabaseException
{
return getContentBlock("std.bullet");
} // end bullet
} // end class ContentOps
/*--------------------------------------------------------------------------------

View File

@ -21,18 +21,21 @@
<action>profile.js.vs</action>
<render-param name="rtgt"/>
<hidden name="tgt" value=""/>
<header name="pw_hdr" caption="Password">
To change your password, enter a new password into the fields below.
</header>
<password name="pass1" caption="Password" size="32" maxlength="128"/>
<password name="pass2" caption="Password" caption2="(retype)" size="32" maxlength="128"/>
<text name="remind" caption="Password reminder phrase" size="32" maxlength="255"/>
<header name="name_hdr" caption="Name"/>
<text name="prefix" caption="Prefix" caption2="(Mr., Ms., etc.)" size="8" maxlength="8"/>
<text name="first" caption="First Name" required="true" size="32" maxlength="64"/>
<text name="mid" caption="Middle initial" size="1" maxlength="1"/>
<text name="last" caption="Last Name" required="true" size="32" maxlength="64"/>
<text name="suffix" caption="Suffix" caption2="(Jr., III, etc.)" size="16" maxlength="16"/>
<header name="loc_hdr" caption="Location"/>
<text name="company" caption="Company" size="32" maxlength="255"/>
<text name="addr1" caption="Address" size="32" maxlength="255"/>
@ -42,6 +45,7 @@
<text name="reg" caption="State/Province" required="true" size="32" maxlength="64"/>
<text name="pcode" caption="Zip/Postal Code" required="true" size="32" maxlength="64"/>
<countrylist name="country" caption="Country" required="true"/>
<header name="phone_hdr" caption="Phone Numbers"/>
<text name="phone" caption="Telephone" size="32" maxlength="32"/>
<checkbox name="pvt_phone" caption="Hide phone number in profile"/>
@ -49,17 +53,22 @@
<checkbox name="pvt_mobile" caption="Hide mobile phone number in profile"/>
<text name="fax" caption="Fax" size="32" maxlength="32"/>
<checkbox name="pvt_fax" caption="Hide fax number in profile"/>
<header name="email_hdr" caption="Internet"/>
<email name="email" caption="E-mail address" required="true" size="32" maxlength="255"/>
<checkbox name="pvt_email" caption="Hide E-mail address in profile"/>
<text name="url" caption="Home Page" caption2="(URL)" size="32" maxlength="255"/>
<header name="pers_hdr" caption="Personal"/>
<text name="descr" caption="Personal description" size="32" maxlength="255"/>
<userphoto name="photo" caption="User Photo" link="profile_photo.js.vs?tgt=${rtgt}" type="servlet"/>
<header name="prefs_hdr" caption="User Preferences"/>
<checkbox name="no_mass_mail" caption="Don't send me mass E-mail messages"/>
<localelist name="locale" caption="Default locale" caption2="(for formatting dates/times)" required="true"/>
<tzlist name="tz" caption="Default time zone" required="true"/>
<int name="scount" caption="Number of search results per page" required="true" min="5" max="100"/>
<button name="update"/>
<button name="cancel"/>
</dialog>

View File

@ -0,0 +1,23 @@
// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(Packages.com.silverwrist.dynamo.util);
req = bsf.lookupBean("request"); // get request
rhelp = bsf.lookupBean("request_help"); // get request helper
// TEMPORARY - redirect to the one find page we have implemented, Categories
dynamo.scriptOutput(new Redirect("SERVLET","find_categories.js.vs"));

View File

@ -0,0 +1,96 @@
// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.lang);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.SearchMode);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.community);
importPackage(Packages.com.silverwrist.venice.content);
req = bsf.lookupBean("request"); // get request
rhelp = bsf.lookupBean("request_help"); // get request helper
user = vlib.getUser(req); // get user
// Get the user's configured page size.
pagesize = cast.toInteger(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
mode = SearchMode.PREFIX;
term = "";
ofs = 0;
fcount = -1;
results = null;
rc = null;
if (rhelp.isVerb("POST"))
{ // Read the form parameters
mode = SearchMode.getEnum(rhelp.getParameter("mode"));
term = rhelp.getParameter("term");
ofs = rhelp.getParameterInt("ofs",0);
fcount = rhelp.getParameterInt("fcount",-1);
// Adjust offset based on the button that was clicked.
if (rhelp.isImageButtonClicked("search"))
{ // beginning of a new search
ofs = 0;
fcount = -1;
} // end if
else if (rhelp.isImageButtonClicked("previous"))
ofs = Math.max(ofs - pagesize,0);
else if (rhelp.isImageButtonClicked("next"))
ofs += pagesize;
// Get the category service object.
catsvc = vcast.queryCategoryService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"categories"));
try
{ // search for categories!
if (fcount<0)
fcount = catsvc.getSearchCategoryCount(mode,term);
results = catsvc.searchForCategories(mode,term,ofs,pagesize);
} // end try
catch (e)
{ // exception thrown
rc = new ErrorBox("Database Error",e,"SERVLET","find_categories.js.vs");
} // end catch
} // end else
if (rc==null)
{ // create the VelocityView for the output
rc = new VelocityView("Find Categories","find_categories.vm");
rc.setParameter("mode",mode.getName());
rc.setParameter("term",term.toString());
rc.setParameter("ofs",cast.toIntegerObject(ofs));
rc.setParameter("fcount",cast.toIntegerObject(fcount));
rc.setParameter("pagesize",cast.toIntegerObject(pagesize));
if (results!=null)
rc.setParameter("results",results);
// Load the profile menu.
mprov = vcast.queryMenuProvider(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-menus"));
menu = mprov.getInlineMenu(user,VeniceNamespaces.CONTENT_LAF_NAMESPACE,"find.menu",cast.newIntArray(0));
menu.setSelectedIndex(0);
rc.setParameter("menu",menu);
} // end if
dynamo.scriptOutput(rc);

View File

@ -120,6 +120,7 @@ if (req_help.isVerb("GET"))
dlg.setValue("no_mass_mail",cast.booleanObject(user.isNoSpam()));
dlg.setValue("locale",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"locale"));
dlg.setValue("tz",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"timezone"));
dlg.setValue("scount",user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
// prepare the dialog and return it
dlg.setRenderParam("rtgt",stringutils.encodeURL(target));
@ -226,6 +227,7 @@ if (op=="update")
user.setNoSpam(user,cast.toBoolean(dlg.getValue("no_mass_mail")));
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"locale",dlg.getValue("locale"));
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"timezone",dlg.getValue("tz"));
user.setObject(user,VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count",dlg.getValue("scount"));
user.setObject(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy",priv);
// Set the "profile last updated" date for the user.

View File

@ -43,3 +43,5 @@
#macro( header2 $title $subtitle )$std.renderObject($std_content.header2($title,$subtitle))#end
#macro( button $type $name )$std.renderObject($std_button.getButton($type,$name))#end
#macro( bullet )$std.renderObject($std_content.bullet())#end

View File

@ -0,0 +1,115 @@
#*
The contents of this file are subject to the Mozilla Public License Version 1.1
(the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
The Original Code is the Venice Web Communities System.
The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
Contributor(s):
*#
#*
Parameters:
mode = Search mode
term = Search term
ofs = Offset within the search we're at right now
fcount = Total number of items found in current search
pagesize = Number of items to display per page
results = Results list from find, a List of VeniceCategory objects (may be null)
menu = Tab menu to render across the top
*#
#render( $menu )
#header1( "Find Categories" )
<form method="POST" action="#formatURL( "SERVLET" "find_categories.js.vs")">
<input type="hidden" name="ofs" value="0">
#comment( "Find Categories form" )
<div align="left"><p>
Display all categories whose name&nbsp;&nbsp;
<select name="mode" size="1">
<option value="PREFIX" #if( $mode.equals("PREFIX") )selected="selected"#end >starts with the string</option>
<option value="SUBSTRING" #if( $mode.equals("SUBSTRING") )selected="selected"#end >contains the string</option>
<option value="REGEXP" #if( $mode.equals("REGEXP") )selected="selected"#end >matches the regular
expression</option>
</select>&nbsp;&nbsp;
<input type="text" name="term" size="32" maxlength="255" value="$!term" /></p>
<p>#button( "INPUT" "search" )</p>
</div>
#comment( "end Find Categories form" )
</form>
#if( $results )
## Do a tricky set of computations here to figure out what we need to display in terms of the search results
## and the form to the right that lets us page through results.
#set( $resultcount = $results.size() )
#set( $is_next = 0 )
#set( $is_prev = 0 )
#if( $resultcount > $pagesize )
#set( $resultcount = $pagesize )
#set( $is_next = 1 )
#end
#if( $ofs > 0 )
#set( $is_prev = 1 )
#end
#set( $is_form = $is_next + $is_prev )
#set( $ndx_first = $ofs + 1 )
#set( $ndx_last = $ofs + $pagesize )
#if( $ndx_last > $fcount )
#set( $ndx_last = $fcount )
#end
#comment( "Results display" )
<hr />
<table width="100%" border="0" align="center"><tr valign="middle">
<td width="50%" align="left">
<b>Search Results</b>
#if( $is_form >= 1 )
(Displaying ${ndx_first}-${ndx_last} of ${fcount})
#end
</td>
<td width="50%" align="right">
#if( $is_form >= 1 )
#comment( "Results navigation form" )
<form method="POST" action="#formatURL( "SERVLET" "find_categories.js.vs")">
<input type="hidden" name="mode" value="$mode" />
<input type="hidden" name="term" value="$term" />
<input type="hidden" name="ofs" value="$ofs" />
<input type="hidden" name="fcount" value="$fcount" />
#if( $is_prev == 1 )
#button( "INPUT" "previous" )
#else
#button( "IMAGE" "0transparent" )
#end
&nbsp;&nbsp;
#if( $is_next == 1 )
#button( "INPUT" "next" )
#else
#button( "IMAGE" "0transparent" )
#end
</form>
#else
&nbsp;
#end
</td>
</tr></table>
#if( $fcount > 0 )
#set( $i = $resultcount )
#foreach( $cat in $results )
#set( $i = $i - 1 )
#if( $i >= 0 )
#bullet() ${cat.toString()}<br />
#end
#end
#else
<em>No categories found.</em>
#end
#comment( "End results display" )
#end

View File

@ -73,7 +73,8 @@
#comment( "Links to Front Page, Help, Find" )
<p><b><a class="frametop" href="#formatURL( "SERVLET" "top.js.vs" )">Front Page</a></b></p>
<p><b>
<a class="frametop" href="TODO">Help</a> | <a class="frametop" href="TODO">Find</a>
<a class="frametop" href="TODO">Help</a> |
<a class="frametop" href="#formatURL( "SERVLET" "find.js.vs" )">Find</a>
</b></p>
</td>

View File

@ -122,7 +122,7 @@ div.imenu ul {
div.imenu ul li {
margin-left: 0;
margin-bottom: 0;
padding: 2px 15px 5px;
padding: 2px 5px 5px;
border: 1px solid #000;
list-style: none;
display: inline;
@ -140,5 +140,6 @@ div.imenu ul li.separator {
border: none;
list-style: none;
display: inline;
color: #ffffff;
background-color: #6666cc;
}