intranet-core 1.1.1 → 1.2.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 +4 -4
- data/lib/intranet/abstract_responder.rb +7 -0
- data/lib/intranet/core/builder.rb +4 -4
- data/lib/intranet/core/version.rb +1 -1
- data/lib/intranet/resources/haml/skeleton.haml +15 -14
- data/lib/intranet/resources/www/style.css +0 -8
- data/spec/intranet/core_spec.rb +11 -1
- data/spec/test_responder/responder.rb +8 -1
- metadata +4 -5
- data/lib/intranet/resources/www/background.jpg +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b297a91ba8ca9fc6a44723c4f9f738d879193828
|
4
|
+
data.tar.gz: bc44f0b1858f045978da8d39824ad36a0a52c485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5094ed435333e80537e85603359276059b345554ae185cdb6c56e9d843ca385b31fc1e1e008e329114c3f5584e509d89087dab4e3e24423a2fbb35f0081457b
|
7
|
+
data.tar.gz: e06fea82c25af97e56230a51df3f4b4f9447fd2218d9ca7b28b0663f83d43d3713cda474aab06c15c45a5860680d02edf5adf95742ee552331e19755e01a19ad
|
@@ -15,6 +15,13 @@ module Intranet
|
|
15
15
|
# @return [String/Nil] The homepage URL of the module, or nil if no homepage is available.
|
16
16
|
def self.module_homepage; end
|
17
17
|
|
18
|
+
# Specifies if the responder instance should be displayed in the main navigation menu or not.
|
19
|
+
# @return [Boolean] True if the responder instance should be added to the main navigation menu,
|
20
|
+
# False otherwise.
|
21
|
+
def in_menu?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
18
25
|
# Destroys the responder instance.
|
19
26
|
# This method gets called when server is shut down.
|
20
27
|
def finalize
|
@@ -47,13 +47,13 @@ module Intranet
|
|
47
47
|
# @param query [Hash] The content of the GET parameters of the URL.
|
48
48
|
# @return [Array] The HTTP return code, the MIME type and the answer body.
|
49
49
|
def do_get(path, query = {})
|
50
|
-
|
51
|
-
status, mime_type, body =
|
50
|
+
responder, responder_path = get_responder(path)
|
51
|
+
status, mime_type, body = responder.generate_page(responder_path, query)
|
52
52
|
|
53
53
|
# Generate header and footer when partial content is returned by the responder
|
54
54
|
if status == 206 && mime_type == 'text/html'
|
55
|
-
body = to_markup('skeleton',
|
56
|
-
|
55
|
+
body = to_markup('skeleton', body: body, css: responder.css_dependencies,
|
56
|
+
js: responder.js_dependencies)
|
57
57
|
status = 200
|
58
58
|
end
|
59
59
|
[status, mime_type, body]
|
@@ -16,20 +16,21 @@
|
|
16
16
|
%nav
|
17
17
|
%a{id: 'closemenu', onclick: 'closeNavMenu();'}= '×'
|
18
18
|
%ul
|
19
|
-
- responders.children_nodes.each do |
|
20
|
-
|
21
|
-
- if
|
22
|
-
%
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
19
|
+
- responders.children_nodes.each do |path, node|
|
20
|
+
- if node.children?
|
21
|
+
- if node.children_nodes.values.any? { |n| n.value.in_menu? } # Create a dropdown menu entry
|
22
|
+
%li
|
23
|
+
%a= I18n.t(path + '.menu', default: path.humanize)
|
24
|
+
%ul
|
25
|
+
- node.children_nodes.each do |subpath, subnode|
|
26
|
+
- if subnode.value.in_menu?
|
27
|
+
%li
|
28
|
+
%a{href: '/' + path + '/' + subpath + '/index.html'}
|
29
|
+
= I18n.t(path + '.' + subpath + '.menu', default: subpath.humanize)
|
30
|
+
- else # Create a regular menu entry
|
31
|
+
- if node.value.in_menu?
|
32
|
+
%li
|
33
|
+
%a{href: '/' + path + '/index.html'}= I18n.t(path + '.menu', default: path.humanize)
|
33
34
|
|
34
35
|
%main
|
35
36
|
= body[:content]
|
@@ -192,17 +192,9 @@ ul.breadcrumb li a, main article a {
|
|
192
192
|
|
193
193
|
/******************************** Main content *******************************/
|
194
194
|
|
195
|
-
body > aside {
|
196
|
-
background: url('background.jpg') fixed top right no-repeat;
|
197
|
-
height: 45%;
|
198
|
-
min-height: 350px;
|
199
|
-
max-height: 500px; /* less than height of background.jpg */
|
200
|
-
}
|
201
|
-
|
202
195
|
body > main {
|
203
196
|
background: #f2f2f2;
|
204
197
|
padding: 57px 0px; /* height of the navigation bar */
|
205
|
-
min-height: 500px; /* lower or equal to height of background.jpg (with padding) */
|
206
198
|
}
|
207
199
|
|
208
200
|
body > main section, body > main article, body > main hr, body > footer p {
|
data/spec/intranet/core_spec.rb
CHANGED
@@ -319,10 +319,15 @@ RSpec.describe Intranet::Core do
|
|
319
319
|
responder = Intranet::TestResponder.new(
|
320
320
|
'/index.html' => [206, 'text/html', { content: 'PARTIAL_CONTENT', title: 'MyTitle' }]
|
321
321
|
)
|
322
|
+
other_responder = Intranet::TestResponder.new({}, [], [], true)
|
322
323
|
@intranet.register_module(responder, [], responder.resources_dir)
|
323
324
|
@intranet.register_module(responder, %w[dep_th1], responder.resources_dir)
|
324
325
|
@intranet.register_module(responder, %w[depth2 res_p1], responder.resources_dir)
|
325
326
|
@intranet.register_module(responder, %w[depth2 resp2], responder.resources_dir)
|
327
|
+
@intranet.register_module(other_responder, %w[depth2 resp], other_responder.resources_dir)
|
328
|
+
@intranet.register_module(other_responder, %w[other1], other_responder.resources_dir)
|
329
|
+
@intranet.register_module(other_responder, %w[other2 res1], other_responder.resources_dir)
|
330
|
+
@intranet.register_module(other_responder, %w[other2 res2], other_responder.resources_dir)
|
326
331
|
thread = Thread.new do
|
327
332
|
@intranet.start
|
328
333
|
end
|
@@ -341,13 +346,18 @@ RSpec.describe Intranet::Core do
|
|
341
346
|
html = socket.readpartial(4096) # read rest of data
|
342
347
|
|
343
348
|
# Returned HTML document main menu
|
344
|
-
expect(html).to
|
349
|
+
expect(html).to match(%r{<a href='/dep_th1/index.html'>.*Dep Th1.*</a>})
|
350
|
+
expect(html).not_to match(%r{<a href='/other1/index.html'>})
|
345
351
|
expect(html).to match(
|
346
352
|
%r{<a>.*Depth2.*</a>.*<ul>.*<a href='/depth2/res_p1/index.html'>.*Res P1.*</a>.*</ul>}m
|
347
353
|
)
|
348
354
|
expect(html).to match(
|
349
355
|
%r{<a>.*Depth2.*</a>.*<ul>.*<a href='/depth2/resp2/index.html'>.*Resp2.*</a>.*</ul>}m
|
350
356
|
)
|
357
|
+
expect(html).not_to match(%r{<a href='/depth2/resp/index.html'>})
|
358
|
+
expect(html).not_to match(%r{<a>.*Other2.*</a>}m)
|
359
|
+
expect(html).not_to match(%r{<a href='/other2/res1/index.html'>})
|
360
|
+
expect(html).not_to match(%r{<a href='/other2/res2/index.html'>})
|
351
361
|
ensure
|
352
362
|
socket.close
|
353
363
|
Thread.kill(thread)
|
@@ -6,11 +6,12 @@ module Intranet
|
|
6
6
|
class TestResponder < AbstractResponder
|
7
7
|
attr_reader :finalized
|
8
8
|
|
9
|
-
def initialize(responses = {}, extra_css = [], extra_js = [])
|
9
|
+
def initialize(responses = {}, extra_css = [], extra_js = [], hide_from_menu = false)
|
10
10
|
@responses = responses
|
11
11
|
@extra_css = extra_css
|
12
12
|
@extra_js = extra_js
|
13
13
|
@finalized = false
|
14
|
+
@hide_from_menu = hide_from_menu
|
14
15
|
end
|
15
16
|
|
16
17
|
def finalize
|
@@ -18,6 +19,12 @@ module Intranet
|
|
18
19
|
super
|
19
20
|
end
|
20
21
|
|
22
|
+
def in_menu?
|
23
|
+
return false if @hide_from_menu
|
24
|
+
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
21
28
|
def self.module_name
|
22
29
|
'test-responder'
|
23
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intranet-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ebling Mis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.63.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.63.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: simplecov
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,7 +174,6 @@ files:
|
|
174
174
|
- lib/intranet/resources/haml/title_and_breadcrumb.haml
|
175
175
|
- lib/intranet/resources/locales/en.yml
|
176
176
|
- lib/intranet/resources/locales/fr.yml
|
177
|
-
- lib/intranet/resources/www/background.jpg
|
178
177
|
- lib/intranet/resources/www/error.png
|
179
178
|
- lib/intranet/resources/www/favicon.ico
|
180
179
|
- lib/intranet/resources/www/fonts/SourceSansPro.woff2
|
Binary file
|