All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gitweb: Avoid overflowing page body frame with large images
@ 2014-02-07  3:31 Andrew Keller
  2014-02-07 12:23 ` Andrew Keller
  2014-02-07 12:35 ` Vincent van Ravesteijn
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Keller @ 2014-02-07  3:31 UTC (permalink / raw)
  To: Git List; +Cc: Tony Finch, Krzesimir Nowak, Jürgen Kreileder

When displaying a blob in gitweb, if it's an image, specify constraints for
maximum display width and height to prevent the image from overflowing the
frame of the enclosing page_body div.

This change assumes that it is more desirable to see the whole image without
scrolling (new behavior) than it is to see every pixel without zooming
(previous behavior).

Signed-off-by: Andrew B Keller <andrew@kellerfarm.com>
---

I recently used Git to archive a set of scanned photos, and I used gitweb to provide access to them.  Overall, everything worked well, but I found it undesirable that I had to zoom out in my browser on every photo to see the whole photo.  In the spirit of making the default behavior the most likely correct behavior, this patch seems to be a good idea.

However, I'm not an expert on the use cases of gitweb.  In order for the maximum size constraints to take effect, the image would have to be at least the size of the web browser window (minus a handful of pixels), so the affected images are usually going to be pretty big.  Are there any common use cases for displaying a large image without scaling (and hence, with scrolling)?

