This question is answered.


Permlink Replies: 12 - Pages: 1 - Last Post: 25-Jun-2017 21:30 Last Post By: RobM
AndreWolff

Posts: 1,746
Registered: 14-Dec-2007
How to detect the jAlbum version?
Posted: 22-Jun-2017 17:46
 
  Click to reply to this thread Reply
The coming PhotoSwipe skin version will contain code like

<ja:if test="<%= (fileCategory ==  Category.webLocation)  %>">
  webloc: '${targetURL}',
 </ja:if>
which gives a crash with jAlbum 13.

It is a pity that the new version can not be used under version 13, so I wonder is there a variable indicating the jAlbum version op the PC so that I can use a construction like:

<ja:if test="<%= (jAlbumVersion >= 14)  %>">
  <ja:if test="<%= (fileCategory ==  Category.webLocation)  %>">
  webloc: '${targetURL}',
  </ja:if>
</ja:if>
which prevents a crash with jAlbum 13?
jGromit

Posts: 7,361
Registered: 31-Jan-2006
Re: How to detect the jAlbum version?
Posted: 22-Jun-2017 18:18   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
You could grab generator or internalVersion and parse it to extract the number. https://jalbum.net/help/en/Variables

But it would be easier simply not to use something that's undefined in jAlbum 13. This will do the same thing as your code, but it won't produce an error:
<ja:if exists="targetURL">
  webloc: '${targetURL}',
 </ja:if>
ctwist

Posts: 543
Registered: 27-Sep-2003
Re: How to detect the jAlbum version?
Posted: 22-Jun-2017 19:25   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
This is how I do it
	// Compare the current version number to the required version
	// Return -1: the current version number is lower; 0: both are the same; 1: the current version number is higher
	protected static int fCompareVersion(final String pCurrentVersion, final String pRequiredVersion)
	{ VersionNumber vCurrentVersion = new VersionNumber(pCurrentVersion);
		VersionNumber vRequiredVersion = new VersionNumber(pRequiredVersion);
		return vCurrentVersion.compareTo(vRequiredVersion);
	}
	
	// Compare the actual jAlbum version number with the required jAlbum version number
	// Return -1: the actual jAlbum version number is lower; 0: both are the same; 1: the actual jAlbum version number is higher
	protected static int fCompareVersion(final String pRequiredVersion)
	{ // Remove the alpha, beta or release candidate version
		Pattern vDelim = Pattern.compile("(a|b|r)");
		String[] vVersionArray = vDelim.split(AlbumBean.getInternalVersion());
 
		return fCompareVersion(vVersionArray[0].trim(), pRequiredVersion);
	}
if (fCompareVersion("14") >= 0) ......


Edited by: ctwist on 22-Jun-2017 13:25

Edited by: ctwist on 22-Jun-2017 13:31

Finally, I think the example is complete.
AndreWolff

Posts: 1,746
Registered: 14-Dec-2007
Re: How to detect the jAlbum version?
Posted: 22-Jun-2017 19:29   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
You could grab generator or internalVersion and parse it to extract the number. https://jalbum.net/help/en/Variables

But it would be easier simply not to use something that's undefined in jAlbum 13. This will do the same thing as your code, but it won't produce an error:

<ja:if exists="targetURL">
  webloc: '${targetURL}',
 </ja:if>
Yes I use that type of code already in the Slide Show 4 skin, which did not crash.

I understand that version 14 is a free update, so everybody can update to 14 without problems. That can be a reason to do nothing!

Thanks for your answer!
jGromit

Posts: 7,361
Registered: 31-Jan-2006
Re: How to detect the jAlbum version?
Posted: 22-Jun-2017 19:50   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
I understand that version 14 is a free update....

No, it's not. If someone purchased a license for jAlbum 13 more than one year ago, and did not renew his subscription after one year, he cannot upgrade to jAlbum 14.
davidekholm

Posts: 3,562
Registered: 18-Oct-2002
Re: How to detect the jAlbum version?
Posted: 23-Jun-2017 16:37   in response to: jGromit in response to: jGromit
Correct
  Click to reply to this thread Reply
When comparing version numbers, use VersionNumber .VersionNumber is more clever than doing string comparisons as it handles beta numbers and understands that x.10 > x.9 (string comparisons get that wrong).
ctwist

Posts: 543
Registered: 27-Sep-2003
Re: How to detect the jAlbum version?
Posted: 23-Jun-2017 17:15   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
I do use VersionNumber, but its documentation says that "xx.a is smaller than xx". I want these to be equivalent. If I am testing a v14 feature in 14b7, I want the feature to be enabled. That is why I strip off a, b and rc numbers before doing the comparison.
davidekholm

Posts: 3,562
Registered: 18-Oct-2002
Re: How to detect the jAlbum version?
Posted: 23-Jun-2017 18:44   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Here's a backwards compatible way to check if the category is webLocation:
<ja:if test="<%= fileCategory.name().equals("webLocation")  %>">
Dschuwi

Posts: 457
Registered: 12-Nov-2003
Re: How to detect the jAlbum version?
Posted: 25-Jun-2017 20:55   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
I have this code in onload.bsh
//
// Test for minimal Jalbum version
// minVersion(String v) returns true if v is greater or equals current Jalbum version
//
 
import se.datadosen.jalbum.FileNameComparator;
 
int versionCompare(String v1, String v2) {
  FileNameComparator cmp = new FileNameComparator(false);
  return cmp.compare(new File(v1), new File(v2));
}
 
boolean minVersion(String v) {
  return versionCompare(v, internalVersion) <= 0;
}

so you could test for any required minimum jAlbum version like this:
<ja:if test="<%= minVersion("14")  %>">
  <ja:if test="<%= (fileCategory ==  Category.webLocation)  %>">
  webloc: '${targetURL}',
  </ja:if>
</ja:if>
jGromit

Posts: 7,361
Registered: 31-Jan-2006
Re: How to detect the jAlbum version?
Posted: 25-Jun-2017 21:09   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
VersionNumber... understands that x.10 > x.9 (string comparisons get that wrong).

<rant>
I'd like to find the first person who started inflicting version numbers on the world like v. 5.12.9, and whack him upside the head. Let's face it, 5.12.9 is not a number, in any numbering system I've ever seen.

The attempt to distinguish between "major," "minor," and "sub-minor" releases seems like a relic to me. It's particularly true with the current jAlbum license model, which isn't tied to a version number at all. If you buy a one-year license for jAlbum 14, for example, and within the next year there's a jAlbum 15 and a jAlbum 16, you end up with a jAlbum 16 license - the number is irrelevant.

I say dump it. Use whole numbers for release versions. For beta versions, perhaps jAlbum 15 beta 1. Easy to tokenize, with numerics that are actual numbers.

Maybe use decimals for bug fixes. Start with 14.01, which gives you the chance to issue 99 bug fixes. Actually, you should start with 14.1 - if you have to issue more than 9 bug fixes, you're in the wrong business. ;)
</rant>
RobM

Posts: 3,102
Registered: 4-Aug-2006
Re: How to detect the jAlbum version?
Posted: 25-Jun-2017 21:16   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
I'd like to find the first person who started inflicting version numbers on the world like v. 5.12.9,
I believe it was a lawyer/attorney. They like numbers like that but hate commas, semicolons and fullstops ;)
jGromit

Posts: 7,361
Registered: 31-Jan-2006
Re: How to detect the jAlbum version?
Posted: 25-Jun-2017 21:25   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
And every time I'm asked what version of macOS I'm using, I have to open up the Macbook and look it up. I mean, really, macOS 10.12.5?!
RobM

Posts: 3,102
Registered: 4-Aug-2006
Re: How to detect the jAlbum version?
Posted: 25-Jun-2017 21:30   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
And every time I'm asked what version of macOS I'm using, I have to open up the Macbook and look it up. I mean, really, macOS 10.12.5?!
Actually it should be more like macOS 10.12.5 (16F73), you only clicked on the 'About this Mac' instead of holding the Alt key down and then selecting Apple menu/System information and then going to Software, system version. ;)
Legend
Forum admins
Helpful Answer
Correct Answer

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