caveat_patch_kids 0.0.5 → 0.0.7

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.
data/README.md CHANGED
@@ -33,13 +33,15 @@ If something does break, and you really need to get back into Propane, you can t
33
33
 
34
34
  These scripts are provided by CaveatPatchKids. Include them by updating ~/.caveat_patch_kids/caveatPatchor.js like:
35
35
 
36
- //= require caveat_patch_kids/the_scripts
36
+ //= require caveat_patch_kids/the_script
37
37
 
38
- * caveat_patch_kids/display_avatars: display gravatars next to user's
38
+ * caveat_patch_kids/display_avatars: display a [Gravatar](http://www.gravatar.com/) next to a user's name
39
+ * caveat_patch_kids/display_cloudapp_images: display [CloudApp](http://getcloudapp.com/) images inline
40
+ * caveat_patch_kids/display_scout: display [Scout](https://scoutapp.com/) graph links as embeded graphs
39
41
  * caveat_patch_kids/embiggen_message_history: increase message history
40
42
  * caveat_patch_kids/stylize_diffs: colorize diffs with red/green
41
- * caveat_patch_kids/stylize_diffs: colorize nagios alerts
42
- * caveat_patch_kids/link_to_rdio_app: update rdio links to go to the Rdio app, instead of a browser
43
+ * caveat_patch_kids/stylize_nagios: colorize nagios alerts
44
+ * caveat_patch_kids/link_to_rdio_app: update [Rdio](http://rdio.com/) links to go to the Rdio app, instead of a browser
43
45
 
44
46
  The original caveatPatchor.js had a lot of mysterious and odd things. Those weren't included by default, but could be of use to someone, somewhere, or maybe just need some cleanup and documentation. See `scripts/caveat_patch_kids/unsupported` for the good.
45
47
 
@@ -1,3 +1,3 @@
1
1
  module CaveatPatchKids
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -2,6 +2,7 @@
2
2
  //
3
3
  //= require caveat_patch_kids/display_avatars
4
4
  //= require caveat_patch_kids/display_cloudapp_images
5
+ //= require caveat_patch_kids/display_scout
5
6
  //= require caveat_patch_kids/embiggen_message_history
6
7
  //= require caveat_patch_kids/stylize_nagios
7
8
  //= require caveat_patch_kids/stylize_diffs
@@ -0,0 +1,50 @@
1
+ Campfire.ScoutGraphExpander = Class.create({
2
+ initialize: function(chat) {
3
+ this.chat = chat;
4
+ var messages = this.chat.transcript.messages;
5
+ for (var i = 0; i < messages.length; i++) {
6
+ this.detectScoutGraphUrl(messages[i]);
7
+ }
8
+ },
9
+
10
+ detectScoutGraphUrl: function(message) {
11
+ if (!message.pending() && message.kind === 'text') {
12
+ var links = message.bodyElement().select('a:not(image)');
13
+ if (links.length != 1) {
14
+ return;
15
+ }
16
+ var link = links[0];
17
+ var href = link.getAttribute('href');
18
+ var match = href.match(/^(https?:\/\/scoutapp.com\/.*\/charts)(\?.*)$/);
19
+ if (!match) return;
20
+
21
+ var embed_src = match[1] + '/embed' + match[2];
22
+
23
+ // add an end_time, if it doesn't exist
24
+ if (!href.match(/end_time/)) {
25
+ href += '&end_time=' + message.chat.timestamp;
26
+ link.setAttribute('href', href);
27
+
28
+ embed_src += '&end_time=' + message.chat.timestamp;
29
+ }
30
+
31
+ var iframe = '<iframe src="' + embed_src + '" width="98%" height="200" style="border:0; margin-top: 5px"></iframe>';
32
+
33
+ message.bodyCell.insert({bottom: iframe});
34
+ }
35
+ },
36
+
37
+ onMessagesInsertedBeforeDisplay: function(messages) {
38
+ for (var i = 0; i < messages.length; i++) {
39
+ this.detectScoutGraphUrl(messages[i]);
40
+ }
41
+ },
42
+
43
+ onMessageAccepted: function(message, messageID) {
44
+ this.detectScoutGraphUrl(message);
45
+ }
46
+ });
47
+
48
+ Campfire.Responders.push("ScoutGraphExpander");
49
+ window.chat.installPropaneResponder("ScoutGraphExpander", "scoutexpander");
50
+
@@ -0,0 +1,40 @@
1
+ Campfire.RdioExpander = Class.create({
2
+ initialize: function(chat) {
3
+ this.chat = chat;
4
+ var messages = this.chat.transcript.messages;
5
+ for (var i = 0; i < messages.length; i++) {
6
+ this.detectRdioURL(messages[i]);
7
+ }
8
+ },
9
+
10
+ detectRdioURL: function(message) {
11
+ if (!message.pending() && message.kind === 'text') {
12
+ var body = message.bodyElement()
13
+ var links = message.bodyElement().select('a:not(image)');
14
+
15
+ for (var i = 0; i < links.length; i++) {
16
+ var link = links[i];
17
+ var href = link.getAttribute('href');
18
+ var match = href.match(/^http:\/\/(rd\.io\/x\/\w*)$/)
19
+ if (match) {
20
+ var rdioHref = "rdio://" + match[1];
21
+ link.setAttribute('href', rdioHref);
22
+ }
23
+ }
24
+ }
25
+ },
26
+
27
+ onMessagesInsertedBeforeDisplay: function(messages) {
28
+ for (var i = 0; i < messages.length; i++) {
29
+ this.detectRdioURL(messages[i]);
30
+ }
31
+ },
32
+
33
+ onMessageAccepted: function(message, messageID) {
34
+ this.detectRdioURL(message);
35
+ }
36
+
37
+ });
38
+
39
+ Campfire.Responders.push("RdioExpander");
40
+ window.chat.installPropaneResponder("RdioExpander", "rdioexpander");
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caveat_patch_kids
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-06 00:00:00.000000000 Z
12
+ date: 2013-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -82,9 +82,10 @@ files:
82
82
  - scripts/caveat_patch_kids/display_avatars.js
83
83
  - scripts/caveat_patch_kids/display_cloudapp_images.js
84
84
  - scripts/caveat_patch_kids/display_githubs.js
85
+ - scripts/caveat_patch_kids/display_scout.js
85
86
  - scripts/caveat_patch_kids/embed_youtube.js
86
87
  - scripts/caveat_patch_kids/embiggen_message_history.js
87
- - scripts/caveat_patch_kids/link_to_rdio_app.coffee
88
+ - scripts/caveat_patch_kids/link_to_rdio_app.js
88
89
  - scripts/caveat_patch_kids/stylize_diffs.js
89
90
  - scripts/caveat_patch_kids/stylize_nagios.js
90
91
  - scripts/caveat_patch_kids/unsupported/display_emoji.js
@@ -1,24 +0,0 @@
1
- Campfire.RdioExpander = Class.create({
2
- initialize: (chat) ->
3
- this.chat = chat
4
- this.detectRdioURL(message) for message in chat.transcript.messages
5
-
6
- detectRdioURL: (message) ->
7
- if !message.pending() and message.kind == 'text'
8
- links = message.bodyElement().select('a:not(image)')
9
- for link in links
10
- href = link.getAttribute('href')
11
- match = href.match(/^http:\/\/(rd\.io\/x\/\w*)$/)
12
- if match
13
- rdioHref = "rdio://" + match[1]
14
- link.setAttribute('href', rdioHref)
15
-
16
- onMessagesInsertedBeforeDisplay: (messages) ->
17
- this.detectRdioURL(message) for message in messages
18
-
19
- onMessageAccepted: (message, messageID) ->
20
- this.detectRdioURL(message)
21
- })
22
-
23
- Campfire.Responders.push("RdioExpander")
24
- window.chat.installPropaneResponder("RdioExpander", "rdioexpander")