diff options
Diffstat (limited to 'pkgs/by-name/ba/back/src/web/generate/mod.rs')
-rw-r--r-- | pkgs/by-name/ba/back/src/web/generate/mod.rs | 82 |
1 files changed, 40 insertions, 42 deletions
diff --git a/pkgs/by-name/ba/back/src/web/generate/mod.rs b/pkgs/by-name/ba/back/src/web/generate/mod.rs index 10146bb..ae783a3 100644 --- a/pkgs/by-name/ba/back/src/web/generate/mod.rs +++ b/pkgs/by-name/ba/back/src/web/generate/mod.rs @@ -34,9 +34,9 @@ pub fn issues( repo_path: &Path, ) -> error::Result<String> { let repository = config - .repositories + .repositories()? .get(repo_path)? - .open(config.repositories.scan_path())?; + .open(&config.scan_path)?; let mut issue_list = issues_from_repository(&repository.to_thread_local())? .into_iter() @@ -76,9 +76,9 @@ struct IssueTemplate { } pub fn issue(config: &BackConfig, repo_path: &Path, prefix: Prefix) -> error::Result<String> { let repository = config - .repositories + .repositories()? .get(repo_path)? - .open(config.repositories.scan_path())? + .open(&config.scan_path)? .to_thread_local(); let maybe_issue = issues_from_repository(&repository)? @@ -113,39 +113,37 @@ struct RepoValue { } pub fn repos(config: &BackConfig) -> error::Result<String> { let repos: Vec<RepoValue> = config - .repositories + .repositories()? .iter() - .filter_map( - |raw_repo| match raw_repo.open(config.repositories.scan_path()) { - Ok(repo) => { - let repo = repo.to_thread_local(); - let git_config = repo.config_snapshot(); - - let path = raw_repo.path().to_string_lossy().to_string(); - - let owner = git_config - .string("cgit.owner") - .map(|v| v.to_string()) - .unwrap_or("<No owner>".to_owned()); - - let description = fs::read_to_string(repo.git_dir().join("description")) - .unwrap_or("<No description>".to_owned()); - - Some(RepoValue { - description, - owner, - path, - }) - } - Err(err) => { - info!( - "Repo '{}' could not be opened: '{err}'", - raw_repo.path().display() - ); - None - } - }, - ) + .filter_map(|raw_repo| match raw_repo.open(&config.scan_path) { + Ok(repo) => { + let repo = repo.to_thread_local(); + let git_config = repo.config_snapshot(); + + let path = raw_repo.path().to_string_lossy().to_string(); + + let owner = git_config + .string("cgit.owner") + .map(|v| v.to_string()) + .unwrap_or("<No owner>".to_owned()); + + let description = fs::read_to_string(repo.git_dir().join("description")) + .unwrap_or("<No description>".to_owned()); + + Some(RepoValue { + description, + owner, + path, + }) + } + Err(err) => { + info!( + "Repo '{}' could not be opened: '{err}'", + raw_repo.path().display() + ); + None + } + }) .collect(); Ok(ReposTemplate { @@ -160,9 +158,9 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> { use rss::{ChannelBuilder, Item, ItemBuilder}; let repository = config - .repositories + .repositories()? .get(repo_path)? - .open(config.repositories.scan_path())? + .open(&config.scan_path)? .to_thread_local(); let issues: Vec<CollapsedIssue> = issues_from_repository(&repository)? @@ -182,7 +180,7 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> { .link(format!( "/{}/{}/issue/{}", repo_path.display(), - &config.root, + &config.root_url, issue.id )) .build() @@ -207,7 +205,7 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> { .link(format!( "/{}/{}/issue/{}", repo_path.display(), - &config.root, + &config.root_url, issue.id )) .build() @@ -219,8 +217,8 @@ pub fn feed(config: &BackConfig, repo_path: &Path) -> error::Result<String> { let channel = ChannelBuilder::default() .title("Issues") - .link(config.root.to_string()) - .description(format!("The rss feed for issues on {}.", &config.root)) + .link(config.root_url.to_string()) + .description(format!("The rss feed for issues on {}.", &config.root_url)) .items(items) .build(); Ok(channel.to_string()) |