hackathon-starter-ui-rails 0.0.2.1 → 0.0.3.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5b9a5b8766b4f3f66ba872e1ce8184c857231a2
|
4
|
+
data.tar.gz: a7eccf0ed6e3c875cfc5911a8a3919dc2f6fbce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45a5daf5052eff3f02cd7d64de2a9b70e063a862fed51a3822979883b0ba8eb77cd9eff8cb4eb52d2aa019965a2dd94b3bc6f18cf88a0d144b3e96ec2ead09ef
|
7
|
+
data.tar.gz: 92141cfb02939d203e306f332fb42b71dea1a5bc5d8298561dd26e12b1813d750f96f512919c22c1c9809f0124ce2c396595f4906da6f70513375f48ccc8f058
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hackathon-starter-ui-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- steigr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -185,8 +185,6 @@ files:
|
|
185
185
|
- app/assets/stylesheets/hackathon-starter-ui-rails/themes/default.scss
|
186
186
|
- app/assets/stylesheets/hackathon-starter-ui-rails/themes/ios7.scss
|
187
187
|
- app/assets/stylesheets/hackathon-starter-ui-rails/themes/modern.scss
|
188
|
-
- app/controllers/concerns/hackathon_starter_helper_navigatable.rb
|
189
|
-
- app/models/hackathon_starter_navigator.rb
|
190
188
|
- lib/hackathon-starter-ui-rails.rb
|
191
189
|
- lib/hackathon/starter/ui/rails.rb
|
192
190
|
- lib/hackathon/starter/ui/rails/engine.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Hackathon
|
2
|
-
module Starter
|
3
|
-
module Helper
|
4
|
-
module Navigatable
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
Rails.logger.info "Naviation for #{name}"
|
8
|
-
class_attribute :navigatable
|
9
|
-
class_attribute :navigation
|
10
|
-
self.navigatable = true
|
11
|
-
self.navigation = Hackathon::Starter::Navigator.instance
|
12
|
-
end
|
13
|
-
# module ClassMethods
|
14
|
-
# def navigation_item position, path='#', label=nil
|
15
|
-
# Hackathon::Starter::Navigator.instance.add << {position: position, path: path, label: label}
|
16
|
-
# end
|
17
|
-
# def navigation_items
|
18
|
-
# Hackathon::Starter::Navigator.instance.all
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
|
-
module Hackathon
|
4
|
-
module Starter
|
5
|
-
class MenuItem
|
6
|
-
include ActiveModel::Model
|
7
|
-
attr_accessor :position
|
8
|
-
attr_accessor :label
|
9
|
-
attr_accessor :path
|
10
|
-
attr_accessor :parent
|
11
|
-
attr_accessor :children
|
12
|
-
def initialize params={}
|
13
|
-
@children ||= {}
|
14
|
-
end
|
15
|
-
def add item
|
16
|
-
if MenuItem.tail(item.position) == ''
|
17
|
-
@children[item.position] = item
|
18
|
-
else
|
19
|
-
head = MenuItem.head item.position
|
20
|
-
tail = MenuItem.tail item.position
|
21
|
-
item.position = tail
|
22
|
-
@children[head] = MenuItem.new unless @children[head]
|
23
|
-
@children[head].add item
|
24
|
-
end
|
25
|
-
end
|
26
|
-
def draw root=false
|
27
|
-
output = []
|
28
|
-
if root
|
29
|
-
output << "<div class='navbar navbar-default navbar-fixed-top' role='navigation'>"
|
30
|
-
output << "<div class='container'>"
|
31
|
-
output << "<div class='navbar-header'>"
|
32
|
-
output << "<button class='navbar-toggle' type='button' data-toggle='collapse' data-target='.navbar-collapse'>"
|
33
|
-
output << "<span class='sr-only'>Toggle Navigation</span>"
|
34
|
-
output << "<span class='icon-bar'></span>"
|
35
|
-
output << "<span class='icon-bar'></span>"
|
36
|
-
output << "<span class='icon-bar'></span>"
|
37
|
-
output << "</button>"
|
38
|
-
url = Rails.application.routes.url_helpers.send((path.to_s + "_path").to_sym)
|
39
|
-
output << "<a href='#{url}' class='navbar-brand'>"
|
40
|
-
output << label
|
41
|
-
output << "</a>"
|
42
|
-
output << "</div>"
|
43
|
-
output << "<div class='collapse navbar-collapse'>"
|
44
|
-
output << "<ul class='nav navbar-nav'>"
|
45
|
-
@children.each do |label,child|
|
46
|
-
output << child.draw
|
47
|
-
end
|
48
|
-
output << "</ul>"
|
49
|
-
output << "</div>"
|
50
|
-
output << "</div>"
|
51
|
-
output << "</div>"
|
52
|
-
else
|
53
|
-
url = Rails.application.routes.url_helpers.send((path.to_s + "_path").to_sym) rescue path
|
54
|
-
if @children.count > 0
|
55
|
-
output << "<li class='dropdown'>"
|
56
|
-
output << "<a href='#{url}' data-toggle='dropdown'>"
|
57
|
-
output << "#{label}<span class='caret'></span>"
|
58
|
-
output << "</a>"
|
59
|
-
output << "<ul class='dropdown-menu' role='menu'>"
|
60
|
-
@children.each do |label,child|
|
61
|
-
output << child.draw
|
62
|
-
end
|
63
|
-
output << "</ul>"
|
64
|
-
output << "</li>"
|
65
|
-
else
|
66
|
-
output << "<li>"
|
67
|
-
output << "<a href='#{url}'>#{@label}</a>"
|
68
|
-
output << "</li>"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
output.join
|
72
|
-
end
|
73
|
-
def to_s
|
74
|
-
"Item(#{@position}): #{label} -> #{path}"
|
75
|
-
end
|
76
|
-
class << self
|
77
|
-
def head position
|
78
|
-
return position.split('/').first if position
|
79
|
-
nil
|
80
|
-
end
|
81
|
-
def tail position
|
82
|
-
return position.split('/')[1..-1].join('/') if position
|
83
|
-
nil
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
class Navigator
|
88
|
-
include Singleton
|
89
|
-
attr_accessor :menu
|
90
|
-
def add *params
|
91
|
-
position = params.first
|
92
|
-
if params.last.class == Hash
|
93
|
-
path = params.last[:path]
|
94
|
-
label = params.last[:label]
|
95
|
-
else
|
96
|
-
path = params[1]
|
97
|
-
label = params[2]
|
98
|
-
end
|
99
|
-
path ||= '#'
|
100
|
-
@menu ||= MenuItem.new
|
101
|
-
unless position
|
102
|
-
@menu.position ||= position
|
103
|
-
@menu.path ||= path
|
104
|
-
@menu.label ||= label
|
105
|
-
else
|
106
|
-
item = MenuItem.new
|
107
|
-
item.position = position
|
108
|
-
item.path = path
|
109
|
-
item.label = label
|
110
|
-
@menu.add item
|
111
|
-
end
|
112
|
-
end
|
113
|
-
def draw
|
114
|
-
@menu.draw(root: true).html_safe
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|