Pandoc Umwandlung zu MediaWiki
This commit is contained in:
		
							parent
							
								
									19be226f11
								
							
						
					
					
						commit
						8526fa4fca
					
				
					 2 changed files with 29 additions and 6 deletions
				
			
		
							
								
								
									
										3
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -2,4 +2,5 @@ | |||
| /.idea | ||||
| plenum_config.sqlite | ||||
| .direnv | ||||
| shell.nix | ||||
| shell.nix | ||||
| pandoc-output.txt | ||||
							
								
								
									
										32
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										32
									
								
								src/main.rs
									
										
									
									
									
								
							|  | @ -33,7 +33,12 @@ use uuid::Uuid; | |||
| use reqwest::Client; | ||||
| use std::error::Error; | ||||
| // use std::future::Future;
 | ||||
| 
 | ||||
| // For MediaWiki-conversion
 | ||||
| use pandoc; | ||||
| use std::io; | ||||
| use std::io::prelude::*; | ||||
| use std::fs::File; | ||||
| 
 | ||||
| // use std::process::Command;
 | ||||
| // use headers::ContentType;
 | ||||
|  | @ -42,6 +47,7 @@ use pandoc; | |||
| use lettre::{Message, SmtpTransport, Transport}; | ||||
| use lettre::message::{header, SinglePart}; | ||||
| use lettre::transport::smtp::authentication::Credentials; | ||||
| use pandoc::{MarkdownExtension, Pandoc, PandocError, PandocOutput}; | ||||
| // MAIL END
 | ||||
| 
 | ||||
| #[derive(PartialEq)] | ||||
|  | @ -130,7 +136,7 @@ async fn main() -> Result<(), Box<dyn Error>> { | |||
|     // let in_3_days_is_plenum = true;
 | ||||
| 
 | ||||
|     let top_anzahl: i32 = 0; // Muss noch gecodet werden
 | ||||
|     let in_1_day_is_plenum = true; | ||||
|     let yesterday_was_plenum = true; // Das ist nur zu Testzwecken, kommt noch weg
 | ||||
|     if in_1_day_is_plenum { | ||||
|         println!("In 1 Tag ist Plenum, deshalb wird eine Erinnerung raus geschickt!"); | ||||
|         let pad_content = download_and_return_pad(format!("{}/download", current_pad_link.clone())).await.expect("Fehler beim Download des Pads!"); | ||||
|  | @ -171,7 +177,7 @@ async fn main() -> Result<(), Box<dyn Error>> { | |||
|     } else if yesterday_was_plenum { | ||||
|         // This logic breaks on 02/2034, but on every other month it works
 | ||||
|         let old_pad_content = download_and_return_pad(format!("{}/download", current_pad_link.clone())).await.expect("Fehler beim Download des Pads!"); | ||||
|         generate_new_pad_for_following_date(übernächster_plenumtermin, überübernächster_plenumtermin, &config).await.expect("Fehler! Plenumspad konnte nicht generiert werden!"); | ||||
|         // MUSS WIEDER REIN NACH DEM TESTEN: generate_new_pad_for_following_date(übernächster_plenumtermin, überübernächster_plenumtermin, &config).await.expect("Fehler! Plenumspad konnte nicht generiert werden!");
 | ||||
|         println!("DATENBANK: aktuelles-plenumspad: {:?} und zukünftiges plenumspad: {:?}", &config.get("aktuelles-plenumspad"), &config.get("zukünftiges-plenumspad")); | ||||
| 
 | ||||
|         let old_pad_content_without_top_instructions = try_to_remove_top_instructions(old_pad_content); | ||||
|  | @ -343,7 +349,23 @@ fn try_to_remove_top_instructions (pad_content: String) -> String { | |||
| 
 | ||||
| fn pad_ins_wiki(old_pad_content: String) { | ||||
|     //Convert Markdown into Mediawiki
 | ||||
| 
 | ||||
|     let pandoc_parsed = old_pad_content; // MUSS GEÄNDERT WERDEN
 | ||||
| 
 | ||||
|     // Vanilla pandoc Befehl: pandoc --from markdown --to mediawiki --no-highlight
 | ||||
|     let mut p = pandoc::new(); | ||||
|     p.set_input(pandoc::InputKind::Pipe(old_pad_content)); | ||||
|     p.set_input_format(pandoc::InputFormat::Markdown, vec![]); | ||||
|     // p.set_output_format(Pandoc::OutputFormat::mediawiki, vec![MarkdownExtension::Smart]);
 | ||||
|     p.set_output(pandoc::OutputKind::File("./pandoc-output.txt".parse().unwrap())); | ||||
|     p.set_output_format(pandoc::OutputFormat::MediaWiki, vec![]); | ||||
|     p.execute().expect("Fehler beim Umwandeln des und speichern des Pads in eine mediawiki-Textdatei"); | ||||
|     
 | ||||
|     // Textdatei wieder einlesen
 | ||||
|     let mut file = File::open("pandoc-output.txt").expect("Fehler beim öffnen der MediaWiki-Textdatei!"); | ||||
|     let mut contents = String::new(); | ||||
|     file.read_to_string(&mut contents).expect("Fehler beim auslesen der MediaWiki-Textdatei!"); | ||||
|     
 | ||||
|     // Passwörter aus Datenbank lesen (ToBeDone)
 | ||||
|     let plenum_bot_user = String::from("PlenumBot@PlenumBot-PW1"); | ||||
|     let plenum_bot_pw = String::from("**OLD_API_PW_REMOVED**"); | ||||
|     
 | ||||
|     
 | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 murmeldin
							murmeldin