Compare commits

..

2 Commits

Author SHA1 Message Date
frosty
660a4918b8 style: changed how favicons appear on the result page 2026-03-23 03:09:00 -04:00
stab
51e7fcaad2 Added favicon to search results 2026-03-23 02:11:26 -04:00
4 changed files with 83 additions and 10 deletions

View File

@@ -20,7 +20,7 @@
#define MD5_HASH_LEN 32
#define HEX_CHARS "0123456789abcdef"
#define INFOBOX_FIELD_COUNT 4
#define INFOBOX_FIELD_COUNT 5
#define MAX_RESULTS_PER_ENGINE 10
#define CURL_TIMEOUT_SECS 15L

View File

@@ -53,7 +53,31 @@ static InfoBox fetch_unit_wrapper(char *query) {
static InfoBox fetch_currency_wrapper(char *query) {
return fetch_currency_data(query);
}
char *get_base_url(const char *input) {
if (!input) return NULL;
const char *start = input;
const char *protocol_pos = strstr(input, "://");
if (protocol_pos) {
start = protocol_pos + 3;
}
const char *end = start;
while (*end && *end != '/' && *end != '?' && *end != '#') {
end++;
}
size_t len = end - start;
char *domain = (char *)malloc(len + 1);
if (!domain) return NULL;
strncpy(domain, start, len);
domain[len] = '\0';
return domain;
}
static int is_calculator_query(const char *query) {
if (!query)
return 0;
@@ -150,6 +174,7 @@ static int add_infobox_to_collection(InfoBox *infobox, char ****collection,
(*collection)[current_count][2] =
infobox->extract ? strdup(infobox->extract) : NULL;
(*collection)[current_count][3] = infobox->url ? strdup(infobox->url) : NULL;
(*collection)[current_count][4] = infobox->url ? strdup(infobox->url) : NULL;
(*inner_counts)[current_count] = INFOBOX_FIELD_COUNT;
return current_count + 1;
@@ -490,6 +515,7 @@ int results_handler(UrlParams *params) {
continue;
}
char *pretty_url = pretty_display_url(display_url);
char *base_url = get_base_url(display_url);
results_matrix[unique_count][0] = strdup(display_url);
results_matrix[unique_count][1] = strdup(pretty_url);
@@ -499,10 +525,12 @@ int results_handler(UrlParams *params) {
results_matrix[unique_count][3] =
all_results[i][j].snippet ? strdup(all_results[i][j].snippet)
: strdup("");
results_matrix[unique_count][4] = strdup(base_url);
results_inner_counts[unique_count] = INFOBOX_FIELD_COUNT;
free(pretty_url);
free(base_url);
free(all_results[i][j].url);
free(all_results[i][j].title);
free(all_results[i][j].snippet);

View File

@@ -272,6 +272,44 @@ h1 span {
gap:60px;
padding:30px 60px;
}
.result-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 2px;
position: relative;
}
.result-favicon {
width: 16px;
height: 16px;
flex-shrink: 0;
background-size: cover;
background-position: center;
position: absolute;
left: -24px;
}
.url {
color: var(--text-secondary);
font-size: 0.85rem;
display: block;
margin-bottom: 4px;
}
@media (max-width: 768px) {
.result-favicon {
width: 14px;
height: 14px;
left: -20px;
}
}
@media (max-width: 480px) {
.result-favicon {
width: 12px;
height: 12px;
left: -16px;
}
}
.results-container {
grid-column:2;
}
@@ -308,12 +346,6 @@ h1 span {
display:inline-block;
margin-bottom:4px;
}
.url {
color:var(--text-secondary);
font-size:0.85rem;
display:block;
margin-bottom:4px;
}
.desc {
color:var(--text-muted);
line-height:1.6;
@@ -426,6 +458,10 @@ h1 span {
@media (max-width:1200px) {
body {
padding-left: 16px;
padding-right: 16px;
}
.content-layout {
grid-template-columns:1fr;
padding:20px 30px;
@@ -447,6 +483,10 @@ h1 span {
}
@media (max-width:768px) {
body {
padding-left: 16px;
padding-right: 16px;
}
header {
flex-direction:column;
gap:12px;

View File

@@ -55,9 +55,14 @@
{{for result in results}}
<div class="result">
<span class="url">
{{result[1]}}
</span>
<div class="result-header">
<div class="result-favicon"
style="background-image: url('https://{{result[4]}}/favicon.ico'), url('https://{{result[4]}}/favicon.png');">
</div>
<span class="url">
{{result[1]}}
</span>
</div>
<a href="{{result[0]}}">
{{result[2]}}
</a>