tusur_header 0.2.1 → 0.2.2
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 +4 -4
- data/config/locales/ru.yml +9 -0
- data/config/sites.yml +1 -1
- data/lib/tusur_header.rb +1 -0
- data/lib/tusur_header/menu_links.rb +147 -0
- data/lib/tusur_header/version.rb +1 -1
- data/tusur_header.gemspec +2 -1
- metadata +21 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c4902fd855ace3aee87f97d124f7abdd1ce9919
|
4
|
+
data.tar.gz: 3d56cc77251c384aceff52ccfd3ee1fd5a4ee854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a6179774eeb7f605736009e9b19b9464ce054be0f50ac763ad8d64ca0f538d0b19f20ebee69997fe7f71e8ee63af2f6fa82d9359480fdfd70bdf789336a5eac
|
7
|
+
data.tar.gz: 35d74ca90b7febecf5c1b71117633c500cd5ba7a49910f0929bde0c2d79f7951ad276de10469d81f6cc8b7d538b94238cfc039ed55b7713a3b14a60782e6beca
|
@@ -0,0 +1,9 @@
|
|
1
|
+
ru:
|
2
|
+
remote_system:
|
3
|
+
abiturient: Сайт для абитуриента ТУСУР
|
4
|
+
attendance: Журнал успеваемости
|
5
|
+
checkpoint: Ввод успеваемости
|
6
|
+
directory: Телефонный справочник
|
7
|
+
gpo: Групповое проектное обучение
|
8
|
+
timetable: Расписание занятий
|
9
|
+
work_program: Генератор рабочих программ
|
data/config/sites.yml
CHANGED
data/lib/tusur_header.rb
CHANGED
@@ -0,0 +1,147 @@
|
|
1
|
+
module TusurHeader
|
2
|
+
class Link
|
3
|
+
include ActionView::Helpers
|
4
|
+
|
5
|
+
attr_accessor :title, :url, :options
|
6
|
+
|
7
|
+
def initialize(title, url, options, separator)
|
8
|
+
@title, @url, @options, @separator = title, url, options, separator
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
(separator? ? separator : link) rescue ''
|
13
|
+
end
|
14
|
+
|
15
|
+
def link
|
16
|
+
content_tag :li, link_to(title, url, options).html_safe
|
17
|
+
end
|
18
|
+
|
19
|
+
def separator?
|
20
|
+
!!@separator
|
21
|
+
end
|
22
|
+
|
23
|
+
def separator
|
24
|
+
content_tag :li, nil, :class => 'divider'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Links
|
29
|
+
include ActionView::Helpers
|
30
|
+
|
31
|
+
attr_accessor :user
|
32
|
+
delegate :uid, :teacher?, :student?, :app_name, :to => :user
|
33
|
+
|
34
|
+
def initialize(user)
|
35
|
+
@user = user
|
36
|
+
end
|
37
|
+
|
38
|
+
def links
|
39
|
+
return [] unless user
|
40
|
+
|
41
|
+
links_data.map { |e| Link.new e[:title], e[:url], e[:options], e[:separator] }
|
42
|
+
end
|
43
|
+
|
44
|
+
def list
|
45
|
+
content_tag :ul, links.join.html_safe, :class => 'dropdown-menu'
|
46
|
+
end
|
47
|
+
|
48
|
+
def system_infos
|
49
|
+
RedisUserConnector.get(user.id).select { |k,_| k =~ /_info/ }
|
50
|
+
end
|
51
|
+
|
52
|
+
def profile_url
|
53
|
+
'https://profile.tusur.ru'
|
54
|
+
end
|
55
|
+
|
56
|
+
def edit_user_link
|
57
|
+
Settings['profile.url'] || profile_url
|
58
|
+
end
|
59
|
+
|
60
|
+
def edit_user_url
|
61
|
+
edit_user_link + '/users/edit'
|
62
|
+
end
|
63
|
+
|
64
|
+
def sign_out_link
|
65
|
+
Settings['profile.url'] || profile_url
|
66
|
+
end
|
67
|
+
|
68
|
+
def sign_out_url
|
69
|
+
path = "/users/sign_out?redirect_url=#{Settings['app.url']}"
|
70
|
+
|
71
|
+
sign_out_link + path
|
72
|
+
end
|
73
|
+
|
74
|
+
# TODO: remove
|
75
|
+
def example_system_infos
|
76
|
+
{
|
77
|
+
:timetable_info => {
|
78
|
+
:url => {
|
79
|
+
:title => 'TITLE #1',
|
80
|
+
:link => 'http://url1.com'
|
81
|
+
},
|
82
|
+
|
83
|
+
:my_url => {
|
84
|
+
:title => 'MY TITLE #1',
|
85
|
+
:link => 'http://my_url1.com'
|
86
|
+
}
|
87
|
+
}.to_json,
|
88
|
+
|
89
|
+
:attendance_info => {
|
90
|
+
:url => {
|
91
|
+
:title => 'TITLE #2',
|
92
|
+
:link => 'http://url2.com'
|
93
|
+
},
|
94
|
+
|
95
|
+
:my_url => {
|
96
|
+
:title => 'MY TITLE #2',
|
97
|
+
:link => 'http://my_url2.com'
|
98
|
+
}
|
99
|
+
}.to_json
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
def links_from_system_infos(key)
|
104
|
+
system_infos.inject([]) do |array, data|
|
105
|
+
array += JSON.parse(data.last).select { |k, _| k.to_s == key }.values
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def links_data
|
110
|
+
@links_hash ||= begin
|
111
|
+
array = []
|
112
|
+
|
113
|
+
if links_from_system_infos('my_url').any?
|
114
|
+
links_from_system_infos('my_url').each do |elem|
|
115
|
+
array << { :title => elem['title'], :url => elem['link'] }
|
116
|
+
end
|
117
|
+
|
118
|
+
array << { :separator => true }
|
119
|
+
end
|
120
|
+
|
121
|
+
array << { :title => 'Кабинет ТУСУР', :url => profile_url+'/' }
|
122
|
+
|
123
|
+
if links_from_system_infos('url').any?
|
124
|
+
links_from_system_infos('url').each do |elem|
|
125
|
+
array << { :title => elem['title'], :url => elem['link'] }
|
126
|
+
end
|
127
|
+
array << { :separator => true }
|
128
|
+
end
|
129
|
+
|
130
|
+
array << { :title => 'Редактировать профиль', :url => edit_user_url }
|
131
|
+
array << { :title => 'Выход', :url => sign_out_url, :options => { :method => :delete } }
|
132
|
+
|
133
|
+
array
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
module MenuLinks
|
139
|
+
def menu_links
|
140
|
+
Links.new(self).links
|
141
|
+
end
|
142
|
+
|
143
|
+
def menu_list
|
144
|
+
Links.new(self).list
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
data/lib/tusur_header/version.rb
CHANGED
data/tusur_header.gemspec
CHANGED
@@ -16,10 +16,11 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
|
18
18
|
s.add_development_dependency 'bundler'
|
19
|
-
s.
|
19
|
+
s.add_dependency 'rails', '~> 4.0'
|
20
20
|
|
21
21
|
s.add_runtime_dependency 'bootstrap-sass', '~> 3.1.1'
|
22
22
|
s.add_runtime_dependency 'coffee-rails'
|
23
|
+
s.add_runtime_dependency 'configliere'
|
23
24
|
s.add_runtime_dependency 'compass-rails'
|
24
25
|
s.add_runtime_dependency 'jquery-rails'
|
25
26
|
s.add_runtime_dependency 'sass-rails', '>= 3.2'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tusur_header
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeny Lapin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
type: :
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bootstrap-sass
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: configliere
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: compass-rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,6 +163,7 @@ files:
|
|
149
163
|
- README.rdoc
|
150
164
|
- Rakefile
|
151
165
|
- app/views/tusur_header/_tusur_header.html.erb
|
166
|
+
- config/locales/ru.yml
|
152
167
|
- config/sites.yml
|
153
168
|
- lib/generators/tusur_header/error_pages_generator.rb
|
154
169
|
- lib/generators/tusur_header/templates/403.html
|
@@ -157,6 +172,7 @@ files:
|
|
157
172
|
- lib/generators/tusur_header/templates/502.html
|
158
173
|
- lib/tusur_header.rb
|
159
174
|
- lib/tusur_header/engine.rb
|
175
|
+
- lib/tusur_header/menu_links.rb
|
160
176
|
- lib/tusur_header/version.rb
|
161
177
|
- test/dummy/README.rdoc
|
162
178
|
- test/dummy/Rakefile
|