Skip to content

Commit

Permalink
Improved way to generate and use CID permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
livid committed Sep 12, 2024
1 parent 0a0b0c7 commit 9df483f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Planet/Entities/MyArticleModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ class MyArticleModel: ArticleModel, Codable {
return URL(string: "https://dweb.link/ipns/\(planet.ipns)\(urlPath)")
}
}
var permalinkURL: URL? {
if let cid = planet.lastPublishedCID, cid.hasPrefix("bafy") {
return URL(string: "https://\(cid).eth.sucks\(link)")
}
return nil
}
var socialImageURL: URL? {
if let heroImage = getHeroImage(), let baseURL = browserURL {
return baseURL.appendingPathComponent(heroImage)
Expand Down
11 changes: 6 additions & 5 deletions Planet/Views/My/MyArticleItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,16 @@ struct MyArticleItemView: View {
if let planet = article.planet, let cid = planet.lastPublishedCID, cid.hasPrefix("bafy") {
Divider()
Button {
let permalink: String = "https://\(cid).eth.sucks\(article.link)"
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(permalink, forType: .string)
if let url = article.permalinkURL {
let permalink: String = url.absoluteString
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(permalink, forType: .string)
}
} label: {
Text("Copy Permalink")
}
Button {
let permalink: String = "https://\(cid).eth.sucks\(article.link)"
if let url = URL(string: permalink) {
if let url = article.permalinkURL {
NSWorkspace.shared.open(url)
}
} label: {
Expand Down
4 changes: 2 additions & 2 deletions Planet/Views/Sidebar/MyPlanetSidebarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct MyPlanetSidebarItem: View {
PlanetStore.shared.isEditingPlanetDonationSettings = true
}
} label: {
Text("Accepts Donation")
Text("Accept Donation")
}

Button {
Expand Down Expand Up @@ -442,7 +442,7 @@ struct MyPlanetSidebarItem: View {
openiTerm(template)
} label: {
Image(systemName: "apple.terminal.fill")
Text("Open in iTerm")
Text("Open Template Folder in iTerm")
}
}

Expand Down
2 changes: 1 addition & 1 deletion Planet/versioning.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_PROJECT_VERSION = 2239
CURRENT_PROJECT_VERSION = 2240

0 comments on commit 9df483f

Please sign in to comment.