nightlight 0.0.2 → 0.0.3

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: 1caf1cc8adbb6c0ea6d5188eeff9c1f03d245f7d
4
- data.tar.gz: 8981ae37e69dfa27501f979f94c45d29791a303c
3
+ metadata.gz: 2bb3cd1cd8137453589cf7d5ea5abb33cbc24b22
4
+ data.tar.gz: 2db2bb4da64d15f3745cef25033f920d33634fb8
5
5
  SHA512:
6
- metadata.gz: ecf5aa3b1da5be86c50855c377cdf0bb2e52634ffd81280862448f10b92a59c77e98abebbb785d5c51f7a10c6664d63ee32d4cadec2a95cd2e591bbf966bd69f
7
- data.tar.gz: 62767315fe6f34688dadeb5fc5b002f3a06d3ba525c2c051fe318002aa2fecf6dcad230b0c88cbf83fd56ea9c3a4edd2056e7bdc04a9c639d3f0124abaa39b07
6
+ metadata.gz: ddb80147493befe0b7bf2a7b61ab8ffdd3efd3d85d0f55c40ad6acee24cd0154fccec91eca46c360ffdaa63b3488a5c546ff771e3dbc3e074f564ea20280c5b8
7
+ data.tar.gz: 2a9655cce8c3d3e57caa5ac1fb3a6bac3d4a2583bacdfa4bea4c5c7d47dd3d5b0c2ad3b5a07ee5b74479e27b58ee27079686983f4c0923cbd7c9ba8e5776ec05
data/README.md CHANGED
@@ -2,10 +2,26 @@
2
2
 
3
3
  Shed light on the dark corners of your app
4
4
 
5
- Nightlight helps you make sure all pages in your app are getting the love and attention they deserve
5
+ Nightlight is an admin interface for tracking what pages are (not) being checked by your team
6
6
 
