@@ -1141,7 +1141,7 @@ fn download_themes(root_path: &str, url: &str) -> Result<()> {
11411141 Ok ( ( ) )
11421142}
11431143
1144- fn try_import_ig ( root_path : & str , site : & Site , secret_key : & Option < String > ) -> Result < ( ) > {
1144+ fn try_import_ig ( root_path : & str , site : & Site , secret_key : & Option < String > ) -> Result < bool > {
11451145 loop {
11461146 let mut response = String :: new ( ) ;
11471147 while response != "n" && response != "y" {
@@ -1151,7 +1151,7 @@ fn try_import_ig(root_path: &str, site: &Site, secret_key: &Option<String>) -> R
11511151 }
11521152
11531153 if response == "n" {
1154- return Ok ( ( ) ) ;
1154+ return Ok ( false ) ;
11551155 } else {
11561156 let Some ( secret_key) = secret_key else {
11571157 println ! ( "Start servus with --sign-content and pass a secret key that will be used to sign the events if you want to import your Instagram content!" ) ;
@@ -1190,7 +1190,7 @@ fn try_import_ig(root_path: &str, site: &Site, secret_key: &Option<String>) -> R
11901190 site. add_content ( root_path, & bare_event. sign ( & secret_key) ) ?;
11911191 println ! ( "Saved post from {}" , ig_post. date) ;
11921192 }
1193- return Ok ( ( ) ) ;
1193+ return Ok ( true ) ;
11941194 }
11951195 Err ( e) => {
11961196 println ! ( "{}" , e) ;
@@ -1200,7 +1200,7 @@ fn try_import_ig(root_path: &str, site: &Site, secret_key: &Option<String>) -> R
12001200 }
12011201}
12021202
1203- fn try_import_twitter ( root_path : & str , site : & Site , secret_key : & Option < String > ) -> Result < ( ) > {
1203+ fn try_import_twitter ( root_path : & str , site : & Site , secret_key : & Option < String > ) -> Result < bool > {
12041204 loop {
12051205 let mut response = String :: new ( ) ;
12061206 while response != "n" && response != "y" {
@@ -1210,7 +1210,7 @@ fn try_import_twitter(root_path: &str, site: &Site, secret_key: &Option<String>)
12101210 }
12111211
12121212 if response == "n" {
1213- return Ok ( ( ) ) ;
1213+ return Ok ( false ) ;
12141214 } else {
12151215 let Some ( secret_key) = secret_key else {
12161216 println ! ( "Start servus with --sign-content and pass a secret key that will be used to sign the events if you want to import your Twitter content!" ) ;
@@ -1230,7 +1230,7 @@ fn try_import_twitter(root_path: &str, site: &Site, secret_key: &Option<String>)
12301230 site. add_content ( root_path, & bare_event. sign ( & secret_key) ) ?;
12311231 println ! ( "Saved post from {}" , tweet. created_at) ;
12321232 }
1233- return Ok ( ( ) ) ;
1233+ return Ok ( true ) ;
12341234 }
12351235 Err ( e) => {
12361236 println ! ( "{}" , e) ;
@@ -1263,10 +1263,16 @@ fn load_or_create_sites(
12631263 print ! ( "Admin pubkey: " ) ;
12641264 io:: stdout ( ) . flush ( ) ?;
12651265 let admin_pubkey = stdin. lock ( ) . lines ( ) . next ( ) . unwrap ( ) ?. to_lowercase ( ) ;
1266- let site = site:: create_site ( root_path, & domain, Some ( admin_pubkey) , themes, None ) ?;
1266+ let mut site = site:: create_site ( root_path, & domain, Some ( admin_pubkey) , themes, None ) ?;
1267+ let config_path = format ! ( "{}/sites/{}/_config.toml" , root_path, & domain) ;
12671268
1268- try_import_ig ( root_path, & site, secret_key) ?;
1269- try_import_twitter ( root_path, & site, secret_key) ?;
1269+ if try_import_ig ( root_path, & site, secret_key) ? {
1270+ site. config . theme = site:: DEFAULT_THEME_PHOTOBLOG . to_string ( ) ;
1271+ site:: save_config ( & config_path, & site. config ) ?;
1272+ site = site:: load_site ( root_path, & domain, themes, & None ) ?;
1273+ } else {
1274+ try_import_twitter ( root_path, & site, secret_key) ?;
1275+ }
12701276
12711277 Ok ( [ ( domain, site) ] . iter ( ) . cloned ( ) . collect ( ) )
12721278 } else {
0 commit comments