Thanks,
Andrew


 gitweb/gitweb.perl       |    2 +-
 gitweb/static/gitweb.css |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3bc0f0b..2c6a77f 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -7094,7 +7094,7 @@ sub git_blob {
 	git_print_page_path($file_name, "blob", $hash_base);
 	print "<div class=\"page_body\">\n";
 	if ($mimetype =~ m!^image/!) {
-		print qq!<img type="!.esc_attr($mimetype).qq!"!;
+		print qq!<img class="image_blob" type="!.esc_attr($mimetype).qq!"!;
 		if ($file_name) {
 			print qq! alt="!.esc_attr($file_name).qq!" title="!.esc_attr($file_name).qq!"!;
 		}
diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
index 3b4d833..cd57c2f 100644
--- a/gitweb/static/gitweb.css
+++ b/gitweb/static/gitweb.css
@@ -32,6 +32,11 @@ img.avatar {
 	vertical-align: middle;
 }
 
+img.image_blob {
+	max-height: 100%;
+	max-width: 100%;
+}
+
 a.list img.avatar {
 	border-style: none;
 }
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] gitweb: Avoid overflowing page body frame with large images
  2014-02-07  3:31 [PATCH] gitweb: Avoid overflowing page body frame with large images Andrew Keller
@ 2014-02-07 12:23 ` Andrew Keller
  2014-02-17 14:25   ` Andrew Keller
  2014-02-07 12:35 ` Vincent van Ravesteijn
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Keller @ 2014-02-07 12:23 UTC (permalink / raw)
  To: Andrew Keller
  Cc: Git List, Tony Finch, Krzesimir Nowak, Jürgen Kreileder

On Feb 6, 2014, at 10:31 PM, Andrew Keller wrote:

> When displaying a blob in gitweb, if it's an image, specify constraints for
> maximum display width and height to prevent the image from overflowing the
> frame of the enclosing page_body div.
> 
> This change assumes that it is more desirable to see the whole image without
> scrolling (new behavior) than it is to see every pixel without zooming
> (previous behavior).
> 
> Signed-off-by: Andrew B Keller <andrew@kellerfarm.com>
> ---
> 
> I recently used Git to archive a set of scanned photos, and I used gitweb to provide access to them.  Overall, everything worked well, but I found it undesirable that I had to zoom out in my browser on every photo to see the whole photo.  In the spirit of making the default behavior the most likely correct behavior, this patch seems to be a good idea.
> 
> However, I'm not an expert on the use cases of gitweb.  In order for the maximum size constraints to take effect, the image would have to be at least the size of the web browser window (minus a handful of pixels), so the affected images are usually going to be pretty big.  Are there any common use cases for displaying a large image without scaling (and hence, with scrolling)?
> 
> Thanks,
> Andrew
> 
> 
> gitweb/gitweb.perl       |    2 +-
> gitweb/static/gitweb.css |    5 +++++
> 2 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 3bc0f0b..2c6a77f 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -7094,7 +7094,7 @@ sub git_blob {
> 	git_print_page_path($file_name, "blob", $hash_base);
> 	print "<div class=\"page_body\">\n";
> 	if ($mimetype =~ m!^image/!) {
> -		print qq!<img type="!.esc_attr($mimetype).qq!"!;
> +		print qq!<img class="image_blob" type="!.esc_attr($mimetype).qq!"!;
> 		if ($file_name) {
> 			print qq! alt="!.esc_attr($file_name).qq!" title="!.esc_attr($file_name).qq!"!;
> 		}
> diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
> index 3b4d833..cd57c2f 100644
> --- a/gitweb/static/gitweb.css
> +++ b/gitweb/static/gitweb.css
> @@ -32,6 +32,11 @@ img.avatar {
> 	vertical-align: middle;
> }
> 
> +img.image_blob {

I wonder if simply "blob" is a better style name here.  "image_blob" stands out a bit amongst the existing code, and "blob" appears to be specific enough for the needs.

> +	max-height: 100%;
> +	max-width: 100%;
> +}
> +
> a.list img.avatar {
> 	border-style: none;
> }
> -- 
> 1.7.7.1

 - Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gitweb: Avoid overflowing page body frame with large images
  2014-02-07  3:31 [PATCH] gitweb: Avoid overflowing page body frame with large images Andrew Keller
  2014-02-07 12:23 ` Andrew Keller
@ 2014-02-07 12:35 ` Vincent van Ravesteijn
  2014-02-07 14:32   ` Andrew Keller
  1 sibling, 1 reply; 7+ messages in thread
From: Vincent van Ravesteijn @ 2014-02-07 12:35 UTC (permalink / raw)
  To: Andrew Keller
  Cc: Git List, Tony Finch, Krzesimir Nowak, Jürgen Kreileder

On Fri, Feb 7, 2014 at 4:31 AM, Andrew Keller <andrew@kellerfarm.com> wrote:
> I recently used Git to archive a set of scanned photos, and I used gitweb to provide access to them.  Overall, everything worked well, but I found it undesirable that I had to zoom out in my browser on every photo to see the whole photo.  In the spirit of making the default behavior the most likely correct behavior, this patch seems to be a good idea.
>
> However, I'm not an expert on the use cases of gitweb.  In order for the maximum size constraints to take effect, the image would have to be at least the size of the web browser window (minus a handful of pixels), so the affected images are usually going to be pretty big.  Are there any common use cases for displaying a large image without scaling (and hence, with scrolling)?
>
> Thanks,
> Andrew
>

It sounds like your usecase is exactly what camlistore.org tries to achieve.

Vincent

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gitweb: Avoid overflowing page body frame with large images
  2014-02-07 12:35 ` Vincent van Ravesteijn
@ 2014-02-07 14:32   ` Andrew Keller
  2014-02-07 15:02     ` Tony Finch
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Keller @ 2014-02-07 14:32 UTC (permalink / raw)
  To: Vincent van Ravesteijn
  Cc: Git List, Tony Finch, Krzesimir Nowak, Jürgen Kreileder

On Feb 7, 2014, at 7:35 AM, Vincent van Ravesteijn <vfr@lyx.org> wrote:

> On Fri, Feb 7, 2014 at 4:31 AM, Andrew Keller <andrew@kellerfarm.com> wrote:
>> I recently used Git to archive a set of scanned photos, and I used gitweb to provide access to them.  Overall, everything worked well, but I found it undesirable that I had to zoom out in my browser on every photo to see the whole photo.  In the spirit of making the default behavior the most likely correct behavior, this patch seems to be a good idea.
>> 
>> However, I'm not an expert on the use cases of gitweb.  In order for the maximum size constraints to take effect, the image would have to be at least the size of the web browser window (minus a handful of pixels), so the affected images are usually going to be pretty big.  Are there any common use cases for displaying a large image without scaling (and hence, with scrolling)?
>> 
>> Thanks,
>> Andrew
>> 
> 
> It sounds like your usecase is exactly what camlistore.org tries to achieve.

Yes.

With that said, I don't think it's unreasonable for a software project to contain images larger than a browser window.  And, when that happens, I'm pretty confident that the default behavior should be to scale the image down so the user can see the whole thing.

 - Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] gitweb: Avoid overflowing page body frame with large images
  2014-02-07 14:32   ` Andrew Keller
@ 2014-02-07 15:02     ` Tony Finch
  0 siblings, 0 replies; 7+ messages in thread
From: Tony Finch @ 2014-02-07 15:02 UTC (permalink / raw)
  To: Andrew Keller
  Cc: Vincent van Ravesteijn, Git List, Krzesimir Nowak, Jürgen Kreileder

Andrew Keller <andrew@kellerfarm.com> wrote:
>
> With that said, I don't think it's unreasonable for a software project
> to contain images larger than a browser window.  And, when that happens,
> I'm pretty confident that the default behavior should be to scale the
> image down so the user can see the whole thing.

Right. And if you want to see the unscaled version of the image you can
view the blob_plain version instead of the (scaled html-wrapped) blob.

Seems sensible in principle to me but I have not reviewed the code.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] gitweb: Avoid overflowing page body frame with large images
  2014-02-07 12:23 ` Andrew Keller
@ 2014-02-17 14:25   ` Andrew Keller
  2014-02-19 19:32     ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Keller @ 2014-02-17 14:25 UTC (permalink / raw)
  To: Git List; +Cc: Tony Finch, Krzesimir Nowak, Jürgen Kreileder

When displaying a blob in gitweb, if it's an image, specify constraints for
maximum display width and height to prevent the image from overflowing the
frame of the enclosing page_body div.

This change assumes that it is more desirable to see the whole image without
scrolling (new behavior) than it is to see every pixel without zooming
(previous behavior).

Signed-off-by: Andrew Keller <andrew@kellerfarm.com>
---

This is an updated copy of this patch.

Could I request a thumbs up, thumbs down, or thumbs sideways from those who develop gitweb?

Thanks,
Andrew Keller

 gitweb/gitweb.perl       |    2 +-
 gitweb/static/gitweb.css |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3bc0f0b..79057b7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -7094,7 +7094,7 @@ sub git_blob {
 	git_print_page_path($file_name, "blob", $hash_base);
 	print "<div class=\"page_body\">\n";
 	if ($mimetype =~ m!^image/!) {
-		print qq!<img type="!.esc_attr($mimetype).qq!"!;
+		print qq!<img class="blob" type="!.esc_attr($mimetype).qq!"!;
 		if ($file_name) {
 			print qq! alt="!.esc_attr($file_name).qq!" title="!.esc_attr($file_name).qq!"!;
 		}
diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
index 3b4d833..3212601 100644
--- a/gitweb/static/gitweb.css
+++ b/gitweb/static/gitweb.css
@@ -32,6 +32,11 @@ img.avatar {
 	vertical-align: middle;
 }
 
+img.blob {
+	max-height: 100%;
+	max-width: 100%;
+}
+
 a.list img.avatar {
 	border-style: none;
 }
-- 
1.7.9.6 (Apple Git-31.1)

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] gitweb: Avoid overflowing page body frame with large images
  2014-02-17 14:25   ` Andrew Keller
@ 2014-02-19 19:32     ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2014-02-19 19:32 UTC (permalink / raw)
  To: Andrew Keller
  Cc: Git List, Tony Finch, Krzesimir Nowak, Jürgen Kreileder

Andrew Keller <andrew@kellerfarm.com> writes:

> When displaying a blob in gitweb, if it's an image, specify constraints for
> maximum display width and height to prevent the image from overflowing the
> frame of the enclosing page_body div.
>
> This change assumes that it is more desirable to see the whole image without
> scrolling (new behavior) than it is to see every pixel without zooming
> (previous behavior).
>
> Signed-off-by: Andrew Keller <andrew@kellerfarm.com>
> ---
>
> This is an updated copy of this patch.
>
> Could I request a thumbs up, thumbs down, or thumbs sideways from those who develop gitweb?

I do not develop gitweb, but the change looks reasonable to me.

>  gitweb/gitweb.perl       |    2 +-
>  gitweb/static/gitweb.css |    5 +++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 3bc0f0b..79057b7 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -7094,7 +7094,7 @@ sub git_blob {
>  	git_print_page_path($file_name, "blob", $hash_base);
>  	print "<div class=\"page_body\">\n";
>  	if ($mimetype =~ m!^image/!) {
> -		print qq!<img type="!.esc_attr($mimetype).qq!"!;
> +		print qq!<img class="blob" type="!.esc_attr($mimetype).qq!"!;
>  		if ($file_name) {
>  			print qq! alt="!.esc_attr($file_name).qq!" title="!.esc_attr($file_name).qq!"!;
>  		}
> diff --git a/gitweb/static/gitweb.css b/gitweb/static/gitweb.css
> index 3b4d833..3212601 100644
> --- a/gitweb/static/gitweb.css
> +++ b/gitweb/static/gitweb.css
> @@ -32,6 +32,11 @@ img.avatar {
>  	vertical-align: middle;
>  }
>  
> +img.blob {
> +	max-height: 100%;
> +	max-width: 100%;
> +}
> +
>  a.list img.avatar {
>  	border-style: none;
>  }

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-02-19 19:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-07  3:31 [PATCH] gitweb: Avoid overflowing page body frame with large images Andrew Keller
2014-02-07 12:23 ` Andrew Keller
2014-02-17 14:25   ` Andrew Keller
2014-02-19 19:32     ` Junio C Hamano
2014-02-07 12:35 ` Vincent van Ravesteijn
2014-02-07 14:32   ` Andrew Keller
2014-02-07 15:02     ` Tony Finch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.