pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wip/fgallery: support --noblur option for dark grey backdrop



Module Name:	pkgsrc-wip
Committed By:	ast <ast%NetBSD.org@localhost>
Pushed By:	ast
Date:		Sun Oct 30 19:42:32 2016 +0100
Changeset:	c4698d90cd65656cea87046ad5a8dccf8ce4ed26

Modified Files:
	fgallery/distinfo
	fgallery/patches/patch-fgallery
	fgallery/patches/patch-view_index.js

Log Message:
wip/fgallery: support --noblur option for dark grey backdrop

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=c4698d90cd65656cea87046ad5a8dccf8ce4ed26

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 fgallery/distinfo                    |  4 +-
 fgallery/patches/patch-fgallery      | 80 +++++++++++++++++++++++++-----------
 fgallery/patches/patch-view_index.js | 61 ++++++++++++++++++++++-----
 3 files changed, 108 insertions(+), 37 deletions(-)

diffs:
diff --git a/fgallery/distinfo b/fgallery/distinfo
index 802a187..36c93be 100644
--- a/fgallery/distinfo
+++ b/fgallery/distinfo
@@ -4,7 +4,7 @@ SHA1 (fgallery-1.8.2.zip) = a4164160f9e7d70fe1b135f11e175e8a470a94f2
 RMD160 (fgallery-1.8.2.zip) = 959854b675a813379e78d8e66022dd2f56e30561
 SHA512 (fgallery-1.8.2.zip) = 1e782b86c74b7cafbb61e46f346b2e42dab9cc3133cf8cedef827f916b5eb29316d86a52020305b56a42fa9d6555423b9d5a175dac4446a0f7f5d538beb9311f
 Size (fgallery-1.8.2.zip) = 158562 bytes
-SHA1 (patch-fgallery) = 4935c8f6fed60cad3d952aa2774591d45a80dbcf
+SHA1 (patch-fgallery) = 32d9833729a63d7f3b33632073dd937ded3524f7
 SHA1 (patch-view_index.css) = 562587d10dc72d8a22a9577cba9cc63fa9473c86
 SHA1 (patch-view_index.html) = 1e62672675b873d547eb11a1f48bf4af582869c6
-SHA1 (patch-view_index.js) = fb0a55b13d2e9db1170d576dfb28753da7608b5e
+SHA1 (patch-view_index.js) = 4a49c8734a3b736f887b62dc493bed461a41c238
diff --git a/fgallery/patches/patch-fgallery b/fgallery/patches/patch-fgallery
index c998e0b..4b9cce1 100644
--- a/fgallery/patches/patch-fgallery
+++ b/fgallery/patches/patch-fgallery
@@ -54,15 +54,16 @@ Pretty print json for easier customization
  my $jpegoptim = 1;
  my $pngoptim = 1;
  my $p7zip = 1;
-@@ -63,6 +61,7 @@ my $workers = 0;
+@@ -63,6 +61,8 @@ my $workers = 0;
  my $sRGB = 1;
  my $indexUrl = undef;
  my @capmethods = ("txt", "xmp", "exif");
 +my $use_symlinks = 0;
++my $do_blur = 1;
  
  
  # support functions
-@@ -73,6 +72,14 @@ sub fatal
+@@ -73,6 +73,14 @@ sub fatal
  }
  
  
@@ -77,7 +78,7 @@ Pretty print json for easier customization
  sub sys
  {
    my @cmd = @_;
-@@ -87,13 +94,13 @@ sub sys
+@@ -87,13 +95,13 @@ sub sys
    }
  
    local $/ = undef;
@@ -93,7 +94,7 @@ Pretty print json for easier customization
  }
  
  
-@@ -110,7 +117,10 @@ sub isin
+@@ -110,7 +118,10 @@ sub isin
  sub slurp
  {
    my ($fn) = @_;
@@ -105,7 +106,7 @@ Pretty print json for easier customization
    local $/;
    return <$fd> // "";
  }
-@@ -132,7 +142,7 @@ sub dispatch
+@@ -132,7 +143,7 @@ sub dispatch
      my $thr = threads->create(sub
      {
        while(defined(my $v = $queue->dequeue_nb())) {
@@ -114,7 +115,7 @@ Pretty print json for easier customization
        }
      });
      push(@threads, $thr);
-@@ -187,7 +197,7 @@ sub clamp
+@@ -187,7 +198,7 @@ sub clamp
  
  sub decode
  {
@@ -123,7 +124,7 @@ Pretty print json for easier customization
  }
  
  
-@@ -263,7 +273,7 @@ sub cap_clean_desc
+@@ -263,7 +274,7 @@ sub cap_clean_desc
  sub cap_from_str
  {
    my ($title, $desc) = split("\n", shift, 2);
@@ -132,7 +133,7 @@ Pretty print json for easier customization
    my $ret = [cap_clean_title($title), ($desc? cap_clean_desc($desc): '')];
    return $ret;
  }
-@@ -322,32 +332,34 @@ sub parse_cap
+@@ -322,32 +333,35 @@ sub parse_cap
  
  sub print_version
  {
@@ -184,10 +185,11 @@ Pretty print json for easier customization
 +  --no-sRGB             do not remap preview/thumbnail color profiles to sRGB
 +  --quality Q           preview image quality (0-100, currently: $imgq)
 +  --index url           specify the URL location for the index/back button
++  --noblur              skip blurry backdrop generation (just dark noise)
  });
    exit(shift);
  }
-@@ -363,17 +375,20 @@ my ($ret, @ARGS) = GetOptions(
+@@ -363,17 +377,21 @@ my ($ret, @ARGS) = GetOptions(
    'i' => sub { $ofile = 1; },
    'j=i' => sub { $workers = parse_int($_[0], $_[1], 1, undef); },
    'o' => sub { $orient = 0; },
@@ -205,11 +207,12 @@ Pretty print json for easier customization
    'quality=i' => sub { $imgq = parse_int($_[0], $_[1], 0, 100); },
 -  'index=s' => sub { $indexUrl = decode($_[1]); });
 +  'index=s' => sub { $indexUrl = decode($_[1]); },
++  'noblur' => sub { $do_blur = 0; },
 +);
  
  if(@ARGV < 2 || @ARGV > 3 || !$ret) {
    print_help(2);
-@@ -383,8 +398,16 @@ my $out = $ARGV[1];
+@@ -383,8 +401,16 @@ my $out = $ARGV[1];
  my $name = (@ARGV < 3? undef: decode($ARGV[2]));
  
  # check paths
@@ -228,7 +231,7 @@ Pretty print json for easier customization
  
  if(!-d $dir) {
    fatal("input directory \"$dir\" does not exist");
-@@ -393,55 +416,37 @@ if(!-d $dir) {
+@@ -393,55 +419,37 @@ if(!-d $dir) {
  } elsif(substr($absOut, 0, length($absDir)) eq $absDir) {
    fatal("output directory is a sub-directory of input, refusing to scan");
  } elsif(!-d $out) {
@@ -308,7 +311,15 @@ Pretty print json for easier customization
  }
  
  # list available files
-@@ -496,7 +501,7 @@ sub analyze_file
+@@ -475,6 +483,7 @@ my @backsize = (int($minthumb[0] * 4), i
+ for my $path("$out/thumbs", "$out/blurs", "$out/imgs", "$out/files")
+ {
+   remove_tree($path);
++  next if ($path eq "$out/blurs") && ! $do_blur;
+   make_path($path);
+ }
+ 
+@@ -496,7 +505,7 @@ sub analyze_file
  
    my $props = ImageInfo($file, {PrintConv => 0, Sort => 'File'});
    unless(defined($props) && isin($props->{FileType}, @filetypes)) {
@@ -317,7 +328,7 @@ Pretty print json for easier customization
    }
  
    # sanitize file name
-@@ -535,9 +540,9 @@ sub analyze_file
+@@ -535,9 +544,9 @@ sub analyze_file
      {
        if($props->{'Comment'})
        {
@@ -330,7 +341,7 @@ Pretty print json for easier customization
        }
      }
      elsif($m eq "txt")
-@@ -545,16 +550,16 @@ sub analyze_file
+@@ -545,16 +554,16 @@ sub analyze_file
        my $txt = "$dir$base.txt";
        if(-f $txt)
        {
@@ -351,7 +362,7 @@ Pretty print json for easier customization
        }
      }
      elsif($m eq "xmp")
-@@ -562,8 +567,8 @@ sub analyze_file
+@@ -562,8 +571,8 @@ sub analyze_file
        my $xmp = ImageInfo("$file.xmp", {PrintConv => 0, Sort => 'File'});
        if(defined($xmp) && ($xmp->{'Title'} || $xmp->{'Description'}))
        {
@@ -362,7 +373,7 @@ Pretty print json for easier customization
        }
      }
    }
-@@ -635,22 +640,24 @@ sub process_img
+@@ -635,22 +644,24 @@ sub process_img
  
    # copy source file
    sys('cp', '-L', $file, $fout);
@@ -399,7 +410,7 @@ Pretty print json for easier customization
    }
  
    # final file mode
-@@ -658,11 +665,12 @@ sub process_img
+@@ -658,11 +669,12 @@ sub process_img
    sys('touch', '-r', $file, $fout);
  
    # intermediate sRGB colorspace conversion
@@ -415,7 +426,7 @@ Pretty print json for easier customization
      sys($tificccmd, '-t0', $ftmp, "$ftmp.tmp");
      rename("$ftmp.tmp", $ftmp);
    }
-@@ -674,13 +682,13 @@ sub process_img
+@@ -674,13 +686,13 @@ sub process_img
  
    # generate main image
    my @sfile = ($props{ImageWidth}, $props{ImageHeight});
@@ -436,7 +447,7 @@ Pretty print json for easier customization
  
    # face/center detection
    my @center = (0.5, 0.5);
-@@ -701,7 +709,7 @@ sub process_img
+@@ -701,7 +713,7 @@ sub process_img
      $thumbrt = $minthumb[1] / $sfile[1];
    }
    my @sthumb = (max(int($sfile[0] * $thumbrt + 0.5), $minthumb[0]),
@@ -445,7 +456,7 @@ Pretty print json for easier customization
    my @mthumb = (min($maxthumb[0], $sthumb[0]), min($maxthumb[1], $sthumb[1]));
  
    # cropping window
-@@ -710,7 +718,7 @@ sub process_img
+@@ -710,7 +722,7 @@ sub process_img
    my $dy = $sthumb[1] - $mthumb[1];
    my $cy = clamp(0, $dy, int($center[1] * $sthumb[1] - $sthumb[1] / 2 + $dy / 2));
  
@@ -454,7 +465,7 @@ Pretty print json for easier customization
        '-gamma', '0.454545',
        '-resize', "$sthumb[0]x$sthumb[1]!",
        '-gravity', 'NorthWest',
-@@ -720,7 +728,7 @@ sub process_img
+@@ -720,17 +732,17 @@ sub process_img
        '-quality', $imgq, "$out/$fthumb");
  
    # blur
@@ -463,7 +474,19 @@ Pretty print json for easier customization
        '-virtual-pixel', 'Mirror',
        '-gaussian-blur', "0x$backblur",
        '-scale', "$backsize[0]x$backsize[1]",
-@@ -747,7 +755,9 @@ sub process_img
+-      '-quality', '90', "$out/$fblur");
++      '-quality', '90', "$out/$fblur") if $do_blur;
+ 
+   my %fdata;
+   $fdata{props} = \%props;
+   $fdata{img} = [$fimg, [map { int } @simg]];
+   $fdata{file} = [$ffile, [map { int } @sfile]];
+-  $fdata{blur} = $fblur;
++  $fdata{blur} = $fblur if $do_blur;
+ 
+   # do not store duplicate information
+   my @tdata = ($fthumb, [map { int } @mthumb]);
+@@ -747,7 +759,9 @@ sub process_img
    }
  
    # remove temporary files
@@ -474,7 +497,7 @@ Pretty print json for easier customization
  
    return \%fdata;
  }
-@@ -807,7 +817,7 @@ if(!$ofile || $slim)
+@@ -807,7 +821,7 @@ if(!$ofile || $slim)
        my $omp = ($ox * $oy / 1e6);
  
        if($mp >= $omp && $mp > $amp && abs($x / $y) >= $panort) {
@@ -483,7 +506,16 @@ Pretty print json for easier customization
        }
      }
  
-@@ -851,7 +861,13 @@ my $fd;
+@@ -828,7 +842,7 @@ $json{version} = $VERSION;
+ $json{name} = $name if($name);
+ $json{download} = $fdownload if($fdownload);
+ $json{index} = $indexUrl if($indexUrl);
+-$json{blur} = \@backsize;
++$json{blur} = \@backsize if $do_blur;
+ $json{thumb} = { min => \@minthumb, max => \@maxthumb };
+ 
+ foreach my $fdata(@adata)
+@@ -851,7 +865,13 @@ my $fd;
  unless(open($fd, ">:raw", "$out/data.json")) {
    fatal("cannot write data file: $!");
  }
