[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gallery-devel
Subject:    Re: [Gallery-devel] set_display_context_callback() and incorrect pagination
From:       Bharat Mediratta <bharat () menalto ! com>
Date:       2013-01-31 0:40:31
Message-ID: CAESa+_kGHSbU6d8wLyq9pcmMt8RU80CS=PY3kbZDKo10B-2KgQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I wasn't very pleased with the last round of code because exposing the
call_user_func_array to the end user is a crappy API.  I wrapped that in a
function in Gallery_Theme so now the caller can do:

  $theme->siblings()

So in thumbnav_block you can do:

  foreach ($theme->siblings() as $sibling) {

and it should just work (I tested it).

-Bharat


On Wed, Jan 30, 2013 at 1:21 PM, Mike Miller <gallery@mikeage.net> wrote:

> On Wed, Jan 30, 2013 at 7:12 PM, Bharat Mediratta <bharat@menalto.com>
> wrote:
> >
> > I committed this change in
> >
> https://github.com/gallery/gallery3/commit/1e4d75c12072b49c3469f18af13bcf3439afc6b0
> > - check it out.  It only covers the official repo.  The one thing it's
> > missing is the ability to paginate the sibling responses, but from the GD
> > example it doesn't look like that's something that the GD module needs.
>
> Working great so far; I simply replaced (in GD):
>
> -        $siblings = $parent->children();
>
> with
>
> +         $siblings = call_user_func_array($siblings_callback[0],
> $siblings_callback[1]);
>
> And it's behaving correctly for search, albums (which always worked) and
> tags.
>
> I then moved onto adding this API to the dynamic module, and it went
> quite smoothly (although browsing a virtual album with 11K items was
> quite slow, and reminded me that I needed to optimize GD not to
> actually look up every URL, but only the ~30 that we might potentially
> display). In case anyone's interested (I need to get in touch with
> Serge D one of these days), all of my modified code is at
> https://github.com/mikeage/greydragon .
>
> I then tried modifying the thumbnav plugin
> (http://codex.galleryproject.org/Gallery3:Modules:thumbnav), and here
> I got into a bit of trouble. thumbnav is a block, but
> $siblings_callback doesn't seem to be defined here. I'm assuming this
> is because it's not created through the normal theme view mechanism; I
> tried a few combinations involving item::get_display_context($item))
> or this->set_global(), but I'm not really sure what I'm doing <g>. I
> hate to ask such a silly question, but I suspect this is something
> that you can answer in a few seconds, and save me quite a bunch of
> time poking around.
>
> Thanks
>
> -- Mike
>
>

[Attachment #5 (text/html)]

<div dir="ltr"><div style><br></div><div style>I wasn&#39;t very pleased with the \
last round of code because exposing the call_user_func_array to the end user is a \
crappy API.  I wrapped that in a function in Gallery_Theme so now the caller can \
do:</div>

<div style><br></div><div style><font face="courier new, monospace">  \
$theme-&gt;siblings()</font></div><div style><font face="courier new, \
monospace"><br></font></div><div style>So in thumbnav_block you can do:<br></div>

<div style><br></div><div style><font face="courier new, monospace">  foreach \
($theme-&gt;siblings() as $sibling) {</font></div><div style><br></div><div style>and \
it should just work (I tested it).</div><div style><br></div>

<div style>-Bharat</div></div><div class="gmail_extra"><br><br><div \
class="gmail_quote">On Wed, Jan 30, 2013 at 1:21 PM, Mike Miller <span \
dir="ltr">&lt;<a href="mailto:gallery@mikeage.net" \
target="_blank">gallery@mikeage.net</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><div class="im">On Wed, Jan 30, 2013 at 7:12 PM, Bharat \
Mediratta &lt;<a href="mailto:bharat@menalto.com">bharat@menalto.com</a>&gt; \
wrote:<br>


&gt;<br>
&gt; I committed this change in<br>
&gt; <a href="https://github.com/gallery/gallery3/commit/1e4d75c12072b49c3469f18af13bcf3439afc6b0" \
target="_blank">https://github.com/gallery/gallery3/commit/1e4d75c12072b49c3469f18af13bcf3439afc6b0</a><br>
 &gt; - check it out.  It only covers the official repo.  The one thing it&#39;s<br>
&gt; missing is the ability to paginate the sibling responses, but from the GD<br>
&gt; example it doesn&#39;t look like that&#39;s something that the GD module \
needs.<br> <br>
</div>Working great so far; I simply replaced (in GD):<br>
<br>
-        $siblings = $parent-&gt;children();<br>
<br>
with<br>
<br>
+         $siblings = call_user_func_array($siblings_callback[0],<br>
$siblings_callback[1]);<br>
<br>
And it&#39;s behaving correctly for search, albums (which always worked) and \
tags.<br> <br>
I then moved onto adding this API to the dynamic module, and it went<br>
quite smoothly (although browsing a virtual album with 11K items was<br>
quite slow, and reminded me that I needed to optimize GD not to<br>
actually look up every URL, but only the ~30 that we might potentially<br>
display). In case anyone&#39;s interested (I need to get in touch with<br>
Serge D one of these days), all of my modified code is at<br>
<a href="https://github.com/mikeage/greydragon" \
target="_blank">https://github.com/mikeage/greydragon</a> .<br> <br>
I then tried modifying the thumbnav plugin<br>
(<a href="http://codex.galleryproject.org/Gallery3:Modules:thumbnav" \
target="_blank">http://codex.galleryproject.org/Gallery3:Modules:thumbnav</a>), and \
here<br> I got into a bit of trouble. thumbnav is a block, but<br>
$siblings_callback doesn&#39;t seem to be defined here. I&#39;m assuming this<br>
is because it&#39;s not created through the normal theme view mechanism; I<br>
tried a few combinations involving item::get_display_context($item))<br>
or this-&gt;set_global(), but I&#39;m not really sure what I&#39;m doing &lt;g&gt;. \
I<br> hate to ask such a silly question, but I suspect this is something<br>
that you can answer in a few seconds, and save me quite a bunch of<br>
time poking around.<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Mike<br>
<br>
</font></span></blockquote></div><br></div>



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan

__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic