Modifica la estructura general del código fuente
Importante actualización que reorganiza el código fuente de PageTop. Usa Cargo para crear un espacio de trabajo con los diferentes proyectos que estructuran las funcionalidades de PageTop en módulos interdependientes que se integran en Drust para construir una solución web para la gestión de contenidos.
This commit is contained in:
parent
4b5d8ce38a
commit
ab0ac11f65
83 changed files with 115 additions and 81 deletions
53
src/util.rs
53
src/util.rs
|
|
@ -1,53 +0,0 @@
|
|||
#[macro_export]
|
||||
/// Macro para construir grupos de pares clave-valor.
|
||||
///
|
||||
/// ```
|
||||
/// let args = args![
|
||||
/// "userName" => "Roberto",
|
||||
/// "photoCount" => 3,
|
||||
/// "userGender" => "male"
|
||||
/// ];
|
||||
/// ```
|
||||
macro_rules! args {
|
||||
( $($KEY:expr => $VALUE:expr),* ) => {{
|
||||
let mut a = std::collections::HashMap::new();
|
||||
$(
|
||||
a.insert(String::from($KEY), $VALUE.into());
|
||||
)*
|
||||
a
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! db_migrations {
|
||||
( $DBCONN:ident ) => {{
|
||||
$crate::run_now({
|
||||
use $crate::db::migration::MigratorTrait;
|
||||
|
||||
migration::Migrator::up($DBCONN, None)
|
||||
})
|
||||
}};
|
||||
}
|
||||
|
||||
pub fn valid_id(id: &str) -> Option<String> {
|
||||
let id = id.trim().replace(" ", "_").to_lowercase();
|
||||
match id.is_empty() {
|
||||
true => None,
|
||||
false => Some(id),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn optional_str(s: &str) -> Option<String> {
|
||||
let s = s.to_owned();
|
||||
match s.is_empty() {
|
||||
true => None,
|
||||
false => Some(s),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn assigned_str(optional: &Option<String>) -> &str {
|
||||
match optional {
|
||||
Some(o) => o.as_str(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue