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


Permlink Replies: 5 - Pages: 1 - Last Post: 24-Feb-2012 15:24 Last Post By: davidekholm
RobM

Posts: 3,170
Registered: 4-Aug-2006
Sibling Links and isHidden()
Posted: 24-Feb-2012 00:26
 
  Click to reply to this thread Reply
Since the introduction of isHidden() to detect hidden folders and files I have been trying to modify my sibling link code so it does not include hidden folders. I've tried everything I can think of and just can't find a solution that works with 10.4 beta.

I need the code to work in .htt files, page-header.inc, post.bsh and finally.bsh.

my current code is
			// Make links to sibling directories that contain an index.html file (Modified from Family Skin)
			void siblingLinks() {
				File[] dirs = imageDirectory.getParentFile().listFiles(new FileFilter() {	//changed directory from output to image
					public boolean accept(File f) {
						return f.isDirectory(); // && new File(f, engine.getIndexPageName() + engine.getPageExtension()).exists(); // only checking image directory otherwise two pass build is required.
					}
				});
				if (dirs.length > 1) out.println("$text.more"); //only output if there are siblings
				for (int i=0; i<dirs.length; i++) {
					String name = dirs[i].getName();
 
					// test was for !title.equals(name) but the replacement works for slides as well as index pages.
					if (!outputDirectory.getName().equals(name) && !name.equals(".jalbum")) {	// don't output curent page (index or slide page) as a sibling link
						out.println(": ");
						out.println("<a href=\"../" + makeSlides + name + "/" + engine.getIndexPageName() + engine.getPageExtension() + "\">" + convertText(name, false) + "</a>");
					}
				}
			}

I've tried changing to imageDirectory.getParent().getChildren() but, in page-header.inc it fails with an error saying can't get children...

The code posted by David in thread http://jalbum.net/forum/thread.jspa?messageID=16461&#16461 also does not exclude hidden folders, so I'm out of ideas :(
Has anyone solved this problem?
davidekholm

Posts: 3,564
Registered: 18-Oct-2002
Re: Sibling Links and isHidden()
Posted: 24-Feb-2012 10:45   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
I recommend starting all over with jAlbum's AlbumObject model instead. jAlbum 10.4 will include an include file called "navigation-bar.inc" that will add top-level sibling links to your album. I modified the code of navigation-bar.inc" a bit to exclude hidden folders. Here's how it looks now:
<%-- Generate top-level page navigation to pages and subfolders --%>
<%
	boolean first = true;
	for (AlbumObject ao : rootFolder.getChildren()) {
		if (!ao.isHidden()) {
			Category cat = ao.getCategory();
			Scope vars = ao.getVars();
			if (cat == Category.webPage || cat == Category.folder) {
				if (!first) {
					out.print(" | ");
				}		
				first = false;
				String name = vars.get("label");
				if (currentObject.isWithin(ao)) {
					name = "<b>" + name + "</b>";
				}
				out.print("<a href=\"" + rootPath + "/" + vars.get("closeupPath") + "\">" + name + "</a>");
			}
		}
	}
%>
davidekholm

Posts: 3,564
Registered: 18-Oct-2002
Re: Sibling Links and isHidden()
Posted: 24-Feb-2012 10:46   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
If you wish it to generate sibling folder links for the current folder instead of generating top-level folders, just change the "rootFolder" to "currentFolder.getParent()"
RobM

Posts: 3,170
Registered: 4-Aug-2006
Re: Sibling Links and isHidden()
Posted: 24-Feb-2012 13:39   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Thanks David, as much as I keep learning Java it seems that there is even more to learn. I'd got as far as realising that I might need to start from scratch, but I know enough to know when I'm beat. I think I now need to rework my main skin so it fits better with these new features.
jGromit

Posts: 7,497
Registered: 31-Jan-2006
Re: Sibling Links and isHidden()
Posted: 24-Feb-2012 14:49   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
BTW, David, looking up isHidden() in the index of the API produces this:

isHidden() - Method in class se.datadosen.component.JProgressSpinner
Tell if ticks are showing

Hmmm.....
davidekholm

Posts: 3,564
Registered: 18-Oct-2002
Re: Sibling Links and isHidden()
Posted: 24-Feb-2012 15:24   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Ah, I didn't update the API doc. Now done, see here
Legend
Forum admins
Helpful Answer
Correct Answer

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