tell-them 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +57 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/tell-them.js.coffee +41 -0
- data/app/assets/stylesheets/tell-them.sass +110 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/tell-them/tell-them.rb +68 -0
- data/lib/tell-them/version.rb +5 -0
- data/lib/tell-them.rb +9 -0
- data/tell-them.gemspec +25 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f882c372fb43f905bc91fe9122f45b28fa9a395
|
4
|
+
data.tar.gz: c6d75ccc1115649c8ef1b7a9640f9efe6b842f48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1c469feecc9cf35294b312d9db72a0473dfebdbc1ae705161a69fb57a8ceb76da6b7b8b3e807ed99a8d2830e321aaf3e9abc266c5b8c3745322c65c0789bfbae
|
7
|
+
data.tar.gz: e508c5162dadd4169b19ea4fb6bfc7219f7b59eb5faf6cc9d8d93bdc7f00332991e3d60c1aaf91849ddd5687ecc3ada72d4d3ba3c5951d7d4916ef31612c3a2b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# TellThem
|
2
|
+
|
3
|
+
> Well, OK. But I don't want people thinking we're
|
4
|
+
> robo-sexuals, so if anyone asks, you're my debugger.
|
5
|
+
>
|
6
|
+
> -- <cite>Bender, Futurama</cite>
|
7
|
+
|
8
|
+
TellThem is a drop-in development aid for rails that puts a nice hovering box over any page which you want to provide debug information for.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'tell-them'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install tell-them
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
You'll need to include the tell-them style file in app/assets/stylesheets/application.scss,
|
29
|
+
|
30
|
+
```
|
31
|
+
//= require tell-them
|
32
|
+
```
|
33
|
+
|
34
|
+
...and add a line into your layout (say in apps/views/layouts/application.html.erb) that will insert the necessary HTML:
|
35
|
+
|
36
|
+
```
|
37
|
+
<%= TellThem.html %>
|
38
|
+
```
|
39
|
+
|
40
|
+
[OPTIONAL] add the script files in app/assets/javascripts/application.js (TellThem doesn't need the javascript to work, but it enables a few nice features like saved prefs, choosing the position of the pop-up debugging box and allowing you to pin it open)
|
41
|
+
|
42
|
+
```
|
43
|
+
//= require tell-them
|
44
|
+
```
|
45
|
+
|
46
|
+
When all that's done, TellThem is ready to use! Whenever you want to expose internal data from the controller to the developer in the webpage, just add it as one or more key:value pairs using a map:
|
47
|
+
|
48
|
+
```
|
49
|
+
TellThem.add(this: 'this is some data!', :'Become Admin' => '/become_admin?source=tell-them')
|
50
|
+
```
|
51
|
+
|
52
|
+
This data will now appear in a little pop-up box on the webpage. Note that the popup box will only appear if Rails.env.development? is true, and it will only appear if at some point in rendering of the page some data has been added with TellThem.add()
|
53
|
+
|
54
|
+
* No data? No box
|
55
|
+
* In production/staging/test? No box
|
56
|
+
|
57
|
+
If the value of any item will parse as a URI, TellThem will wrap it in a link so that it's clickable.
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
load_prefs = ->
|
2
|
+
prefs = JSON.parse(localStorage.getItem("tellThemPrefs"))
|
3
|
+
return if !prefs?
|
4
|
+
$('#tell-them-box').removeClass('pinned')
|
5
|
+
if prefs.pinned == 1
|
6
|
+
$('#tell-them-box').addClass('pinned')
|
7
|
+
$('#tell-them-box .controls .pin').text('Unpin')
|
8
|
+
$('#tell-them-box').addClass(prefs.corner)
|
9
|
+
$('#tell-them-box .controls .corners button').removeClass('current')
|
10
|
+
$('#tell-them-box .controls .corners button[data-target-corner=' + prefs.corner + ']').addClass('current')
|
11
|
+
|
12
|
+
save_prefs = ->
|
13
|
+
pin_value = 0
|
14
|
+
if $('#tell-them-box').hasClass('pinned')
|
15
|
+
pin_value = 1
|
16
|
+
prefs = {
|
17
|
+
corner: $('#tell-them-box .controls .corners button.current').data('target-corner'),
|
18
|
+
pinned: pin_value
|
19
|
+
}
|
20
|
+
localStorage.setItem("tellThemPrefs", JSON.stringify(prefs))
|
21
|
+
|
22
|
+
change_corners = (e) ->
|
23
|
+
$('#tell-them-box').removeClass('top-left top-right bottom-left bottom-right')
|
24
|
+
$('#tell-them-box .controls .corners button').removeClass('current')
|
25
|
+
$(this).addClass('current')
|
26
|
+
$('#tell-them-box').addClass($(this).data('target-corner'))
|
27
|
+
save_prefs()
|
28
|
+
|
29
|
+
toggle_pin = (e) ->
|
30
|
+
$('#tell-them-box').toggleClass('pinned')
|
31
|
+
if $('#tell-them-box').hasClass('pinned')
|
32
|
+
$('#tell-them-box .controls .pin').text('Unpin')
|
33
|
+
else
|
34
|
+
$('#tell-them-box .controls .pin').text('Pin')
|
35
|
+
save_prefs()
|
36
|
+
|
37
|
+
$ ->
|
38
|
+
load_prefs()
|
39
|
+
$('#tell-them-box .controls .corners button').on 'click', change_corners
|
40
|
+
$('#tell-them-box .controls .pin').on 'click', toggle_pin
|
41
|
+
$('#tell-them-box .controls').css('display', 'block')
|
@@ -0,0 +1,110 @@
|
|
1
|
+
=positionable-box($distance)
|
2
|
+
position: fixed
|
3
|
+
bottom: $distance
|
4
|
+
right: $distance
|
5
|
+
border-radius: 1em
|
6
|
+
box-sizing: border-box
|
7
|
+
box-shadow: 0.1em 0.1em 0.5em rgba(128,64,0,0.3)
|
8
|
+
background-color: orange
|
9
|
+
&.top-right
|
10
|
+
top: $distance
|
11
|
+
right: $distance
|
12
|
+
bottom: initial
|
13
|
+
left: initial
|
14
|
+
&.top-left
|
15
|
+
top: $distance
|
16
|
+
left: $distance
|
17
|
+
bottom: initial
|
18
|
+
right: initial
|
19
|
+
&.bottom-right
|
20
|
+
bottom: $distance
|
21
|
+
right: $distance
|
22
|
+
top: initial
|
23
|
+
left: initial
|
24
|
+
&.bottom-left
|
25
|
+
bottom: $distance
|
26
|
+
left: $distance
|
27
|
+
top: initial
|
28
|
+
right: initial
|
29
|
+
|
30
|
+
$pad: 2%
|
31
|
+
|
32
|
+
#tell-them-box
|
33
|
+
+positionable-box($pad)
|
34
|
+
width: 5%
|
35
|
+
padding-top: 1em
|
36
|
+
cursor: pointer
|
37
|
+
box-shadow: 0.2em 0.2em 1em rgba(128,64,0,0.8)
|
38
|
+
-webkit-transition: width 0.1s height 0.1s
|
39
|
+
transition: width 0.1s height 0.1s
|
40
|
+
text-align: center
|
41
|
+
&:before
|
42
|
+
content: "?"
|
43
|
+
color: white
|
44
|
+
font-size: 32pt
|
45
|
+
font-weight: bold
|
46
|
+
.contents
|
47
|
+
display: none
|
48
|
+
.controls
|
49
|
+
display: none
|
50
|
+
position: relative
|
51
|
+
margin: $pad
|
52
|
+
border-radius: 1em
|
53
|
+
padding: $pad
|
54
|
+
background-color: white
|
55
|
+
.corners
|
56
|
+
position: relative
|
57
|
+
width: 2em
|
58
|
+
height: 2em
|
59
|
+
button
|
60
|
+
position: absolute
|
61
|
+
width: 50%
|
62
|
+
height: 50%
|
63
|
+
border: 1px solid black
|
64
|
+
background-color: white
|
65
|
+
cursor: pointer
|
66
|
+
&.current
|
67
|
+
background-color: black
|
68
|
+
&:hover
|
69
|
+
background-color: gray
|
70
|
+
&[data-target-corner="top-left"]
|
71
|
+
top: 0
|
72
|
+
left: 0
|
73
|
+
&[data-target-corner="top-right"]
|
74
|
+
top: 0
|
75
|
+
right: 0
|
76
|
+
&[data-target-corner="bottom-left"]
|
77
|
+
bottom: 0
|
78
|
+
left: 0
|
79
|
+
&[data-target-corner="bottom-right"]
|
80
|
+
bottom: 0
|
81
|
+
right: 0
|
82
|
+
.pin
|
83
|
+
position: absolute
|
84
|
+
top: 40%
|
85
|
+
right: $pad
|
86
|
+
border-radius: $pad
|
87
|
+
background-color: white
|
88
|
+
color: black
|
89
|
+
cursor: pointer
|
90
|
+
dl
|
91
|
+
text-align: left
|
92
|
+
margin: $pad
|
93
|
+
border-radius: 1em
|
94
|
+
padding: $pad
|
95
|
+
background-color: white
|
96
|
+
dt
|
97
|
+
font-weight: bold
|
98
|
+
&:hover, &.pinned
|
99
|
+
cursor: default
|
100
|
+
width: 50%
|
101
|
+
&:before
|
102
|
+
display: none
|
103
|
+
.contents
|
104
|
+
display: block
|
105
|
+
&.pinned
|
106
|
+
.contents
|
107
|
+
.controls
|
108
|
+
.pin
|
109
|
+
background-color: black
|
110
|
+
color: white
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tell-them"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
module TellThem
|
2
|
+
def self.add(data)
|
3
|
+
TellThemStore.instance.add(data)
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.has_data?
|
7
|
+
TellThemStore.instance.has_data?
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.data
|
11
|
+
TellThemStore.instance.data
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.html
|
15
|
+
return '' unless has_data? && ::Rails.env.development?
|
16
|
+
box_html.html_safe
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def self.box_html
|
22
|
+
box = '<div id="tell-them-box">'
|
23
|
+
box += ' <div class="contents">'
|
24
|
+
box += ' <div class="controls">'
|
25
|
+
box += ' <div class="corners">'
|
26
|
+
box += ' <button data-target-corner="top-left"></button>'
|
27
|
+
box += ' <button data-target-corner="top-right"></button>'
|
28
|
+
box += ' <button data-target-corner="bottom-left"></button>'
|
29
|
+
box += ' <button class="current" data-target-corner="bottom-right"></button>'
|
30
|
+
box += ' </div>'
|
31
|
+
box += ' <button class="pin">Pin</button>'
|
32
|
+
box += ' </div>'
|
33
|
+
box += ' <dl class="items">'
|
34
|
+
data.each do |k,v|
|
35
|
+
box += " <dt>#{k}</dt>"
|
36
|
+
begin
|
37
|
+
URI::parse(v)
|
38
|
+
box += " <dd><a href=\"#{v}\">#{v}</a></dd>"
|
39
|
+
rescue URI::InvalidURIError
|
40
|
+
box += " <dd>#{v}</dd>"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
box += ' </dl>'
|
44
|
+
box += ' </div>'
|
45
|
+
box += '</div>'
|
46
|
+
box
|
47
|
+
end
|
48
|
+
|
49
|
+
class TellThemStore
|
50
|
+
include Singleton
|
51
|
+
|
52
|
+
def initialize
|
53
|
+
@data_store = {}
|
54
|
+
end
|
55
|
+
|
56
|
+
def add(data)
|
57
|
+
data.each { |k,v| @data_store[k] = v }
|
58
|
+
end
|
59
|
+
|
60
|
+
def has_data?
|
61
|
+
@data_store.any?
|
62
|
+
end
|
63
|
+
|
64
|
+
def data
|
65
|
+
@data_store
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/tell-them.rb
ADDED
data/tell-them.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tell-them/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tell-them"
|
8
|
+
spec.version = TellThem::Rails::VERSION
|
9
|
+
spec.authors = ["K M Lawrence"]
|
10
|
+
spec.email = ["keith@kludge.co.uk"]
|
11
|
+
|
12
|
+
spec.summary = %q{Adds a fixed debug button to a dev site}
|
13
|
+
spec.description = %q{Adds a fixed debug button to a dev site, which you can put debug information into easily}
|
14
|
+
spec.homepage = "https://www.github.com/KludgeKML/tell_them"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "railties", ">= 3.1"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tell-them
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- K M Lawrence
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Adds a fixed debug button to a dev site, which you can put debug information
|
56
|
+
into easily
|
57
|
+
email:
|
58
|
+
- keith@kludge.co.uk
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- app/assets/javascripts/tell-them.js.coffee
|
68
|
+
- app/assets/stylesheets/tell-them.sass
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/tell-them.rb
|
72
|
+
- lib/tell-them/tell-them.rb
|
73
|
+
- lib/tell-them/version.rb
|
74
|
+
- tell-them.gemspec
|
75
|
+
homepage: https://www.github.com/KludgeKML/tell_them
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.8
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Adds a fixed debug button to a dev site
|
99
|
+
test_files: []
|