Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds activity flushing and tane
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Mar 27, 2012
1 parent 9f41521 commit c050cc8
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -31,6 +31,8 @@ group :assets do
gem 'uglifier', '>= 1.0.3'
end

gem 'tane', :path => "../tane", :group => :development

# Test gems, obviously
group :test do
gem 'rspec-rails'
Expand Down
15 changes: 15 additions & 0 deletions Gemfile.lock
@@ -1,3 +1,14 @@
PATH
remote: ../tane
specs:
tane (0.0.3)
awesome_print
erubis
highline
launchy
rake
rest-client

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -30,6 +41,7 @@ GEM
multi_json (~> 1.0)
addressable (2.2.7)
arel (3.0.2)
awesome_print (1.0.2)
aws-sdk (1.3.8)
httparty (~> 0.7)
json (~> 1.4)
Expand Down Expand Up @@ -105,6 +117,8 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
launchy (2.1.0)
addressable (~> 2.2.6)
mail (2.4.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand Down Expand Up @@ -215,5 +229,6 @@ DEPENDENCIES
sass-rails (~> 3.2.3)
shoulda-matchers
sqlite3
tane!
thin
uglifier (>= 1.0.3)
9 changes: 9 additions & 0 deletions app/assets/javascripts/backbone/helpers/channels.js.coffee
Expand Up @@ -2,6 +2,7 @@ class Kandan.Helpers.Channels

@options:
autoScrollThreshold: 0.90
maxActivities: 10

@replaceCreateButton: ()->
$tabNav = $(".create_channel").parent().parent()
Expand Down Expand Up @@ -49,6 +50,12 @@ class Kandan.Helpers.Channels
confirmAgain = confirm("Are you damn sure?")
return confirmAgain

@flushActivities: (channelID)->
$channelActivities = $("#channel-activities-#{channelID}")
if $channelActivities.children().length > @options.maxActivities
oldest = $channelActivities.children().first().data("activity_id")
$channelActivities.children().first().remove()
$channelActivities.prev().data("oldest", oldest)

@deleteChannel: (channelIndex)->
channelID = @get_channel_id_from_tab_index(channelIndex)
Expand Down Expand Up @@ -99,13 +106,15 @@ class Kandan.Helpers.Channels
@channel_activities_el(activity_attributes.channel_id)
.append(@new_activity_view(activity_attributes).render().el)
@set_pagination_data(activity_attributes.channel_id)
# @flushActivities($(el).parent().data("channel_id"))


@add_notification: (activity_attributes)->
$channel_elements = $(".channel-activities")
activity_attributes["created_at"] = new Date()
for el in $channel_elements
$(el).append(@new_activity_view(activity_attributes).render().el)
@flushActivities($(el).parent().data("channel_id"))


@set_pagination_state: (channel_id, more_activities, oldest)->
Expand Down
14 changes: 13 additions & 1 deletion app/assets/javascripts/backbone/plugins/attachments.js.coffee
Expand Up @@ -11,6 +11,7 @@ class Kandan.Plugins.Attachments
<input id="channel_id_<%= channel_id %>" name="channel_id[<%= channel_id %>]" type="hidden"/>
<input id="file" name="file" type="file"/>
<input name="commit" type="submit" value="Upload"/>
<div class="dropzone" style="height: 100px;background-color: #000;"></div>
</form>
''')

Expand Down Expand Up @@ -38,7 +39,7 @@ class Kandan.Plugins.Attachments
csrf_token: @csrf_token()
})
$widget_el.html($upload_form)

@init_dropzone @channel_id()
$file_list = $("<ul></ul>")
attachments = new Kandan.Collections.Attachments([], {channel_id: @channel_id()})
attachments.fetch({success: (collection)=>
Expand All @@ -51,6 +52,17 @@ class Kandan.Plugins.Attachments
})


@init_dropzone: (channel_id)->
$(".dropzone").filedrop({
fallback_id: "file",
url: "/channels/#{channel_id}/attachments.json",
paramname: 'file',
uploadFinished: (i, file, response, time)->
console.log "upload complete"
dragOver: ->
console.log "reached dropzone!"
})

@init: ()->
Kandan.Widgets.register @plugin_namespace
Kandan.Data.Channels.register_callback "change", ()=>
Expand Down
1 change: 0 additions & 1 deletion app/controllers/attachments_controller.rb
Expand Up @@ -20,7 +20,6 @@ def create
@channel = Channel.find(params[:channel_id])
@attachment = Attachment.new(params[:attachment])


@attachment.user_id = current_user.id
@attachment.channel_id = @channel.id
@attachment.file = params[:file]
Expand Down
4 changes: 2 additions & 2 deletions app/models/attachment.rb
Expand Up @@ -8,8 +8,8 @@ class Attachment < ActiveRecord::Base
:storage => :s3,
:s3_credentials => {
:access_key_id => ENV['S3_ACCESS_KEY_ID'],
:secret_access_key => ENV['S3_SECRET_ACCESS_KEY'],
:session_token => ENV['STS_SESSION_TOKEN']
:secret_access_key => ENV['S3_SECRET_ACCESS_KEY']#,
#:session_token => ENV['STS_SESSION_TOKEN']
},
:bucket => ENV['S3_BUCKET'],
:url => "/:attachment/:id/:style/:basename.:extension",
Expand Down
4 changes: 3 additions & 1 deletion app/views/main/index.html.erb
Expand Up @@ -10,7 +10,9 @@
<div class="sidebar">
<div class="header">
<div class="search">
<input type="text" class="query"/>
<form method="get" action="/search" target="_blank">
<input type="text" class="query"/>
</form>
</div>
<div class="logo">Kandan</div>
</div>
Expand Down

0 comments on commit c050cc8

Please sign in to comment.