tree_html 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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +26 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/tree_html/tree_html.css +88 -0
- data/lib/tree_html/version.rb +3 -0
- data/lib/tree_html.rb +31 -0
- data/tree_html.gemspec +26 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 32e02a7a7197313a2373e84da8c2f3749ff37861
|
4
|
+
data.tar.gz: 6ce9b46ee6beda93e6600d744095c2174b9f768c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c701672785acb2a3184878705877c62eeee4c031b3f7101cc0e5d1981596fa737ad91f047e7e15e6b6aa45d71620043b4f81c40b669eb15aafc08b36d2569da1
|
7
|
+
data.tar.gz: af7d0900a0b7a083975561b920229b0e74fe329f3562b350b5b228f790f0b3836eee5fe8025eb39de651f03000d659c92b43e91a64c3c8d7565e98fc4ea57cec
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 ken
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# TreeHtml
|
2
|
+
|
3
|
+
Generate plain css tree structure.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'tree_html'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install tree_html
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In Node class, `include TreeHtml`, then implement `label_for_tree_graph` and `children_for_tree_graph`, then call`tree_html` on node object to get ul/li fragment, or `tree_html_full` to get a html file with pre-defined style.
|
24
|
+
|
25
|
+
Or checkout [test/tree_html_test.rb](https://github.com/turnon/tree_html/blob/master/test/tree_html_test.rb) to see how to use.
|
26
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tree_html"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
body {
|
2
|
+
font-family: 'Dejavu Sans Mono', 'Arial', sans-serif;
|
3
|
+
}
|
4
|
+
|
5
|
+
* {
|
6
|
+
margin: 0;
|
7
|
+
padding: 0;
|
8
|
+
}
|
9
|
+
|
10
|
+
.tree-html ul {
|
11
|
+
margin-left: 15px;
|
12
|
+
}
|
13
|
+
|
14
|
+
.tree-html li {
|
15
|
+
list-style-type: none;
|
16
|
+
margin: 10px;
|
17
|
+
position: relative;
|
18
|
+
}
|
19
|
+
|
20
|
+
.tree-html li::before {
|
21
|
+
content: "";
|
22
|
+
position: absolute;
|
23
|
+
top: -7px;
|
24
|
+
left: -15px;
|
25
|
+
border-left: 1px dotted #ccc;
|
26
|
+
border-bottom: 1px dotted #ccc;
|
27
|
+
width: 15px;
|
28
|
+
height: 15px;
|
29
|
+
}
|
30
|
+
|
31
|
+
.tree-html li::after {
|
32
|
+
position: absolute;
|
33
|
+
content: "";
|
34
|
+
top: 8px;
|
35
|
+
left: -15px;
|
36
|
+
border-left: 1px dotted #ccc;
|
37
|
+
width: 15px;
|
38
|
+
height: 100%;
|
39
|
+
}
|
40
|
+
|
41
|
+
.tree-html li:last-child::after {
|
42
|
+
display: none;
|
43
|
+
}
|
44
|
+
|
45
|
+
ul.tree-html>li:first-child::before {
|
46
|
+
display: none;
|
47
|
+
}
|
48
|
+
|
49
|
+
.tree-html li a {
|
50
|
+
padding: 2px 5px;
|
51
|
+
}
|
52
|
+
|
53
|
+
.tree-html li a:hover, .tree-html li a:hover+ul li a,
|
54
|
+
.tree-html li a:focus, .tree-html li a:focus+ul li a {
|
55
|
+
background: gray;
|
56
|
+
}
|
57
|
+
|
58
|
+
.tree-html label {
|
59
|
+
margin: 0 0 0 5px;
|
60
|
+
border: 1px solid #ccc;
|
61
|
+
width: .6em;
|
62
|
+
height: .6em;
|
63
|
+
display: inline-block;
|
64
|
+
line-height: .65;
|
65
|
+
}
|
66
|
+
|
67
|
+
.tree-html label::before {
|
68
|
+
color: #ccc;
|
69
|
+
font-family: serif;
|
70
|
+
margin-left: 0.02em;
|
71
|
+
}
|
72
|
+
|
73
|
+
input[type='checkbox'] {
|
74
|
+
margin-left: 5px;
|
75
|
+
display: none
|
76
|
+
}
|
77
|
+
|
78
|
+
input[type='checkbox']:checked ~ ul {
|
79
|
+
display: none
|
80
|
+
}
|
81
|
+
|
82
|
+
input[type="checkbox"] + label::before {
|
83
|
+
content: '-';
|
84
|
+
}
|
85
|
+
|
86
|
+
input[type="checkbox"]:checked + label::before {
|
87
|
+
content: '+';
|
88
|
+
}
|
data/lib/tree_html.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "tree_html/version"
|
2
|
+
|
3
|
+
module TreeHtml
|
4
|
+
def tree_html
|
5
|
+
"<ul class='tree-html'>#{li}</ul>"
|
6
|
+
end
|
7
|
+
|
8
|
+
def tree_html_full custom_css=''
|
9
|
+
"<!DOCTYPE HTML><html><head><meta charset='utf-8'/><style>#{css(custom_css)}</style></head><body>#{tree_html}</body></html>"
|
10
|
+
end
|
11
|
+
|
12
|
+
Css = File.expand_path('../tree_html/tree_html.css', __FILE__)
|
13
|
+
|
14
|
+
def css addition=''
|
15
|
+
File.read(Css) + addition
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def li
|
21
|
+
"<li>#{checkbox}<a>#{label_for_tree_html}</a>#{sub_ul}</li>"
|
22
|
+
end
|
23
|
+
|
24
|
+
def checkbox
|
25
|
+
children_for_tree_html.empty? ? '' : "<input type='checkbox' id='#{object_id}'><label for='#{object_id}'></label>"
|
26
|
+
end
|
27
|
+
|
28
|
+
def sub_ul
|
29
|
+
children_for_tree_html.empty? ? '' : "<ul>#{children_for_tree_html.map{|c| c.li}.join}</ul>"
|
30
|
+
end
|
31
|
+
end
|
data/tree_html.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tree_html/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tree_html"
|
8
|
+
spec.version = TreeHtml::VERSION
|
9
|
+
spec.authors = ["ken"]
|
10
|
+
spec.email = ["block24block@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{generate plain css tree structure}
|
13
|
+
spec.homepage = "https://github.com/turnon/tree_html"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tree_html
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ken
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- block24block@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/tree_html.rb
|
71
|
+
- lib/tree_html/tree_html.css
|
72
|
+
- lib/tree_html/version.rb
|
73
|
+
- tree_html.gemspec
|
74
|
+
homepage: https://github.com/turnon/tree_html
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.6.8
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: generate plain css tree structure
|
98
|
+
test_files: []
|