Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version History opens full release notes (changelog) if informed #2001

Merged
merged 1 commit into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Resources/SampleAppcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<sparkle:releaseNotesLink>
https://you.com/app/2.0.html
</sparkle:releaseNotesLink>
<sparkle:fullReleaseNotesLink>
https://you.com/app/changelog.php
</sparkle:fullReleaseNotesLink>
<pubDate>Wed, 09 Jan 2006 19:20:11 +0000</pubDate>
<enclosure url="https://you.com/app/Your%20Great%20App%202.0.zip" length="1623481" type="application/octet-stream" sparkle:edSignature="WVyVJpOx+a5+vNWJVY79TRjFKveNk+VhGJf2iti4CZtJsJewIUGvh/1AKKEAFbH1qUwx+vro1ECuzOsMmumoBA==" />
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
Expand All @@ -23,6 +26,9 @@
<sparkle:releaseNotesLink>
https://you.com/app/1.5.html
</sparkle:releaseNotesLink>
<sparkle:fullReleaseNotesLink>
https://you.com/app/changelog.php?up-to=1.5
</sparkle:fullReleaseNotesLink>
<pubDate>Wed, 01 Jan 2006 12:20:11 +0000</pubDate>
<enclosure url="https://you.com/app/Your%20Great%20App%201.5.zip" length="1472893" type="application/octet-stream" sparkle:edSignature="pNFd7KbcQSu+Mq7UYrbQXTPq82luht2ACXm/r2utp1u/Uv/5hWqctdT2jwQgMejW7DRoeV/hVr6J4VdZYdwWDw==" />
<sparkle:minimumSystemVersion>10.11</sparkle:minimumSystemVersion>
Expand All @@ -35,6 +41,9 @@
<sparkle:releaseNotesLink>
https://you.com/app/1.4.html
</sparkle:releaseNotesLink>
<sparkle:fullReleaseNotesLink>
https://you.com/app/changelog.php?up-to=1.4
</sparkle:fullReleaseNotesLink>
<sparkle:version>241</sparkle:version>
<sparkle:shortVersionString>1.4</sparkle:shortVersionString>
<pubDate>Wed, 25 Dec 2005 12:20:11 +0000</pubDate>
Expand Down
9 changes: 8 additions & 1 deletion Sparkle/SPUStandardUserDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,15 @@ - (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(v
secondaryAction = ^{
[delegate standardUserDriverShowVersionHistoryForAppcastItem:latestAppcastItem];
};
} else if (latestAppcastItem.fullReleaseNotesURL != nil) {
// Open the full release notes URL if informed
[alert addButtonWithTitle:localizedButtonTitle];

secondaryAction = ^{
[[NSWorkspace sharedWorkspace] openURL:(NSURL * _Nonnull)latestAppcastItem.fullReleaseNotesURL];
};
} else if (latestAppcastItem.releaseNotesURL != nil) {
// Fall back to opening the release notes URL (or forthcoming full version history link attr!)
// Fall back to opening the release notes URL
[alert addButtonWithTitle:localizedButtonTitle];

secondaryAction = ^{
Expand Down
12 changes: 12 additions & 0 deletions Sparkle/SUAppcastItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
*/
@property (copy, readonly, nullable) NSString *itemDescription;

/**
The full release notes URL of the appcast item if provided.

This external link will open when `Version History` button is clicked. The link should point to the product's changelog.

The delegate `standardUserDriverShowVersionHistoryForAppcastItem` will be used instead if implemented.
If none is set `releaseNotesURL` will be used.

This is extracted from the @c <sparkle:fullReleaseNotesLink> element.
*/
@property (readonly, nullable) NSURL *fullReleaseNotesURL;

/**
The required minimum system operating version string for this update if provided.

Expand Down
20 changes: 20 additions & 0 deletions Sparkle/SUAppcastItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
static NSString *SUAppcastItemMaximumSystemVersionKey = @"maximumSystemVersion";
static NSString *SUAppcastItemMinimumSystemVersionKey = @"minimumSystemVersion";
static NSString *SUAppcastItemReleaseNotesURLKey = @"releaseNotesURL";
static NSString *SUAppcastItemFullReleaseNotesURLKey = @"fullReleaseNotesURL";
static NSString *SUAppcastItemTitleKey = @"title";
static NSString *SUAppcastItemVersionStringKey = @"versionString";
static NSString *SUAppcastItemPropertiesKey = @"propertiesDictionary";
Expand Down Expand Up @@ -65,6 +66,7 @@ @implementation SUAppcastItem
@synthesize maximumSystemVersion = _maximumSystemVersion;
@synthesize minimumSystemVersion = _minimumSystemVersion;
@synthesize releaseNotesURL = _releaseNotesURL;
@synthesize fullReleaseNotesURL = _fullReleaseNotesURL;
@synthesize title = _title;
@synthesize versionString = _versionString;
@synthesize osString = _osString;
Expand Down Expand Up @@ -114,6 +116,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder
_minimumSystemVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemMinimumSystemVersionKey] copy];
_minimumAutoupdateVersion = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastElementMinimumAutoupdateVersion] copy];
_releaseNotesURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemReleaseNotesURLKey];
_fullReleaseNotesURL = [decoder decodeObjectOfClass:[NSURL class] forKey:SUAppcastItemFullReleaseNotesURLKey];
_title = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemTitleKey] copy];

NSString *versionString = [(NSString *)[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemVersionStringKey] copy];
Expand Down Expand Up @@ -188,6 +191,10 @@ - (void)encodeWithCoder:(NSCoder *)encoder
[encoder encodeObject:self.releaseNotesURL forKey:SUAppcastItemReleaseNotesURLKey];
}

if (self.fullReleaseNotesURL != nil) {
[encoder encodeObject:self.fullReleaseNotesURL forKey:SUAppcastItemFullReleaseNotesURLKey];
}

if (self.title != nil) {
[encoder encodeObject:self.title forKey:SUAppcastItemTitleKey];
}
Expand Down Expand Up @@ -543,6 +550,19 @@ - (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(
} else {
_releaseNotesURL = nil;
}

// Get full release notes URL if informed.
NSString *fullReleaseNotesString = [dict objectForKey:SUAppcastElementFullReleaseNotesLink];
if (fullReleaseNotesString) {
NSURL *url = [NSURL URLWithString:fullReleaseNotesString];
if ([url isFileURL]) {
SULog(SULogLevelError, @"Full release notes with file:// URLs are not supported");
} else {
_fullReleaseNotesURL = url;
}
} else {
_fullReleaseNotesURL = nil;
}

NSArray *deltaDictionaries = [dict objectForKey:SUAppcastElementDeltas];
if (deltaDictionaries) {
Expand Down
1 change: 1 addition & 0 deletions Sparkle/SUConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ extern NSString *const SUAppcastElementMinimumAutoupdateVersion;
extern NSString *const SUAppcastElementMinimumSystemVersion;
extern NSString *const SUAppcastElementMaximumSystemVersion;
extern NSString *const SUAppcastElementReleaseNotesLink;
extern NSString *const SUAppcastElementFullReleaseNotesLink;
extern NSString *const SUAppcastElementTags;
extern NSString *const SUAppcastElementPhasedRolloutInterval;
extern NSString *const SUAppcastElementInformationalUpdate;
Expand Down
1 change: 1 addition & 0 deletions Sparkle/SUConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
NSString *const SUAppcastElementMinimumSystemVersion = @"sparkle:minimumSystemVersion";
NSString *const SUAppcastElementMaximumSystemVersion = @"sparkle:maximumSystemVersion";
NSString *const SUAppcastElementReleaseNotesLink = @"sparkle:releaseNotesLink";
NSString *const SUAppcastElementFullReleaseNotesLink = @"sparkle:fullReleaseNotesLink";
NSString *const SUAppcastElementTags = @"sparkle:tags";
NSString *const SUAppcastElementPhasedRolloutInterval = @"sparkle:phasedRolloutInterval";
NSString *const SUAppcastElementInformationalUpdate = @"sparkle:informationalUpdate";
Expand Down