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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf5a56e43b31aff50e2987cb337fdca3308f5444
4
- data.tar.gz: c319c8fa7398563f469bb403edb7fff1923c126c
3
+ metadata.gz: b297a91ba8ca9fc6a44723c4f9f738d879193828
4
+ data.tar.gz: bc44f0b1858f045978da8d39824ad36a0a52c485
5
5
  SHA512:
6
- metadata.gz: 0cd16c07120e3a5f3996a9b186d69c40a5816ad58b3852b988d334a82a18637bf2f130dc098ce7d465976a4148b412cbb1955e001cad546ccf5c77d2d23b7599
7
- data.tar.gz: a280390146e29d0fa3be5c44faebdc6f72b54d4c7e4599dd81ae94bde5c15e4481ece613c236d777522433beae0c9cb16dd92842488318a109b712f7ef2b9a8d
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
- resp, responder_path = get_responder(path)
51
- status, mime_type, body = resp.generate_page(responder_path, query)
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', is_home: path == '/index.html', body: body,
56
- css: resp.css_dependencies, js: resp.js_dependencies)
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]
@@ -6,7 +6,7 @@ module Intranet
6
6
  NAME = 'intranet-core'
7
7
 
8
8
  # The version of the gem, according to semantic versionning.
9
- VERSION = '1.1.1'
9
+ VERSION = '1.2.0'
10
10
 
11
11
  # The URL of the gem homepage.
12
12
  HOMEPAGE_URL = 'https://rubygems.org/gems/intranet-core'
@@ -16,20 +16,21 @@
16
16
  %nav
17
17
  %a{id: 'closemenu', onclick: 'closeNavMenu();'}= '×'
18
18
  %ul
19
- - responders.children_nodes.each do |child_id, child_node|
20
- %li
21
- - if child_node.children? # Create a dropdown menu entry
22
- %a= I18n.t(child_id + '.menu', default: child_id.humanize)
23
- %ul
24
- - child_node.children_nodes.each do |child_url, node|
25
- %li
26
- %a{href: '/' + child_id + '/' + child_url + '/index.html'}
27
- = I18n.t(child_id + '.' + child_url + '.menu', default: child_url.humanize)
28
- - else # Create a regular menu entry
29
- %a{href: '/' + child_id + '/index.html'}= I18n.t(child_id + '.menu', default: child_id.humanize)
30
-
31
- - if is_home
32
- %aside
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 {
@@ -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 match(%r{<a href='/dep_th1/index.html'>.*Dep Th1.*</a>})
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.1.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-02 00:00:00.000000000 Z
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.61.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.61.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