Merge remote-tracking branch 'brentsimmons/master'

This commit is contained in:
Olof Hellman 2018-01-11 00:53:37 -08:00
commit 215a44fce7
6 changed files with 68 additions and 10 deletions

View File

@ -6,6 +6,24 @@
<description>Most recent Evergreen changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 1.0d31</title>
<description><![CDATA[
<p>Improve the promptness and reliability of user avatars appearing in the timeline.</p>
<p>Fix a bug detecting some JSON Feeds — those that use escaping on forward slashes in the text, such as http://curtclifton.net/feed.json</p>
<p>Draw a white unread indicator in the timeline when the cell is selected and emphasized.</p>
<p>Remove Error Log command from menu, since the Error Log wont be until after 1.0.</p>
<p>Use the git commit number as the build number in Info.plist. Use Curtis Herberts script: https://blog.curtisherbert.com/automated-build-numbers/</p>
<p>Add Om Maliks feed to the default list.</p>
<p>Check /index.xml when finding a feed when there are no other leads.</p>
]]></description>
<pubDate>Mon, 08 Jan 2018 13:15:00 -0800</pubDate>
<enclosure url="https://ranchero.com/downloads/Evergreen1.0d31.zip" sparkle:version="775" sparkle:shortVersionString="1.0d31" length="7224599" type="application/zip" />
<sparkle:minimumSystemVersion>10.13</sparkle:minimumSystemVersion>
</item>
<item>
<title>Version 1.0d30</title>
<description><![CDATA[

View File

@ -8,10 +8,12 @@
import Cocoa
// Unlike UndoableCommand commands, you instantiate one of each of these and reuse them.
protocol SendToCommand {
func canSendObject(_ object: Any?) -> Bool
func sendObject(_ object: Any?)
func canSendObject(_ object: Any?, selectedText: String?) -> Bool
func sendObject(_ object: Any?, selectedText: String?)
}
extension SendToCommand {

View File

@ -10,12 +10,12 @@ import Foundation
final class SendToMarsEditCommand: SendToCommand {
func canSendObject(_ object: Any?) -> Bool {
func canSendObject(_ object: Any?, selectedText: String?) -> Bool {
return false
}
func sendObject(_ object: Any?) {
func sendObject(_ object: Any?, selectedText: String?) {
}
}

View File

@ -7,6 +7,7 @@
//
import Cocoa
import Data
// Not undoable.
@ -21,16 +22,50 @@ final class SendToMicroBlogCommand: SendToCommand {
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: NSApplication.didBecomeActiveNotification, object: nil)
}
func canSendObject(_ object: Any?) -> Bool {
func canSendObject(_ object: Any?, selectedText: String?) -> Bool {
if !appExists {
guard appExists, let article = object as? Article, let _ = article.preferredLink else {
return false
}
return false
return true
}
func sendObject(_ object: Any?) {
func sendObject(_ object: Any?, selectedText: String?) {
guard canSendObject(object, selectedText: selectedText) else {
return
}
guard let article = object as? Article else {
return
}
// TODO: get text from contentHTML or contentText if no title and no selectedText.
var s = ""
if let selectedText = selectedText {
s += selectedText
if let link = article.preferredLink {
s += "\n\n\(link)"
}
}
else if let title = article.title {
s += title
if let link = article.preferredLink {
s = "[" + s + "](" + link + ")"
}
}
else if let link = article.preferredLink {
s = link
}
guard let encodedString = s.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {
return
}
guard let url = URL(string: "microblog://post?text=" + encodedString) else {
return
}
let _ = try? NSWorkspace.shared.open(url, options: [], configuration: [:])
}
@objc func appDidBecomeActive(_ note: Notification) {

View File

@ -214,7 +214,7 @@ class TimelineTableCellView: NSTableCellView {
avatarImageView.wantsLayer = true
avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
if avatarImageView.image == nil {
avatarImageView.layer?.backgroundColor = NSColor(calibratedWhite: 0.0, alpha: 0.1).cgColor
avatarImageView.layer?.backgroundColor = NSColor(calibratedWhite: 0.0, alpha: 0.05).cgColor
}
else {
avatarImageView.layer?.backgroundColor = NSColor.clear.cgColor

View File

@ -119,6 +119,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
NotificationCenter.default.addObserver(self, selector: #selector(feedIconDidBecomeAvailable(_:)), name: .FeedIconDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(avatarDidBecomeAvailable(_:)), name: .AvatarDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .ImageDidBecomeAvailable, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil)
NSUserDefaultsController.shared.addObserver(self, forKeyPath: timelineFontSizeKVOKey, options: NSKeyValueObservingOptions(rawValue: 0), context: nil)
@ -351,7 +352,9 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
@objc func imageDidBecomeAvailable(_ note: Notification) {
queueReloadAvailableCells()
if showAvatars {
queueReloadAvailableCells()
}
}
func fontSizeInDefaultsDidChange() {