7
7
  Inspired by [Cap Watkins](https://twitter.com/cap)' [The Dark Corners of Your UI](http://blog.capwatkins.com/dark-corners)
8
8
 
9
+ ## Features
10
+
11
+ - Indicate when you've checked a page and leave a comment (all good? bugs? link to Trello card?)
12
+ - See what pages haven't been checked in a while
13
+ - Sync with `GET` routes from `config/routes.rb`, or maintain your own list of pages
14
+ - Assign pages to yourself to check, and see who's already checking what
15
+ - Get a random page to check that nobody else is checking
16
+
17
+ ## Benefits
18
+
19
+ - Keep fresh eyes on pages you don't see very often (onboarding, edge cases)
20
+ - Discover things your automated tests aren't catching (CSS bugs, typos, bad impressions, forgot-to-update-that-too's)
21
+ - Discover things that user feedback isn't catching
22
+ - Improve product quality and internal product awareness (each person check a random page every day?)
23
+ - Share page-level meta info across a team (useful notes, gotchyas, how-to's, please-don't's)
24
+
9
25
  ## Installation
10
26
 
11
27
  Add this line to your application's Gemfile:
@@ -56,7 +72,7 @@ authenticate :user, lambda{|user| user.admin? } do
56
72
  end
57
73
  ```
58
74
 
59
- ### Credit
75
+ ## Credit
60
76
 
61
77
  Inspired by:
62
78
  - [Cap Watkins](https://twitter.com/cap)' [The Dark Corners of Your UI](http://blog.capwatkins.com/dark-corners)
@@ -7,6 +7,7 @@
7
7
 
8
8
  body {
9
9
  padding-top: 30px;
10
+ padding-bottom: 100px;
10
11
  }
11
12
 
12
13
  table tr td {
@@ -1,11 +1,12 @@
1
1
  module Nightlight
2
2
  class ActivitiesController < BaseController
3
3
 
4
+ before_action :enforce_current_user, only: [:create]
4
5
  before_action :set_page
5
6
 
6
7
  def create
7
8
  @status = @page.activities.status.new activity_params
8
- @status.user = current_user if respond_to?(:current_user)
9
+ @status.user = current_user
9
10
  if @status.save
10
11
  flash[:success] = "Status updated."
11
12
  redirect_to page_url(@page)
@@ -12,5 +12,14 @@ module Nightlight
12
12
  end
13
13
 
14
14
  layout "nightlight/application"
15
+
16
+ private
17
+
18
+ def enforce_current_user
19
+ unless respond_to?(:current_user) && current_user
20
+ flash[:error] = "This feature requires a logged in user."
21
+ redirect_to root_url
22
+ end
23
+ end
15
24
  end
16
25
  end
@@ -1,5 +1,7 @@
1
1
  module Nightlight
2
2
  class PagesController < BaseController
3
+
4
+ before_action :enforce_current_user, only: [:edit, :update, :new, :create, :destroy, :assign, :unassign, :checked, :add_yes, :add_no, :random]
3
5
  before_action :set_page, only: [:show, :edit, :update, :destroy, :assign, :unassign, :checked]
4
6
  before_action :authorize_assignee, only: [:unassign]
5
7
 
@@ -8,7 +10,8 @@ module Nightlight
8
10
  @new_pages = routes_pages.select do |r|
9
11
  Nightlight::Page.where(path: r[:path]).none?
10
12
  end
11
- if params[:hidden]
13
+
14
+ if params[:all]
12
15
  @hidden_pages = Nightlight::Page.hidden
13
16
  end
14
17
  end
@@ -45,21 +48,31 @@ module Nightlight
45
48
  end
46
49
  end
47
50
 
51
+ def destroy
52
+ @page.destroy
53
+ flash[:success] = "Page deleted."
54
+ redirect_to root_url
55
+ end
56
+
48
57
  def add_yes
49
58
  @page = Page.new page_params
50
- @page.save
51
- respond_to do |format|
52
- format.js { render 'nightlight/pages/add' }
59
+ if @page.save
60
+ flash[:success] = "Page added."
61
+ else
62
+ flash[:error] = @page.errors.full_messages.first
53
63
  end
64
+ redirect_to root_url
54
65
  end
55
66
 
56
67
  def add_no
57
68
  @page = Page.new page_params
58
69
  @page.hidden = true
59
- @page.save
60
- respond_to do |format|
61
- format.js { render 'nightlight/pages/add' }
70
+ if @page.save
71
+ flash[:success] = "Settings saved."
72
+ else
73
+ flash[:error] = @page.errors.full_messages.first
62
74
  end
75
+ redirect_to root_url
63
76
  end
64
77
 
65
78
  def assign
@@ -110,8 +123,8 @@ module Nightlight
110
123
  all_routes = Rails.application.routes.routes
111
124
  require 'action_dispatch/routing/inspector'
112
125
  inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
113
- routes = inspector.send(:collect_routes, all_routes)
114
- routes.select{|r| r[:verb]=="GET" }
126
+ routes = inspector.send(:collect_routes, all_routes).dup
127
+ routes.select{|route| route.tap{|r| r[:path] = r[:path].sub(/\(\.:format\)$/,'') }[:verb]=="GET" }
115
128
  end
116
129
 
117
130
  def set_page
@@ -2,13 +2,16 @@ module Nightlight
2
2
  module PagesHelper
3
3
 
4
4
  def avg_page_brightness pages
5
- avg = pages.map(&:brightness).sum.to_f / pages.size.to_f
6
- avg.to_i
5
+ if pages.any?
6
+ avg = pages.map(&:brightness).sum.to_f / pages.size.to_f
7
+ avg.to_i
8
+ else
9
+ 0
10
+ end
7
11
  end
8
12
 
9
13
  def link_to_page page
10
14
  path = page.sample_path.presence || page.path
11
- path = path.sub(/\(\.:format\)$/,'')
12
15
  link_to page.path, path, target: '_blank'
13
16
  end
14
17
 
@@ -10,7 +10,11 @@ module Nightlight
10
10
  scope :unassigned, ->{ where assignee_id: nil }
11
11
 
12
12
  def to_param
13
- [id, name.gsub("'", "").parameterize].join("-")
13
+ if name.present?
14
+ [id, name.gsub("'", "").parameterize].join("-")
15
+ else
16
+ id
17
+ end
14
18
  end
15
19
 
16
20
  def brightness
@@ -1,11 +1,16 @@
1
1
  <%- success = success || flash[:success] %>
2
2
  <%- error = error || flash[:error] %>
3
+ <%- notice = notice || flash[:notice] %>
3
4
  <% if success %>
4
- <div class="alert alert-success">
5
+ <div class="alert alert-success text-center">
5
6
  <%= success %>
6
7
  </div>
7
8
  <% elsif error %>
8
- <div class="alert alert-danger">
9
+ <div class="alert alert-danger text-center">
9
10
  <%= error %>
10
11
  </div>
12
+ <% elsif notice %>
13
+ <div class="alert alert-warning text-center">
14
+ <%= notice %>
15
+ </div>
11
16
  <% end %>
@@ -22,7 +22,7 @@
22
22
  <%= last_checked_at page %>
23
23
  </td>
24
24
  <td>
25
- <% if page.assignee && page.assignee==current_user %>
25
+ <% if page.assignee && respond_to?(:current_user) && page.assignee==current_user %>
26
26
  <%= link_to 'You', page_path(page), class: 'btn btn-primary btn-xs' %>
27
27
  <% elsif page.assignee %>
28
28
  <%= link_to page.assignee.name, page_path(page), class: 'btn btn-warning btn-xs' %>
@@ -15,3 +15,5 @@
15
15
  </div>
16
16
 
17
17
  <%= render 'nightlight/pages/form' %>
18
+
19
+ <%= link_to 'Delete this page', page_path(@page), data: {method: :delete, confirm: "Are you sure?"}, class: 'text-danger pull-right' %>
@@ -1,14 +1,20 @@
1
1
  <div class="clearfix" style="margin-bottom:20px">
2
2
  <div class="pull-right">
3
3
  <%= link_to "New Page", new_page_path, class: 'btn btn-default' %>
4
- <%= link_to "Check Random Page", random_pages_path, class: 'btn btn-primary', data: {method: :post} %>
4
+ <%= link_to "Check Random Page", random_pages_path, class: "btn btn-primary #{'disabled' unless @pages.any?}", data: {method: :post} %>
5
5
  </div>
6
6
  <h3 style="margin:0"><%= render 'nightlight/pages/brightness', brightness: avg_page_brightness(@pages) %></h3>
7
7
  </div>
8
8
 
9
+ <% if @pages.empty? %>
10
+ <div class="alert alert-success text-center">
11
+ Welcome! <code>GET</code> routes in your <code>config/routes.rb</code> can be imported below. You can also register pages manually by clicking <strong>New Page</strong>.
12
+ </div>
13
+ <% end %>
14
+
9
15
  <% if @new_pages.any? %>
10
16
  <div class="panel panel-warning">
11
- <div class="panel-heading" style="text-align:center">New pages found</div>
17
+ <div class="panel-heading" style="text-align:center">New <code>GET</code> routes found in <code>config/routes.rb</code>:</div>
12
18
  <div class="panel-body">
13
19
  <table class="table">
14
20
  <thead>
@@ -27,8 +33,8 @@
27
33
  <td><%= page[:path] %></td>
28
34
  <td><%= page[:reqs] %></td>
29
35
  <td>
30
- <%= link_to 'Yes', add_yes_pages_path(page: {name: page[:name], path: page[:path], reqs: page[:reqs]}), class: 'btn btn-default btn-xs', data: {remote: true, method: :post} %>
31
- <%= link_to 'No', add_no_pages_path(page: {name: page[:name], path: page[:path], reqs: page[:reqs]}), class: 'btn btn-default btn-xs', data: {remote: true, method: :post} %>
36
+ <%= link_to 'Yes', add_yes_pages_path(page: {name: page[:name], path: page[:path], reqs: page[:reqs]}), class: 'btn btn-default btn-xs', data: {method: :post} %>
37
+ <%= link_to 'No', add_no_pages_path(page: {name: page[:name], path: page[:path], reqs: page[:reqs]}), class: 'btn btn-default btn-xs', data: {method: :post} %>
32
38
  </td>
33
39
  </tr>
34
40
  <% end %>
@@ -36,15 +42,27 @@
36
42
  </table>
37
43
  </div>
38
44
  </div>
45
+ <% elsif @pages.empty? %>
46
+ <div class="alert alert-warning text-center">
47
+ No <code>GET</code> routes found in <code>config/routes.rb</code>.
48
+ </div>
39
49
  <% end %>
40
50
 
41
51
  <h2>Pages</h2>
42
- <%= render 'nightlight/pages/pages', pages: @pages %>
52
+ <% if @pages.any? %>
53
+ <%= render 'nightlight/pages/pages', pages: @pages %>
54
+ <% else %>
55
+ <p class="text-muted">There are no pages.</p>
56
+ <% end %>
43
57
 
44
- <% if @hidden_pages %>
45
- <h2 id="hidden">Hidden Pages</h2>
46
- <%= render 'nightlight/pages/pages', pages: @hidden_pages, hidden: true %>
58
+ <% if params[:all] %>
59
+ <h4 id="hidden">Hidden Pages</h4>
60
+ <% if @hidden_pages.any? %>
61
+ <%= render 'nightlight/pages/pages', pages: @hidden_pages, hidden: true %>
62
+ <% else %>
63
+ <p class="text-muted">There are no hidden pages.</p>
64
+ <% end %>
47
65
  <% else %>
48
- <%= link_to "Show hidden pages", pages_path(hidden: true, anchor: 'hidden') %>
66
+ <%= link_to "Show all pages", pages_path(all: true) %>
49
67
  <% end %>
50
68
 
@@ -25,7 +25,7 @@
25
25
 
26
26
  <div class="well text-center">
27
27
  <% if @page.assignee %>
28
- <% if @page.assignee == current_user %>
28
+ <% if respond_to?(:current_user) && @page.assignee == current_user %>
29
29
  <h3 style="margin-top:0">You are checking this</h3>
30
30
  <%= link_to "Done!", checked_page_path(@page), class: 'btn btn-primary btn-lg', data: {method: :post} %>
31
31
  <br/>
@@ -1,3 +1,3 @@
1
1
  module Nightlight
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nightlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Sullivan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -88,7 +88,6 @@ files:
88
88
  - app/views/nightlight/pages/_brightness.html.erb
89
89
  - app/views/nightlight/pages/_form.html.erb
90
90
  - app/views/nightlight/pages/_pages.html.erb
91
- - app/views/nightlight/pages/add.js.erb
92
91
  - app/views/nightlight/pages/edit.html.erb
93
92
  - app/views/nightlight/pages/index.html.erb
94
93
  - app/views/nightlight/pages/new.html.erb
@@ -1,13 +0,0 @@
1
- <% if @page.valid? %>
2
-
3
- var html = "<%= j(render('layouts/nightlight/alert', success: "Settings saved.")) %>";
4
- $('#alerts').html(html);
5
- var path = "<%= j(@page.path) %>";
6
- $('.new-page[data-path="'+path+'"]').remove();
7
-
8
- <% else %>
9
-
10
- var html = "<%= j(render('layouts/nightlight/alert', error: @page.errors.full_messages.first)) %>";
11
- $('#alerts').html(html);
12
-
13
- <% end %>