Skip to content

Commit e19a86b

Browse files
jrgnsJurgens du Toit
authored andcommitted
refac: Use SB Admin 2 as a theme
1 parent fd4623f commit e19a86b

File tree

6 files changed

+51
-46
lines changed

6 files changed

+51
-46
lines changed

config.ru

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
55
require 'proxes'
66
require 'proxes/db'
77

8+
raise 'Unconfigured' unless ENV['ELASTICSEARCH_URL']
9+
10+
use Rack::Static, urls: ['/assets'], root: 'public'
11+
812
use Rack::Session::Pool
913
# use Rack::Session::Cookie,
1014
# :key => '_ProxES_session',

lib/proxes/app.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ def root_url
1818
route do |r|
1919
r.multi_route
2020

21-
r.public
22-
2321
r.get do
2422
authenticate!
2523

lib/proxes/base.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Base < Roda
1111

1212
use Rack::MethodOverride
1313
plugin :all_verbs
14+
plugin :empty_root
1415

1516
plugin :default_headers,
1617
'Content-Type'=>'text/html',
@@ -26,13 +27,14 @@ class Base < Roda
2627
plugin :indifferent_params
2728
plugin :flash
2829
plugin :halt
29-
plugin :public, root: opts[:public]
3030

3131
plugin(:not_found) { view 'http_404' }
3232
plugin(:error_handler) do |e|
3333
case true
3434
when e.is_a?(Roda::RodaPlugins::Authentication::NotAuthenticated) || e.is_a?(OmniAuth::Error)
3535
request.redirect '/auth/identity'
36+
when e.is_a?(Pundit::NotAuthorizedError)
37+
request.halt 404
3638
else
3739
logger.error e
3840
raise e unless ENV['RACK_ENV'] == 'production'

views/_navbar.haml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
.navbar.navbar-default.navbar-fixed-top
2-
.container-fluid
3-
.navbar-header
4-
%span.navbar-brand
5-
ProxES
6-
- if defined? title
7-
= "- #{title}"
8-
%button.navbar-toggle.collapsed{ type: 'button', 'data-toggle': 'collapse', 'data-target': '#navbar', 'aria-expanded': 'false', 'aria-controls': 'navbar' }
9-
%span.sr-only Toggle navigation
10-
%span.icon-bar.bar1
11-
%span.icon-bar.bar2
12-
%span.icon-bar.bar3
13-
#navbar.navbar-collapse.collapse
14-
-if current_user
15-
%form.navbar-form.navbar-right{ action: '/auth/identity', method: 'post' }
16-
= csrf_tag
17-
%input{ name: '_method', value: 'DELETE', type: 'hidden' }
18-
%button.btn.btn-default{ type: 'submit' }
19-
/ %i.ti-panel
20-
Logout
21-
- else
22-
%ul.nav.navbar-nav.navbar-right
23-
%li
24-
%a.btn.btn-link{ href: '/auth/identity' }
25-
Log In
1+
.navbar.navbar-default.navbar-static-top{ role: 'navigation', style: 'margin-bottom: 0' }
2+
.navbar-header
3+
%span.navbar-brand
4+
ProxES
5+
- if defined? title
6+
= "- #{title}"
7+
%button.navbar-toggle.collapsed{ type: 'button', 'data-toggle': 'collapse', 'data-target': '#navbar', 'aria-expanded': 'false', 'aria-controls': 'navbar' }
8+
%span.sr-only Toggle navigation
9+
%span.icon-bar.bar1
10+
%span.icon-bar.bar2
11+
%span.icon-bar.bar3
12+
-if current_user
13+
%form.nav.navbar-top-links.navbar-form.navbar-right{ action: '/auth/identity', method: 'post' }
14+
= csrf_tag
15+
%input{ name: '_method', value: 'DELETE', type: 'hidden' }
16+
%button.btn.btn-default{ type: 'submit' }
17+
/ %i.ti-panel
18+
Logout
19+
.navbar-default.sidebar{ role: 'navigation' }
20+
= partial('sidebar')
21+
- else
22+
%ul.nav.navbar-top-links.navbar-right
23+
%li
24+
%a.btn.btn-link{ href: '/auth/identity' }
25+
Log In

views/_sidebar.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- if defined?(current_user) && current_user
33
%li
44
%a{ href: root_url + '/' }
5-
%i.fa.fa-pie-chart
5+
%i.fa.fa-dashboard.fa-fw
66
Dashboard
77
- if current_user.admin?
88
%li

views/layout.haml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,31 @@
1515
%meta{ name: "author", content: "" }
1616

1717
/ Le styles
18-
%link{ rel: 'stylesheet', href: 'https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cerulean/bootstrap.min.css', media: 'screen' }
18+
%link{ rel: 'stylesheet', href: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', media: 'screen' }
19+
%link{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/startbootstrap-sb-admin-2/3.3.7+1/css/sb-admin-2.min.css', media: 'screen' }
20+
%link{ rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/metisMenu/2.5.2/metisMenu.min.css', media: 'screen' }
1921
%link{ rel: 'stylesheet', href: 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', media: 'screen' }
2022
/[if lt IE 9] <script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
2123
/[if lt IE 9] <script src="https://cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
22-
%style
23-
body { padding-top: 60px; }
24-
%body
25-
= partial('navbar', locals: { title: (defined?(title) ? title : 'ProxES') })
26-
.container-fluid
27-
.row
28-
.col-md-3.sidebar
29-
= partial('sidebar')
3024

31-
.col-md-9
32-
= partial('notifications')
33-
= yield
34-
%footer.footer.text-muted.text-center
35-
%hr
36-
.copyright
37-
:plain
38-
&copy; <script>document.write(new Date().getFullYear())</script>, JadeIT
25+
%body
26+
#wrapper
27+
= partial('navbar', locals: { title: (defined?(title) ? title : 'ProxES') })
28+
#page-wrapper
29+
.row
30+
.col-md-12
31+
= partial('notifications')
32+
= yield
33+
%footer.footer.text-muted.text-center
34+
%hr
35+
.copyright
36+
:plain
37+
&copy; <script>document.write(new Date().getFullYear())</script>, JadeIT
3938

4039

4140
/ Placed at the end of the document so the pages load faster
4241
%script{ type: 'text/javascript', src: '/assets/js/bundle.js' }
42+
%script{ type: 'text/javascript', src: 'https://cdnjs.cloudflare.com/ajax/libs/startbootstrap-sb-admin-2/3.3.7+1/js/sb-admin-2.min.js' }
4343
%script{ type: 'text/javascript', src: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js' }
44+
%script{ type: 'text/javascript', src: 'https://cdnjs.cloudflare.com/ajax/libs/metisMenu/2.5.2/metisMenu.min.js' }
4445
%script{ type: 'text/javascript', src: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' }

0 commit comments

Comments
 (0)