markdown-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +3 -0
  4. data/CODE_OF_CONDUCT.md +13 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +19 -0
  8. data/Rakefile +10 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/exe/markdown-ui +37 -0
  12. data/lib/markdown-ui.rb +130 -0
  13. data/lib/markdown-ui/button/animated.rb +22 -0
  14. data/lib/markdown-ui/button/basic.rb +17 -0
  15. data/lib/markdown-ui/button/custom.rb +20 -0
  16. data/lib/markdown-ui/button/element.rb +59 -0
  17. data/lib/markdown-ui/button/focusable.rb +23 -0
  18. data/lib/markdown-ui/button/group/buttons/custom.rb +21 -0
  19. data/lib/markdown-ui/button/group/buttons/element.rb +28 -0
  20. data/lib/markdown-ui/button/group/buttons/icon.rb +19 -0
  21. data/lib/markdown-ui/button/group/buttons/standard.rb +19 -0
  22. data/lib/markdown-ui/button/icon.rb +17 -0
  23. data/lib/markdown-ui/button/labeled_icon.rb +23 -0
  24. data/lib/markdown-ui/button/standard.rb +17 -0
  25. data/lib/markdown-ui/container/alignment/center.rb +19 -0
  26. data/lib/markdown-ui/container/alignment/left.rb +19 -0
  27. data/lib/markdown-ui/container/alignment/right.rb +19 -0
  28. data/lib/markdown-ui/container/custom.rb +17 -0
  29. data/lib/markdown-ui/container/element.rb +38 -0
  30. data/lib/markdown-ui/container/standard.rb +17 -0
  31. data/lib/markdown-ui/container/text.rb +17 -0
  32. data/lib/markdown-ui/content/custom.rb +16 -0
  33. data/lib/markdown-ui/content/header.rb +19 -0
  34. data/lib/markdown-ui/content/icon.rb +24 -0
  35. data/lib/markdown-ui/content/item.rb +21 -0
  36. data/lib/markdown-ui/content/list.rb +23 -0
  37. data/lib/markdown-ui/content/parser.rb +66 -0
  38. data/lib/markdown-ui/content/text.rb +24 -0
  39. data/lib/markdown-ui/divider/element.rb +0 -0
  40. data/lib/markdown-ui/divider/hidden.rb +0 -0
  41. data/lib/markdown-ui/divider/standard.rb +0 -0
  42. data/lib/markdown-ui/grid/column/column.rb +18 -0
  43. data/lib/markdown-ui/grid/grid.rb +18 -0
  44. data/lib/markdown-ui/grid/row/row.rb +18 -0
  45. data/lib/markdown-ui/header/header.rb +30 -0
  46. data/lib/markdown-ui/label/custom.rb +20 -0
  47. data/lib/markdown-ui/label/element.rb +34 -0
  48. data/lib/markdown-ui/menu/custom.rb +20 -0
  49. data/lib/markdown-ui/menu/element.rb +62 -0
  50. data/lib/markdown-ui/menu/pagination.rb +17 -0
  51. data/lib/markdown-ui/menu/pointing.rb +17 -0
  52. data/lib/markdown-ui/menu/secondary.rb +17 -0
  53. data/lib/markdown-ui/menu/standard.rb +17 -0
  54. data/lib/markdown-ui/menu/tabular.rb +17 -0
  55. data/lib/markdown-ui/menu/text.rb +17 -0
  56. data/lib/markdown-ui/menu/vertical.rb +17 -0
  57. data/lib/markdown-ui/message/custom_message.rb +20 -0
  58. data/lib/markdown-ui/message/list_message.rb +17 -0
  59. data/lib/markdown-ui/message/message.rb +40 -0
  60. data/lib/markdown-ui/message/standard_message.rb +17 -0
  61. data/lib/markdown-ui/segment/custom_segment.rb +18 -0
  62. data/lib/markdown-ui/segment/horizontal_segment.rb +16 -0
  63. data/lib/markdown-ui/segment/padded_segment.rb +16 -0
  64. data/lib/markdown-ui/segment/piled_segment.rb +16 -0
  65. data/lib/markdown-ui/segment/segment.rb +34 -0
  66. data/lib/markdown-ui/segment/stacked_segment.rb +16 -0
  67. data/lib/markdown-ui/segment/standard_segment.rb +16 -0
  68. data/lib/markdown-ui/segment/vertical_segment.rb +16 -0
  69. data/lib/markdown-ui/tag/custom_tag.rb +25 -0
  70. data/lib/markdown-ui/tag/item_tag.rb +24 -0
  71. data/lib/markdown-ui/tag/list_tag.rb +40 -0
  72. data/lib/markdown-ui/tag/span_tag.rb +14 -0
  73. data/lib/markdown-ui/tag/standard_tag.rb +23 -0
  74. data/lib/markdown-ui/tag/tag.rb +37 -0
  75. data/lib/markdown-ui/utils/klass_util.rb +11 -0
  76. data/lib/markdown-ui/version.rb +3 -0
  77. data/markdown-ui.gemspec +36 -0
  78. data/website/index.html +369 -0
  79. data/website/index.md +389 -0
  80. metadata +208 -0
