-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds basic styling for sidebar * Adds link plugin * Adds image plugin * Adds Youtube plugin * Adds basic music player plugin [WIP] * Adds a stub Kandan.Store API to get music player working * View fix: escapes message if not processed by a modifier * Template fix: unescape certain elements in templates * Switch from jquery template to underscore templates * Deletes unnecessary templates * Removes ember-rails dependency Signed-off-by: Akash Manohar J <[email protected]>
- Loading branch information
Showing
17 changed files
with
139 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/assets/javascripts/backbone/plugins/image_embed.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Kandan.Plugins.ImageEmbed | ||
@regex: /^http.*\.(jpg|jpeg|gif|png)/i | ||
@image_template: _.template('<a target="_blank" href="<%= image_url %>"><img class="image-embed" src="<%= image_url %>" height="200" width="200" /></a>') | ||
|
||
@init: ()-> | ||
Kandan.Modifiers.register @regex, (message, state)=> | ||
message.content = @image_template({ image_url: message.content }) | ||
console.log message.content | ||
return Kandan.Helpers.Activities.build_from_message_template(message) | ||
|
||
Kandan.Plugins.register "Kandan.Plugins.ImageEmbed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
class Kandan.Plugins.Link | ||
class Kandan.Plugins.LinkEmbed | ||
|
||
@regex: /http:\S*/g | ||
@link_template: _.template('<a target="_blank" href="<%- url %>"><%- url %></a>') | ||
|
||
@init: ()-> | ||
Kandan.Modifiers.register @regex, (message, state)=> | ||
message.content = message.content.replace @regex, '<a target="_blank" href="$1">$1</a>' | ||
message.content = message.content | ||
.replace(@regex, @link_template({ url: "$1" })) | ||
return Kandan.Helpers.Activities.build_from_message_template(message) | ||
|
||
Kandan.Plugins.register "Kandan.Plugins.Link" | ||
Kandan.Plugins.register "Kandan.Plugins.LinkEmbed" |
84 changes: 84 additions & 0 deletions
84
app/assets/javascripts/backbone/plugins/music_player.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
class Kandan.Plugins.MusicPlayer | ||
|
||
@plugin_namespace: "Kandan.Plugins.MusicPlayer" | ||
@plugin_id: "" | ||
@widget_name: "music_player" | ||
@play_regex: /^\/play .+/ | ||
@stop_regex: /^\/stop/ | ||
@local_song_data: false | ||
|
||
|
||
@play_template: _.template('<strong><a class="audio-play">playing</a> <a target="_blank" href="<%- url %>"><%- url %></a></strong>') | ||
@song_template: _.template('<li><%= song.split("/").pop() %></li>') | ||
|
||
|
||
@set_error: (error_message)-> | ||
console.log "music player error", error_message | ||
|
||
|
||
@create_song_list: (songs)-> | ||
$songs = $('<ul class="songs"></ul>') | ||
if songs.length == 0 | ||
$songs = "No songs! Maybe add some?" | ||
else | ||
$songs.append(@song_template({song: song})) for song in songs | ||
return $songs | ||
|
||
|
||
@render: ($widget_el)-> | ||
$widget_element_class = $widget_el.attr('class') | ||
|
||
if @local_song_data | ||
$songs = @create_song_list(@local_song_data) | ||
else | ||
@get_songs({ | ||
success: (songs)=> | ||
$songs = @create_song_list(songs) | ||
|
||
failure: ()-> | ||
@set_error("Could not load songs") | ||
}) | ||
$widget_el.html($songs) | ||
|
||
|
||
# TODO add support for sounds | ||
@init: (plugin_id)-> | ||
@plugin_id = plugin_id | ||
@register_modifier() | ||
@register_widget() | ||
|
||
|
||
@register_widget: ()-> | ||
Kandan.Widgets.register @widget_name, @plugin_namespace | ||
|
||
|
||
@register_modifier: ()-> | ||
Kandan.Modifiers.register @play_regex, (message, state)=> | ||
if state == Kandan.Helpers.Activities.ACTIVE_STATE | ||
console.log "add song to player and play song" | ||
@store_song url | ||
else | ||
console.log "song is history" | ||
|
||
message.content = @play_template({url: message.content.split @play_regex}) | ||
return Kandan.Helpers.Activities.build_from_base_template message | ||
|
||
|
||
# TODO display error about song not being added by creating an activity locally | ||
@store_song: (url)-> | ||
@get_songs({ | ||
success: (data)=> | ||
data.push url | ||
Kandan.Store.set @plugin_id, { | ||
success: (data)-> | ||
@local_song_data = data | ||
Kandan.Widgets.render_widget @widget_name | ||
} | ||
}) | ||
|
||
|
||
@get_songs: (callbacks)-> | ||
Kandan.Store.get @plugin_id, callbacks | ||
|
||
|
||
Kandan.Plugins.register "Kandan.Plugins.MusicPlayer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/assets/javascripts/backbone/plugins/youtube_embed.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class Kandan.Plugins.YoutubeEmbed | ||
|
||
@regex: /^http(s)?:\/\/www.youtube.com\/watch/i | ||
@youtube_id_pattern: /\Wv=([\w|\-]*)/ | ||
|
||
@youtube_embed_template: _.template('<div class="youtube-preview"><a target="_blank" class="youtube-preview-link" href="<%= video_url %>"><img class="youtube-preview-image" src="<% thumb_url %>" /></a></div>') | ||
|
||
@init: ()-> | ||
Kandan.Modifiers.register @regex, (message, state)=> | ||
video_id = message.content.match(@youtube_id_pattern)[1] | ||
thumb_url = "http://img.youtube.com/vi/#{ video_id }/0.jpg" | ||
message.content = @youtube_embed_template({ | ||
video_url: message.content, | ||
image_url: thumb_url | ||
}) | ||
return Kandan.Helpers.Activities.build_from_message_template(message) | ||
|
||
Kandan.Plugins.register "Kandan.Plugins.YoutubeEmbed" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Kandan.Store | ||
@get: (plugin_id, callbacks)-> | ||
# TODO this should change | ||
data = ["http://google.com/song.mp3", "http://google.com/song2.mp3"] | ||
callbacks.success(data) | ||
|
||
@set: (plugin_id, callbacks)-> | ||
callbacks.success(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,6 @@ | |
*= require_self | ||
*= require_tree . | ||
*/ | ||
|
||
.container {width: 80%; float: left} | ||
.sidebar {width: 20%; float: right} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<%= @activity.content %> | ||
<%- @activity.content %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<%= @activity.user.first_name %>: <%= @activity.content %> | ||
<%= @activity.user.first_name %>: <%- @activity.content %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ | |
# note that it will be overwritten if you use your own mailer class with default "from" parameter. | ||
config.mailer_sender = "[email protected]" | ||
|
||
config.cas_base_url = "http://noshido.com:3000/cas" if Rails.env.development? | ||
|
||
# Configure the class responsible to send e-mails. | ||
# config.mailer = "Devise::Mailer" | ||
|
||
|