This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Pages: 1 - Last Post: 29-Oct-2017 22:11 Last Post By: jGromit
jGromit

Posts: 33,171
Registered: 31-Jan-2006
How about a predir.bsh?
Posted: 24-Oct-2011 22:07
 
  Click to reply to this thread Reply
Maybe there's an easy way to do this, and I've just missed it, but...

We have init.bsh and finally.bsh, each of which is run once per album build. Then we have postdir.bsh, which is run after each directory is processed. But there's no corresponding predir.bsh, as far as I know. It would be run just before each directory is processed.

I suppose I can simulate it by calling a routine from index.htt, and checking to see if indexNum is void or one before actually letting it do anything. Seems clunky, however.
RobM

Posts: 4,382
Registered: 4-Aug-2006
Re: How about a predir.bsh?
Posted: 24-Oct-2011 23:55   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Wouldn't it depend on what was trying to be done? Is there a way of getting the next directory from within postdir.bsh? Sounds interesting.
davidekholm

Posts: 21,450
Registered: 18-Oct-2002
Re: How about a predir.bsh?
Posted: 02-Nov-2011 22:16   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
No, there is no easy way to get the next directory from within postdir.bsh. I guess it would be symmetric to provide a predir.bsh too. What's the intended use in this case?
jGromit

Posts: 33,171
Registered: 31-Jan-2006
Re: How about a predir.bsh?
Posted: 02-Nov-2011 22:57   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
A simple case: in Matrix, I need to do some computations to determine the height of the thumbnail boxes on the pages. I want the same height on all index pages for this directory (index, index2, index3, etc.). I do a quick iteration through all the items in this directory to pick up some needed information.

I can't do this in init.bsh, because there will be different values for different directories. If I do it in index.htt, it's doing the routine when it creates index.html, then again when it creates index2.html, and so on. It needs to do it only once for the directory. So, I'm checking for indexNum equals void or one, so I do the routine only once. It works, but it's clumsy.

Similarly, it's sometimes necessary to set a variable for a directory, like isSomething=false, to keep track of whether something is present in the directory. As each item is processed, isSomething may be set to true. In postdir.bsh, I want to use that variable. For the next directory, however, I want to start out with it set to false again.
davidekholm

Posts: 21,450
Registered: 18-Oct-2002
Re: How about a predir.bsh?
Posted: 03-Nov-2011 11:55   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
I see, Let me consider it. Personally I don't think it sounds that clunky to do that stuff within index.htt using an if test. If we introduce a predir.bsh that also has the downside of making the skin require an update to jAlbum.
jGromit

Posts: 33,171
Registered: 31-Jan-2006
Re: How about a predir.bsh?
Posted: 03-Nov-2011 12:31   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
It's not a big deal - just something I ran into when I was getting confused about whether I needed to set some variables at the album level, the directory level, or the page level, and suddenly realized there was no truly direct way of doing something at the directory level.

(Part of the same exercise, really, and the one I'm more interested in, is the "local" problem I've run into with iterating through the folders in a directory - thread in the General Development section. I ran into that one at the same time, since it involves doing something for an entire directory, regardless of page boundaries.)

Lots of skin changes require the latest version of jAlbum, so that never worries me. Most of the current versions of the bundled skins won't run with anything before jAlbum 10, for example, because of the licensing checks.
davidekholm

Posts: 21,450
Registered: 18-Oct-2002
Re: How about a predir.bsh?
Posted: 03-Nov-2011 13:31   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
I'll dig through the backlog of forum posts now that I'm back from my vacation, and I'll naturally comment on your thread in General Development too.
Dschuwi

Posts: 1,521
Registered: 12-Nov-2003
Re: How about a predir.bsh?
Posted: 03-Nov-2011 15:28   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
EarlyOut wrote:
So, I'm checking for indexNum equals void or one, so I do the routine only once. It works, but it's clumsy.

I wouldn't consider this to be clumsy. It is pretty straightforward. Or at least as straightforward as hundreds of other conditional tests which need to be done for a skin to work ;-)
ctwist

Posts: 1,411
Registered: 27-Sep-2003
Re: How about a predir.bsh?
Posted: 03-Nov-2011 18:09   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
I had a similar requirement (don't bother looking for it - it isn't published yet). In index.htt, in fileIterator, I check whether or not the current file is a directory. If it is, I scan the sub-folder and do some set-up work. It was easy.

My objective was to automatically exclude some files from the album. Since jAlbum does not start to work with the sub-folders until the parent folder has been generated, I can manipulate the sub-folder from within the parent folder's iteration of index.htt.

For the root folder, I had to replicate the code in init.bsh. This is the only downside of this approach; the code has to be in 2 places (if there were a predir.bsh it would be in one place). However, this is a minor point.
jGromit

Posts: 33,171
Registered: 31-Jan-2006
Re: How about a predir.bsh?
Posted: 29-Oct-2017 22:11   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
Only took six years, but jAlbum now recognizes a predir.bsh or predir.js file. It's executed once per directory.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums