|
|
@ -48,9 +48,7 @@ Reader::Reader( |
|
|
|
{ |
|
|
|
{ |
|
|
|
markup.append( |
|
|
|
markup.append( |
|
|
|
Make::link( |
|
|
|
Make::link( |
|
|
|
g_uri_to_string( // @TODO validate NULL
|
|
|
|
base, |
|
|
|
base |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
address, |
|
|
|
address, |
|
|
|
date, |
|
|
|
date, |
|
|
|
alt |
|
|
|
alt |
|
|
@ -249,36 +247,49 @@ Glib::ustring Reader::Make::header( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Glib::ustring Reader::Make::link( |
|
|
|
Glib::ustring Reader::Make::link( |
|
|
|
const Glib::ustring & BASE, |
|
|
|
GUri * base, |
|
|
|
const Glib::ustring & ADDRESS, |
|
|
|
const Glib::ustring & ADDRESS, |
|
|
|
const Glib::ustring & DATE, |
|
|
|
const Glib::ustring & DATE, |
|
|
|
const Glib::ustring & ALT |
|
|
|
const Glib::ustring & ALT |
|
|
|
) { |
|
|
|
) { |
|
|
|
// Compose link description using optional date/alt values
|
|
|
|
// Make relative links absolute
|
|
|
|
Glib::ustring description; |
|
|
|
const auto ABSOLUTE = g_uri_resolve_relative( |
|
|
|
|
|
|
|
g_uri_to_string( |
|
|
|
|
|
|
|
base |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
ADDRESS.c_str(), |
|
|
|
|
|
|
|
G_URI_FLAGS_NONE, |
|
|
|
|
|
|
|
NULL // GError * @TODO
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (!DATE.empty()) |
|
|
|
// Build link text
|
|
|
|
|
|
|
|
Glib::ustring alt; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Indicate external links
|
|
|
|
|
|
|
|
if (strcmp(g_uri_get_host(base), g_uri_get_host(g_uri_parse(ABSOLUTE, G_URI_FLAGS_NONE, NULL)))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
description.append( |
|
|
|
alt.append( |
|
|
|
DATE |
|
|
|
"⇖" |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!ALT.empty()) |
|
|
|
// Append date on available
|
|
|
|
|
|
|
|
if (!DATE.empty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
description.append( |
|
|
|
alt.append( |
|
|
|
description.empty() ? ALT : description + " " + ALT |
|
|
|
alt.empty() ? DATE : " " + DATE |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Make relative links absolute using base given
|
|
|
|
// Append alt text
|
|
|
|
const auto ABSOLUTE = g_uri_resolve_relative( |
|
|
|
if (!ALT.empty()) |
|
|
|
BASE.c_str(), |
|
|
|
{ |
|
|
|
ADDRESS.c_str(), |
|
|
|
alt.append( |
|
|
|
G_URI_FLAGS_NONE, |
|
|
|
alt.empty() ? ALT : " " + ALT |
|
|
|
NULL // GError * @TODO
|
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Build markup and get result
|
|
|
|
return Glib::ustring::sprintf( |
|
|
|
return Glib::ustring::sprintf( |
|
|
|
"<a href=\"%s\" title=\"%s\">%s</a>\n", |
|
|
|
"<a href=\"%s\" title=\"%s\">%s</a>\n", |
|
|
|
Glib::Markup::escape_text( |
|
|
|
Glib::Markup::escape_text( |
|
|
@ -288,7 +299,7 @@ Glib::ustring Reader::Make::link( |
|
|
|
ADDRESS |
|
|
|
ADDRESS |
|
|
|
), |
|
|
|
), |
|
|
|
Glib::Markup::escape_text( |
|
|
|
Glib::Markup::escape_text( |
|
|
|
description |
|
|
|
alt |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|