Merge lp:~tristan-rivoallan/vanilla-miner/vm-597913 into lp:vanilla-miner

Proposed by Tristan Rivoallan
Status: Merged
Merged at revision: 55
Proposed branch: lp:~tristan-rivoallan/vanilla-miner/vm-597913
Merge into: lp:vanilla-miner
Diff against target: 464 lines (+155/-127)
11 files modified
apps/frontend/config/app.yml (+5/-13)
apps/frontend/modules/resource/actions/actions.class.php (+110/-95)
apps/frontend/modules/resource/templates/_documentation/howto.php (+7/-7)
apps/frontend/modules/resource/templates/_documentation/links/cookbook.php (+3/-3)
apps/frontend/modules/resource/templates/collectionsSuccess.php (+7/-2)
apps/frontend/modules/resource/templates/getHtml.php (+1/-1)
apps/frontend/modules/resource/templates/segmentsSuccess.php (+1/-1)
apps/frontend/templates/layout.php (+1/-1)
lib/vendor/CI/Search/Formatter/Json.php (+4/-3)
lib/vendor/CI/Search/Link/Segment.php (+15/-0)
web/css/main.css (+1/-1)
To merge this branch: bzr merge lp:~tristan-rivoallan/vanilla-miner/vm-597913
Reviewer Review Type Date Requested Status
Tristan Rivoallan Approve
Review via email: mp+28767@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tristan Rivoallan (tristan-rivoallan) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apps/frontend/config/app.yml'
2--- apps/frontend/config/app.yml 2010-06-03 14:47:58 +0000
3+++ apps/frontend/config/app.yml 2010-06-29 16:08:28 +0000
4@@ -3,16 +3,8 @@
5
6 # default values
7 all:
8- resources:
9- collections: [link]
10- link:
11- segments: [all, images, mp3, youtube]
12- all:
13- formats: [html, json]
14- mp3:
15- formats: [html, json, xspf]
16- youtube:
17- formats: [html, json, xspf]
18- images:
19- formats: [html, json]
20-
21\ No newline at end of file
22+ miner:
23+ collections:
24+ links:
25+ model: Link
26+ segments: [all, mp3, images, youtube]
27\ No newline at end of file
28
29=== modified file 'apps/frontend/modules/resource/actions/actions.class.php'
30--- apps/frontend/modules/resource/actions/actions.class.php 2010-06-04 15:59:32 +0000
31+++ apps/frontend/modules/resource/actions/actions.class.php 2010-06-29 16:08:28 +0000
32@@ -8,99 +8,114 @@
33 */
34 class resourceActions extends sfActions
35 {
36- public function executeCollections(sfWebRequest $request)
37- {
38- $collections = array();
39- $collections_names = sfConfig::get('app_resources_collections', array());
40- foreach ($collections_names as $collection_name)
41- {
42- $collections[$collection_name] = array('count' => Doctrine::getTable(ucfirst($collection_name))->count());
43- }
44- $this->collections = $collections;
45- }
46-
47- public function executeSegments(sfWebRequest $request)
48- {
49- $segments = array();
50- if ($resource_parameters = sfConfig::get(sprintf('app_resources_%s', $request->getParameter('collection')), false))
51- {
52- $segments = $resource_parameters['segments'];
53- }
54-
55- $this->segments = $segments;
56- }
57-
58- public function executeFormats(sfWebRequest $request)
59- {
60- $segment_formats = array();
61- if ($resource_parameters = sfConfig::get(sprintf('app_resources_%s', $request->getParameter('collection')), false))
62- {
63- $segment_formats = $resource_parameters[$request->getParameter('segment')]['formats'];
64- }
65-
66- $this->formats = $segment_formats;
67- }
68-
69- public function executeGet(sfWebRequest $request)
70- {
71- // TODO : a good place to learn about dependency injection ?
72- // TODO : "q" query parameter makes it possible to directly query solr (no sfLuceneCriteria)
73-
74- // Gather meaningful parameters
75- $resource_collection = $request->getParameter('collection', 'unknown');
76- $resource_segment = $request->getParameter('segment', 'all');
77- $format = $request->getParameter('format', 'html');
78-
79- // TODO : autoload those clases
80- include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/%s/Segment.php', ucfirst($resource_collection));
81- include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/%s/Segment/%s.php', ucfirst($resource_collection), ucfirst($resource_segment));
82- include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/Formatter/%s.php', ucfirst($format));
83-
84- // Get results from selected resource segment
85- $resource_segment_class = sprintf('CI_Search_%s_Segment_%s', ucfirst($resource_collection), ucfirst($resource_segment));
86- if (!class_exists($resource_segment_class))
87- {
88- throw new InvalidArgumentException(sprintf('Search class "%s" does not exist for "%s/%s" resource segment', $resource_segment_class, $resource_collection, $resource_segment));
89- }
90- // TODO : lucene index must be configurable
91- $resource_segment_instance = new $resource_segment_class($this->getContext()->getEventDispatcher(), sfLucene::getInstance('IndexA', 'fr'));
92- $raw_results = $resource_segment_instance->search($request->getParameterHolder());
93-
94- // Make sure results are unique (this a just a hack)
95- // see http://www.php.net/manual/en/function.array-unique.php#91134
96- // NOTE : it sucks as it makes the "limit" parameter not trustable
97- // TODO : resource unicity must be enforced when importing documents into solr
98- if ($this->getRequestParameter('hack_unique_results', false))
99- {
100- $raw_results_unique = array();
101- foreach ($raw_results as $result)
102- {
103- $raw_results_unique[md5($result['url'])] = $result;
104- }
105- $raw_results = $raw_results_unique;
106- }
107-
108- // Format results
109- $formatter_class = sprintf('CI_Search_Formatter_%s', ucfirst($format));
110- if (!class_exists($formatter_class))
111- {
112- throw new InvalidArgumentException(sprintf('Formatter class "%s" does not exist for format "%s"', $formatter_class, $format));
113- }
114- $formatter = new $formatter_class($this->getContext()->getEventDispatcher());
115- $results = $formatter->format($raw_results);
116-
117- // Tweak response depending on formatter
118- $this->getResponse()->setContentType($formatter->content_type);
119- $this->setLayout($formatter->sf_has_layout);
120- if (!$formatter->sf_has_layout)
121- {
122- sfConfig::set('sf_web_debug', false);
123- }
124-
125- // Pass results to view
126- $this->results = $results;
127-
128- // Select template
129- return ucfirst($format);
130- }
131+ public function executeCollections(sfWebRequest $request)
132+ {
133+ $collections = array();
134+ $collections_names = sfConfig::get('app_miner_collections', array());
135+
136+ foreach ($collections_names as $collection_name => $collection_info)
137+ {
138+ include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/%s/Segment.php', $collection_info['model']);
139+
140+ // Alphabetical sort of segments
141+ sort($collection_info['segments']);
142+
143+ // Gather informations about each collection segment
144+ $segments_infos = array();
145+ foreach ($collection_info['segments'] as $segment_name)
146+ {
147+ include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/%s/Segment/%s.php', $collection_info['model'], ucfirst($segment_name));
148+ $search_classname = sprintf('CI_Search_%s_Segment_%s', $collection_info['model'], $segment_name);
149+ // TODO : Lucene instance must be configurable
150+ $search = new $search_classname($this->dispatcher, sfLucene::getInstance('IndexA', 'fr'));
151+ $segments_infos[$segment_name] = array('count' => $search->count($request->getParameterHolder()));
152+ }
153+
154+ $collections[$collection_name] = array(
155+ 'count' => Doctrine::getTable($collection_info['model'])->count(),
156+ 'segments' => $segments_infos
157+ );
158+ }
159+ $this->collections = $collections;
160+ }
161+
162+ public function executeSegments(sfWebRequest $request)
163+ {
164+ $collections = sfConfig::get('app_miner_collections');
165+ $segments = array();
166+ if (isset($collections[$request->getParameter('collection')]));
167+ {
168+ $segments = $collections[$request->getParameter('collection')]['segments'];
169+ }
170+ $this->segments = $segments;
171+ }
172+
173+ public function executeFormats(sfWebRequest $request)
174+ {
175+ $segment_formats = array();
176+ if ($resource_parameters = sfConfig::get(sprintf('app_resources_%s', $request->getParameter('collection')), false))
177+ {
178+ $segment_formats = $resource_parameters[$request->getParameter('segment')]['formats'];
179+ }
180+
181+ $this->formats = $segment_formats;
182+ }
183+
184+ public function executeGet(sfWebRequest $request)
185+ {
186+ // TODO : a good place to learn about dependency injection ?
187+ // TODO : "q" query parameter makes it possible to directly query solr (no sfLuceneCriteria)
188+
189+ // Gather meaningful parameters
190+ $resource_collection = $request->getParameter('collection', 'unknown');
191+ $resource_segment = $request->getParameter('segment', 'all');
192+ $format = $request->getParameter('format', 'html');
193+
194+ // Get model corresponding to collection
195+ $collections_infos = sfConfig::get('app_miner_collections');
196+ if (!isset($collections_infos[$resource_collection]))
197+ {
198+ throw new InvalidArgumentException(sprintf('Unknown collection "%s"', $resource_collection));
199+ }
200+ $collection = $collections_infos[$resource_collection];
201+ $resource_model = $collection['model'];
202+
203+ // TODO : autoload those classes
204+ include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/%s/Segment.php', ucfirst($resource_model));
205+ include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/%s/Segment/%s.php', ucfirst($resource_model), ucfirst($resource_segment));
206+ include sprintf(sfConfig::get('sf_lib_dir').'/vendor/CI/Search/Formatter/%s.php', ucfirst($format));
207+
208+ // Get results from selected resource segment
209+ $resource_segment_class = sprintf('CI_Search_%s_Segment_%s', ucfirst($resource_model), ucfirst($resource_segment));
210+ if (!class_exists($resource_segment_class))
211+ {
212+ throw new InvalidArgumentException(sprintf('Search class "%s" does not exist for "%s/%s" resource segment', $resource_segment_class, $resource_model, $resource_segment));
213+ }
214+ // TODO : lucene index must be configurable
215+ $resource_segment_instance = new $resource_segment_class($this->getContext()->getEventDispatcher(), sfLucene::getInstance('IndexA', 'fr'));
216+ $raw_results = $resource_segment_instance->search($request->getParameterHolder());
217+
218+ // Format results
219+ $formatter_class = sprintf('CI_Search_Formatter_%s', ucfirst($format));
220+ if (!class_exists($formatter_class))
221+ {
222+ throw new InvalidArgumentException(sprintf('Formatter class "%s" does not exist for format "%s"', $formatter_class, $format));
223+ }
224+ $formatter = new $formatter_class($this->getContext()->getEventDispatcher());
225+ $results = $formatter->format($raw_results);
226+
227+ // Tweak response depending on formatter
228+ $this->getResponse()->setContentType($formatter->content_type);
229+ $this->setLayout($formatter->sf_has_layout);
230+ if (!$formatter->sf_has_layout)
231+ {
232+ sfConfig::set('sf_web_debug', false);
233+ }
234+
235+ // Pass results to view
236+ $this->results = $results;
237+
238+ // Select template
239+ return ucfirst($format);
240+ }
241 }
242
243=== modified file 'apps/frontend/modules/resource/templates/_documentation/howto.php'
244--- apps/frontend/modules/resource/templates/_documentation/howto.php 2010-06-04 14:55:07 +0000
245+++ apps/frontend/modules/resource/templates/_documentation/howto.php 2010-06-29 16:08:28 +0000
246@@ -1,9 +1,9 @@
247 <h3 id="howto-segment">Choix du segment</h3>
248 <p>
249 La première chose à faire est de choisir le <a href="#segments">segment</a> à requêter. Cela permet d'obtenir l'URL de requêtage.
250- Par exemple, l'URL de requêtage du segment <a href="#segments-images">images</a> est
251+ Par exemple, l'URL de requêtage du segment <a href="#segments-images">images</a> est
252 </p>
253-<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=link&segment=images', true) ?></pre>
254+<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=links&segment=images', true) ?></pre>
255
256 <h3 id="howto-response">Définition de la forme de la réponse</h3>
257 <h4 id="howto-response-limit">Limitation du nombre d'enregistrements</h4>
258@@ -12,7 +12,7 @@
259 Il faut utiliser le paramètre <a href="#common-parameters-limit">limit</a>.
260 Par exemple, pour récupérer trois enregistrements :
261 </p>
262-<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=link&segment=images', true) ?>?<strong>limit=3</strong></pre>
263+<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=links&segment=images', true) ?>?<strong>limit=3</strong></pre>
264
265 <h4 id="howto-response-sort">Définition du mode de tri</h4>
266 <p>
267@@ -20,7 +20,7 @@
268 Par défaut, les enregistrements sont triés par <a href="#schema-contributed_at">date de contribution</a> croissante.
269 Ainsi, pour trier les enregistrement par <a href="#schema-discussion_id">identifiant de discussion</a> décroissant :
270 </p>
271-<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=link&segment=images&limit=3', true) ?>&amp;<strong>sort_field=discussion_id</strong>&amp;<strong>sort_direction=desc</strong></pre>
272+<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=links&segment=images&limit=3', true) ?>&amp;<strong>sort_field=discussion_id</strong>&amp;<strong>sort_direction=desc</strong></pre>
273
274 <h4 id="howto-response-format">Définition du format de réponse</h4>
275 <p>
276@@ -28,14 +28,14 @@
277 Le format par défaut est <a href="#formats-html">HTML</a>.
278 Pour obtenir la réponse au format JSON :
279 </p>
280-<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=link&segment=images&limit=3&sort_field=discussion_id&sort_direction=desc', true) ?>&amp;<strong>format=json</strong></pre>
281+<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=links&segment=images&limit=3&sort_field=discussion_id&sort_direction=desc', true) ?>&amp;<strong>format=json</strong></pre>
282
283 <h4 id="howto-filter">Filtrage en fonction des attributs</h4>
284 <p>
285 Il est enfin possible de restreindre le jeu d'enregistrements retourné en fonction de valeurs de leurs attributs <a href="#schema">schema</a>.
286 Par exemple, pour limiter les enregistrements retournés au images contribuées par l'utilisateur "mbertier" :
287 </p>
288-<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=link&segment=images&limit=3&sort_field=discussion_id&sort_direction=desc&format=json', true) ?>&amp;<strong>contributor_name=mbertier</strong></pre>
289+<pre>GET <?php echo url_for('@resources_collection_segment_get?collection=links&segment=images&limit=3&sort_field=discussion_id&sort_direction=desc&format=json', true) ?>&amp;<strong>contributor_name=mbertier</strong></pre>
290
291 <p>La réponse à cette requête :</p>
292 <pre id="howto-response-test">
293@@ -43,7 +43,7 @@
294 </pre>
295 <script type="text/javascript">
296 $('#howto-response-test')
297- .load('<?php echo url_for('@resources_collection_segment_get?collection=link&segment=images&limit=3&sort_field=discussion_id&sort_direction=desc&format=json&contributor_name=mbertier') ?>');
298+ .load('<?php echo url_for('@resources_collection_segment_get?collection=links&segment=images&limit=3&sort_field=discussion_id&sort_direction=desc&format=json&contributor_name=mbertier') ?>');
299 </script>
300 <p>
301 Il est possible d'ajouter de requêter plusieurs attributs. Dans ce cas la requête est de type ET.
302
303=== renamed directory 'apps/frontend/modules/resource/templates/_documentation/link' => 'apps/frontend/modules/resource/templates/_documentation/links'
304=== modified file 'apps/frontend/modules/resource/templates/_documentation/links/cookbook.php'
305--- apps/frontend/modules/resource/templates/_documentation/link/cookbook.php 2010-06-14 21:43:23 +0000
306+++ apps/frontend/modules/resource/templates/_documentation/links/cookbook.php 2010-06-29 16:08:28 +0000
307@@ -12,7 +12,7 @@
308 <h3 id="example-1">Récupération de 5 liens vers des MP3, par ordre décroissant de date de contribution, au format XSPF</h3>
309
310 <h4 id="example-1-request">Requête</h4>
311-<pre>GET <?php echo $prefix ?><strong>/collections/link/segments/mp3/get</strong>?<strong>limit=5</strong>&amp;<strong>sort_direction=desc</strong>&amp;<strong>sort_field=contributed_at</strong>&amp;<strong>format=xspf</strong></pre>
312+<pre>GET <?php echo $prefix ?><strong>/collections/links/segments/mp3/get</strong>?<strong>limit=5</strong>&amp;<strong>sort_direction=desc</strong>&amp;<strong>sort_field=contributed_at</strong>&amp;<strong>format=xspf</strong></pre>
313
314 <h4 id="example-1-response">Réponse</h4>
315 <pre class="sh_xml"><?php echo htmlentities('
316@@ -41,7 +41,7 @@
317 <h3 id="example-2">Récupération du premier lien posté vers une vidéo Youtube par l'utilisateur "mbertier", au format Json</h3>
318
319 <h4 id="example-2-request">Requête</h4>
320-<pre>GET <?php echo $prefix?><strong>/collections/link/segments/youtube/get</strong>?<strong>limit=1</strong>&amp;<strong>sort_direction=asc</strong>&amp;<strong>sort_field=contributed_at</strong>&amp;<strong>contributor_name=mbertier</strong>&amp;<strong>format=json</strong></pre>
321+<pre>GET <?php echo $prefix?><strong>/collections/links/segments/youtube/get</strong>?<strong>limit=1</strong>&amp;<strong>sort_direction=asc</strong>&amp;<strong>sort_field=contributed_at</strong>&amp;<strong>contributor_name=mbertier</strong>&amp;<strong>format=json</strong></pre>
322
323 <h4 id="example-2-response">Réponse</h4>
324 <pre class="sh_javascript"><?php echo htmlentities('
325@@ -64,7 +64,7 @@
326 <h3 id="example-3">Récupération de toutes les vidéos du topic "Des clips, des clips, rien que des clips", au format PHP sérialisé</h3>
327
328 <h4 id="example-3-request">Requête</h4>
329-<pre>GET <?php echo $prefix?><strong>/collections/link/segments/youtube/get</strong>?<strong>limit=-1</strong>&amp;<strong>discusion_id=1679</strong>&amp;<strong>format=php</strong></pre>
330+<pre>GET <?php echo $prefix?><strong>/collections/links/segments/youtube/get</strong>?<strong>limit=-1</strong>&amp;<strong>discusion_id=1679</strong>&amp;<strong>format=php</strong></pre>
331
332 <h4 id="example-3-response">Réponse (tronquée)</h4>
333 <pre class="sh_php"><?php echo htmlentities('
334
335=== modified file 'apps/frontend/modules/resource/templates/collectionsSuccess.php'
336--- apps/frontend/modules/resource/templates/collectionsSuccess.php 2010-06-14 21:43:23 +0000
337+++ apps/frontend/modules/resource/templates/collectionsSuccess.php 2010-06-29 16:08:28 +0000
338@@ -23,9 +23,14 @@
339 <h2>Collections de ressources</h2>
340 <?php foreach ($collections as $collection_name => $collection_data): ?>
341 <h3><?php echo $collection_name ?></h3>
342- <?php // TODO : data are not accessible in partial. WTF ? ?>
343 <?php include_partial(sprintf('resource/documentation/%s/description', $collection_name), array('collection_name' => $collection_name, 'collection_data' => $collection_data)) ?>
344- <p>À ce jour, cette collection regroupe <strong><?php echo $collection_data['count'] ?></strong> ressources.</p>
345+ <p>À ce jour, cette collection regroupe <strong><?php echo $collection_data['segments']['all']['count'] ?></strong> ressources.</p>
346 <p><?php echo link_to('Consulter la documentation', '@resources_collection?collection='.$collection_name) ?></p>
347+ <p>Segments disponibles :</p>
348+ <ul>
349+ <?php foreach ($collection_data['segments'] as $segment_name => $segment_infos): ?>
350+ <li><a href="<?php echo url_for(sprintf('@resources_collection?collection=%s#segments-%s', $collection_name, $segment_name)) ?>" title="Consulter la documentation du segment <?php echo $segment_name ?>"><?php echo $segment_name ?></a> : <strong><?php echo $segment_infos['count']?></strong> ressources</li>
351+ <?php endforeach; ?>
352+ </ul>
353 <?php endforeach; ?>
354 </div>
355\ No newline at end of file
356
357=== modified file 'apps/frontend/modules/resource/templates/getHtml.php'
358--- apps/frontend/modules/resource/templates/getHtml.php 2010-06-02 15:44:11 +0000
359+++ apps/frontend/modules/resource/templates/getHtml.php 2010-06-29 16:08:28 +0000
360@@ -1,4 +1,4 @@
361-<p>Found <?php echo count($results) ?> results :</p>
362+<p>Displaying <?php echo count($results) ?> out of <?php echo $results['num_found']?> found results :</p>
363 <ul>
364 <?php foreach ($results as $resource): ?>
365 <li><pre><?php echo print_r($resource, true) ?></pre></li>
366
367=== modified file 'apps/frontend/modules/resource/templates/segmentsSuccess.php'
368--- apps/frontend/modules/resource/templates/segmentsSuccess.php 2010-06-14 21:43:23 +0000
369+++ apps/frontend/modules/resource/templates/segmentsSuccess.php 2010-06-29 16:08:28 +0000
370@@ -36,7 +36,7 @@
371 <h4 id="segments-<?php echo $segment?>"><?php echo $segment ?></h4>
372 <?php include_partial(sprintf('resource/documentation/%s/segment/%s', $sf_request->getParameter('collection'), $segment)); ?>
373 <p>URL de requête :</p>
374- <pre>GET <?php echo url_for(sprintf('@resources_collection_segment_get?collection=%s&segment=%s', $sf_request->getParameter('collection'), $segment), true) ?></pre>
375+ <pre>GET <a href="<?php echo url_for(sprintf('@resources_collection_segment_get?collection=%s&segment=%s', $sf_request->getParameter('collection'), $segment), true) ?>" ><?php echo url_for(sprintf('@resources_collection_segment_get?collection=%s&segment=%s', $sf_request->getParameter('collection'), $segment), true) ?></a></pre>
376 <?php endforeach; ?>
377 </div>
378 </div>
379\ No newline at end of file
380
381=== modified file 'apps/frontend/templates/layout.php'
382--- apps/frontend/templates/layout.php 2010-06-24 16:24:46 +0000
383+++ apps/frontend/templates/layout.php 2010-06-29 16:08:28 +0000
384@@ -20,7 +20,7 @@
385
386 <hr />
387
388- <p><a href="https://launchpad.net/vanilla-miner/+milestone/0.4.0">Vanilla Miner 0.4.0</a> a été développé par <a href="http://www.constructions-incongrues.net/">Constructions Incongrues</a> et est hébergé par <a href="http://www.pastis-hosting.net">Pastis Hosting</a>.</p>
389+ <p><a href="https://launchpad.net/vanilla-miner/+milestone/0.4.0">Vanilla Miner 0.4.0</a> est développé par <a href="http://www.constructions-incongrues.net/">Constructions Incongrues</a> et est hébergé par <a href="http://www.pastis-hosting.net">Pastis Hosting</a>.</p>
390 <p>Le code source du service est <a href="https://launchpad.net/vanilla-miner">distribué</a> sous licence <a href="http://www.gnu.org/licenses/agpl.html">GNU Affero GPLv3</a>.</p>
391 <p>Ce service utilise (notamment) <a href="http://www.symfony-project.org">symfony</a>, <a href="http://www.doctrine-project.org">Doctrine</a> et <a href="http://lucene.apache.org/solr/">Solr</a>.</p>
392 <p>Contact : contact @ musiques-incongrues . net</p>
393
394=== modified file 'lib/vendor/CI/Search/Formatter/Json.php'
395--- lib/vendor/CI/Search/Formatter/Json.php 2010-06-02 13:35:38 +0000
396+++ lib/vendor/CI/Search/Formatter/Json.php 2010-06-29 16:08:28 +0000
397@@ -3,16 +3,17 @@
398 {
399 public $content_type = 'application/json';
400 public $sf_has_layout = false;
401-
402+
403 protected $event_dispatcher;
404-
405+
406 public function __construct(sfEventDispatcher $dispatcher)
407 {
408 $this->event_dispatcher = $dispatcher;
409 }
410-
411+
412 public function format(array $resources)
413 {
414+
415 return json_encode($resources);
416 }
417 }
418\ No newline at end of file
419
420=== modified file 'lib/vendor/CI/Search/Link/Segment.php'
421--- lib/vendor/CI/Search/Link/Segment.php 2010-06-23 20:09:52 +0000
422+++ lib/vendor/CI/Search/Link/Segment.php 2010-06-29 16:08:28 +0000
423@@ -35,6 +35,18 @@
424 return $results_array;
425 }
426
427+ public function count(sfParameterHolder $parameters)
428+ {
429+ // Build search criteria from request parameters
430+ $c = $this->buildLuceneCriteria($parameters);
431+ $c->setLimit(0);
432+
433+ // Retrieve results from Solr
434+ $results_lucene = $this->lucene->friendlyFind($c);
435+
436+ return $results_lucene->count();
437+ }
438+
439 protected function buildLuceneCriteria(sfParameterHolder $parameters)
440 {
441 $c = new sfLuceneCriteria();
442@@ -103,6 +115,9 @@
443 $results_array[] = $result_array;
444 }
445
446+ // Total number of results found
447+ $results_array['num_found'] = $results_lucene->count();
448+
449 return $results_array;
450 }
451
452
453=== modified file 'web/css/main.css'
454--- web/css/main.css 2010-06-14 21:43:23 +0000
455+++ web/css/main.css 2010-06-29 16:08:28 +0000
456@@ -1,7 +1,7 @@
457 body { margin: 0; text-align: center; font-size: large; font-family: "Crimson Text"; }
458 h1, h2 { font-family: "Lobster"; }
459 h1 { text-align: center }
460-pre { padding: 1em; }
461+pre { padding: 1em; background-color: #eee; }
462 dl { margin-left: 1em; }
463 dt { font-weight: bold; }
464 a { color: #666; }

Subscribers

People subscribed via source and target branches

to all changes: