pagebuilder 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gems.rb +6 -0
- data/lib/pagebuilder.rb +11 -0
- data/lib/pagebuilder/document.rb +31 -0
- data/lib/pagebuilder/elements.rb +8 -0
- data/lib/pagebuilder/elements/anchor.rb +31 -0
- data/lib/pagebuilder/elements/basic.rb +38 -0
- data/lib/pagebuilder/elements/input.rb +44 -0
- data/lib/pagebuilder/elements/inputs.rb +13 -0
- data/lib/pagebuilder/elements/inputs/checkbox.rb +19 -0
- data/lib/pagebuilder/elements/inputs/email.rb +18 -0
- data/lib/pagebuilder/elements/inputs/file.rb +18 -0
- data/lib/pagebuilder/elements/inputs/hidden.rb +18 -0
- data/lib/pagebuilder/elements/inputs/password.rb +18 -0
- data/lib/pagebuilder/elements/inputs/radio_button.rb +19 -0
- data/lib/pagebuilder/elements/inputs/search.rb +18 -0
- data/lib/pagebuilder/elements/inputs/submit_button.rb +18 -0
- data/lib/pagebuilder/elements/inputs/text.rb +18 -0
- data/lib/pagebuilder/tag_helpers.rb +23 -0
- data/lib/pagebuilder/tag_helpers/embeds.rb +65 -0
- data/lib/pagebuilder/tag_helpers/forms.rb +90 -0
- data/lib/pagebuilder/tag_helpers/lists.rb +33 -0
- data/lib/pagebuilder/tag_helpers/miscellaneous.rb +59 -0
- data/lib/pagebuilder/tag_helpers/page_structure.rb +69 -0
- data/lib/pagebuilder/tag_helpers/pagebuilder_prefixed_helpers.rb +28 -0
- data/lib/pagebuilder/tag_helpers/tables.rb +49 -0
- data/lib/pagebuilder/tag_helpers/text_markup.rb +165 -0
- data/lib/pagebuilder/version.rb +4 -0
- data/pagebuilder.gemspec +34 -0
- metadata +170 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module Elements
|
5
|
+
module Inputs
|
6
|
+
|
7
|
+
# Creates file input nodes
|
8
|
+
class File < PageBuilder::Elements::Input
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
self.type = 'file'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module Elements
|
5
|
+
module Inputs
|
6
|
+
|
7
|
+
# Creates hidden input nodes
|
8
|
+
class Hidden < PageBuilder::Elements::Input
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
self.type = 'hidden'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module Elements
|
5
|
+
module Inputs
|
6
|
+
|
7
|
+
# Creates password input nodes
|
8
|
+
class Password < PageBuilder::Elements::Input
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
self.type = 'password'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module Elements
|
5
|
+
module Inputs
|
6
|
+
|
7
|
+
# Creates radio button nodes and adds some helper
|
8
|
+
# methods for commonly used attributes
|
9
|
+
class RadioButton < PageBuilder::Elements::Input
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
super
|
13
|
+
self.type = 'radio'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module Elements
|
5
|
+
module Inputs
|
6
|
+
|
7
|
+
# Creates search input nodes
|
8
|
+
class Search < PageBuilder::Elements::Input
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
self.type = 'search'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module Elements
|
5
|
+
module Inputs
|
6
|
+
|
7
|
+
# Creates submit button nodes
|
8
|
+
class SubmitButton < PageBuilder::Elements::Input
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
self.type = 'submit'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module Elements
|
5
|
+
module Inputs
|
6
|
+
|
7
|
+
# Creates text input nodes
|
8
|
+
class Text < PageBuilder::Elements::Input
|
9
|
+
|
10
|
+
def initialize(*args)
|
11
|
+
super
|
12
|
+
self.type = 'text'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Helper module to make building pages easier
|
2
|
+
module PageBuilder::TagHelpers
|
3
|
+
|
4
|
+
# Helper for converting this object to html
|
5
|
+
# It passes arguments along to whatever is set as the
|
6
|
+
# pagebuilder document so see associated documentation for the
|
7
|
+
# allowed arguments
|
8
|
+
def to_html(*args)
|
9
|
+
pagebuilder_document.to_html(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
# Actual helper implementations are split into several files
|
15
|
+
# to help with organization
|
16
|
+
require 'pagebuilder/tag_helpers/embeds'
|
17
|
+
require 'pagebuilder/tag_helpers/forms'
|
18
|
+
require 'pagebuilder/tag_helpers/lists'
|
19
|
+
require 'pagebuilder/tag_helpers/miscellaneous'
|
20
|
+
require 'pagebuilder/tag_helpers/page_structure'
|
21
|
+
require 'pagebuilder/tag_helpers/pagebuilder_prefixed_helpers'
|
22
|
+
require 'pagebuilder/tag_helpers/tables'
|
23
|
+
require 'pagebuilder/tag_helpers/text_markup'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module TagHelpers
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def area(content = nil, **attributes)
|
9
|
+
pagebuilder_basic_element('area', content, attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
def audio(content = nil, **attributes)
|
13
|
+
pagebuilder_basic_element('audio', content, attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def canvas(content = nil, **attributes)
|
17
|
+
pagebuilder_basic_element('canvas', content, attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def embed(content = nil, **attributes)
|
21
|
+
pagebuilder_basic_element('embed', content, attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def figcaption(content = nil, **attributes)
|
25
|
+
pagebuilder_basic_element('figcaption', content, attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def figure(content = nil, **attributes)
|
29
|
+
pagebuilder_basic_element('figure', content, attributes)
|
30
|
+
end
|
31
|
+
|
32
|
+
def iframe(content = nil, **attributes)
|
33
|
+
pagebuilder_basic_element('iframe', content, attributes)
|
34
|
+
end
|
35
|
+
|
36
|
+
def img(content = nil, **attributes)
|
37
|
+
pagebuilder_basic_element('img', content, attributes)
|
38
|
+
end
|
39
|
+
|
40
|
+
def map(content = nil, **attributes)
|
41
|
+
pagebuilder_basic_element('map', content, attributes)
|
42
|
+
end
|
43
|
+
|
44
|
+
def object(content = nil, **attributes)
|
45
|
+
pagebuilder_basic_element('object', content, attributes)
|
46
|
+
end
|
47
|
+
|
48
|
+
def param(content = nil, **attributes)
|
49
|
+
pagebuilder_basic_element('param', content, attributes)
|
50
|
+
end
|
51
|
+
|
52
|
+
def source(content = nil, **attributes)
|
53
|
+
pagebuilder_basic_element('source', content, attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def track(content = nil, **attributes)
|
57
|
+
pagebuilder_basic_element('track', content, attributes)
|
58
|
+
end
|
59
|
+
|
60
|
+
def video(content = nil, **attributes)
|
61
|
+
pagebuilder_basic_element('video', content, attributes)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module TagHelpers
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def button(content = nil, **attributes)
|
9
|
+
pagebuilder_basic_element('button', content, attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
def checkbox(content = nil, **attributes)
|
13
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::Checkbox, content, attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def email_input(content = nil, **attributes)
|
17
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::Email, content, attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def fieldset(content = nil, **attributes)
|
21
|
+
pagebuilder_basic_element('fieldset', content, attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def file_input(content = nil, **attributes)
|
25
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::File, content, attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def form(content = nil, **attributes)
|
29
|
+
pagebuilder_basic_element('form', content, attributes)
|
30
|
+
end
|
31
|
+
|
32
|
+
def hidden_input(content = nil, **attributes)
|
33
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::Hidden, content, attributes)
|
34
|
+
end
|
35
|
+
|
36
|
+
def input(content = nil, **attributes)
|
37
|
+
pagebuilder_configured_element(PageBuilder::Elements::Input, content, attributes)
|
38
|
+
end
|
39
|
+
|
40
|
+
def keygen(content = nil, **attributes)
|
41
|
+
pagebuilder_basic_element('keygen', content, attributes)
|
42
|
+
end
|
43
|
+
|
44
|
+
# TODO add helpers for things like labeled_input
|
45
|
+
def label(content = nil, **attributes)
|
46
|
+
pagebuilder_basic_element('label', content, attributes)
|
47
|
+
end
|
48
|
+
|
49
|
+
def legend(content = nil, **attributes)
|
50
|
+
pagebuilder_basic_element('legend', content, attributes)
|
51
|
+
end
|
52
|
+
|
53
|
+
def optgroup(content = nil, **attributes)
|
54
|
+
pagebuilder_basic_element('optgroup', content, attributes)
|
55
|
+
end
|
56
|
+
|
57
|
+
def option(content = nil, **attributes)
|
58
|
+
pagebuilder_basic_element('option', content, attributes)
|
59
|
+
end
|
60
|
+
|
61
|
+
def password_input(content = nil, **attributes)
|
62
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::Password, content, attributes)
|
63
|
+
end
|
64
|
+
|
65
|
+
def radio_button(content = nil, **attributes)
|
66
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::RadioButton, content, attributes)
|
67
|
+
end
|
68
|
+
|
69
|
+
def search_input(content = nil, **attributes)
|
70
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::Search, content, attributes)
|
71
|
+
end
|
72
|
+
|
73
|
+
def select(content = nil, **attributes)
|
74
|
+
pagebuilder_basic_element('select', content, attributes)
|
75
|
+
end
|
76
|
+
|
77
|
+
def submit_button(content = nil, **attributes)
|
78
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::SubmitButton, content, attributes)
|
79
|
+
end
|
80
|
+
|
81
|
+
def text_input(content = nil, **attributes)
|
82
|
+
pagebuilder_configured_element(PageBuilder::Elements::Inputs::Text, content, attributes)
|
83
|
+
end
|
84
|
+
|
85
|
+
def textarea(content = nil, **attributes)
|
86
|
+
pagebuilder_basic_element('textarea', content, attributes)
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module TagHelpers
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def dd(content = nil, **attributes)
|
9
|
+
pagebuilder_basic_element('dd', content, attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
def dl(content = nil, **attributes)
|
13
|
+
pagebuilder_basic_element('dl', content, attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def dt(content = nil, **attributes)
|
17
|
+
pagebuilder_basic_element('dt', content, attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def li(content = nil, **attributes)
|
21
|
+
pagebuilder_basic_element('li', content, attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def ol(content = nil, **attributes)
|
25
|
+
pagebuilder_basic_element('ol', content, attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def ul(content = nil, **attributes)
|
29
|
+
pagebuilder_basic_element('ul', content, attributes)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module TagHelpers
|
5
|
+
|
6
|
+
# Define all helpers as private so they don't polute the
|
7
|
+
# public method space for the class these are included in
|
8
|
+
private
|
9
|
+
|
10
|
+
def a(content = nil, **attributes)
|
11
|
+
pagebuilder_configured_element(Elements::Anchor, content, attributes)
|
12
|
+
end
|
13
|
+
|
14
|
+
def br(content = nil, **attributes)
|
15
|
+
pagebuilder_basic_element('br', content, attributes)
|
16
|
+
end
|
17
|
+
|
18
|
+
def datalist(content = nil, **attributes)
|
19
|
+
pagebuilder_basic_element('datalist', content, attributes)
|
20
|
+
end
|
21
|
+
|
22
|
+
def dialog(content = nil, **attributes)
|
23
|
+
pagebuilder_basic_element('dialog', content, attributes)
|
24
|
+
end
|
25
|
+
|
26
|
+
def hr(content = nil, **attributes)
|
27
|
+
pagebuilder_basic_element('hr', content, attributes)
|
28
|
+
end
|
29
|
+
|
30
|
+
def menu(content = nil, **attributes)
|
31
|
+
pagebuilder_basic_element('menu', content, attributes)
|
32
|
+
end
|
33
|
+
|
34
|
+
def menuitem(content = nil, **attributes)
|
35
|
+
pagebuilder_basic_element('menuitem', content, attributes)
|
36
|
+
end
|
37
|
+
|
38
|
+
def noscript(content = nil, **attributes)
|
39
|
+
pagebuilder_basic_element('noscript', content, attributes)
|
40
|
+
end
|
41
|
+
|
42
|
+
def progress(content = nil, **attributes)
|
43
|
+
pagebuilder_basic_element('progress', content, attributes)
|
44
|
+
end
|
45
|
+
|
46
|
+
def script(content = nil, **attributes)
|
47
|
+
pagebuilder_basic_element('script', content, attributes)
|
48
|
+
end
|
49
|
+
|
50
|
+
def style(content = nil, **attributes)
|
51
|
+
pagebuilder_basic_element('style', content, attributes)
|
52
|
+
end
|
53
|
+
|
54
|
+
def template(content = nil, **attributes)
|
55
|
+
pagebuilder_basic_element('template', content, attributes)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageBuilder
|
4
|
+
module TagHelpers
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def article(content = nil, **attributes)
|
9
|
+
pagebuilder_basic_element('article', content, attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
def aside(content = nil, **attributes)
|
13
|
+
pagebuilder_basic_element('aside', content, attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def div(content = nil, **attributes)
|
17
|
+
pagebuilder_basic_element('div', content, attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def footer(content = nil, **attributes)
|
21
|
+
pagebuilder_basic_element('footer', content, attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def h1(content = nil, **attributes)
|
25
|
+
pagebuilder_basic_element('h1', content, attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
def h2(content = nil, **attributes)
|
29
|
+
pagebuilder_basic_element('h2', content, attributes)
|
30
|
+
end
|
31
|
+
|
32
|
+
def h3(content = nil, **attributes)
|
33
|
+
pagebuilder_basic_element('h3', content, attributes)
|
34
|
+
end
|
35
|
+
|
36
|
+
def h4(content = nil, **attributes)
|
37
|
+
pagebuilder_basic_element('h4', content, attributes)
|
38
|
+
end
|
39
|
+
|
40
|
+
def h5(content = nil, **attributes)
|
41
|
+
pagebuilder_basic_element('h5', content, attributes)
|
42
|
+
end
|
43
|
+
|
44
|
+
def h6(content = nil, **attributes)
|
45
|
+
pagebuilder_basic_element('h6', content, attributes)
|
46
|
+
end
|
47
|
+
|
48
|
+
def header(content = nil, **attributes)
|
49
|
+
pagebuilder_basic_element('header', content, attributes)
|
50
|
+
end
|
51
|
+
|
52
|
+
def hgroup(content = nil, **attributes)
|
53
|
+
pagebuilder_basic_element('hgroup', content, attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def main(content = nil, **attributes)
|
57
|
+
pagebuilder_basic_element('main', content, attributes)
|
58
|
+
end
|
59
|
+
|
60
|
+
def nav(content = nil, **attributes)
|
61
|
+
pagebuilder_basic_element('nav', content, attributes)
|
62
|
+
end
|
63
|
+
|
64
|
+
def section(content = nil, **attributes)
|
65
|
+
pagebuilder_basic_element('section', content, attributes)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|