SafeSort 0.9.8

A place for you to show off what you have made with LiveCode

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

SafeSort 0.9.8

Post by marksmithhfx » Tue Jan 09, 2024 11:24 pm

Finally out in the wild. For those not familiar, SafeSort (formerly SafariSorter) is an application that lets you easily read and sort the topmost level of your Safari bookmark folders. Something Safari itself does not provide. For those who would like to kick the tires, SafeSort is available through TestFlight at the link below.

https://testflight.apple.com/join/n3LpOEZ5

If you do test please let me now if you have any suggestions or requests. All feedback is appreciated and will be considered. Even if it is just to say “Hey, it’s working fine” that is appreciated as well. (Richard, you will be happy to know it has buttons AND menus now and you can hide the buttons if you just want a menu driven application. You see, I do take all feedback into consideration 😊).

A few things are a bit unusual with this app. I want to highlight the first because of Panos’s contribution to it. We have had discussion on this forum before about accessing files outside the app sandbox (for example, using Privacy & Security settings in System Preferences to “expand” the apps reach to “Full Disk Access” and the like, or using the Open File dialog to allow the user to give temporary permission). Two problems with these methods are (1) the permission is not “sticky”. Each time the user launches the app they have to re-authorize access to the file and (2) for Full Disk Access It won’t work if the app is sandboxed. However, there is a way to use the open file dialog to authorize permission and make it sticky even when the app is sandboxed. It’s called a security scoped bookmark and you can read more about it here:

https://developer.apple.com/documentati ... _sandbox#

Particularly in the section: Persist access to files with security-scoped URL bookmarks

This is where Panos comes in. There are a number of system calls that need to be made in order to implement security scoped bookmarks… ones to save, load, refresh and stop using them. Panos kindly agreed to wrap these calls into a LC extension called, appropriately, securityscopedbookmarks. If you are interested or need further information I am sure he would be happy to oblige.

The 2nd unique feature is another library that Panos created called checkSafari which checks to see if Safari is running using an Apple approved method and again, he wrapped the system call into a LC extension. This one has “Safari” hard coded into it, but could be extended (I think) to work with other applications as well. The point of this extension for SafeSort is I don’t want my app to try writing to the bookmark file while Safari is or might be. So if it’s running I ask the user to close it first so we don’t step on each other — a potential opportunity to corrupt the file. The app also provides an option to create a binary Backup of the bookmarks file. If things go south, you can use the Restore command to restore the original file.

Enjoy, kick the tires and let me know if you have any preference among the 5 different button styles that are implemented in the app.

Cheers and many thanks,
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: SafeSort 0.9.8

Post by marksmithhfx » Wed Jan 17, 2024 11:05 am

As a further note to this, SafeSort contains a demonstration of a very slick scrolling widget called "scrollingCredits" developed by Bernd Niggeman. The cool thing about it is how "smooth" Bernd managed to make the scroll work. I am sure if you have a need to scroll some text smoothly, Bernd would be happy to provide some technical assistance.

On a related note, SafeSort uses the plain vanilla table field to display the Safari folder names (for you to re-order). But a nice addition is the ability to drag and drop rows in the table field. Credit for this feat of engineering goes to Scott Rossi and Simon Knight.

Finally, credit goes to Stam Kapetanakis for the idea to do this crazy program in the first place. I had written an earlier version (intended really for my own use) that had the user import and export the bookmarks using the Safari functions (in the File menu) to get a "flat file" output of the bookmarks that could be readily imported into a LC utility to read and sort the text records. Stam commented, when I shared that utility here, to the effect (and I am paraphrasing) "Very nice, but too bad you can't read and write the Safari bookmarks file directly" and thus the journey began. Thank you Stam... it certainly has been an incredible process of discovering how complicated such a simple project can become (and to give just some flavour of the challenge, here is the format of the bookmarks file):
The Safari bookmarks file is a binary property list. If the file is shared across user devices
using iCloud then the format is an encrypted binary property list. A property list is a hierarchically structured
list of XML formatted key value pairs."
SafeSort reads/writes both formats of the bookmarks file without reference to external libraries (all LC script with a little help from "plutil -convert xml1" to do the binary conversion).

Best wishes,
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

Post Reply

Return to “Made With LiveCode”