remove gw_get_got_link function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index 5dde781..9abbe2f 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -158,14 +158,15 @@ static const struct kvalid gw_keys[KEY__ZMAX] = {
static struct gw_dir *gw_init_gw_dir(char *);
static struct gw_header *gw_init_header(void);
-static const struct got_error *gw_get_repo_description(char **, struct gw_trans *,
- char *);
+static const struct got_error *gw_get_repo_description(char **,
+ struct gw_trans *, char *);
static const struct got_error *gw_get_repo_owner(char **, struct gw_trans *,
char *);
static const struct got_error *gw_get_time_str(char **, time_t, int);
static const struct got_error *gw_get_repo_age(char **, struct gw_trans *,
char *, char *, int);
-static const struct got_error *gw_get_file_blame_blob(char **, struct gw_trans *);
+static const struct got_error *gw_get_file_blame_blob(char **,
+ struct gw_trans *);
static const struct got_error *gw_get_file_read_blob(char **, size_t *,
struct gw_trans *);
static const struct got_error *gw_get_repo_tree(char **, struct gw_trans *);
@@ -174,8 +175,8 @@ static const struct got_error *gw_get_diff(char **, struct gw_trans *,
static const struct got_error *gw_get_repo_tags(char **, struct gw_trans *,
struct gw_header *, int, int);
static const struct got_error *gw_get_repo_heads(char **, struct gw_trans *);
-static const struct got_error *gw_get_clone_url(char **, struct gw_trans *, char *);
-static char *gw_get_got_link(struct gw_trans *);
+static const struct got_error *gw_get_clone_url(char **, struct gw_trans *,
+ char *);
static char *gw_get_site_link(struct gw_trans *);
static const struct got_error *gw_html_escape(char **, const char *);
static const struct got_error *gw_colordiff_line(char **, char *);
@@ -1617,7 +1618,7 @@ gw_template(size_t key, void *arg)
const struct got_error *error = NULL;
enum kcgi_err kerr;
struct gw_trans *gw_trans = arg;
- char *gw_got_link, *gw_site_link;
+ char *gw_site_link, *img_src = NULL;
switch (key) {
case (TEMPL_HEAD):
@@ -1626,15 +1627,29 @@ gw_template(size_t key, void *arg)
return 0;
break;
case(TEMPL_HEADER):
- gw_got_link = gw_get_got_link(gw_trans);
- if (gw_got_link != NULL) {
- kerr = khttp_puts(gw_trans->gw_req, gw_got_link);
- if (kerr != KCGI_OK) {
- free(gw_got_link);
- return 0;
- }
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_DIV,
+ KATTR_ID, "got_link", KATTR__MAX);
+ if (kerr != KCGI_OK)
+ return 0;
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_A,
+ KATTR_HREF, gw_trans->gw_conf->got_logo_url,
+ KATTR_TARGET, "_sotd", KATTR__MAX);
+ if (kerr != KCGI_OK)
+ return 0;
+ if (asprintf(&img_src, "/%s",
+ gw_trans->gw_conf->got_logo) == -1)
+ return 0;
+ kerr = khtml_attr(gw_trans->gw_html_req, KELEM_IMG,
+ KATTR_SRC, img_src, KATTR__MAX);
+ if (kerr != KCGI_OK) {
+ free(img_src);
+ return 0;
+ }
+ kerr = khtml_closeelem(gw_trans->gw_html_req, 3);
+ if (kerr != KCGI_OK) {
+ free(img_src);
+ return 0;
}
- free(gw_got_link);
break;
case (TEMPL_SITEPATH):
gw_site_link = gw_get_site_link(gw_trans);
@@ -3253,18 +3268,6 @@ done:
}
static char *
-gw_get_got_link(struct gw_trans *gw_trans)
-{
- char *link;
-
- if (asprintf(&link, got_link, gw_trans->gw_conf->got_logo_url,
- gw_trans->gw_conf->got_logo) == -1)
- return NULL;
-
- return link;
-}
-
-static char *
gw_get_site_link(struct gw_trans *gw_trans)
{
char *link = NULL, *repo = NULL, *action = NULL;