@@ -3,6 +3,7 @@ use std::{
33 path:: { Path , PathBuf } ,
44} ;
55
6+ use rocket:: response:: Redirect ;
67use std:: str:: FromStr ;
78
89use comrak:: { format_html_with_plugins, parse_document, Arena , ComrakPlugins } ;
@@ -62,7 +63,10 @@ lazy_static! {
6263( "transformers/fine_tuning/" , "api/sql-extension/pgml.tune" ) ,
6364( "guides/predictions/overview" , "api/sql-extension/pgml.predict/" ) ,
6465( "machine-learning/supervised-learning/data-pre-processing" , "api/sql-extension/pgml.train/data-pre-processing" ) ,
65- ( "api/client-sdk/getting-started" , "api/client-sdk/" ) ,
66+ ( "introduction/getting-started/import-your-data/" , "introduction/import-your-data/" ) ,
67+ ( "introduction/getting-started/import-your-data/foreign-data-wrapper" , "introduction/import-your-data/foreign-data-wrappers" ) ,
68+ ( "use-cases/embeddings/generating-llm-embeddings-with-open-source-models-in-postgresml" , "open-source/pgml/guides/embeddings/in-database-generation" ) ,
69+ ( "use-cases/natural-language-processing" , "open-source/pgml/guides/natural-language-processing" ) ,
6670] )
6771) ;
6872}
@@ -857,6 +861,50 @@ pub async fn careers_apply(title: PathBuf, cluster: &Cluster) -> Result<Response
857861Ok ( ResponseOk ( layout. render ( page) ) )
858862}
859863
864+ /// Redirect api to open-source
865+ #[ get( "/docs/api/<path..>" ) ]
866+ pub async fn api_redirect ( path : PathBuf ) ->Redirect {
867+ match path. to_str ( ) . unwrap ( ) {
868+ "apis" =>Redirect :: permanent ( "/docs/open-source/korvus/" ) ,
869+ "client-sdk/search" =>{
870+ Redirect :: permanent ( "/docs/open-source/korvus/guides/document-search" )
871+ }
872+ "client-sdk/getting-started" =>Redirect :: permanent ( "/docs/open-source/korvus/" ) ,
873+ "sql-extensions/pgml.predict/" =>Redirect :: permanent ( "/docs/open-source/pgml/api/pgml.predict/" ) ,
874+ "sql-extensions/pgml.deploy" =>Redirect :: permanent ( "/docs/open-source/pgml/api/pgml.deploy" ) ,
875+ _ =>Redirect :: permanent ( "/docs/open-source/" . to_owned ( ) + path. to_str ( ) . unwrap ( ) ) ,
876+ }
877+ }
878+
879+ /// Redirect our old sql-extension path.
880+ #[ get( "/docs/open-source/sql-extension/<path..>" ) ]
881+ pub async fn sql_extension_redirect ( path : PathBuf ) ->Redirect {
882+ Redirect :: permanent ( "/docs/open-source/pgml/api/" . to_owned ( ) + path. to_str ( ) . unwrap ( ) )
883+ }
884+
885+ /// Redirect our old pgcat path.
886+ #[ get( "/docs/product/pgcat/<path..>" ) ]
887+ pub async fn pgcat_redirect ( path : PathBuf ) ->Redirect {
888+ Redirect :: permanent ( "/docs/open-source/pgcat/" . to_owned ( ) + path. to_str ( ) . unwrap ( ) )
889+ }
890+
891+ /// Redirect our old cloud-database path.
892+ #[ get( "/docs/product/cloud-database/<path..>" ) ]
893+ pub async fn cloud_database_redirect ( path : PathBuf ) ->Redirect {
894+ let path = path. to_str ( ) . unwrap ( ) ;
895+ if path. is_empty ( ) {
896+ Redirect :: permanent ( "/docs/cloud/overview" )
897+ } else {
898+ Redirect :: permanent ( "/docs/cloud/" . to_owned ( ) + path)
899+ }
900+ }
901+
902+ /// Redirect our old pgml docs.
903+ #[ get( "/docs/open-source/client-sdk/<path..>" ) ]
904+ pub async fn pgml_redirect ( path : PathBuf ) ->Redirect {
905+ Redirect :: permanent ( "/docs/open-source/korvus/api/" . to_owned ( ) + path. to_str ( ) . unwrap ( ) )
906+ }
907+
860908#[ get( "/docs/<path..>" , rank =5 ) ]
861909async fn get_docs (
862910path : PathBuf ,
@@ -936,6 +984,7 @@ async fn docs_landing_page(cluster: &Cluster) -> Result<ResponseOk, crate::respo
936984Ok ( ResponseOk ( doc_layout. render ( page) ) )
937985}
938986
987+ /// Redirect our old MkDocs paths to the new ones under `/docs`.
939988#[ get( "/user_guides/<path..>" , rank =5 ) ]
940989async fn get_user_guides ( path : PathBuf ) ->Result < Response , crate :: responses:: NotFound > {
941990Ok ( Response :: redirect ( format ! ( "/docs/{}" , path. display( ) . to_string( ) ) ) )
@@ -1003,6 +1052,11 @@ pub fn routes() -> Vec<Route> {
10031052 search,
10041053 search_blog,
10051054 demo,
1055+ sql_extension_redirect,
1056+ api_redirect,
1057+ pgcat_redirect,
1058+ pgml_redirect,
1059+ cloud_database_redirect
10061060]
10071061}
10081062