mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
feat(core): tags and types are names, one type per page implying a tag
Tags no longer have pages. A page has at most one type, which implies a tag of the same name. Tags are stored sorted. Adds rename_tag and remove_tag. Schema v6 turns tag pages into notes and trims types to the first one. History exports synapse-type:: and reads the old forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
39e7e43071
commit
e2ed9054c6
11 files changed
+373
-328
No files matched your search
@@ -17,12 +17,12 @@ pub fn new_id() -> Uuid {
|
||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum PageKind {
|
||||
/// Also what the retired `tag` kind of schema v5 reads as (tags no longer have pages).
|
||||
#[default]
|
||||
#[serde(alias = "tag")]
|
||||
Note,
|
||||
Hub,
|
||||
Template,
|
||||
/// A topic page: notes point at it from their `tags`.
|
||||
Tag,
|
||||
}
|
||||
|
||||
impl PageKind {
|
||||
@@ -31,7 +31,6 @@ impl PageKind {
|
||||
PageKind::Note => "note",
|
||||
PageKind::Hub => "hub",
|
||||
PageKind::Template => "template",
|
||||
PageKind::Tag => "tag",
|
||||
}
|
||||
}
|
||||
/// Unknown values read as notes.
|
||||
@@ -39,7 +38,6 @@ impl PageKind {
|
||||
match s {
|
||||
"hub" => PageKind::Hub,
|
||||
"template" => PageKind::Template,
|
||||
"tag" => PageKind::Tag,
|
||||
_ => PageKind::Note,
|
||||
}
|
||||
}
|
||||
@@ -66,11 +64,13 @@ pub struct Page {
|
||||
/// pages no longer hubs); readers ignore those.
|
||||
#[serde(default)]
|
||||
pub hubs: Vec<PageId>,
|
||||
/// Titles of the tag pages ([`PageKind::Tag`]) this page is filed under, any number; see
|
||||
/// `tags`. Always in step with the tag pages (created on first use).
|
||||
/// Tag names this page is filed under, any number (names only: tags have no pages); see
|
||||
/// `tags`. Its types count as tags too without being listed here.
|
||||
#[serde(default)]
|
||||
pub tags: Vec<String>,
|
||||
/// What kind of thing this is ("persona", "lugar"...): plain names, not pages; see `types`.
|
||||
/// What kind of thing this is ("persona", "lugar"...): a name, not a page; see `types`.
|
||||
/// Holds zero or one entry (a list only for compatibility with older replicas: readers
|
||||
/// use the first, see [`Page::page_type`]). The type implies a tag of the same name.
|
||||
#[serde(default)]
|
||||
pub types: Vec<String>,
|
||||
}
|
||||
@@ -79,15 +79,16 @@ impl Page {
|
||||
pub fn is_journal(&self) -> bool {
|
||||
self.journal_date.is_some()
|
||||
}
|
||||
/// The page's single type, if any.
|
||||
pub fn page_type(&self) -> Option<&str> {
|
||||
self.types.first().map(String::as_str)
|
||||
}
|
||||
pub fn is_hub(&self) -> bool {
|
||||
self.kind == PageKind::Hub
|
||||
}
|
||||
pub fn is_template(&self) -> bool {
|
||||
self.kind == PageKind::Template
|
||||
}
|
||||
pub fn is_tag(&self) -> bool {
|
||||
self.kind == PageKind::Tag
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
|
||||
Reference in new issue
Block a user