markdown-ui 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Changelog +14 -0
  4. data/Gemfile +3 -0
  5. data/components/collections/markdown-ui-grid/lib/grid/column/column.rb +6 -9
  6. data/components/collections/markdown-ui-grid/lib/grid/grid.rb +6 -9
  7. data/components/collections/markdown-ui-grid/lib/grid/row/row.rb +6 -9
  8. data/components/collections/markdown-ui-grid/markdown-ui-grid.gemspec +1 -1
  9. data/components/collections/markdown-ui-menu/lib/menu/custom.rb +12 -12
  10. data/components/collections/markdown-ui-menu/lib/menu/element.rb +54 -52
  11. data/components/collections/markdown-ui-menu/lib/menu/pagination.rb +11 -10
  12. data/components/collections/markdown-ui-menu/lib/menu/pointing.rb +11 -10
  13. data/components/collections/markdown-ui-menu/lib/menu/secondary.rb +11 -10
  14. data/components/collections/markdown-ui-menu/lib/menu/standard.rb +11 -10
  15. data/components/collections/markdown-ui-menu/lib/menu/tabular.rb +11 -10
  16. data/components/collections/markdown-ui-menu/lib/menu/text.rb +11 -10
  17. data/components/collections/markdown-ui-menu/lib/menu/vertical.rb +11 -10
  18. data/components/collections/markdown-ui-message/lib/message/custom_message.rb +11 -11
  19. data/components/collections/markdown-ui-message/lib/message/list_message.rb +10 -9
  20. data/components/collections/markdown-ui-message/lib/message/message.rb +32 -29
  21. data/components/collections/markdown-ui-message/lib/message/standard_message.rb +10 -9
  22. data/components/collections/markdown-ui-message/lib/message/version.rb +1 -1
  23. data/components/collections/markdown-ui-message/markdown-ui-message.gemspec +2 -2
  24. data/components/elements/markdown-ui-button/lib/button/animated.rb +24 -22
  25. data/components/elements/markdown-ui-button/lib/button/basic.rb +14 -12
  26. data/components/elements/markdown-ui-button/lib/button/custom.rb +16 -14
  27. data/components/elements/markdown-ui-button/lib/button/element.rb +55 -53
  28. data/components/elements/markdown-ui-button/lib/button/focusable.rb +14 -12
  29. data/components/elements/markdown-ui-button/lib/button/group/buttons/custom.rb +14 -12
  30. data/components/elements/markdown-ui-button/lib/button/group/buttons/element.rb +22 -20
  31. data/components/elements/markdown-ui-button/lib/button/group/buttons/icon.rb +14 -12
  32. data/components/elements/markdown-ui-button/lib/button/group/buttons/standard.rb +14 -12
  33. data/components/elements/markdown-ui-button/lib/button/icon.rb +14 -12
  34. data/components/elements/markdown-ui-button/lib/button/labeled_icon.rb +19 -17
  35. data/components/elements/markdown-ui-button/lib/button/standard.rb +14 -12
  36. data/components/elements/markdown-ui-container/lib/container/alignment/center.rb +1 -1
  37. data/components/elements/markdown-ui-container/lib/container/alignment/left.rb +1 -1
  38. data/components/elements/markdown-ui-container/lib/container/alignment/right.rb +1 -1
  39. data/components/elements/markdown-ui-container/lib/container/custom.rb +1 -1
  40. data/components/elements/markdown-ui-container/lib/container/element.rb +5 -5
  41. data/components/elements/markdown-ui-container/lib/container/standard.rb +1 -1
  42. data/components/elements/markdown-ui-container/lib/container/text.rb +1 -1
  43. data/components/elements/markdown-ui-content/lib/content/basic_block.rb +19 -0
  44. data/components/elements/markdown-ui-content/lib/content/content_block.rb +1 -1
  45. data/components/elements/markdown-ui-content/lib/content/custom.rb +1 -1
  46. data/components/elements/markdown-ui-content/lib/content/divider_block.rb +1 -1
  47. data/components/elements/markdown-ui-content/lib/content/field_block.rb +1 -1
  48. data/components/elements/markdown-ui-content/lib/content/flag.rb +2 -2
  49. data/components/elements/markdown-ui-content/lib/content/form_block.rb +1 -1
  50. data/components/elements/markdown-ui-content/lib/content/header.rb +2 -2
  51. data/components/elements/markdown-ui-content/lib/content/header_block.rb +1 -1
  52. data/components/elements/markdown-ui-content/lib/content/icon.rb +2 -2
  53. data/components/elements/markdown-ui-content/lib/content/input_block.rb +1 -1
  54. data/components/elements/markdown-ui-content/lib/content/item.rb +4 -4
  55. data/components/elements/markdown-ui-content/lib/content/item_block.rb +1 -1
  56. data/components/elements/markdown-ui-content/lib/content/list.rb +6 -6
  57. data/components/elements/markdown-ui-content/lib/content/parser.rb +17 -17
  58. data/components/elements/markdown-ui-content/lib/content/span_block.rb +1 -1
  59. data/components/elements/markdown-ui-content/lib/content/text.rb +6 -6
  60. data/components/elements/markdown-ui-header/lib/header/header.rb +3 -3
  61. data/components/elements/markdown-ui-input/lib/input/custom.rb +4 -4
  62. data/components/elements/markdown-ui-input/lib/input/element.rb +10 -10
  63. data/components/elements/markdown-ui-label/lib/label/custom.rb +2 -2
  64. data/components/elements/markdown-ui-label/lib/label/element.rb +9 -16
  65. data/components/elements/markdown-ui-segment/lib/segment/custom_segment.rb +1 -1
  66. data/components/elements/markdown-ui-segment/lib/segment/horizontal_segment.rb +1 -1
  67. data/components/elements/markdown-ui-segment/lib/segment/padded_segment.rb +1 -1
  68. data/components/elements/markdown-ui-segment/lib/segment/piled_segment.rb +1 -1
  69. data/components/elements/markdown-ui-segment/lib/segment/segment.rb +6 -6
  70. data/components/elements/markdown-ui-segment/lib/segment/stacked_segment.rb +1 -1
  71. data/components/elements/markdown-ui-segment/lib/segment/standard_segment.rb +1 -1
  72. data/components/elements/markdown-ui-segment/lib/segment/vertical_segment.rb +1 -1
  73. data/components/shared/markdown-ui-shared/Gemfile +2 -0
  74. data/components/shared/markdown-ui-shared/lib/markdown-ui-shared.rb +3 -0
  75. data/components/shared/markdown-ui-shared/lib/shared/tag_klass.rb +77 -0
  76. data/components/shared/markdown-ui-shared/lib/shared/version.rb +5 -0
  77. data/components/shared/markdown-ui-shared/markdown-ui-shared.gemspec +37 -0
  78. data/lib/markdown-ui.rb +10 -132
  79. data/lib/markdown-ui/renderers/block_quote.rb +47 -0
  80. data/lib/markdown-ui/renderers/double_emphasis.rb +97 -0
  81. data/lib/markdown-ui/renderers/emphasis.rb +23 -0
  82. data/lib/markdown-ui/renderers/header.rb +9 -0
  83. data/lib/markdown-ui/renderers/horizontal_rule.rb +19 -0
  84. data/lib/markdown-ui/renderers/link.rb +10 -0
  85. data/lib/markdown-ui/renderers/list.rb +10 -0
  86. data/lib/markdown-ui/renderers/paragraph.rb +9 -0
  87. data/lib/markdown-ui/renderers/quote.rb +9 -0
  88. data/lib/markdown-ui/shared.rb +7 -0
  89. data/lib/markdown-ui/tag/article_tag.rb +14 -0
  90. data/lib/markdown-ui/tag/button_tag.rb +6 -19
  91. data/lib/markdown-ui/tag/custom_tag.rb +11 -10
  92. data/lib/markdown-ui/tag/focusable_button_tag.rb +6 -19
  93. data/lib/markdown-ui/tag/footer_tag.rb +14 -0
  94. data/lib/markdown-ui/tag/header_tag.rb +14 -0
  95. data/lib/markdown-ui/tag/input_tag.rb +7 -27
  96. data/lib/markdown-ui/tag/item_tag.rb +6 -14
  97. data/lib/markdown-ui/tag/label_tag.rb +6 -19
  98. data/lib/markdown-ui/tag/list_tag.rb +18 -21
  99. data/lib/markdown-ui/tag/section_tag.rb +14 -0
  100. data/lib/markdown-ui/tag/span_tag.rb +7 -7
  101. data/lib/markdown-ui/tag/standard_tag.rb +6 -19
  102. data/lib/markdown-ui/tag/tag.rb +18 -20
  103. data/lib/markdown-ui/tools/html_formatter.rb +11 -0
  104. data/lib/markdown-ui/utils/klass_util.rb +13 -3
  105. data/lib/markdown-ui/version.rb +1 -1
  106. data/website/docs/flag.html +1 -1
  107. data/website/docs/icon.html +609 -0
  108. data/website/docs/icon.md +691 -0
  109. data/website/docs/toc.html +4 -0
  110. data/website/docs/toc.md +5 -2
  111. data/website/index.html +2 -2
  112. metadata +25 -2
