caveat_patch_kids 0.0.4 → 0.0.5

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.
@@ -1,3 +1,3 @@
1
1
  module CaveatPatchKids
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  //= require caveat_patch_kids
2
2
  //
3
3
  //= require caveat_patch_kids/display_avatars
4
+ //= require caveat_patch_kids/display_cloudapp_images
4
5
  //= require caveat_patch_kids/embiggen_message_history
5
6
  //= require caveat_patch_kids/stylize_nagios
6
7
  //= require caveat_patch_kids/stylize_diffs
@@ -0,0 +1,53 @@
1
+ Campfire.CloudAppExpander = 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.detectCloudAppURL(messages[i]);
7
+ }
8
+ },
9
+
10
+ detectCloudAppURL: function(message) {
11
+ /* we are going to use the messageID to uniquely identify our requestJSON request
12
+ so we don't check pending messages */
13
+ if (!message.pending() && message.kind === 'text') {
14
+ var links = message.bodyElement().select('a:not(image)');
15
+ if (links.length != 1) {
16
+ return;
17
+ }
18
+ var href = links[0].getAttribute('href');
19
+ var match = href.match(/^https?:\/\/cl.ly\/image\/[A-Za-z0-9]+\/?$/);
20
+ if (!match) return;
21
+ window.propane.requestJSON(message.id(), href, 'window.chat.cloudappexpander', 'onEmbedDataLoaded', 'onEmbedDataFailed');
22
+ }
23
+ },
24
+
25
+ onEmbedDataLoaded: function(messageID, data) {
26
+ var message = window.chat.transcript.getMessageById(messageID);
27
+ if (!message) return;
28
+
29
+ if (data['item_type'] === 'image') {
30
+ var imageURL = data['content_url'];
31
+ message.resize((function() {
32
+ message.bodyCell.insert({bottom: '<div style="width:100%; margin-top:5px; padding-top: 5px; border-top:1px dotted #ccc;"><a href="'+imageURL+'" class="image loading" target="_blank">' + '<img src="'+imageURL+'" onload="$dispatch(&quot;inlineImageLoaded&quot;, this)" onerror="$dispatch(&quot;inlineImageLoadFailed&quot;, this)" /></a></div>'});
33
+ }).bind(this));
34
+ }
35
+ },
36
+
37
+ onEmbedDataFailed: function(messageID) {
38
+ /* No cleanup required, we only alter the HTML after we get back a succesful load from the data */
39
+ },
40
+
41
+ onMessagesInsertedBeforeDisplay: function(messages) {
42
+ for (var i = 0; i < messages.length; i++) {
43
+ this.detectCloudAppURL(messages[i]);
44
+ }
45
+ },
46
+
47
+ onMessageAccepted: function(message, messageID) {
48
+ this.detectCloudAppURL(message);
49
+ }
50
+ });
51
+
52
+ Campfire.Responders.push("CloudAppExpander");
53
+ window.chat.installPropaneResponder("CloudAppExpander", "cloudappexpander");
@@ -0,0 +1,24 @@
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")
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.4
4
+ version: 0.0.5
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-02-26 00:00:00.000000000 Z
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
@@ -80,10 +80,11 @@ files:
80
80
  - scripts/caveat_patch_kids/bundles/all.js
81
81
  - scripts/caveat_patch_kids/bundles/unsupported.js
82
82
  - scripts/caveat_patch_kids/display_avatars.js
83
+ - scripts/caveat_patch_kids/display_cloudapp_images.js
83
84
  - scripts/caveat_patch_kids/display_githubs.js
84
85
  - scripts/caveat_patch_kids/embed_youtube.js
85
86
  - scripts/caveat_patch_kids/embiggen_message_history.js
86
- - scripts/caveat_patch_kids/link_to_rdio_app.js
87
+ - scripts/caveat_patch_kids/link_to_rdio_app.coffee
87
88
  - scripts/caveat_patch_kids/stylize_diffs.js
88
89
  - scripts/caveat_patch_kids/stylize_nagios.js
89
90
  - scripts/caveat_patch_kids/unsupported/display_emoji.js
@@ -122,3 +123,4 @@ specification_version: 3
122
123
  summary: CaveatPatchKids is a tool for generating, sharing, and maintaing caveatPatchor.js
123
124
  files for use with Propane, powered by sprockets and other fun stuff
124
125
  test_files: []
126
+ has_rdoc:
@@ -1,40 +0,0 @@
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");