@@ -0,0 +1,28 @@
1
+ module MarkdownUI::Button
2
+ module Group
3
+ module Buttons
4
+ class Element
5
+ def initialize(element, content)
6
+ @element = element
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ element = @element.strip
12
+ content = @content.strip
13
+ mode = OpenStruct.new(
14
+ :icon? => !(element =~ /icon/i).nil?
15
+ )
16
+
17
+ if element.length == "buttons".length
18
+ MarkdownUI::Button::Group::Buttons::Standard.new(element, content).render
19
+ elsif mode.icon?
20
+ MarkdownUI::Button::Group::Buttons::Icon.new(element, content).render
21
+ else
22
+ MarkdownUI::Button::Group::Buttons::Custom.new(element, content).render
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ module MarkdownUI::Button
2
+ module Group
3
+ module Buttons
4
+ class Icon
5
+ def initialize(element, content)
6
+ @element = element
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ klass = "ui #{@element} icon buttons"
12
+ content = @content.strip
13
+
14
+ MarkdownUI::StandardTag.new(content, klass).render
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module MarkdownUI::Button
2
+ module Group
3
+ module Buttons
4
+ class Standard
5
+ def initialize(element, content)
6
+ @element = element
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ klass = "ui #{@element} buttons"
12
+ content = @content.strip
13
+
14
+ MarkdownUI::StandardTag.new(content, klass).render
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Button
4
+ class Icon
5
+ def initialize(content, klass = nil)
6
+ @klass = klass
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ content = MarkdownUI::Content::Parser.new(@content).parse
12
+ klass = "ui #{@klass} icon button"
13
+
14
+ MarkdownUI::StandardTag.new(content, klass).render
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Button
4
+ class LabeledIcon
5
+ def initialize(icon, label, klass = nil)
6
+ @klass = klass
7
+ @icon = icon
8
+ @label = label
9
+ end
10
+
11
+ def render
12
+ icon = MarkdownUI::Content::Parser.new(@icon).parse
13
+ label = MarkdownUI::Content::Parser.new(@label).parse
14
+ klass = "ui #{@klass} labeled icon button"
15
+
16
+ content = []
17
+ content << icon
18
+ content << label
19
+
20
+ MarkdownUI::StandardTag.new(content.join, klass).render
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Button
4
+ class Standard
5
+ def initialize(content, klass = nil)
6
+ @klass = klass
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ klass = "ui #{@klass} button"
12
+ content = MarkdownUI::Content::Parser.new(@content).parse
13
+
14
+ MarkdownUI::StandardTag.new(content, klass).render
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Container
4
+ module Alignment
5
+ class Center
6
+ def initialize(element, content)
7
+ @element = element
8
+ @content = content
9
+ end
10
+
11
+ def render
12
+ klass = "ui #{@element} center aligned container"
13
+ content = @content.strip
14
+
15
+ MarkdownUI::StandardTag.new(content, klass).render
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Container
4
+ module Alignment
5
+ class Left
6
+ def initialize(element, content)
7
+ @element = element
8
+ @content = content
9
+ end
10
+
11
+ def render
12
+ klass = "ui #{@element} left aligned container"
13
+ content = @content.strip
14
+
15
+ MarkdownUI::StandardTag.new(content, klass).render
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Container
4
+ module Alignment
5
+ class Right
6
+ def initialize(element, content)
7
+ @element = element
8
+ @content = content
9
+ end
10
+
11
+ def render
12
+ klass = "ui #{@element} right aligned container"
13
+ content = @content.strip
14
+
15
+ MarkdownUI::StandardTag.new(content, klass).render
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Container
4
+ class Custom
5
+ def initialize(element, content)
6
+ @element = element
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ klass = "ui #{@element} container"
12
+ content = @content.strip
13
+
14
+ MarkdownUI::StandardTag.new(content, klass).render
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,38 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Container
4
+ class Element
5
+ def initialize(element, content)
6
+ @element = element
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ element = @element.strip
12
+ content = @content.strip
13
+
14
+ mode = OpenStruct.new(
15
+ :text? => !(element =~ /text/i).nil?,
16
+ :left? => !(element =~ /left/i).nil?,
17
+ :right? => !(element =~ /right/i).nil?,
18
+ :center? => !(element =~ /center/i).nil?,
19
+ :aligned? => !(element =~ /aligned/i).nil?
20
+ )
21
+
22
+ if element.length == "container".length
23
+ MarkdownUI::Container::Standard.new(element, content).render
24
+ elsif mode.left? && mode.aligned?
25
+ MarkdownUI::Container::Alignment::Left.new(element, content).render
26
+ elsif mode.right? && mode.aligned?
27
+ MarkdownUI::Container::Alignment::Right.new(element, content).render
28
+ elsif mode.center? && mode.aligned?
29
+ MarkdownUI::Container::Alignment::Center.new(element, content).render
30
+ elsif mode.text?
31
+ MarkdownUI::Container::Text.new(element, content).render
32
+ else
33
+ MarkdownUI::Container::Custom.new(element, content).render
34
+ end
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Container
4
+ class Standard
5
+ def initialize(element, content)
6
+ @element = element
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ klass = "ui #{@element} container"
12
+ content = @content.strip
13
+
14
+ MarkdownUI::StandardTag.new(content, klass).render
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI::Container
4
+ class Text
5
+ def initialize(element, content)
6
+ @element = element
7
+ @content = content
8
+ end
9
+
10
+ def render
11
+ klass = "ui #{@element} text container"
12
+ content = @content.strip
13
+
14
+ MarkdownUI::StandardTag.new(content, klass).render
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI
4
+ module Content
5
+ class Custom
6
+ def initialize(content, klass = nil)
7
+ @content = content
8
+ @klass = klass
9
+ end
10
+
11
+ def render
12
+ @content.strip
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI
4
+ module Content
5
+ class Header
6
+ def initialize(content, klass = nil)
7
+ @content = content
8
+ @klass = klass
9
+ end
10
+
11
+ def render
12
+ klass = "#{@klass} header"
13
+ content = @content.strip
14
+
15
+ MarkdownUI::StandardTag.new(content, klass).render
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI
4
+ module Content
5
+ class Icon
6
+ def initialize(content, klass = nil)
7
+ @content = content
8
+ @klass = klass
9
+ end
10
+
11
+ def render
12
+ content = @content.downcase
13
+ klass = MarkdownUI::KlassUtil.new("#{@content} #{@klass} icon").klass
14
+
15
+ output = []
16
+ output << "<i"
17
+ output << klass
18
+ output << "></i>"
19
+
20
+ output.join
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI
4
+ module Content
5
+ class Item
6
+ def initialize(content, klass = nil, link = nil)
7
+ @content = content
8
+ @klass = klass
9
+ @link = link
10
+ end
11
+
12
+ def render
13
+ klass = "#{@klass} item"
14
+ content = @content.strip
15
+ link = @link
16
+
17
+ MarkdownUI::ItemTag.new(content, klass, link).render
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # coding: UTF-8
2
+
3
+ module MarkdownUI
4
+ module Content
5
+ class List
6
+ def initialize(content, klass = nil, type = nil, data = nil)
7
+ @content = content
8
+ @klass = klass
9
+ @type = type
10
+ @data = data
11
+ end
12
+
13
+ def render
14
+ klass = "#{@klass} list"
15
+ content = @content.strip
16
+ type = @type
17
+ data = @data
18
+
19
+ MarkdownUI::ListTag.new(content, klass, type, data).render
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,66 @@
1
+ # coding: UTF-8
2
+ require 'ostruct'
3
+
4
+ module MarkdownUI
5
+ module Content
6
+ class Parser
7
+ def initialize(content = nil)
8
+ @content = content
9
+ end
10
+
11
+ def parse
12
+ if @content.is_a? Array
13
+ final_content = []
14
+
15
+ @content.each do |c|
16
+ content = c.split(":")
17
+ final_content << process(content)
18
+ end
19
+
20
+ final_content.join
21
+ else
22
+ content = if !(@content =~ /\:/).nil?
23
+ @content.split(":")
24
+ else
25
+ @content.split("\n")
26
+ end
27
+
28
+ process(content)
29
+ end
30
+ end
31
+
32
+ def process(content)
33
+ content_type, actual_content = content[0], content[1]
34
+ klass = content[2] if content.size > 2
35
+
36
+ mode = OpenStruct.new(
37
+ :text? => !(content_type =~ /text/i).nil?,
38
+ :icon? => !(content_type =~ /icon/i).nil?,
39
+ :flag? => !(content_type =~ /flag/i).nil?,
40
+ :image? => !(content_type =~ /image/i).nil?,
41
+ :header? => !(content_type =~ /header/i).nil?,
42
+ :list? => !(content_type =~ /list/i).nil?,
43
+ :unordered? => !(content_type =~ /unordered/i).nil?,
44
+ :ordered? => !(content_type =~ /ordered/i).nil?
45
+ )
46
+
47
+ if mode.text?
48
+ MarkdownUI::Content::Text.new(actual_content, klass).render
49
+ elsif mode.icon?
50
+ MarkdownUI::Content::Icon.new(actual_content, klass).render
51
+ elsif mode.header?
52
+ MarkdownUI::Content::Header.new(actual_content, klass).render
53
+ elsif mode.list? && mode.ordered?
54
+ MarkdownUI::Content::List.new(actual_content, klass, :ordered).render
55
+ elsif mode.list? && mode.unordered?
56
+ MarkdownUI::Content::List.new(actual_content, klass, :unordered).render
57
+ elsif mode.list?
58
+ MarkdownUI::Content::List.new(actual_content, klass).render
59
+ else
60
+ MarkdownUI::Content::Custom.new(content.join(" "), klass).render
61
+ end
62
+ end
63
+
64
+ end
65
+ end
66
+ end