@@ -3,6 +3,7 @@ use std::{
3
3
path:: { Path , PathBuf } ,
4
4
} ;
5
5
6
+ use rocket:: response:: Redirect ;
6
7
use std:: str:: FromStr ;
7
8
8
9
use comrak:: { format_html_with_plugins, parse_document, Arena , ComrakPlugins } ;
@@ -62,7 +63,10 @@ lazy_static! {
62
63
( "transformers/fine_tuning/" , "api/sql-extension/pgml.tune" ) ,
63
64
( "guides/predictions/overview" , "api/sql-extension/pgml.predict/" ) ,
64
65
( "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" ) ,
66
70
] )
67
71
) ;
68
72
}
@@ -857,6 +861,50 @@ pub async fn careers_apply(title: PathBuf, cluster: &Cluster) -> Result<Response
857
861
Ok ( ResponseOk ( layout. render ( page) ) )
858
862
}
859
863
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
+
860
908
#[ get( "/docs/<path..>" , rank = 5 ) ]
861
909
async fn get_docs (
862
910
path : PathBuf ,
@@ -936,6 +984,7 @@ async fn docs_landing_page(cluster: &Cluster) -> Result<ResponseOk, crate::respo
936
984
Ok ( ResponseOk ( doc_layout. render ( page) ) )
937
985
}
938
986
987
+ /// Redirect our old MkDocs paths to the new ones under `/docs`.
939
988
#[ get( "/user_guides/<path..>" , rank = 5 ) ]
940
989
async fn get_user_guides ( path : PathBuf ) -> Result < Response , crate :: responses:: NotFound > {
941
990
Ok ( Response :: redirect ( format ! ( "/docs/{}" , path. display( ) . to_string( ) ) ) )
@@ -1003,6 +1052,11 @@ pub fn routes() -> Vec<Route> {
1003
1052
search,
1004
1053
search_blog,
1005
1054
demo,
1055
+ sql_extension_redirect,
1056
+ api_redirect,
1057
+ pgcat_redirect,
1058
+ pgml_redirect,
1059
+ cloud_database_redirect
1006
1060
]
1007
1061
}
1008
1062
0 commit comments