Permlink Replies: 3 - Pages: 1 - Last Post: 13 Mar 22, 21:41 Last Post By: RobM
RobM

Posts: 4,171
Registered: 4-Aug-2006
Convert project to mirror project.
Posted: 22 Oct 21, 23:44
  Click to reply to this thread Reply
This tool will either make a copy of a project, in mirrored form, or convert one to mirrored
form. If the project is within the My Albums directory, it will make a mirrored copy, if outside it will delete all jAlbum project specific files.

It currently requires the mirrored project to be built like any new project. Future versions may negate that one off step.

Full instructions at http://robm.jalbum.net/External%20Tools%20and%20plugins%20for%20jAlbum/Convert%20project%20to%20mirror/index.html

Edited by: RobM on 13 Mar 2022, 20:39
Improved ordering of objects in the mirrored project. Folders, images etc. now in correct order, page templates and pdfs etc. still might not be.
davidekholm

Posts: 4,059
Registered: 18-Oct-2002
Re: Convert project to mirror project.
Posted: 25 Jan 22, 12:31   in response to: RobM in response to: RobM
  Click to reply to this thread Reply
Thanks Rob. I just had a glance at the code. Here are two more recommendations for shorter, more readable and more robust code:
  • Whenever you can, use "foreach" loops instead of Iterators. Any List/Collection that implements "Iterable" (and they all do) allows for the shorter foreach construct:
    for (String s : projectList) { // do something with each string here } 
    
  • Never rely on the formatting returned by calling .toString() on an object. It's for human use. Also, avoid string arithmetics unless you start off with a string. It simply makes your code more brittle. Imagine me changing the visual "toString" formatting of a LinkFile so that the "->" is changed. That will break your code. Instead, try to keep the higher level data abstraction (File, LinkFile, AlbumObject etc).
davidekholm

Posts: 4,059
Registered: 18-Oct-2002
Re: Convert project to mirror project.
Posted: 25 Jan 22, 12:37   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
Also, If you want to mirror any tree, using recursion is probably easier than a flat iteration as given by getDescendants().
RobM

Posts: 4,171
Registered: 4-Aug-2006
Re: Convert project to mirror project.
Posted: 25 Jan 22, 12:37   in response to: davidekholm in response to: davidekholm
  Click to reply to this thread Reply
davidekholm wrote:
Thanks Rob. I just had a glance at the code. Here are two more recommendations for shorter, more readable and more robust code:
  • Whenever you can, use "foreach" loops instead of Iterators. Any List/Collection that implements "Iterable" (and they all do) allows for the shorter foreach construct:
    for (String s : projectList) { // do something with each string here } 
    
  • Never rely on the formatting returned by calling .toString() on an object. It's for human use. Also, avoid string arithmetics unless you start off with a string. It simply makes your code more brittle. Imagine me changing the visual "toString" formatting of a LinkFile so that the "->" is changed. That will break your code. Instead, try to keep the higher level data abstraction (File, LinkFile, AlbumObject etc).
I will look again at my code, while it still makes sense to me ;)
Glad you only glanced at it, probably saved me a lot of embarrassment :)
Legend
Forum admins
Helpful Answer
Correct Answer

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