Skip to content

Commit db832d8

Browse files
committed
Set zallery theme if importing IG.
1 parent 29b7d86 commit db832d8

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/main.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

src/site.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use tide::log;
1414
use walkdir::WalkDir;
1515

1616
const DEFAULT_THEME: &str = "hyde";
17+
pub const DEFAULT_THEME_PHOTOBLOG: &str = "zallery";
1718

1819
use crate::{
1920
content, nostr,
@@ -567,7 +568,7 @@ pub fn load_site(
567568

568569
if let Some(theme) = themes.get(&config.theme) {
569570
let extra_config: HashMap<String, toml::Value> = toml::from_str(&theme.extra_config)?;
570-
config = config.with_extra(extra_config, false);
571+
config = config.with_extra(extra_config, true);
571572
}
572573

573574
let mut site = Site {

0 commit comments

Comments
 (0)