rustyphoenixlecture 1.7.1

This project aims to provide a simple a powerfull lecture compilation to generate html web sites
/***************************************
	Auteur : Pierre Aubert
	Mail : pierre.aubert@lapp.in2p3.fr
	Licence : CeCILL-C
****************************************/

use crate::pcontent::{
	pabstractcontent::{PAbstractContent, PAbstractLectureBackend},
	plabeler::PLabelId,
	preferenceurl::PReferenceUrl
};

///Reference in any other PContent of the lecture
#[derive(Debug, Clone, Default, PartialEq)]
pub struct PContentReference{
	///Reference name
	p_reference: String,
	///Name of an other lecture the reference refers to (empty if it is the current lecture)
	p_other_lecture_name: String,
	///Url to jump to the reference
	p_url: PReferenceUrl,
}

impl PContentReference {
	///Constructor of a PContentReference
	/// # Parameters
	/// - `reference` : reference of the content
	pub fn new(reference: &String) -> Self{
		PContentReference {
			p_reference: reference.clone(),
			p_other_lecture_name: String::from(""),
			p_url: Default::default(),
		}
	}
	///Constructor of a PContentReference
	/// # Parameters
	/// - `other_lecture_reference` : reference of the content
	/// - `other_lecture_name` : name of the other lecture the reference refers to
	pub fn from_other_lecture(other_lecture_reference: &String, other_lecture_name: &String) -> Self{
		PContentReference {
			p_reference: other_lecture_reference.clone(),
			p_other_lecture_name: other_lecture_name.clone(),
			p_url: Default::default(),
		}
	}
	///Set the url of the PContentReference
	/// # Parameters
	/// - `url` : url of the PContentReference
	pub fn set_url(&mut self, url: &PReferenceUrl){
		self.p_url = url.clone();
	}
	///Get the reference name of the PContentReference
	/// # Returns
	/// Reference name of the PContentReference
	pub fn get_reference(&self) -> &String{
		&self.p_reference
	}
	///Get the name of the lecture reference of the PContentReference
	/// # Returns
	/// Name of the lecture reference of the PContentReference
	pub fn get_other_lecture_name(&self) -> &String{
		&self.p_other_lecture_name
	}
}

impl PAbstractContent for PContentReference{
	///Say if the PContent has an embeded label
	/// # Returns
	/// True if the PContent has an embeded label, false otherwise
	fn has_embeded_label(&self) -> bool{
		false
	}
	///Get the reference url of the current PContent
	/// # Parameters
	/// - `_current_file` : current output file of the PContent
	/// - `_id` : id of the PContent
	/// # Returns
	/// Corresponding PReferenceUrl
	fn get_reference_url(&self, _current_file: &String, _id: usize) -> PReferenceUrl{
		self.p_url.clone()
	}
	///Convert the current struct into html
	/// # Parameters
	/// - `backend` : backend which write a lecture in files
	/// - `id` : id of the PContent
	fn to_html<TLectureBackend>(&self, backend: &mut TLectureBackend, id: &PLabelId)
		where TLectureBackend: PAbstractLectureBackend
	{
		//TODO : At some point we will be able to make a thumbnail of the url destination, but let's make all things work before
		// println!("PContentReference::to_html : save reference '{}'", self.p_reference);
		self.p_url.to_html(backend, id);
	}
}