From e88423c83ebb46fb1f7e1084ccb702493906dd68 Mon Sep 17 00:00:00 2001 From: qinluhe Date: Fri, 21 Jun 2024 00:00:47 +0800 Subject: [PATCH] feat: support publish view and unpublish views --- frontend/rust-lib/flowy-document/src/manager.rs | 3 +-- frontend/rust-lib/flowy-folder-pub/src/entities.rs | 2 ++ frontend/rust-lib/flowy-folder/src/manager.rs | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/rust-lib/flowy-document/src/manager.rs b/frontend/rust-lib/flowy-document/src/manager.rs index 41a797aa3b..f281413601 100644 --- a/frontend/rust-lib/flowy-document/src/manager.rs +++ b/frontend/rust-lib/flowy-document/src/manager.rs @@ -75,8 +75,7 @@ impl DocumentManager { } } - /// In order to support the requirement of automatically publishing sub-documents in publishing requirements, - /// we need to read binary data from disk instead of reading from the open document. + /// Get the encoded collab of the document. pub async fn encode_collab(&self, doc_id: &str) -> FlowyResult { let doc_state = DataSource::Disk; let uid = self.user_service.user_id()?; diff --git a/frontend/rust-lib/flowy-folder-pub/src/entities.rs b/frontend/rust-lib/flowy-folder-pub/src/entities.rs index 393f1d7afb..e67a780fba 100644 --- a/frontend/rust-lib/flowy-folder-pub/src/entities.rs +++ b/frontend/rust-lib/flowy-folder-pub/src/entities.rs @@ -73,12 +73,14 @@ pub struct PublishViewMeta { #[derive(Clone, Debug, Eq, PartialEq)] pub struct PublishViewPayload { pub meta: PublishViewMeta, + /// The doc_state of the encoded collab. pub data: Vec, } #[derive(Clone, Debug, Eq, PartialEq)] pub struct PublishInfoResponse { pub view_id: String, + /// one part of publish url: /{namespace}/{publish_name} pub publish_name: String, pub namespace: Option, } diff --git a/frontend/rust-lib/flowy-folder/src/manager.rs b/frontend/rust-lib/flowy-folder/src/manager.rs index 1e158dbad5..ce5da67474 100644 --- a/frontend/rust-lib/flowy-folder/src/manager.rs +++ b/frontend/rust-lib/flowy-folder/src/manager.rs @@ -941,8 +941,8 @@ impl FolderManager { Ok(()) } - /// The view will be published to the web with the specified view id. - /// The [publish_name] is the [view name] + [view id] when currently published + /// Publish the view with the given view id. + /// [publish_name] is one part of the URL of the published view. if it is None, the default publish name will be used. The default publish name is generated by the view id and view name. #[tracing::instrument(level = "debug", skip(self), err)] pub async fn publish_view(&self, view_id: &str, publish_name: Option) -> FlowyResult<()> { let view = self @@ -971,6 +971,7 @@ impl FolderManager { Ok(()) } + /// Unpublish the view with the given view id. #[tracing::instrument(level = "debug", skip(self), err)] pub async fn unpublish_views(&self, view_ids: Vec) -> FlowyResult<()> { let workspace_id = self.user.workspace_id()?; @@ -981,12 +982,16 @@ impl FolderManager { Ok(()) } + /// Get the publish info of the view with the given view id. + /// The publish info contains the namespace and publish_name of the view. #[tracing::instrument(level = "debug", skip(self), err)] pub async fn get_publish_info(&self, view_id: &str) -> FlowyResult { let publish_info = self.cloud_service.get_publish_info(view_id).await?; Ok(publish_info) } + /// Get the namespace of the current workspace. + /// The namespace is used to generate the URL of the published view. #[tracing::instrument(level = "debug", skip(self), err)] pub async fn set_publish_namespace(&self, namespace: String) -> FlowyResult<()> { let workspace_id = self.user.workspace_id()?; @@ -997,6 +1002,7 @@ impl FolderManager { Ok(()) } + /// Get the namespace of the current workspace. #[tracing::instrument(level = "debug", skip(self), err)] pub async fn get_publish_namespace(&self) -> FlowyResult { let workspace_id = self.user.workspace_id()?;