servables
Servables are any non-core data-structure that is built with the objective of being written to a stream.
Missing docstring for Servable
. Check Documenter's build log for details.
components
A component is a Servable which contains markup information and can easily be translated into elements with properties..
Toolips.Component
— TypeComponent <: Servable
- name::String
- f::Function
- properties::Dict A component is a standard servable which is used to represent HTML tag
structures. Indexing a Component with a Symbol or a String will return or set a Component's property to that index. The two special indexes are :children and :text. :text will change the inner content of the Component and :children is where components that will be written inside the Component go. You can add to these with push!(c::Servable, c2::Servable)
example
using Toolips
image_style = Style("example")
image_anim = Animation("img_anim")
image_anim[:from] = "opacity" => "0%"
image_anim[:to] = "opacity" => "100%"
animate!(image_style)
r = route("/") do c::AbstractConnection
newimage = img("newimage", src = "/logo.png")
style!(newimage, image_style)
write!(c, newimage)
end
field info
- name::String - The name field is the way that a component is denoted in code.
- f::Function - The function that gets called with the Connection as an
argument.
- properties::Dict - A dictionary of symbols and values.
constructors
- Component(name::String = "", tag::String = "", properties::Dict = Dict())
- Component(name::String, tag::String, props::Base.Pairs)
Indexing a component will yield its .properties:
Missing docstring for getindex(::Servable, ::Symbol)
. Check Documenter's build log for details.
Base.getindex
— MethodInterface
getindex(::Servable, ::String) -> ::Any
Returns a property value by string or name.
example
c = p("hello", text = "Hello world")
c[:text]
"Hello world!"
c["opacity"] = "50%"
c["opacity"]
"50%"
Base.setindex!
— MethodInterface
setindex!(s::Servable, a::Any, symb::Symbol) -> _
Sets the property represented by the symbol to the provided value.
example
c = p("world")
c[:text] = "hello world!"
Missing docstring for setindex!(::Servable, ::Any, ::Symbol)
. Check Documenter's build log for details.
Base.setindex!
— MethodInterface
setindex!(s::Servable, a::Any, symb::String) -> _
Sets the property represented by the string to the provided value. Use the appropriate web-format, such as "50%" or "50px".
example
c = p("world")
c["align"] = "center"
There is a library of default components that comes with toolips. Generally, their name coincides with a docstring. All of these take an infinite number of key-word arguments. These arguments become the properties of a Servable.
Toolips.img
— Functionimg(name::String; args ...) -> ::Component
Returns the img Component with the key-word arguments provided in args as properties.
example
image = img("mylogo", src = "assets/logo.png")
write!(c, image)
Toolips.link
— Functionlink(name::String; args ...) -> ::Component
Returns the link Component with the key-word arguments provided in args as properties.
example
mylink = link("mylink", href = "http://toolips.app")
write!(c, mylink)
Toolips.meta
— Functionmeta(name::String; args ...) -> ::Component
Returns the meta Component with the key-word arguments provided in args as properties.
example
metainfo = meta("metainfo", rel = "meta-description", text = "hello")
write!(c, metainfo)
Toolips.input
— Functioninput(name::String; args ...) -> ::Component
Returns the input Component with the key-word arguments provided in args as properties.
example
element = input("mylogo")
write!(c, element)
Toolips.a
— Functiona(name::String; args ...) -> ::Component
Returns the a Component with the key-word arguments provided in args as properties.
example
element = a("mylogo")
write!(c, element)
Toolips.p
— Functionp(name::String; args ...) -> ::Component
Returns the p Component with the key-word arguments provided in args as properties.
example
p1 = input("mylogo")
write!(c, p)
Toolips.h
— Functionh(name::String; args ...) -> ::Component
Returns the h Component with the key-word arguments provided in args as properties.
example
h1 = h("heading1", 1)
write!(c, h1)
Missing docstring for img
. Check Documenter's build log for details.
Toolips.ul
— Functionul(name::String; args ...) -> ::Component
Returns the ul Component with the key-word arguments provided in args as properties.
example
ul1 = ul("mylogo")
write!(c, ul)
Toolips.li
— Functionli(name::String; args ...) -> ::Component
Returns the li Component with the key-word arguments provided in args as properties.
example
li1 = li("mylogo")
write!(c, li)
Toolips.divider
— Functiondivider(name::String; args ...) -> ::Component
Returns the div Component with the key-word arguments provided in args as properties.
example
divider1 = divider("mylogo")
write!(c, divider)
Toolips.br
— Functionbr(name::String; args ...) -> ::Component
Returns the br Component with the key-word arguments provided in args as properties.
example
comp = br("newcomp")
write!(c, comp)
Toolips.i
— Functioni(name::String; args ...) -> ::Component
Returns the i Component with the key-word arguments provided in args as properties.
example
comp = i("newcomp")
write!(c, comp)
Toolips.title
— Functiontitle(name::String; args ...) -> ::Component
Returns the title Component with the key-word arguments provided in args as properties.
example
comp = title("newcomp")
write!(c, comp)
Toolips.span
— Functionspan(name::String; args ...) -> ::Component
Returns the span Component with the key-word arguments provided in args as properties.
example
comp = span("newcomp")
write!(c, comp)
Toolips.iframe
— Functioniframe(name::String; args ...) -> ::Component
Returns the iframe Component with the key-word arguments provided in args as properties.
example
comp = iframe("newcomp")
write!(c, comp)
Toolips.svg
— Functionsvg(name::String; args ...) -> ::Component
Returns the svg Component with the key-word arguments provided in args as properties.
example
comp = svg("newcomp")
write!(c, comp)
Toolips.element
— Functionelement(name::String; args ...) -> ::Component
Returns the element Component with the key-word arguments provided in args as properties.
example
comp = element("newcomp")
write!(c, comp)
Toolips.label
— Functionlabel(name::String; args ...) -> ::Component
Returns the label Component with the key-word arguments provided in args as properties.
example
lbl = label("mylogo", src = "assets/logo.png")
write!(c, lbl)
Toolips.script
— Functionscript(name::String; args ...) -> ::Component
Returns the script Component with the key-word arguments provided in args as properties.
example
comp = script("newcomp")
write!(c, comp)
Toolips.nav
— Functionnav(name::String; args ...) -> ::Component
Returns the nav Component with the key-word arguments provided in args as properties.
example
comp = nav("newcomp")
write!(c, comp)
Toolips.button
— Functionbutton(name::String; args ...) -> ::Component
Returns the button Component with the key-word arguments provided in args as properties.
example
comp = button("newcomp")
write!(c, comp)
Toolips.form
— Functionform(name::String; args ...) -> ::Component
Returns the form Component with the key-word arguments provided in args as properties.
example
comp = form("newcomp")
write!(c, comp)
We can also compose components together using push! and style them using style!
Missing docstring for push!(::Servable, ::Servable)
. Check Documenter's build log for details.
Missing docstring for push!(::Servable, ::Vector{Servable})
. Check Documenter's build log for details.
Missing docstring for push!(::Component, ::Servable ...)
. Check Documenter's build log for details.
Toolips.properties!
— MethodInterface
properties!(c::Servable, s::Servable) -> _
Copies properties from s,properties into c.properties.
example
comp = Component()
othercomp = Component()
othercomp["opacity"] = "100%"
properties!(comp, othercomp)
comp["opacity"]
100%
Missing docstring for push!(::Component, ::Servable)
. Check Documenter's build log for details.
Toolips.style!
— FunctionInterface
style!(c::Servable, s::Style) -> _
Applies the style to a servable.
example
serv = p("wow")
mystyle = Style("mystyle", color = "lightblue")
style!(serv, mystyle)
Interface
style!(c::Servable, s::Pair ...) -> _
Applies the style pairs to the servable's "style" property.
example
mycomp = p("mycomp")
style!(mycomp, "background-color" => "lightblue", "color" => "white")
Interface
style!(::Style, ::Style) -> _
Copies the properties from the second style into the first style.
example
style1 = Style("firsts")
style2 = Style("seconds")
style1["color"] = "orange"
style!(style2, style1)
style2["color"]
"orange"
style components
Style components are change the style of a Component
Toolips.StyleComponent
— Typeabstract type StyleComponent <: Servable
No different from a normal Servable, simply an abstract type step for the interface to separate working with Animations and Styles.
Servable Consistencies
Servables can be written to a Connection via thier f() function and the
interface. They can also be indexed with strings or symbols to change properties
##### Consistencies
- f::Function - Function whose output to be written to http. Must take a single
positonal argument of type ::Connection or ::AbstractConnection
The main style components are Animations and Styles.
Toolips.Animation
— TypeAnimation
- name::String
- keyframes::Dict
- f::Function
- delay::Float64
- length::Float64
- iterations::Integer An animation can be used to animate Styles with the animate! method. Animating
is done by indexing by either percentage, or symbols, such as from and to.
example
anim = Animation("myanim")
anim[:from] = "opacity" => "0%"
anim[:to] = "opacity" => "100%"
style = Style("example")
animate!(style, anim)
field info
- name::String - The name of the animation.
- keyframes::Dict - The keyframes that have been pushed so far.
- f::Function - The function called when writing to a Connection.
- delay::Float64 - The delay before the animation begins.
- length::Float64 - The amount of time the animation should play.
- iterations::Integer - The number of times the animation should repeat. When
set to 0 the animation will loop indefinitely.
constructors
Animation(name::String = "animation", delay::Float64 = 0.0, length::Float64 = 5.2, iterations::Integer = 1)
Animating and property adjustment is done with indexing.
file
The file Servable, as you might expect, serves a file via a directory.
Toolips.File
— TypeFile <: Servable
dir::String f::Function Serves a file into a Connection.
example
f = File("hello.txt")
r = route("/") do c
write!(c, f)
end
field info
- dir::String - The directory of a file to serve.
- f::Function - Function whose output to be written to http().
constructors
- File(dir::String)