@@ -0,0 +1,5 @@
1
+ module MarkdownUI
2
+ module Shared
3
+ VERSION = '0.1'
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shared/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'markdown-ui-shared'
8
+ spec.version = MarkdownUI::Shared::VERSION
9
+ spec.authors = ['Joel Bryan Juliano']
10
+ spec.email = ['joelbryan.juliano@gmail.com']
11
+
12
+ spec.summary = %q{Responsive User Interfaces in Markdown}
13
+ spec.description = %q{Create responsive UI/UX for mobile and web using Markdown Syntax}
14
+ spec.homepage = 'https://github.com/jjuliano/markdown-ui'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_dependency 'bundler', '~> 1.10', '~> 1.9'
31
+ spec.add_dependency 'redcarpet', '~> 3.2'
32
+ spec.add_dependency 'nokogiri', '~> 1.6'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'test-unit', '~> 3.0'
35
+ spec.add_development_dependency 'simplecov', '~> 0.10'
36
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
37
+ end
@@ -1,12 +1,10 @@
1
1
  # coding: UTF-8
2
- require 'markdown-ui/version'
3
2
 
4
3
  require 'redcarpet'
5
4
  require 'nokogiri'
6
5
  require 'ostruct'
7
6
 
8
- require 'markdown-ui/element'
9
- require 'markdown-ui/collection'
7
+ require_relative 'markdown-ui/shared'
10
8
 
11
9
  ['markdown-ui/**/*.rb'].each do |dir|
12
10
  Dir[File.join(File.dirname(__FILE__), dir)].sort.each { |f| require_relative f }
@@ -14,124 +12,15 @@ end
14
12
 
15
13
  module MarkdownUI
16
14
  class Renderer < Redcarpet::Render::HTML
17
- include MarkdownUI::Element
18
- include MarkdownUI::Collection
19
-
20
- def hrule
21
- klass = 'ui divider'
22
- MarkdownUI::StandardTag.new(nil, klass).render
23
- end
24
-
25
- def paragraph(text)
26
- text
27
- end
28
-
29
- def emphasis(text)
30
- text =~ /icon/i ? MarkdownUI::Content::Icon.new(text).render : MarkdownUI::Content::Flag.new(text).render
31
- end
32
-
33
- def double_emphasis(text)
34
- args = text.split('|')
35
- element = args[0].split(' ')
36
-
37
- content = if args[1].strip =~ /\,/
38
- args[1].split(',')
39
- else
40
- args[1].strip
41
- end if !args[1].nil?
42
-
43
- klass = if args[0].strip =~ /\./
44
- k = args[0].split('.')
45
- k.reverse!
46
- k.shift
47
- end
48
-
49
- _id = !args[2].nil? ? args[2].downcase : nil
50
-
51
- data_attributes = !args[3].nil? ? args[3].downcase : nil
52
-
53
- html do
54
- if content
55
- case element.join(' ')
56
- when /button/i
57
- MarkdownUI::Button::Element.new(element, content, klass, _id).render
58
- when /input/i
59
- MarkdownUI::Input::Element.new(element, content, klass, _id).render
60
- when /menu/i
61
- MarkdownUI::Menu::Element.new(element, content, klass).render
62
- when /message/i
63
- MarkdownUI::Message.new(element, content, klass).render
64
- when /tag/i
65
- MarkdownUI::Tag.new(element[0].downcase, content, _id, data_attributes).render
66
- when /header/i
67
- MarkdownUI::Header.new(content, 0).render
68
- end
69
- end
70
- end
71
- end
72
-
73
- def block_quote(text)
74
- element, content = text.split(':')
75
-
76
- html do
77
- if content
78
- case element
79
- when /segment/i
80
- MarkdownUI::Segment.new(element, content).render
81
- when /grid/i
82
- MarkdownUI::Grid.new(element, content).render
83
- when /column/i
84
- MarkdownUI::Column.new(element, content).render
85
- when /container/i
86
- MarkdownUI::Container::Element.new(element, content).render
87
- when /buttons/i
88
- MarkdownUI::Button::Group::Buttons::Element.new(element, content).render
89
- when /button/i
90
- MarkdownUI::Button::Element.new(element, content).render
91
- when /menu/i
92
- MarkdownUI::Menu::Element.new(element, content).render
93
- when /message/i
94
- MarkdownUI::Message.new(element, content).render
95
- when /label/i
96
- MarkdownUI::Label::Element.new(element, content).render
97
- when /item/i
98
- MarkdownUI::Content::ItemBlock.new(element, content).render
99
- when /form/i
100
- MarkdownUI::Content::FormBlock.new(element, content).render
101
- when /field/i
102
- MarkdownUI::Content::FieldBlock.new(element, content).render
103
- when /input/i
104
- MarkdownUI::Content::InputBlock.new(element, content).render
105
- when /divider/i
106
- MarkdownUI::Content::DividerBlock.new(element, content).render
107
- when /header/i
108
- MarkdownUI::Content::HeaderBlock.new(element, content).render
109
- when /content/i
110
- MarkdownUI::Content::ContentBlock.new(element, content).render
111
- when /span/i
112
- MarkdownUI::Content::SpanBlock.new(element, content).render
113
- end
114
- end
115
- end
116
- end
117
-
118
- def list(content, list_type)
119
- klass = "ui #{list_type}"
120
- html { MarkdownUI::Content::List.new(content, klass, list_type).render }
121
- end
122
-
123
- def link(link, klass, content)
124
- _klass = "ui #{klass}"
125
- html { MarkdownUI::Content::Item.new(content, _klass, link).render }
126
- end
127
-
128
- def quote(text)
129
- html { "<p>#{text}</p>" }
130
- end
131
-
132
- def header(text, level)
133
- html { MarkdownUI::Header.new(text, level).render }
134
- end
15
+ include MarkdownUI::Renderers::Header
16
+ include MarkdownUI::Renderers::Quote
17
+ include MarkdownUI::Renderers::Link
18
+ include MarkdownUI::Renderers::List
19
+ include MarkdownUI::Renderers::BlockQuote
20
+ include MarkdownUI::Renderers::DoubleEmphasis
21
+ include MarkdownUI::Renderers::Emphasis
22
+ include MarkdownUI::Renderers::Paragraph
23
+ include MarkdownUI::Renderers::HorizontalRule
135
24
 
