perus 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c2a9dfa74d571f5e3606c2880f7627c3b517375
4
- data.tar.gz: b1886d133049343030045f2d66d9399236c5b090
3
+ metadata.gz: 426902fcecc63ec81acf9352f4bafba9fa1988d4
4
+ data.tar.gz: 36838e6272731efce01b25f8c8773d4ed8622cfe
5
5
  SHA512:
6
- metadata.gz: de5364f5fb8c3ae625a338796173747b23fdbe171eee0b66523aada3f41b53bb2e39fc692679fd095bb36fa4f5b5d169c5cd514f8b661bd770d1203cdccdb92d
7
- data.tar.gz: c00611873d24559cac53083efd1dbd76dc6397f2f138ee8db5aea0d7522c3b2223bae81578fa9ce56a8a1f9efe8aaf00f49450ce6e4efff5c6ab229276ef3d6b
6
+ metadata.gz: a4e06d529a4d1d00f2beba82bd5c118b662fedd4b5b70856d39fadbd9a28781c3a9c2243ab9670dac271c69ace4ad6e8961c6988590b296536816a941995d146
7
+ data.tar.gz: 2bb970e51ed715718b85078c46c34218d25f4596994136215cf99d313e32a78822ebcba13120848e4b38d542caee7726a4f7a75fc15dd17fc8dd0550339abe02
@@ -40,6 +40,7 @@ module Perus::Server
40
40
  else
41
41
  redirect url_prefix + 'admin/#{plural}'
42
42
  end
43
+ return
43
44
  rescue
44
45
  end
45
46
  end
@@ -62,6 +63,7 @@ module Perus::Server
62
63
  begin
63
64
  @record.update(params[:record])
64
65
  redirect url_prefix + 'admin/#{plural}'
66
+ return
65
67
  rescue
66
68
  end
67
69
  end
@@ -39,7 +39,7 @@ module Perus::Server
39
39
 
40
40
  # static admin index page
41
41
  get '/admin' do
42
- redirect '/admin/systems'
42
+ redirect "#{url_prefix}admin/systems"
43
43
  end
44
44
 
45
45
  post '/admin/scripts/:id/commands' do
@@ -6,11 +6,21 @@ module Perus::Server
6
6
  end
7
7
 
8
8
  def nav_item(path, name, li = true)
9
- if path.start_with?('/admin/')
10
- klass = request.path_info.start_with?(path) ? 'selected' : ''
9
+ # when hosted behind a fronting server such as nginx, path_info
10
+ # will start with '/' not url_prefix
11
+ adjusted_path = path
12
+ if path.index(url_prefix) == 0
13
+ adjusted_path = path.sub(url_prefix, '/')
14
+ end
15
+
16
+ # admin links are highlighted for sub pages as well as their own
17
+ # top level page. e.g 'groups' matches '/groups/1'
18
+ if adjusted_path.start_with?('/admin/')
19
+ klass = request.path_info.start_with?(adjusted_path) ? 'selected' : ''
11
20
  else
12
- klass = request.path_info == path ? 'selected' : ''
21
+ klass = request.path_info == adjusted_path ? 'selected' : ''
13
22
  end
23
+
14
24
  anchor = "<a class=\"#{klass}\" href=\"#{path}\">#{name}</a>"
15
25
  li ? "<li>#{anchor}</li>" : anchor
16
26
  end
@@ -1,13 +1,15 @@
1
1
  require 'thin'
2
2
 
3
3
  DEFAULT_SERVER_OPTIONS = {
4
- 'uploads_dir' => './uploads',
5
- 'uploads_url' => 'http://localhost:3000/uploads/',
6
- 'db_path' => './perus.db',
7
- 'listen' => '0.0.0.0',
8
- 'port' => 3000,
9
- 'site_name' => 'Perus',
10
- 'url_prefix' => '/'
4
+ '__anonymous__' => {
5
+ 'uploads_dir' => './uploads',
6
+ 'uploads_url' => 'http://localhost:3000/uploads/',
7
+ 'db_path' => './perus.db',
8
+ 'listen' => '0.0.0.0',
9
+ 'port' => 3000,
10
+ 'site_name' => 'Perus',
11
+ 'url_prefix' => '/'
12
+ }
11
13
  }
12
14
 
13
15
  module Perus::Server
@@ -1,8 +1,8 @@
1
1
  <html>
2
2
  <head>
3
- <link rel="stylesheet" type="text/css" href="/fonts/opensans/stylesheet.css">
4
- <link rel="stylesheet" type="text/css" href="/css/reset.css">
5
- <link rel="stylesheet" type="text/css" href="/css/style.css">
3
+ <link rel="stylesheet" type="text/css" href="<%= url_prefix %>fonts/opensans/stylesheet.css">
4
+ <link rel="stylesheet" type="text/css" href="<%= url_prefix %>css/reset.css">
5
+ <link rel="stylesheet" type="text/css" href="<%= url_prefix %>css/style.css">
6
6
  <title>Overview</title>
7
7
  <script src="<%= url_prefix %>js/jquery.js"></script>
8
8
  </head>
@@ -24,7 +24,7 @@
24
24
  </li>
25
25
  <li>
26
26
  <a href="<%= url_prefix %>admin">Admin</a>
27
- <% if request.path.start_with?("#{url_prefix}admin") %>
27
+ <% if request.path.start_with?('/admin') %>
28
28
  <ul>
29
29
  <%= nav_item("#{url_prefix}admin/systems", 'Systems') %>
30
30
  <%= nav_item("#{url_prefix}admin/groups", 'Groups') %>
data/lib/perus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Perus
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Cannings