diff --git a/AppleScript/Excel-CreateFeedStatisticsSpreadsheet.applescript b/AppleScript/Excel-CreateFeedStatisticsSpreadsheet.applescript new file mode 100644 index 000000000..b3fe5533a --- /dev/null +++ b/AppleScript/Excel-CreateFeedStatisticsSpreadsheet.applescript @@ -0,0 +1,49 @@ +-- This script creates an Excel spreadsheet with statistics about all the feeds in your NetNewsWire + +-- the exportToExcel() function creats a single line of data in a spreadsheet + +to exportToExcel(docname, rowIndex, feedname, numArticles, numStars, numRead) + tell application "Microsoft Excel" + tell worksheet 1 of document docname + set value of cell 1 of row rowIndex to feedname + set value of cell 2 of row rowIndex to numArticles + set value of cell 3 of row rowIndex to numStars + set value of cell 4 of row rowIndex to numRead + end tell + end tell +end exportToExcel + + +-- the script starts here +-- First, we make a new Excel spreadsheet and fill in the column headers + +tell application "Microsoft Excel" + set newdoc to make new document + tell worksheet 1 of newdoc + set value of cell 1 of row 1 to "Name of Feed" + set value of cell 2 of row 1 to "Articles" + set value of cell 3 of row 1 to "Read" + set value of cell 4 of row 1 to "Stars" + end tell + set docname to name of newdoc +end tell + +-- Then we loop though all the feeds of all the accounts +-- for each feed, we calculate how many articles there are, how many are read, and how many are starred +-- then, we send off the information to Excel + +set totalFeeds to 0 +tell application "NetNewsWire" + set allAccounts to every account + repeat with nthAccount in allAccounts + set allFeeds to every feed of nthAccount + repeat with nthFeed in allFeeds + set feedname to name of nthFeed + set articleCount to count (get every article of nthFeed) + set readCount to count (get every article of nthFeed where read is true) + set starCount to count (get every article of nthFeed where starred is true) + set totalFeeds to totalFeeds + 1 + my exportToExcel(docname, totalFeeds + 1, feedname, articleCount, readCount, starCount) + end repeat + end repeat +end tell diff --git a/AppleScript/OmniFocus-AddToNNWReadingList.applescript b/AppleScript/OmniFocus-AddToNNWReadingList.applescript new file mode 100644 index 000000000..310047578 --- /dev/null +++ b/AppleScript/OmniFocus-AddToNNWReadingList.applescript @@ -0,0 +1,42 @@ +-- This script presumes that you are an OmniFocus user, +-- and that you'd like to have a project in OmniFocus for a reading list of articles from NetNewsWire. +-- Running this script creates a new task in an OmniFocus project called "NetNewsWire reading list" +-- with information about the current article. + +-- Ideally, the name of the task will be the name of the article, but some articles don't have names +-- so if there is not name for the article, just use a default string "A NetNewsWireArticle without a title" +to getTitleOrSomething() + tell application "NetNewsWire" + set myTitle to the title of the current article + if (myTitle is "") then + set myTitle to "A NetNewsWireArticle without a title" + end if + end tell +end getTitleOrSomething + + +-- Here's where the script starts + +-- first get the url and the title of the current article +tell application "NetNewsWire" + set myUrl to the url of the current article + set myTitle to my getTitleOrSomething() +end tell + +tell application "OmniFocus" + tell document 1 + + -- Second, ensure that the front OmniFocus document has a project called "NetNewsWire reading list" + set names to name of every project + if names does not contain "NetNewsWire reading list" then + make new project with properties {name:"NetNewsWire reading list"} + end if + + -- lastly, add a task in that project referring to the current article + -- the "Note" field of the task will contain the url for the article + tell project "NetNewsWire reading list" + make new task with properties {name:myTitle, note:myUrl} + end tell + + end tell +end tell \ No newline at end of file diff --git a/AppleScript/README.md b/AppleScript/README.md new file mode 100644 index 000000000..1b2dcbfe5 --- /dev/null +++ b/AppleScript/README.md @@ -0,0 +1,2 @@ +Sample AppleScript scripts go in this folder. + diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 20347183b..cf29c7700 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -401,7 +401,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, return feed } - public func removeFeed(_ feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { + public func removeFeed(_ feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { delegate.removeFeed(for: self, with: feed, from: container, completion: completion) } diff --git a/Frameworks/Account/AccountDelegate.swift b/Frameworks/Account/AccountDelegate.swift index 6c9cef9e2..3764186a0 100644 --- a/Frameworks/Account/AccountDelegate.swift +++ b/Frameworks/Account/AccountDelegate.swift @@ -36,7 +36,7 @@ protocol AccountDelegate { func createFeed(for account: Account, url: String, name: String?, container: Container, completion: @escaping (Result) -> Void) func renameFeed(for account: Account, with feed: Feed, to name: String, completion: @escaping (Result) -> Void) func addFeed(for account: Account, with: Feed, to container: Container, completion: @escaping (Result) -> Void) - func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) + func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result) -> Void) func moveFeed(for account: Account, with feed: Feed, from: Container, to: Container, completion: @escaping (Result) -> Void) func restoreFeed(for account: Account, feed: Feed, container: Container, completion: @escaping (Result) -> Void) diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift index 8d28bc646..4286c04ed 100644 --- a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -392,7 +392,7 @@ final class FeedbinAccountDelegate: AccountDelegate { } - func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { + func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { if feed.folderRelationship?.count ?? 0 > 1 { deleteTagging(for: account, with: feed, from: container, completion: completion) } else { diff --git a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift index f54c12ad7..30d69a5d8 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountDelegate.swift @@ -139,8 +139,8 @@ final class LocalAccountDelegate: AccountDelegate { completion(.success(())) } - func removeFeed(for account: Account, with feed: Feed, from container: Container?, completion: @escaping (Result) -> Void) { - container?.removeFeed(feed) + func removeFeed(for account: Account, with feed: Feed, from container: Container, completion: @escaping (Result) -> Void) { + container.removeFeed(feed) completion(.success(())) } diff --git a/Mac/Resources/Credits.rtf b/Mac/Resources/Credits.rtf index 9f75bfd28..164db859e 100644 --- a/Mac/Resources/Credits.rtf +++ b/Mac/Resources/Credits.rtf @@ -1,4 +1,4 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf200 +{\rtf1\ansi\ansicpg1252\cocoartf1671\cocoasubrtf500 {\fonttbl\f0\fnil\fcharset0 LucidaGrande-Bold;\f1\fnil\fcharset0 LucidaGrande;} {\colortbl;\red255\green255\blue255;\red0\green0\blue0;} {\*\expandedcolortbl;;\cssrgb\c0\c0\c0\cname textColor;} @@ -32,7 +32,7 @@ Major code contributors: {\field{\*\fldinst{HYPERLINK "https://github.com/olofhe \f0\b \cf2 Thanks:\ \pard\pardeftab720\li360\sa60\partightenfactor0 -\f1\b0 \cf2 Thanks to Sheila and my family; thanks to my friends in Seattle and around the globe; thanks to my co-workers and friends at {\field{\*\fldinst{HYPERLINK "https://www.omnigroup.com/"}}{\fldrslt The Omni Group}}; thanks to the ever-patient and ever-awesome NetNewsWire beta testers.\ +\f1\b0 \cf2 Thanks to Sheila and my family; thanks to my friends in Seattle and around the globe; thanks to my co-workers and friends at {\field{\*\fldinst{HYPERLINK "https://www.omnigroup.com/"}}{\fldrslt The Omni Group}}; thanks to the ever-patient and ever-awesome NetNewsWire beta testers. Thanks to {\field{\*\fldinst{HYPERLINK "https://github.com/"}}{\fldrslt GitHub}}, {\field{\*\fldinst{HYPERLINK "https://slack.com/"}}{\fldrslt Slack}}, and {\field{\*\fldinst{HYPERLINK "https://circleci.com/"}}{\fldrslt CircleCI}} for making open source collaboration easy and fun.\ \ \pard\pardeftab720\sa60\partightenfactor0 diff --git a/Mac/Scriptability/Account+Scriptability.swift b/Mac/Scriptability/Account+Scriptability.swift index 80637f6be..a89e59522 100644 --- a/Mac/Scriptability/Account+Scriptability.swift +++ b/Mac/Scriptability/Account+Scriptability.swift @@ -58,8 +58,10 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta var container: Container? = nil if let scriptableFolder = scriptableFeed.container as? ScriptableFolder { container = scriptableFolder.folder + } else { + container = account } - account.removeFeed(scriptableFeed.feed, from: container) { result in + account.removeFeed(scriptableFeed.feed, from: container!) { result in } } } diff --git a/Shared/Commands/DeleteCommand.swift b/Shared/Commands/DeleteCommand.swift index cb7f6f3cc..972ffcc8c 100644 --- a/Shared/Commands/DeleteCommand.swift +++ b/Shared/Commands/DeleteCommand.swift @@ -153,19 +153,28 @@ private struct SidebarItemSpecifier { func delete(completion: @escaping () -> Void) { if let feed = feed { + + guard let container = path.resolveContainer() else { + completion() + return + } + BatchUpdate.shared.start() - account?.removeFeed(feed, from: path.resolveContainer()) { result in + account?.removeFeed(feed, from: container) { result in BatchUpdate.shared.end() completion() self.checkResult(result) } + } else if let folder = folder { + BatchUpdate.shared.start() account?.removeFolder(folder) { result in BatchUpdate.shared.end() completion() self.checkResult(result) } + } }