Skip to content

Commit

Permalink
feat: Open links on the Internet Archive from the context menu (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbmorley authored Jun 15, 2021
1 parent 09b1893 commit c15ca3b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/BookmarksCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
D84CE488261E2B7D00AF1901 /* Pinboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = D84CE487261E2B7D00AF1901 /* Pinboard.swift */; };
D8569FCC261E2603006926BF /* BookmarksCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8569FC2261E2603006926BF /* BookmarksCore.framework */; };
D8569FD3261E2603006926BF /* BookmarksCore.h in Headers */ = {isa = PBXBuildFile; fileRef = D8569FC5261E2603006926BF /* BookmarksCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
D8717C4E2679153F007617C5 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8717C4D2679153F007617C5 /* URL.swift */; };
D8717C4F2679153F007617C5 /* URL.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8717C4D2679153F007617C5 /* URL.swift */; };
D8AA4055261E2E8D00D11421 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AA4054261E2E8D00D11421 /* String.swift */; };
D8AA4061261E305200D11421 /* NSCoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AA4060261E305200D11421 /* NSCoder.swift */; };
D8B04B1E261EC65D00376ADD /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8B04B1D261EC65C00376ADD /* Settings.swift */; };
Expand Down Expand Up @@ -100,6 +102,7 @@
D8569FC6261E2603006926BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D8569FCB261E2603006926BF /* BookmarksCore iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "BookmarksCore iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
D8569FD2261E2603006926BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D8717C4D2679153F007617C5 /* URL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URL.swift; sourceTree = "<group>"; };
D8AA4054261E2E8D00D11421 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
D8AA4060261E305200D11421 /* NSCoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSCoder.swift; sourceTree = "<group>"; };
D8B04B1D261EC65C00376ADD /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -240,6 +243,7 @@
D8AA4060261E305200D11421 /* NSCoder.swift */,
D8AA4054261E2E8D00D11421 /* String.swift */,
D8D3F5B4261E5AF300B2D66F /* UIImage.swift */,
D8717C4D2679153F007617C5 /* URL.swift */,
D8D3F601261E5BF600B2D66F /* URLComponents.swift */,
D8D3F610261E5C0C00B2D66F /* View.swift */,
);
Expand Down Expand Up @@ -519,6 +523,7 @@
D8D3F59F261E5AAE00B2D66F /* WebViewDownloader.swift in Sources */,
D8B04B1F261EC65D00376ADD /* Settings.swift in Sources */,
D84CE484261E2AD000AF1901 /* Post.swift in Sources */,
D8717C4E2679153F007617C5 /* URL.swift in Sources */,
D8B04B31261EC7E700376ADD /* BookmarksManager.swift in Sources */,
D8D3F602261E5BF600B2D66F /* URLComponents.swift in Sources */,
D8AA4055261E2E8D00D11421 /* String.swift in Sources */,
Expand Down Expand Up @@ -560,6 +565,7 @@
D8D3F59E261E5AAE00B2D66F /* WebViewDownloader.swift in Sources */,
D8B04B1E261EC65D00376ADD /* Settings.swift in Sources */,
D8CF8CA1261E35B300E52E85 /* Pinboard.swift in Sources */,
D8717C4F2679153F007617C5 /* URL.swift in Sources */,
D8B04B32261EC7E700376ADD /* BookmarksManager.swift in Sources */,
D8D3F603261E5BF600B2D66F /* URLComponents.swift in Sources */,
D8CF8CB0261E35BB00E52E85 /* String.swift in Sources */,
Expand Down
29 changes: 29 additions & 0 deletions core/BookmarksCore/Extensions/URL.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2020-2021 InSeven Limited
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import Foundation

public extension URL {

var internetArchiveUrl: URL {
URL(string: "https://web.archive.org/web/*/")!.appendingPathComponent(self.absoluteString)
}

}
4 changes: 4 additions & 0 deletions macos/Bookmarks/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ struct ContentView: View {
NSWorkspace.shared.open(item.url)
}
Divider()
Button("View on Internet Archive") {
NSWorkspace.shared.open(item.url.internetArchiveUrl)
}
Divider()
Button("Share") {
print("Share")
print(item.identifier)
Expand Down

0 comments on commit c15ca3b

Please sign in to comment.