svnno****@sourc*****
svnno****@sourc*****
Tue Feb 26 03:56:53 JST 2008
Revision: 3403 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3403 Author: pal_gene Date: 2008-02-26 03:56:53 +0900 (Tue, 26 Feb 2008) Log Message: ----------- *Make highlight in search result. modified: module/search/kz-hyper-estraier-search.c Modified Paths: -------------- kazehakase/trunk/module/search/kz-hyper-estraier-search.c Modified: kazehakase/trunk/module/search/kz-hyper-estraier-search.c =================================================================== --- kazehakase/trunk/module/search/kz-hyper-estraier-search.c 2008-02-25 18:56:48 UTC (rev 3402) +++ kazehakase/trunk/module/search/kz-hyper-estraier-search.c 2008-02-25 18:56:53 UTC (rev 3403) @@ -327,8 +327,11 @@ { ESTDOC *doc; const gchar *title, *uri, *date; - gchar *desc, *cache_str = NULL; + gchar *cache_str = NULL; const gchar *cache_link, *thumb_uri, *thumb_filename; + gchar *desc, **desc_highlight; + guint desc_len, desc_i; + GString *desc_str; doc = est_mtdb_get_doc(he_search->db, results[i], 0); if (!doc) @@ -363,7 +366,26 @@ { cache_str = g_strdup(""); } - + + /* make highlight keyword */ + desc_highlight = g_strsplit_set(desc, "\n", 0); + g_free(desc); + desc_len = g_strv_length(desc_highlight); + desc_str = g_string_sized_new(strlen(desc)); + for(desc_i=0; desc_i < desc_len; desc_i++) { + char *found = strchr(desc_highlight[desc_i], '\t'); + if (found) { + *found = '\0'; + g_string_append(desc_str, "<b>"); + g_string_append(desc_str, desc_highlight[desc_i]); + g_string_append(desc_str, "</b>"); + } else { + g_string_append(desc_str, desc_highlight[desc_i]); + } + } + g_strfreev(desc_highlight); + desc = g_string_free(desc_str, FALSE); + g_string_append_printf(html, CONTENT, uri,