List for cgit developers and users
 help / color / mirror / Atom feed
From: Jason at zx2c4.com (Jason A. Donenfeld)
Subject: [PATCH 2/3] about: send images plain
Date: Sat, 15 Aug 2015 01:07:32 +0200	[thread overview]
Message-ID: <CAHmME9r6-A11iQox+oOJQaJurYTEBt7vidcUaZYrweqQg_pNkQ@mail.gmail.com> (raw)
In-Reply-To: <1439586997-25333-1-git-send-email-list@eworm.de>

Excellent! This is a very wanted tweak indeed, and it's finally possible
thanks to the rework merged today that moves layout into each function.
Awesome.

I'm on a camping trip this weekend, so I'll get to merging this late on
Sunday or Monday morning.
On Aug 14, 2015 11:16 PM, "Christian Hesse" <list at eworm.de> wrote:

> From: Christian Hesse <mail at eworm.de>
>
> The about page used to display just fine, but images were broken: The
> binary image data was embedded in html code.
> Use cgit_print_plain() to send images in plain mode and make them
> available on about page.
>
> Signed-off-by: Christian Hesse <mail at eworm.de>
> ---
>  ui-summary.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/ui-summary.c b/ui-summary.c
> index fb04dc3..99c9234 100644
> --- a/ui-summary.c
> +++ b/ui-summary.c
> @@ -9,9 +9,10 @@
>  #include "cgit.h"
>  #include "ui-summary.h"
>  #include "html.h"
> +#include "ui-blob.h"
>  #include "ui-log.h"
> +#include "ui-plain.h"
>  #include "ui-refs.h"
> -#include "ui-blob.h"
>  #include "ui-shared.h"
>
>  static int urls;
> @@ -100,8 +101,38 @@ static char* append_readme_path(const char *filename,
> const char *ref, const cha
>
>  void cgit_print_repo_readme(char *path)
>  {
> -       char *filename, *ref;
> +       char *ext = NULL, *filename, *ref, *mimetype = NULL;
>         int free_filename = 0;
> +       int freemime = 0;
> +       struct string_list_item *mime;
> +
> +       if (ctx.qry.path)
> +               ext = strrchr(ctx.qry.path, '.');
> +
> +       if (ext && *(++ext)) {
> +               mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
> +               if (mime) {
> +                       mimetype = (char *)mime->util;
> +               } else {
> +                       mimetype =
> get_mimetype_from_file(ctx.cfg.mimetype_file, ext);
> +                       if (mimetype)
> +                               freemime = 1;
> +               }
> +       }
> +
> +       if (mimetype && strncmp(mimetype, "image/", 6) == 0) {
> +               ctx.page.mimetype = mimetype;
> +               ctx.page.charset = NULL;
> +               cgit_print_plain();
> +
> +               if (freemime)
> +                       free(mimetype);
> +
> +               return;
> +       }
> +
> +       if (freemime)
> +               free(mimetype);
>
>         cgit_print_layout_start();
>         if (ctx.repo->readme.nr == 0)
> --
> 2.5.0
>
> _______________________________________________
> CGit mailing list
> CGit at lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/cgit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150815/0d2b36e7/attachment-0001.html>


  parent reply	other threads:[~2015-08-14 23:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-14 14:50 [PATCH 1/2] move get_mimetype_from_file() to shared list
2015-08-14 14:50 ` [PATCH 2/2] about: send images plain list
2015-08-14 15:13   ` john
2015-08-14 21:16     ` [PATCH 2/3] " list
2015-08-14 21:16       ` [PATCH 3/3] move shared code to get_mimetype_from_file() list
2015-08-15 11:29         ` john
2015-08-15 20:12           ` list
2015-08-14 23:07       ` Jason [this message]
2015-08-15 20:10         ` [PATCH 2/3] about: send images plain list
2015-08-15 11:30       ` john
2015-08-15 20:08         ` [PATCH 2/3] refactor get_mimetype_from_file() to get_mimetype_from_qrypath() list
2015-08-15 20:08           ` [PATCH 3/3] ui-summary: send images plain for about page list
2015-08-16 12:19           ` [PATCH 2/3] refactor get_mimetype_from_file() to get_mimetype_from_qrypath() john
2015-08-16 12:51             ` list
2015-08-16 12:53               ` [PATCH 2/3] refactor get_mimetype_from_file() to get_mimetype_for_filename() list
2015-08-16 12:53                 ` [PATCH 3/3] ui-summary: send images plain for about page list

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHmME9r6-A11iQox+oOJQaJurYTEBt7vidcUaZYrweqQg_pNkQ@mail.gmail.com \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).