forked from DevComp/ssh-portfolio
fix: broken build when blog
feature is disabled
Also brings back the warning on blog tab when feature isn't enabled.
This commit is contained in:
parent
b6bf444fcf
commit
caf29b3511
3 changed files with 27 additions and 10 deletions
2
build.rs
2
build.rs
|
@ -4,7 +4,9 @@ use anyhow::Result;
|
|||
use ssh_key::{rand_core, Algorithm, EcdsaCurve, LineEnding, PrivateKey};
|
||||
use vergen_gix::{BuildBuilder, CargoBuilder, Emitter, GixBuilder};
|
||||
|
||||
#[cfg(feature = "blog")]
|
||||
const ATPROTO_LEXICON_DIR: &str = "src/atproto/lexicons";
|
||||
#[cfg(feature = "blog")]
|
||||
const ATPROTO_CLIENT_DIR: &str = "src/atproto";
|
||||
const SSH_KEY_ALGOS: &[(&'static str, Algorithm)] = &[
|
||||
("rsa.pem", Algorithm::Rsa { hash: None }),
|
||||
|
|
33
src/app.rs
33
src/app.rs
|
@ -96,6 +96,7 @@ impl App {
|
|||
tabs,
|
||||
content,
|
||||
cat,
|
||||
#[cfg(feature = "blog")]
|
||||
selection_list,
|
||||
})
|
||||
}
|
||||
|
@ -319,7 +320,7 @@ impl App {
|
|||
.map_err(|err| std::io::Error::other(err))?;
|
||||
|
||||
// Render the content
|
||||
let mut content_rect = Rect {
|
||||
let content_rect = Rect {
|
||||
x: chunks[1].x,
|
||||
y: chunks[1].y,
|
||||
width: chunks[0].width,
|
||||
|
@ -339,22 +340,34 @@ impl App {
|
|||
.draw(frame, frame.area())
|
||||
.map_err(|err| std::io::Error::other(err))?;
|
||||
|
||||
#[cfg(feature = "blog")]
|
||||
if tabs.current_tab() == 2 {
|
||||
// Render the post selection list if the blog tab is selected
|
||||
let mut content_rect = content_rect;
|
||||
content_rect.x += 1;
|
||||
content_rect.y += 1;
|
||||
content_rect.width -= 2;
|
||||
content_rect.height -= 2;
|
||||
|
||||
self.selection_list
|
||||
.try_lock()
|
||||
.map_err(|err| std::io::Error::other(err))?
|
||||
.draw(
|
||||
frame,
|
||||
content_rect,
|
||||
#[cfg(feature = "blog")]
|
||||
{
|
||||
// Render the post selection list if the blog tab is selected
|
||||
self.selection_list
|
||||
.try_lock()
|
||||
.map_err(|err| std::io::Error::other(err))?
|
||||
.draw(frame, content_rect)
|
||||
.map_err(|err| std::io::Error::other(err))?;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "blog"))]
|
||||
{
|
||||
// If blog feature is not enabled, render a placeholder
|
||||
content_rect.height = 1;
|
||||
let placeholder = Paragraph::new(
|
||||
"Blog feature is disabled. Enable the `blog` feature to view this tab.",
|
||||
)
|
||||
.map_err(|err| std::io::Error::other(err))?;
|
||||
.style(Style::default().fg(Color::Red).add_modifier(Modifier::BOLD));
|
||||
|
||||
frame.render_widget(placeholder, content_rect);
|
||||
}
|
||||
}
|
||||
|
||||
Ok::<_, std::io::Error>(())
|
||||
|
|
|
@ -15,11 +15,13 @@ use crate::{action::Action, config::Config, tui::Event};
|
|||
mod tabs;
|
||||
mod content;
|
||||
mod cat;
|
||||
#[cfg(feature = "blog")]
|
||||
mod selection_list;
|
||||
|
||||
pub use tabs::*;
|
||||
pub use content::*;
|
||||
pub use cat::*;
|
||||
#[cfg(feature = "blog")]
|
||||
pub use selection_list::*;
|
||||
|
||||
/// `Component` is a trait that represents a visual and interactive element of the user interface.
|
||||
|
|
Loading…
Add table
Reference in a new issue