@@ -68,12 +68,10 @@ public class HtmlSnippets implements SnippetsConsumer
6868 private final Writer writer ;
6969
7070 private int ctx = 10 ;
71- private String docCss = "hit" ;
7271 private String doclineFieldName = "docline" ;
7372 private String hrefBase = "" ;
7473 private String hrefExt = "" ;
7574 private String hrefSearch = "" ;
76- private String snipCss = "hit snippet" ;
7775
7876 private String content ;
7977 private Document doc ;
@@ -154,28 +152,6 @@ public void docClose(final int docId) throws IOException
154152 writer .flush ();
155153 }
156154
157- /**
158- * Returns the CSS class applied to the {@code <article>} element.
159- *
160- * @return CSS class string
161- */
162- public String docCss ()
163- {
164- return docCss ;
165- }
166-
167- /**
168- * Sets the CSS class applied to the {@code <article>} element.
169- *
170- * @param docCss CSS class string
171- * @return this instance
172- */
173- public HtmlSnippets docCss (final String docCss )
174- {
175- this .docCss = docCss ;
176- return this ;
177- }
178-
179155 /**
180156 * Returns the name of the stored field used as the document heading.
181157 *
@@ -211,15 +187,25 @@ public void docOpen(final int docId) throws IOException
211187 {
212188 doc = storedFields .document (docId );
213189 id = doc .get (ALIX_ID );
214- writer .append ("<article id=\" " ).append (id )
215- .append ("\" data-docid=\" " ).append (String .valueOf (docId ))
216- .append ("\" class=\" " ).append (docCss ).append ("\" >\n " );
190+ writer .append ("<article" )
191+ .append (" id=\" " ).append (id ).append ("\" " )
192+ .append (" data-docid=\" " ).append (String .valueOf (docId )).append ("\" " )
193+ .append (" class=\" result\" " )
194+ .append (">\n " );
195+
196+ String url = hrefBase + id + hrefExt + hrefSearch ;
217197 if (doclineFieldName != null ) {
218198 final String docline = doc .get (doclineFieldName );
219199 if (docline != null ) {
220- writer .append ("<h2><a href=\" " ).append (hrefBase ).append (id )
221- .append (hrefExt ).append (hrefSearch ).append ("\" >" )
222- .append (docline ).append ("</a></h2>\n " );
200+ writer .append ("<h4" )
201+ .append (" data-href=\" " ).append (url ).append ("\" " )
202+ .append (">\n " )
203+ .append ("<span>" ).append (docline ).append ("</span>\n " )
204+ .append ("<a" )
205+ .append (" href=\" " ).append (url ).append ("\" " )
206+ .append (" class=\" result-open\" " )
207+ .append (">→</a>\n " )
208+ .append ("</h4>\n " );
223209 }
224210 }
225211 }
@@ -243,17 +229,19 @@ public void docSnippets(final int docId, final Snippets snippets) throws IOExcep
243229 {
244230 docOpen (docId );
245231 content = doc .get (contentFieldName );
246- if (snipLimit > 0 && content != null ) {
232+ final int snipCount = snippets .snips4doc ();
233+ if (snipLimit > 0 && content != null && snipCount > 0 ) {
247234 topSnips .clear ();
248- final int snipCount = snippets .snips4doc ();
249235 for (int snipOrd = 0 ; snipOrd < snipCount ; snipOrd ++) {
250236 final int startPos = Math .max (0 , snippets .snipStartPosition (snipOrd ) - ctx );
251237 final int endPos = snippets .snipEndPosition (snipOrd ) + ctx ;
252238 topSnips .push (snipOrd , scoreSnippet (docId , startPos , endPos ));
253239 }
240+ writer .append ("<ol class=\" snippets\" >\n " );
254241 for (final TopArray .IdScore pair : topSnips ) {
255242 print (snippets , pair .id ());
256243 }
244+ writer .append ("</ol>\n " );
257245 }
258246 docClose (docId );
259247 }
@@ -324,30 +312,6 @@ public HtmlSnippets hrefSearch(final String hrefSearch)
324312 return this ;
325313 }
326314
327- /**
328- * Returns the CSS class applied to {@code <li>} elements emitted for each
329- * snippet line.
330- *
331- * @return CSS class string
332- */
333- public String snipCss ()
334- {
335- return snipCss ;
336- }
337-
338- /**
339- * Sets the CSS class applied to {@code <li>} elements emitted for each
340- * snippet line.
341- *
342- * @param snipCss CSS class string
343- * @return this instance
344- */
345- public HtmlSnippets snipCss (final String snipCss )
346- {
347- this .snipCss = snipCss ;
348- return this ;
349- }
350-
351315 /**
352316 * Returns the maximum number of snippets rendered per document.
353317 *
@@ -381,9 +345,14 @@ private void print(final Snippets snippets, final int snipOrd) throws IOExceptio
381345 final int leftMatchStartOffset = snippets .matchStartOffset (leftMatchOrd );
382346 final int rightMatchEndOffset = snippets .matchEndOffset (rightMatchOrd );
383347
384- writer .append ("<li class=\" " ).append (snipCss ).append ("\" ><a href=\" " )
385- .append (hrefBase ).append (id ).append (hrefExt ).append (hrefSearch )
386- .append ("#snippet" ).append (String .valueOf (snipOrd )).append ("\" >" );
348+ final String url = hrefBase + id + hrefExt + hrefSearch + "#snippet" + snipOrd ;
349+ writer
350+ .append ("<li" )
351+ .append (" class=\" snippet\" " )
352+ .append (" data-href=\" " ).append (url ).append ("\" " )
353+ .append (">" )
354+ .append ("<p>" );
355+
387356
388357 final int leftOffset = Markup .leftBoundary (content , leftMatchStartOffset , ctx , -1 );
389358 detagger .detag (writer , content , leftOffset , leftMatchStartOffset );
@@ -406,7 +375,13 @@ private void print(final Snippets snippets, final int snipOrd) throws IOExceptio
406375
407376 final int rightOffset = Markup .rightBoundary (content , rightMatchEndOffset , ctx , -1 );
408377 detagger .detag (writer , content , rightMatchEndOffset , rightOffset );
409- writer .append ("</a></li>\n " );
378+ // gutter snippet link
379+ writer .append ("</p>" )
380+ .append ("\n <a" )
381+ .append (" class=\" snippet-open\" " )
382+ .append (" href=\" " ).append (url ).append ("\" " )
383+ .append ("\" >→</a>" );
384+ writer .append ("</li>\n " );
410385 }
411386
412387 /**
0 commit comments