mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-01 09:50:16 +00:00
Merge branch '7.1.3-pre' of https://github.com/Ranchero-Software/NetNewsWire into 7.1.3-pre
This commit is contained in:
commit
e1149fd28b
4 files changed
+15
-76
No files matched your search
@@ -54,7 +54,11 @@ final class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
}
|
||||
|
||||
if openInDefaultBrowser == false {
|
||||
feedURLString = feedURLString.replacingOccurrences(of: "feed:", with: "x-netnewswire-feed:")
|
||||
if feedURLString.hasPrefix("feeds:") {
|
||||
feedURLString = "x-netnewswire-feed:" + feedURLString.dropFirst("feeds:".count)
|
||||
} else if feedURLString.hasPrefix("feed:") {
|
||||
feedURLString = "x-netnewswire-feed:" + feedURLString.dropFirst("feed:".count)
|
||||
}
|
||||
}
|
||||
|
||||
if let feedURL = URL(string: feedURLString) {
|
||||
|
||||
@@ -1,72 +1,9 @@
|
||||
var thisPageLinkObjects = null;
|
||||
// The button is enabled on every web page. Clicking sends the page URL to the app,
|
||||
// whose FeedFinder module does all feed discovery — head links, page scanning,
|
||||
// URL guessing, special cases — so the logic lives in exactly one place.
|
||||
|
||||
// I convert the native "link" node into an object that I can pass out to the global page
|
||||
function objectFromLink(theLink) {
|
||||
var linkObject = new Object();
|
||||
|
||||
linkObject.href = theLink.href;
|
||||
linkObject.type = theLink.type;
|
||||
linkObject.title = theLink.title;
|
||||
|
||||
return linkObject;
|
||||
}
|
||||
|
||||
// Some sites will list feeds with inappropriate or at least less-than-ideal information
|
||||
// in the MIME type attribute. We cover some edge cases here that allow to be passed through,
|
||||
// where they will successfully open as "feed://" URLs in the browser.
|
||||
function isValidFeedLink(theLink) {
|
||||
var isValid = false;
|
||||
|
||||
switch (theLink.type)
|
||||
{
|
||||
case "application/atom+xml":
|
||||
case "application/x.atom+xml":
|
||||
case "application/rss+xml":
|
||||
// These types do not require other criteria.
|
||||
isValid = (theLink.href != null);
|
||||
|
||||
case "text/xml":
|
||||
case "application/rdf+xml":
|
||||
// These types require a title that has "RSS" in it.
|
||||
if (theLink.title && theLink.title.search(/RSS/i) != -1)
|
||||
{
|
||||
isValid = (theLink.href != null);
|
||||
}
|
||||
}
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
function scanForSyndicationFeeds() {
|
||||
// In case we don't find any, we establish that we have at least tried by setting the
|
||||
// variables to empty instead of null.
|
||||
thisPageLinkObjects = []
|
||||
|
||||
thisPageLinks = document.querySelectorAll("link[href][rel~='alternate'][type]");
|
||||
|
||||
for (thisLinkIndex = 0; thisLinkIndex < thisPageLinks.length; thisLinkIndex++)
|
||||
{
|
||||
var thisLink = thisPageLinks[thisLinkIndex];
|
||||
if (isValidFeedLink(thisLink))
|
||||
{
|
||||
thisPageLinkObjects.push(objectFromLink(thisLink));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function subscribeToFeed(theFeed) {
|
||||
// Convert the URL to a feed:// scheme because Safari
|
||||
// will refuse to load e.g. a feed that is listed merely
|
||||
// as "text/xml". We do some preflighting of the link rel
|
||||
// in the PageLoadEnd.js so we can be more confident it's a
|
||||
// good feed: URL.
|
||||
var feedURL = theFeed.href;
|
||||
if (!feedURL.startsWith('feed:'))
|
||||
{
|
||||
feedURL = 'feed:' + feedURL;
|
||||
}
|
||||
|
||||
safari.extension.dispatchMessage("subscribeToFeed", { "url": feedURL });
|
||||
function subscribeToPage() {
|
||||
safari.extension.dispatchMessage("subscribeToFeed", { "url": "feed:" + document.location.href });
|
||||
}
|
||||
|
||||
function messageHandler(event) {
|
||||
@@ -77,10 +14,9 @@ function messageHandler(event) {
|
||||
// causing multiple responses to broadcast message about toolbar
|
||||
// button being clicked. In the case of the "extra" injections,
|
||||
// the document location is null, so we can avoid doing on anything.
|
||||
if ((document.location != null) && (thisPageLinkObjects.length > 0))
|
||||
if (document.location != null)
|
||||
{
|
||||
feedToOpen = thisPageLinkObjects[0];
|
||||
subscribeToFeed(feedToOpen);
|
||||
subscribeToPage();
|
||||
}
|
||||
}
|
||||
else if (event.name === "ping")
|
||||
@@ -93,7 +29,7 @@ function messageHandler(event) {
|
||||
// succeed even if its been disabled and the page reloaded. Checking for the existence of
|
||||
// document.location seems to ensure we have enough of a handle still on the document that
|
||||
// we can do something useful with it.
|
||||
var shouldValidate = (document.location != null) && (thisPageLinkObjects.length > 0);
|
||||
var shouldValidate = (document.location != null);
|
||||
|
||||
// Pass back the same validationID we were handed so they can look up the correlated validationHandler
|
||||
safari.extension.dispatchMessage("pong", { "validationID": event.message.validationID, "shouldValidate": shouldValidate });
|
||||
@@ -105,6 +41,5 @@ document.addEventListener("DOMContentLoaded", function(event) {
|
||||
if ((window.top === window) && (typeof safari != 'undefined') && (document.location != null))
|
||||
{
|
||||
safari.self.addEventListener("message", messageHandler, false)
|
||||
scanForSyndicationFeeds();
|
||||
}
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "./NetNewsWire_version.xcconfig"
|
||||
|
||||
// High Level Settings common to both the Mac application and any extensions we bundle with it
|
||||
MARKETING_VERSION = 7.1.2b2
|
||||
MARKETING_VERSION = 7.1.3b1
|
||||
|
||||
APP_GROUP_ID = group.$(ORGANIZATION_IDENTIFIER).NetNewsWire-Evergreen$(APP_GROUP_SUFFIX)
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
CURRENT_PROJECT_VERSION = 7112
|
||||
CURRENT_PROJECT_VERSION = 7200
|
||||
Reference in new issue
Block a user