making presentations use reveal_js.rs for getting slide_count
This commit is contained in:
parent
da361a55a7
commit
7dfb4caeaf
2 changed files with 20 additions and 11 deletions
|
@ -8,6 +8,7 @@ mod presentation_model {
|
||||||
use diesel::{delete, insert_into, prelude::*, update};
|
use diesel::{delete, insert_into, prelude::*, update};
|
||||||
// use sqlx::Connection;
|
// use sqlx::Connection;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!(< QAbstractListModel >);
|
include!(< QAbstractListModel >);
|
||||||
|
@ -191,9 +192,9 @@ mod presentation_model {
|
||||||
let presentation_id = self.rust().highest_id + 1;
|
let presentation_id = self.rust().highest_id + 1;
|
||||||
let presentation_title = QString::from(name);
|
let presentation_title = QString::from(name);
|
||||||
let presentation_path = url.to_qstring();
|
let presentation_path = url.to_qstring();
|
||||||
println!("{:?}", file_path.extension().unwrap());
|
let presentation_html =
|
||||||
let presentation_html = file_path.extension().unwrap()
|
file_path.extension().unwrap() == "html";
|
||||||
== std::ffi::OsStr::new(".html");
|
debug!(html = presentation_html, ?file_path, extension = ?file_path.extension());
|
||||||
|
|
||||||
if self.as_mut().add_item(
|
if self.as_mut().add_item(
|
||||||
presentation_id,
|
presentation_id,
|
||||||
|
@ -222,13 +223,18 @@ mod presentation_model {
|
||||||
// println!("{:?}", db);
|
// println!("{:?}", db);
|
||||||
let mut actual_page_count = new_page_count;
|
let mut actual_page_count = new_page_count;
|
||||||
if presentation_html {
|
if presentation_html {
|
||||||
let actual_path =
|
let actual_path = PathBuf::from(
|
||||||
presentation_path.clone().to_string();
|
presentation_path.clone().to_string(),
|
||||||
|
);
|
||||||
actual_page_count =
|
actual_page_count =
|
||||||
reveal_js::count_slides_and_fragments(
|
reveal_js::count_slides_and_fragments(
|
||||||
actual_path.trim(),
|
&actual_path,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
debug!(
|
||||||
|
page_count = actual_page_count,
|
||||||
|
html = presentation_html
|
||||||
|
);
|
||||||
|
|
||||||
let presentation = self::Presentation {
|
let presentation = self::Presentation {
|
||||||
id: presentation_id,
|
id: presentation_id,
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// use dirs;
|
// use dirs;
|
||||||
use std::fs::read_to_string;
|
use std::{fs::read_to_string, path::Path};
|
||||||
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
|
||||||
pub fn count_slides_and_fragments(html_file_path: &str) -> i32 {
|
pub fn count_slides_and_fragments(html_file_path: Path) -> i32 {
|
||||||
|
debug!("Starting slide counter");
|
||||||
// Read the HTML file
|
// Read the HTML file
|
||||||
let html_content = read_to_string(html_file_path)
|
let html_content = read_to_string(html_file_path)
|
||||||
.expect("Failed to read HTML file");
|
.expect("Failed to read HTML file");
|
||||||
|
@ -21,9 +23,10 @@ pub fn count_slides_and_fragments(html_file_path: &str) -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
let total = num_slides + num_fragments;
|
let total = num_slides + num_fragments;
|
||||||
println!(
|
debug!(
|
||||||
"SLIDE_NUMBERS: slides: {:?}, fragments: {:?}, total: {:?}",
|
slides = num_slides,
|
||||||
num_slides, num_fragments, total
|
fragments = num_fragments,
|
||||||
|
total = total
|
||||||
);
|
);
|
||||||
|
|
||||||
total as i32
|
total as i32
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue