start of a search page
authorMike Rylander <mrylander@gmail.com>
Mon, 8 Apr 2013 15:57:38 +0000 (11:57 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 8 Apr 2013 15:57:38 +0000 (11:57 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>

src/perl/lib/templates/search [new file with mode: 0644]

diff --git a/src/perl/lib/templates/search b/src/perl/lib/templates/search
new file mode 100644 (file)
index 0000000..9a9914b
--- /dev/null
@@ -0,0 +1,64 @@
+[%
+
+WRAPER home;
+
+desired_types = cgi.param('otypes');
+desired_otypes = [];
+desired_otype_ids = [];
+IF desired_types.size > 0;
+    desired_otypes = cstore.search_depository_base_object_type({ hint => desired_types });
+    FOREACH dot IN desired_otypes;
+        desired_otype_ids.push(dot.id());
+    END;
+END;
+
+otypes = cstore.retrieve_all_depository_base_object_type();
+
+otype_by_label = [];
+FOREACH o IN otypes;
+    otype_by_label.push(o.label());
+    otype_by_label.push(o);
+END;
+otype_by_label = otype_by_label.hash;
+
+IF !api %]
+
+<form method="GET">
+
+Packages containing:
+<select name="otypes" multiple="multiple">
+    <option value="*">Any</option>'
+
+[% FOREACH l IN otype_by_label.keys.sort %]
+    <option value="[% otype_by_label.$l.hint() %]" [% 'checked="checked"' IF desired_types.grep(otype_by_label.$l.hint()) %]>[% $l %]</option>
+[% END %]
+
+</select><hr/>
+
+<input type="submit" name="action" value="Search"/>
+
+</form>
+
+[%
+
+END;
+
+items = cstore.search_depository_item({ otype => desired_otype_ids });
+pids = [];
+FOREACH i in items;
+    pids.push(i.package());
+END;
+
+pkgs = cstore.search_depository_packages([{ id => pids.unique },{ flesh => 1, flesh_fields => { dp => ['rating'] }}]);
+pkg_by_rating = [];
+FOREACH p IN pkgs;
+    pkg_by_rating.push( p.rating() _ p.title().lowercase );
+    pkg_by_rating.push( p );
+END;
+pkg_by_rating = pkg_by_rating.hash;
+
+FOREACH p IN pkg_by_rating.keys.sort;
+    INCLUDE package_summary pkg = pkg_by_rating.$p;
+END;
+
+%]