136
25
  protected
137
26
 
@@ -140,16 +29,5 @@ module MarkdownUI
140
29
  HTMLFormatter.new(yield).to_html
141
30
  end
142
31
  end
143
-
144
- end
145
-
146
- class HTMLFormatter
147
- def initialize(text)
148
- @doc = Nokogiri::XML(text, &:noblanks).to_xhtml(indent: 2)
149
- end
150
-
151
- def to_html
152
- @doc
153
- end
154
32
  end
155
33
  end
@@ -0,0 +1,47 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module BlockQuote
4
+ def block_quote(text)
5
+ element, content = text.split(':')
6
+ @params = element.split
7
+
8
+ @elements = Hash.new(MarkdownUI::Content::BasicBlock).merge(
9
+ button: MarkdownUI::Button::Element,
10
+ segment: MarkdownUI::Segment,
11
+ grid: MarkdownUI::Grid,
12
+ column: MarkdownUI::Column,
13
+ container: MarkdownUI::Container::Element,
14
+ buttons: MarkdownUI::Button::Group::Buttons::Element,
15
+ label: MarkdownUI::Label::Element,
16
+ span: MarkdownUI::Content::SpanBlock,
17
+ content: MarkdownUI::Content::ContentBlock,
18
+ divider: MarkdownUI::Content::DividerBlock,
19
+ field: MarkdownUI::Content::FieldBlock,
20
+ form: MarkdownUI::Content::FormBlock,
21
+ item: MarkdownUI::Content::ItemBlock,
22
+ tag: MarkdownUI::Tag,
23
+ menu: MarkdownUI::Menu::Element,
24
+ message: MarkdownUI::Message::Element,
25
+ input: MarkdownUI::Content::InputBlock,
26
+ header: MarkdownUI::Content::HeaderBlock
27
+ )
28
+
29
+ html { @elements[key].new(element, content).render } if content
30
+ end
31
+
32
+ protected
33
+
34
+ def regexp
35
+ Regexp.new (@params.collect { |u| u.downcase }).join('|'), "i"
36
+ end
37
+
38
+ def key
39
+ keys.grep(regexp).first
40
+ end
41
+
42
+ def keys
43
+ @elements.keys
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,97 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module DoubleEmphasis
4
+ def double_emphasis(text)
5
+ @text = text
6
+
7
+ html do
8
+ case combined_elements
9
+ when /button/i
10
+ render_button
11
+ when /input/i
12
+ render_input
13
+ when /menu/i
14
+ render_menu
15
+ when /message/i
16
+ render_message
17
+ when /tag/i
18
+ render_tag
19
+ when /header/i
20
+ render_header
21
+ end if content
22
+ end
23
+ end
24
+
25
+ protected
26
+
27
+ def render_header
28
+ MarkdownUI::Header.new(content, 0).render
29
+ end
30
+
31
+ def render_tag
32
+ MarkdownUI::Tag.new(first_element, content, _id, data_attributes).render
33
+ end
34
+
35
+ def first_element
36
+ element[0].downcase
37
+ end
38
+
39
+ def render_message
40
+ MarkdownUI::Message::Element.new(element, content, klass).render
41
+ end
42
+
43
+ def render_menu
44
+ MarkdownUI::Menu::Element.new(element, content, klass).render
45
+ end
46
+
47
+ def render_input
48
+ MarkdownUI::Input::Element.new(element, content, klass, _id).render
49
+ end
50
+
51
+ def render_button
52
+ MarkdownUI::Button::Element.new(element, content, klass, _id).render
53
+ end
54
+
55
+ def data_attributes
56
+ !args[3].nil? ? args[3].downcase : nil
57
+ end
58
+
59
+ def _id
60
+ !args[2].nil? ? args[2].downcase : nil
61
+ end
62
+
63
+ def klass
64
+ if args.is_a? Array
65
+ if args[0].strip =~ /\./
66
+ k = args[0].split('.')
67
+ k.reverse!
68
+ k.shift
69
+ end
70
+ end
71
+ end
72
+
73
+ def content
74
+ if args.is_a? Array
75
+ if args[1].strip =~ /\,/
76
+ args[1].split(',')
77
+ else
78
+ args[1].strip
79
+ end if !args[1].nil?
80
+ end
81
+ end
82
+
83
+ def element
84
+ args[0].split(' ') if args.is_a? Array
85
+ end
86
+
87
+ def args
88
+ @text.split('|') if @text
89
+ end
90
+
91
+ def combined_elements
92
+ element.join(' ')
93
+ end
94
+ end
95
+ end
96
+ end
97
+
@@ -0,0 +1,23 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module Emphasis
4
+ def emphasis(text)
5
+ is_icon?(text) ? render_icon(text) : render_flag(text)
6
+ end
7
+
8
+ protected
9
+
10
+ def render_flag(text)
11
+ MarkdownUI::Content::Flag.new(text).render
12
+ end
13
+
14
+ def render_icon(text)
15
+ MarkdownUI::Content::Icon.new(text).render
16
+ end
17
+
18
+ def is_icon?(text)
19
+ text =~ /icon/i
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module Header
4
+ def header(text, level)
5
+ html { MarkdownUI::Header.new(text, level).render }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module HorizontalRule
4
+ def hrule
5
+ render_standard_tag
6
+ end
7
+
8
+ protected
9
+
10
+ def render_standard_tag
11
+ MarkdownUI::StandardTag.new(nil, divider_klass).render
12
+ end
13
+
14
+ def divider_klass
15
+ 'ui divider'
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module Link
4
+ def link(link, klass, content)
5
+ _klass = "ui #{klass}"
6
+ html { MarkdownUI::Content::Item.new(content, _klass, link).render }
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module List
4
+ def list(content, list_type)
5
+ klass = "ui #{list_type}"
6
+ html { MarkdownUI::Content::List.new(content, klass, list_type).render }
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module Paragraph
4
+ def paragraph(text)
5
+ text
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module MarkdownUI
2
+ module Renderers
3
+ module Quote
4
+ def quote(text)
5
+ html { "<p>#{text}</p>" }
6
+ end
7
+ end
8
+ end
9
+ end