diff --git a/fgallery/patches/patch-view_index.js b/fgallery/patches/patch-view_index.js
index ff5ad22..909aaee 100644
--- a/fgallery/patches/patch-view_index.js
+++ b/fgallery/patches/patch-view_index.js
@@ -58,8 +58,16 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
  
    if(imgrt > (contSize.x / contSize.y))
    {
-@@ -390,11 +389,9 @@ function showCap(nodelay)
+@@ -388,17 +387,20 @@ function hideCap(nodelay)
+ function showCap(nodelay)
+ {
    if(capst == 'never') return;
++  var cap = imgs.data[ecap.eidx]['caption'];
++  if(!cap || (cap[0].length + cap[1].length == 0))
++  {
++    hideCap(true);
++    return;
++  }
    captm = resetTimeout(captm);
    ecap.get('tween').cancel();
 -
@@ -70,7 +78,11 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
    if(capst != 'always')
    {
      // calculate a decent reading time
-@@ -408,7 +405,6 @@ function showCap(nodelay)
+-    var cap = imgs.data[ecap.eidx]['caption'];
+     var words = cap[0].split(' ').length + cap[1].split(' ').length;
+     var delay = Math.max(capdelay, rdwdelay * words);
+     captm = hideCap.delay(delay);
+@@ -408,7 +410,6 @@ function showCap(nodelay)
  function toggleCap()
  {
    if(!imgs.captions) return;
@@ -78,7 +90,7 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
    // switch mode
    if(capst == 'normal')
      capst = 'never';
-@@ -416,53 +412,76 @@ function toggleCap()
+@@ -416,53 +417,76 @@ function toggleCap()
      capst = 'always';
    else
      capst = 'normal';
@@ -167,7 +179,18 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
  }
  
  function onMainReady()
-@@ -549,7 +568,8 @@ function onMainReady()
+@@ -544,26 +568,31 @@ function onMainReady()
+   fx.start('opacity', 1);
+ 
+   var rp = Math.floor(Math.random() * 100);
+-  eback.src = imgs.data[eidx].blur;
+-  enoise.setStyle('background-position', rp + 'px ' + rp + 'px');
++  eback.src = '';
++  if (imgs.data[eidx].blur)
++  {
++    eback.src = imgs.data[eidx].blur;
++    enoise.setStyle('background-position', rp + 'px ' + rp + 'px');
++  }
  
    tthr = resetTimeout(tthr);
    idle.start();
@@ -177,7 +200,14 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
    centerThumb(d);
  
    // prefetch next image
-@@ -563,7 +583,7 @@ function onMainReady()
+   if(prefetch && sdir != 0)
+   {
+     var data = imgs.data[umod(eidx + sdir, imgs.data.length)];
+-    Asset.images([data.img[0], data.blur]);
++    Asset.images([data.img[0], data.blur? data.blur :[]]);
+   }
+ }
+ 
  function showThrobber()
  {
    var img = new Element('img', { id: 'throbber' });
@@ -186,7 +216,7 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
    ehdr.empty();
    img.inject(ehdr);
    ehdr.setStyle('display', 'block');
-@@ -574,31 +594,19 @@ function showThrobber()
+@@ -574,31 +603,19 @@ function showThrobber()
  function hideHdr()
  {
    if(idle.started)
@@ -222,7 +252,16 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
  function flash()
  {
    eflash.setStyle('display', 'block');
-@@ -722,16 +730,6 @@ function initGallery(data)
+@@ -637,7 +654,7 @@ function load(i)
+   if(i == eidx) return;
+ 
+   var data = imgs.data[i];
+-  var assets = Asset.images([data.img[0], data.blur],
++  var assets = Asset.images([data.img[0], data.blur? data.blur: []],
+   {
+     onComplete: function() { if(i == eidx) onMainReady(); }
+   });
+@@ -722,16 +739,6 @@ function initGallery(data)
    ecap = new Element('div', { id: 'caption' });
    ecap.inject(econt);
  
@@ -239,7 +278,7 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
    ehdr = new Element('div', { id: 'header' });
    ehdr.set('tween', { link: 'ignore' })
    ehdr.inject(econt);
-@@ -771,10 +769,9 @@ function initGallery(data)
+@@ -771,10 +778,9 @@ function initGallery(data)
  
    // events and navigation shortcuts
    elist.addEvent('scroll', onScroll);
@@ -251,7 +290,7 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
  
    window.addEvent('keydown', function(ev)
    {
-@@ -788,10 +785,6 @@ function initGallery(data)
+@@ -788,10 +794,6 @@ function initGallery(data)
        ev.stop();
        next();
      }
@@ -262,7 +301,7 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
    });
  
    econt.addEvent('mousewheel', function(ev)
-@@ -819,8 +812,7 @@ function initGallery(data)
+@@ -819,8 +821,7 @@ function initGallery(data)
      timeout: hidedelay,
      events: ['mousemove', 'mousedown', 'mousewheel']
    }).start();
@@ -272,7 +311,7 @@ webserver to /usr/pkg/share/fgallery/view in DocumentRoot hierarchies
  
    // general idle callback
    idle = new IdleTimer(window, { timeout: hidedelay }).start();
-@@ -871,12 +863,11 @@ function init()
+@@ -871,12 +872,11 @@ function init()
    }).get();
  
    // preload some resources


Home | Main Index | Thread Index | Old Index