This question is answered.


Permlink Replies: 6 - Pages: 1 - Last Post: 03-Dec-2017 09:13 Last Post By: AndreWolff Threads: [ Previous | Next ]
AndreWolff

Posts: 2,333
Registered: 14-Dec-2007
How to get the absolute URL of an album?
Posted: 02-Dec-2017 09:07
 
  Click to reply to this thread Reply
For the Facebook share action I need the absolute URL (starting with “http”).

After I uploaded an album and saved the project, next time jAlbum remembers this absolute URL, but I can't find it in the jap project file.

So my question is is there a way to get that URL in the index.htt file?
davidekholm

Posts: 21,873
Registered: 18-Oct-2002
Re: How to get the absolute URL of an album?
Posted: 02-Dec-2017 11:31   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Once an album has been uploaded once (so jAbum knows the location, the URL to that album can be accessed like this:
rootFolder.getProperties().get(AOP.ALBUM_URL);
AndreWolff

Posts: 2,333
Registered: 14-Dec-2007
Re: How to get the absolute URL of an album?
Posted: 02-Dec-2017 12:47   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Once an album has been uploaded once (so jAbum knows the location, the URL to that album can be accessed like this:
rootFolder.getProperties().get(AOP.ALBUM_URL);
That works only for the top album, but I need this info also for the folder albums.

I tried:
String albumURL= currentFolder.getProperties().get(AOP.ALBUM_URL);
and
if (level==0) {
  String albumURL= rootFolder.getProperties().get(AOP.ALBUM_URL);
} else {
  String albumURL= rootFolder.getProperties().get(AOP.ALBUM_URL) + currentFolder.getName();
}
but that does not work.
Why says the API that currentFolder is deprecated?
What is the replacement?

Edited by: AndreWolff on 02-Dec-2017 13:00
davidekholm

Posts: 21,873
Registered: 18-Oct-2002
Re: How to get the absolute URL of an album?
Posted: 02-Dec-2017 13:39   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
currentFolder isn't deprecated. Your code example won't work for folders that are under other folders, i.e. it will only work for the 1:st level of folders. This sample gives you a full path to the current folder. Note that it only works for albums that have already been uploaded:
IO.combinePaths(rootFolder.getProperties().get(AOP.ALBUM_URL), currentFolder.getPathFromRoot());
AndreWolff

Posts: 2,333
Registered: 14-Dec-2007
Re: How to get the absolute URL of an album?
Posted: 02-Dec-2017 13:57   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Attachment depreciated.PNG (57.1 KB)
davidekholm wrote:
currentFolder isn't deprecated.
see attached screenshot!
This sample gives you a full path to the current folder. Note that it only works for albums that have already been uploaded:
IO.combinePaths(rootFolder.getProperties().get(AOP.ALBUM_URL), currentFolder.getPathFromRoot());
I have in index.htt this code:
if (level==0) {
  String albumURL= rootFolder.getProperties().get(AOP.ALBUM_URL);
} else {
  String albumURL= IO.combinePaths(rootFolder.getProperties().get(AOP.ALBUM_URL), currentFolder.getPathFromRoot());
}
and
<!-- albumURL= ${albumURL} -->

This gives in the top album:

<!-- albumURL= http://AndreWolff.jalbum.net/Terschelling_SS4/ -->

but in a folder album:

<!-- albumURL= -->
davidekholm

Posts: 21,873
Registered: 18-Oct-2002
Re: How to get the absolute URL of an album?
Posted: 02-Dec-2017 17:31   in response to: AndreWolff in response to: AndreWolff
Correct
  Click to reply to this thread Reply
See http://jalbum.net/api/se/datadosen/jalbum/CompiledScript.html for how to resolve the deprecation warning. It's the whole class that's deprecated.

You don't, and shouldn't use that if/else construct. The code I passed works no matter what level you are at. Less code repetition is better code. But remember to do a null-check first in case the album hasn't been uploaded at all.
AndreWolff

Posts: 2,333
Registered: 14-Dec-2007
Re: How to get the absolute URL of an album?
Posted: 02-Dec-2017 17:49   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
You don't, and shouldn't use that if/else construct. The code I passed works no matter what level you are at. Less code repetition is better code. But remember to do a null-check first in case the album hasn't been uploaded at all.
Although I don't understand why it is not working with if/else, you are correct, it gives now the expected result!

Thanks and have a nice weekend!

Edit

However, the result should be improved, see this thread.

Edited by: AndreWolff on 03-Dec-2017 09:12
Legend
Forum admins
Helpful Answer
Correct Answer

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