Skip to content

Commit

Permalink
Merge branch 'main' into hashtags
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuatbrown authored Dec 9, 2024
2 parents 52d4056 + 3a8536b commit 774ba36
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Release Notes
- Fixed display of mastodon usernames so it shows @username@server.instance rather than [email protected]
- Nos now publishes the hashtags it finds in your note when you post. This means it works the way you’ve always expected it to work. [#44](https://github.com/verse-pbc/issues/issues/44)

### Internal Changes

## [1.0.3] - 2024-12-04Z

### Release Notes
Expand Down
2 changes: 1 addition & 1 deletion Nos/Models/CoreData/Author+CoreDataClass.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import Logger
}

var hasMostrNIP05: Bool {
nip05?.hasSuffix("@mostr.pub") == true
nip05?.hasSuffix(".mostr.pub") == true
}

var nip05Parts: (username: String, domain: String)? {
Expand Down
26 changes: 21 additions & 5 deletions Nos/Views/Components/Author/NIP05View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,33 @@ struct NIP05View: View {

/// A view that displays the given parts of the NIP-05 in different colors.
func nip05Text(parts: (username: String, domain: String)) -> some View {
if parts.username == "_" {
Text(parts.domain)
.foregroundStyle(Color.primaryTxt)
if parts.domain.hasSuffix(".mostr.pub") {
// Extract the first part of the domain (before .mostr.pub)
let domainPrefix = parts.domain.replacingOccurrences(
of: ".mostr.pub",
with: ""
)
// Replace hyphens with dots
let formattedDomain = domainPrefix.replacingOccurrences(
of: "-",
with: "."
)

return Text("@" + parts.username)
.foregroundStyle(Color.primaryTxt) +
Text("@" + formattedDomain)
.foregroundStyle(Color.secondaryTxt)
} else if parts.username == "_" {
return Text(parts.domain)
.foregroundStyle(Color.secondaryTxt)
} else {
Text(parts.username)
return Text(parts.username)
.foregroundStyle(Color.primaryTxt) +
Text("@" + parts.domain)
.foregroundStyle(Color.secondaryTxt)
}
}

/// A view that displays the given `nip05` as text with strikethrough.
/// Useful for when a user's NIP-05 is invalid, such as when they enter a raw domain like "example.com"
/// for their NIP-05 identifier.
Expand Down
4 changes: 2 additions & 2 deletions Nos/Views/Components/NosNavigationStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ struct NosNavigationStack<Content: View>: View {
ProfileView(author: author)
}
case .url(let url):
URLView(url: url)
URLView(url: url)
case .replyTo(let eventID):
EventObservationView(eventID: eventID) { event in
NoteView(note: event, showKeyboard: true)
}
}
})
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Nos/Views/Profile/ActivityPubBadgeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct ActivityPubBadgeView: View {
@ObservedObject var author: Author

var fediverseServer: String {
let regex = /[0-9A-Za-z._-]+_at_(?<fediverse>[0-9A-Za-z._-]+)@mostr\.pub/
let regex = /[0-9A-Za-z._-]+@(?<fediverse>[0-9A-Za-z._-]+)\.mostr\.pub/
guard let match = author.nip05?.firstMatch(of: regex) else {
return "mostr.pub"
}
Expand Down

0 comments on commit 774ba36

Please sign in to comment.