Libera la versión de desarrollo 0.0.5
This commit is contained in:
parent
c6bbd565ab
commit
b02a92dbb0
16 changed files with 113 additions and 113 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "pagetop"
|
||||
version = "0.0.4"
|
||||
version = "0.0.5"
|
||||
edition = "2021"
|
||||
|
||||
authors = [
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use crate::prelude::*;
|
|||
pub struct Block {
|
||||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptionId,
|
||||
title : OptionAttr,
|
||||
id : OptIden,
|
||||
title : OptAttr,
|
||||
html : Vec<Markup>,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -15,8 +15,8 @@ impl PageComponent for Block {
|
|||
Block {
|
||||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptionId::none(),
|
||||
title : OptionAttr::none(),
|
||||
id : OptIden::none(),
|
||||
title : OptAttr::none(),
|
||||
html : Vec::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ enum ContainerType { Header, Footer, Main, Section, Wrapper }
|
|||
pub struct Container {
|
||||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptionId,
|
||||
id : OptIden,
|
||||
container : ContainerType,
|
||||
components: PageContainer,
|
||||
template : String,
|
||||
|
|
@ -17,7 +17,7 @@ impl PageComponent for Container {
|
|||
Container {
|
||||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptionId::none(),
|
||||
id : OptIden::none(),
|
||||
container : ContainerType::Wrapper,
|
||||
components: PageContainer::new(),
|
||||
template : "default".to_owned(),
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ pub struct Button {
|
|||
renderable : fn() -> bool,
|
||||
weight : i8,
|
||||
button_type: ButtonType,
|
||||
name : OptionAttr,
|
||||
value : OptionAttr,
|
||||
autofocus : OptionAttr,
|
||||
disabled : OptionAttr,
|
||||
name : OptAttr,
|
||||
value : OptAttr,
|
||||
autofocus : OptAttr,
|
||||
disabled : OptAttr,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -20,10 +20,10 @@ impl PageComponent for Button {
|
|||
renderable : always,
|
||||
weight : 0,
|
||||
button_type: ButtonType::Button,
|
||||
name : OptionAttr::none(),
|
||||
value : OptionAttr::none(),
|
||||
autofocus : OptionAttr::none(),
|
||||
disabled : OptionAttr::none(),
|
||||
name : OptAttr::none(),
|
||||
value : OptAttr::none(),
|
||||
autofocus : OptAttr::none(),
|
||||
disabled : OptAttr::none(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -42,14 +42,14 @@ impl PageComponent for Button {
|
|||
ButtonType::Reset => ("reset", "btn btn-primary form-reset" ),
|
||||
ButtonType::Submit => ("submit", "btn btn-primary form-submit")
|
||||
};
|
||||
let id_item = match &self.name.option() {
|
||||
let id = match &self.name.option() {
|
||||
Some(name) => Some(format!("edit-{}", name)),
|
||||
_ => None
|
||||
};
|
||||
html! {
|
||||
button
|
||||
type=(button_type)
|
||||
id=[&id_item]
|
||||
id=[&id]
|
||||
class=(button_class)
|
||||
name=[&self.name.option()]
|
||||
value=[&self.value.option()]
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@ use crate::prelude::*;
|
|||
pub struct Date {
|
||||
renderable : fn() -> bool,
|
||||
weight : i8,
|
||||
name : OptionAttr,
|
||||
value : OptionAttr,
|
||||
label : OptionAttr,
|
||||
placeholder : OptionAttr,
|
||||
autofocus : OptionAttr,
|
||||
autocomplete: OptionAttr,
|
||||
disabled : OptionAttr,
|
||||
readonly : OptionAttr,
|
||||
required : OptionAttr,
|
||||
help_text : OptionAttr,
|
||||
name : OptAttr,
|
||||
value : OptAttr,
|
||||
label : OptAttr,
|
||||
placeholder : OptAttr,
|
||||
autofocus : OptAttr,
|
||||
autocomplete: OptAttr,
|
||||
disabled : OptAttr,
|
||||
readonly : OptAttr,
|
||||
required : OptAttr,
|
||||
help_text : OptAttr,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -22,16 +22,16 @@ impl PageComponent for Date {
|
|||
Date {
|
||||
renderable : always,
|
||||
weight : 0,
|
||||
name : OptionAttr::none(),
|
||||
value : OptionAttr::none(),
|
||||
label : OptionAttr::none(),
|
||||
placeholder : OptionAttr::none(),
|
||||
autofocus : OptionAttr::none(),
|
||||
autocomplete: OptionAttr::none(),
|
||||
disabled : OptionAttr::none(),
|
||||
readonly : OptionAttr::none(),
|
||||
required : OptionAttr::none(),
|
||||
help_text : OptionAttr::none(),
|
||||
name : OptAttr::none(),
|
||||
value : OptAttr::none(),
|
||||
label : OptAttr::none(),
|
||||
placeholder : OptAttr::none(),
|
||||
autofocus : OptAttr::none(),
|
||||
autocomplete: OptAttr::none(),
|
||||
disabled : OptAttr::none(),
|
||||
readonly : OptAttr::none(),
|
||||
required : OptAttr::none(),
|
||||
help_text : OptAttr::none(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ impl PageComponent for Date {
|
|||
}
|
||||
|
||||
fn default_render(&self, _: &mut PageAssets) -> Markup {
|
||||
let (class_item, id_item) = match self.name.option() {
|
||||
let (class, id) = match self.name.option() {
|
||||
Some(name) => (
|
||||
format!("form-item form-item-{} form-type-date", name),
|
||||
Some(format!("edit-{}", name))
|
||||
|
|
@ -56,9 +56,9 @@ impl PageComponent for Date {
|
|||
)
|
||||
};
|
||||
html! {
|
||||
div class=(class_item) {
|
||||
div class=(class) {
|
||||
@if self.label.has_value() {
|
||||
label class="form-label" for=[&id_item] {
|
||||
label class="form-label" for=[&id] {
|
||||
(self.label.value()) " "
|
||||
@if self.required.has_value() {
|
||||
span
|
||||
|
|
@ -72,7 +72,7 @@ impl PageComponent for Date {
|
|||
}
|
||||
input
|
||||
type="date"
|
||||
id=[&id_item]
|
||||
id=[&id]
|
||||
class="form-control"
|
||||
name=[&self.name.option()]
|
||||
value=[&self.value.option()]
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ pub enum FormMethod {Get, Post}
|
|||
pub struct Form {
|
||||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptionId,
|
||||
action : OptionAttr,
|
||||
id : OptIden,
|
||||
action : OptAttr,
|
||||
method : FormMethod,
|
||||
charset : OptionAttr,
|
||||
charset : OptAttr,
|
||||
elements : PageContainer,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -19,10 +19,10 @@ impl PageComponent for Form {
|
|||
Form {
|
||||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptionId::none(),
|
||||
action : OptionAttr::none(),
|
||||
id : OptIden::none(),
|
||||
action : OptAttr::none(),
|
||||
method : FormMethod::Post,
|
||||
charset : OptionAttr::some("UTF-8"),
|
||||
charset : OptAttr::some("UTF-8"),
|
||||
elements : PageContainer::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use crate::prelude::*;
|
|||
|
||||
pub struct Hidden {
|
||||
weight : i8,
|
||||
name : OptionId,
|
||||
value : OptionAttr,
|
||||
name : OptIden,
|
||||
value : OptAttr,
|
||||
}
|
||||
|
||||
impl PageComponent for Hidden {
|
||||
|
|
@ -11,8 +11,8 @@ impl PageComponent for Hidden {
|
|||
fn new() -> Self {
|
||||
Hidden {
|
||||
weight : 0,
|
||||
name : OptionId::none(),
|
||||
value : OptionAttr::none(),
|
||||
name : OptIden::none(),
|
||||
value : OptAttr::none(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -21,14 +21,14 @@ impl PageComponent for Hidden {
|
|||
}
|
||||
|
||||
fn default_render(&self, _: &mut PageAssets) -> Markup {
|
||||
let id_item = match self.name.option() {
|
||||
let id = match self.name.option() {
|
||||
Some(name) => Some(format!("value-{}", name)),
|
||||
_ => None
|
||||
};
|
||||
html! {
|
||||
input
|
||||
type="hidden"
|
||||
id=[&id_item]
|
||||
id=[&id]
|
||||
name=[&self.name.option()]
|
||||
value=[&self.value.option()];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,19 @@ pub struct Input {
|
|||
renderable : fn() -> bool,
|
||||
weight : i8,
|
||||
input_type : InputType,
|
||||
name : OptionId,
|
||||
value : OptionAttr,
|
||||
label : OptionAttr,
|
||||
name : OptIden,
|
||||
value : OptAttr,
|
||||
label : OptAttr,
|
||||
size : Option<u16>,
|
||||
minlength : Option<u16>,
|
||||
maxlength : Option<u16>,
|
||||
placeholder : OptionAttr,
|
||||
autofocus : OptionAttr,
|
||||
autocomplete: OptionAttr,
|
||||
disabled : OptionAttr,
|
||||
readonly : OptionAttr,
|
||||
required : OptionAttr,
|
||||
help_text : OptionAttr,
|
||||
placeholder : OptAttr,
|
||||
autofocus : OptAttr,
|
||||
autocomplete: OptAttr,
|
||||
disabled : OptAttr,
|
||||
readonly : OptAttr,
|
||||
required : OptAttr,
|
||||
help_text : OptAttr,
|
||||
template : String,
|
||||
}
|
||||
|
||||
|
|
@ -29,19 +29,19 @@ impl PageComponent for Input {
|
|||
renderable : always,
|
||||
weight : 0,
|
||||
input_type : InputType::Textfield,
|
||||
name : OptionId::none(),
|
||||
value : OptionAttr::none(),
|
||||
label : OptionAttr::none(),
|
||||
name : OptIden::none(),
|
||||
value : OptAttr::none(),
|
||||
label : OptAttr::none(),
|
||||
size : Some(60),
|
||||
minlength : None,
|
||||
maxlength : Some(128),
|
||||
placeholder : OptionAttr::none(),
|
||||
autofocus : OptionAttr::none(),
|
||||
autocomplete: OptionAttr::none(),
|
||||
disabled : OptionAttr::none(),
|
||||
readonly : OptionAttr::none(),
|
||||
required : OptionAttr::none(),
|
||||
help_text : OptionAttr::none(),
|
||||
placeholder : OptAttr::none(),
|
||||
autofocus : OptAttr::none(),
|
||||
autocomplete: OptAttr::none(),
|
||||
disabled : OptAttr::none(),
|
||||
readonly : OptAttr::none(),
|
||||
required : OptAttr::none(),
|
||||
help_text : OptAttr::none(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ impl PageComponent for Input {
|
|||
}
|
||||
|
||||
fn default_render(&self, _: &mut PageAssets) -> Markup {
|
||||
let (input_type, class_type) = match &self.input_type {
|
||||
let (type_input, type_class) = match &self.input_type {
|
||||
InputType::Email => ("email", "form-type-email"),
|
||||
InputType::Password => ("password", "form-type-password"),
|
||||
InputType::Search => ("search", "form-type-search"),
|
||||
|
|
@ -63,20 +63,20 @@ impl PageComponent for Input {
|
|||
InputType::Textfield => ("text", "form-type-textfield"),
|
||||
InputType::Url => ("url", "form-type-url")
|
||||
};
|
||||
let (class_item, id_item) = match &self.name.option() {
|
||||
let (class, id) = match &self.name.option() {
|
||||
Some(name) => (
|
||||
format!("form-item form-item-{} {}", name, class_type),
|
||||
format!("form-item form-item-{} {}", name, type_class),
|
||||
Some(format!("edit-{}", name))
|
||||
),
|
||||
None => (
|
||||
format!("form-item {}", class_type),
|
||||
format!("form-item {}", type_class),
|
||||
None
|
||||
)
|
||||
};
|
||||
html! {
|
||||
div class=(class_item) {
|
||||
div class=(class) {
|
||||
@if self.label.has_value() {
|
||||
label class="form-label" for=[&id_item] {
|
||||
label class="form-label" for=[&id] {
|
||||
(self.label.value()) " "
|
||||
@if self.required.has_value() {
|
||||
span
|
||||
|
|
@ -89,8 +89,8 @@ impl PageComponent for Input {
|
|||
}
|
||||
}
|
||||
input
|
||||
type=(input_type)
|
||||
id=[&id_item]
|
||||
type=(type_input)
|
||||
id=[&id]
|
||||
class="form-control"
|
||||
name=[&self.name.option()]
|
||||
value=[&self.value.option()]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
|||
pub struct Column {
|
||||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptionId,
|
||||
id : OptIden,
|
||||
components: PageContainer,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ impl PageComponent for Column {
|
|||
Column {
|
||||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptionId::none(),
|
||||
id : OptIden::none(),
|
||||
components: PageContainer::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use crate::prelude::*;
|
|||
pub struct Row {
|
||||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptionId,
|
||||
id : OptIden,
|
||||
columns : PageContainer,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ impl PageComponent for Row {
|
|||
Row {
|
||||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptionId::none(),
|
||||
id : OptIden::none(),
|
||||
columns : PageContainer::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ impl MenuItem {
|
|||
pub struct Menu {
|
||||
renderable: fn() -> bool,
|
||||
weight : i8,
|
||||
id : OptionId,
|
||||
id : OptIden,
|
||||
items : PageContainer,
|
||||
template : String,
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ impl PageComponent for Menu {
|
|||
Menu {
|
||||
renderable: always,
|
||||
weight : 0,
|
||||
id : OptionId::none(),
|
||||
id : OptIden::none(),
|
||||
items : PageContainer::new(),
|
||||
template : "default".to_owned(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ async fn demo() -> app::Result<Markup> {
|
|||
.using_theme("Bootsier")
|
||||
.with_title(l("page_title").as_str())
|
||||
.add_to("content", hello_world())
|
||||
.add_to("content", hello_world2())
|
||||
.add_to("content", hello_world_original())
|
||||
.add_to("content", just_visiting())
|
||||
.add_to("content", about_pagetop())
|
||||
.add_to("content", promo_pagetop())
|
||||
|
|
@ -35,7 +35,7 @@ async fn demo() -> app::Result<Markup> {
|
|||
.render()
|
||||
}
|
||||
|
||||
fn hello_world2() -> Container {
|
||||
fn hello_world() -> Container {
|
||||
Container::header()
|
||||
.add(grid::Row::new()
|
||||
.add_column(grid::Column::new()
|
||||
|
|
@ -76,7 +76,7 @@ fn hello_world2() -> Container {
|
|||
)
|
||||
}
|
||||
|
||||
fn hello_world() -> Chunck {
|
||||
fn hello_world_original() -> Chunck {
|
||||
Chunck::with(html! {
|
||||
header id="header" class="header" {
|
||||
div class="container" {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
pub use maud::{DOCTYPE, Markup, PreEscaped, html};
|
||||
|
||||
mod optional_id;
|
||||
pub use optional_id::OptionId;
|
||||
mod optional_attr;
|
||||
pub use optional_attr::OptionAttr;
|
||||
mod optiden;
|
||||
pub use optiden::OptIden;
|
||||
mod optattr;
|
||||
pub use optattr::OptAttr;
|
||||
mod classes;
|
||||
pub use classes::Classes;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
pub struct OptionAttr(Option<String>);
|
||||
pub struct OptAttr(Option<String>);
|
||||
|
||||
impl OptionAttr {
|
||||
impl OptAttr {
|
||||
pub fn none() -> Self {
|
||||
OptionAttr(None)
|
||||
OptAttr(None)
|
||||
}
|
||||
|
||||
pub fn some(value: &str) -> Self {
|
||||
let value = value.trim();
|
||||
match value.is_empty() {
|
||||
true => OptionAttr(None),
|
||||
false => OptionAttr(Some(value.to_owned())),
|
||||
true => OptAttr(None),
|
||||
false => OptAttr(Some(value.to_owned())),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
pub struct OptionId(Option<String>);
|
||||
pub struct OptIden(Option<String>);
|
||||
|
||||
impl OptionId {
|
||||
impl OptIden {
|
||||
pub fn none() -> Self {
|
||||
OptionId(None)
|
||||
OptIden(None)
|
||||
}
|
||||
|
||||
pub fn with_value(&mut self, id: &str) {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{Lazy, app, trace};
|
||||
use crate::config::SETTINGS;
|
||||
use crate::html::{Classes, DOCTYPE, Markup, OptionAttr, html};
|
||||
use crate::html::{Classes, DOCTYPE, Markup, OptAttr, html};
|
||||
use crate::response::page::{PageAssets, PageComponent, PageContainer};
|
||||
|
||||
use std::sync::RwLock;
|
||||
|
|
@ -40,10 +40,10 @@ static DEFAULT_DIRECTION: Lazy<Option<String>> = Lazy::new(|| {
|
|||
pub enum TextDirection { Auto, LeftToRight, RightToLeft }
|
||||
|
||||
pub struct Page<'a> {
|
||||
language : OptionAttr,
|
||||
direction : OptionAttr,
|
||||
title : OptionAttr,
|
||||
description : OptionAttr,
|
||||
language : OptAttr,
|
||||
direction : OptAttr,
|
||||
title : OptAttr,
|
||||
description : OptAttr,
|
||||
assets : PageAssets,
|
||||
body_classes: Classes,
|
||||
regions : HashMap<&'a str, PageContainer>,
|
||||
|
|
@ -55,15 +55,15 @@ impl<'a> Page<'a> {
|
|||
pub fn new() -> Self {
|
||||
Page {
|
||||
language : match &*DEFAULT_LANGUAGE {
|
||||
Some(language) => OptionAttr::some(language),
|
||||
_ => OptionAttr::none(),
|
||||
Some(language) => OptAttr::some(language),
|
||||
_ => OptAttr::none(),
|
||||
},
|
||||
direction : match &*DEFAULT_DIRECTION {
|
||||
Some(direction) => OptionAttr::some(direction),
|
||||
_ => OptionAttr::none(),
|
||||
Some(direction) => OptAttr::some(direction),
|
||||
_ => OptAttr::none(),
|
||||
},
|
||||
title : OptionAttr::none(),
|
||||
description : OptionAttr::none(),
|
||||
title : OptAttr::none(),
|
||||
description : OptAttr::none(),
|
||||
body_classes: Classes::some_class("body"),
|
||||
assets : PageAssets::new(),
|
||||
regions : COMPONENTS.read().unwrap().clone(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue