social_stream-documents 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,3 +48,14 @@ showAllDocumentComments = function(id){
48
48
  //and hide the hide_show_comments
49
49
  $("#"+id).children(".hide_show_comments").hide();
50
50
  };
51
+
52
+ toggleDocumentEdit = function(){
53
+ if($("#document_edit").css("display")=="none"){
54
+ $("#document_edit").show("slow");
55
+ $("#document_edit_action").addClass("selected");
56
+
57
+ }else{
58
+ $("#document_edit").hide("slow");
59
+ $("#document_edit_action").removeClass("selected");
60
+ }
61
+ }
@@ -45,13 +45,42 @@
45
45
  margin-left: 30px;
46
46
  }
47
47
  #document_info #actions .action{
48
- margin-right: 10px;
48
+ margin-right: 10px;
49
+ padding: 5px;
50
+ }
51
+ #document_info #actions .action.selected{
52
+ border: thin solid $separation-color;
53
+ background: $secondary-color;
49
54
  }
50
55
  #document_info #actions .action img{
51
56
  width: 16px;
52
57
  height: 16px;
53
58
  }
54
59
 
60
+ #document_edit {
61
+ margin: 5px 5px 0px 5px;
62
+ border: thin solid $separation-color;
63
+ background: $secondary-color;
64
+
65
+ }
66
+ #document_edit textarea{
67
+ resize: none;
68
+ height: 75px;
69
+ }
70
+ #document_edit .form_row {
71
+ padding: 5px 10px;
72
+ }
73
+ #document_edit .form_label {
74
+ width: 100px;
75
+ }
76
+ #document_edit .form_field {
77
+ width: 415px;
78
+ padding: 0;
79
+ }
80
+ #document_edit .form_tag {
81
+ width: 100%;
82
+ }
83
+
55
84
  #document_comments {
56
85
  margin-top: 20px;
57
86
  padding-top: 10px;
@@ -1,2 +1,2 @@
1
- class AudiosController < CommonDocumentsController
1
+ class AudiosController < DocumentsController
2
2
  end
@@ -1,19 +1,44 @@
1
- class DocumentsController < CommonDocumentsController
1
+ class DocumentsController < InheritedResources::Base
2
2
  respond_to :html, :js
3
-
4
- SEND_FILE_METHOD = :default
5
3
 
4
+ belongs_to_subjects :optional => true
5
+
6
+ before_filter :profile_subject!, :only => :index
7
+
8
+ load_and_authorize_resource :except => :index
9
+
10
+ SEND_FILE_METHOD = :default
6
11
  def create
7
12
  super do |format|
8
13
  format.all {redirect_to request.referer || home_path}
9
14
  end
10
15
  end
11
-
16
+
17
+ def update
18
+ update! do |success, failure|
19
+ failure.html { render :action => :show }
20
+ success.html { render :action => :show }
21
+ end
22
+ end
23
+
24
+ def show
25
+ respond_to do |format|
26
+ format.html {render :action => :show}
27
+ format.all {
28
+ path = resource.file.path(params[:style] || params[:format])
29
+
30
+ send_file path,
31
+ :filename => resource.file_file_name,
32
+ :disposition => "inline"
33
+ }
34
+ end
35
+ end
36
+
12
37
  #TODO: we have to add the mimetype as in videos_controller
13
38
  def download
14
39
  path = @document.file.path(params[:style])
15
40
 
16
- head(:bad_request) and return unless File.exist?(path)
41
+ head(:bad_request) and return unless File.exist?(path)
17
42
 
18
43
  send_file_options = {
19
44
  :filename => @document.file_file_name,
@@ -22,13 +47,29 @@ class DocumentsController < CommonDocumentsController
22
47
 
23
48
  # Ask Victor about the rationale of this:
24
49
  case SEND_FILE_METHOD
25
- when :apache then send_file_options[:x_sendfile] = true
26
- when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''))
50
+ when :apache then send_file_options[:x_sendfile] = true
51
+ when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''))
27
52
  end
28
53
 
29
54
  send_file(path, send_file_options)
30
55
  end
31
56
 
57
+ def destroy
58
+ @post_activity = resource.post_activity
59
+
60
+ destroy!
61
+ end
62
+
63
+ private
64
+
65
+ def collection
66
+ @activities = profile_subject.wall(:profile,
67
+ :for => current_subject,
68
+ :object_type => Array(self.class.index_object_type)).
69
+ page(params[:page]).
70
+ per(params[:per])
71
+ end
72
+
32
73
  class << self
33
74
  def index_object_type
34
75
  [ :Audio, :Video, :Picture, :Document ]
@@ -1,2 +1,2 @@
1
- class PicturesController < CommonDocumentsController
1
+ class PicturesController < DocumentsController
2
2
  end
@@ -1,2 +1,2 @@
1
- class VideosController < CommonDocumentsController
1
+ class VideosController < DocumentsController
2
2
  end
@@ -8,8 +8,11 @@ class Document < ActiveRecord::Base
8
8
  :path => ':rails_root/documents/:class/:id_partition/:style/:filename.:extension'
9
9
 
10
10
  validates_attachment_presence :file
11
+ validates_presence_of :title
11
12
 
12
- before_create :set_title_and_description
13
+ before_validation(:on => :create) do
14
+ set_title_and_description
15
+ end
13
16
 
14
17
  define_index do
15
18
  indexes title
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @audio } %>
@@ -24,11 +24,12 @@
24
24
  </div>
25
25
  <br class="clearfloat" />
26
26
  <div id="actions">
27
- <%= link_to image_tag("btn/download.png") + t('document.actions.download'), download_document_path(document), :class => :action %>
28
- <%= link_to image_tag("btn/edit.png") + t('document.actions.edit'), "javascript:toggleEdit();", :class => :action %>
27
+ <%= link_to content_tag(:span,image_tag("btn/download.png") + t('document.actions.download'), :class => :action), download_document_path(document) %>
28
+ <%= link_to content_tag(:span,image_tag("btn/edit.png") + t('document.actions.edit'), :class => :action, :id => :document_edit_action), "javascript:toggleDocumentEdit();" %>
29
29
  <% if document.post_activity.delete_object_by?(current_subject) %>
30
- <%= link_to image_tag("btn/error.png") + t('document.actions.delete'), document.post_activity.direct_object , :confirm => t('confirm_delete',
30
+ <%= link_to content_tag(:span,image_tag("btn/error.png") + t('document.actions.delete'), :class => :action), document.post_activity.direct_object , :confirm => t('confirm_delete',
31
31
  :scope => document.post_activity.direct_object.class.to_s.underscore), :method => :delete %>
32
32
  <% end %>
33
33
  </div>
34
34
  </div>
35
+ <%= render :partial => "common/edit_form", :locals => {:document => document} %>
@@ -0,0 +1,49 @@
1
+ <div class="block" id="document_edit" style="display:none;">
2
+ <%= form_for(document, :html => { :method => :put }) do |f| %>
3
+ <% if document and document.errors.any? %>
4
+ <%= javascript_tag do %>
5
+ $(document).ready(function(){
6
+ toggleDocumentEdit();
7
+ });
8
+ <% end %>
9
+ <div class="error">
10
+ <ul>
11
+ <% document.errors.full_messages.each do |msg| %>
12
+ <li>
13
+ <%= msg %>
14
+ </li>
15
+ <% end %>
16
+ </ul>
17
+ </div>
18
+ <% end %>
19
+ <div class="form_row">
20
+ <div class="form_label">
21
+ <%= f.label t('document.info.title.title') %>
22
+ </div>
23
+ <div class="form_field">
24
+ <%= f.text_field :title, :class => "form_tag" %>
25
+ </div>
26
+ </div>
27
+ <div class="form_row">
28
+ <div class="form_label">
29
+ <%= f.label t('document.info.description.title') %>
30
+ </div>
31
+ <div class="form_field">
32
+ <%= f.text_area :description, :class => "form_tag" %>
33
+ </div>
34
+ </div>
35
+ <!--
36
+ <div class="form_row">
37
+ <div class="form_label">
38
+ <%#= f.label t('document.info.file.title') %>
39
+ </div>
40
+ <div class="form_field">
41
+ <%#= f.file_field :file, :class => "form_tag" %>
42
+ </div>
43
+ </div>
44
+ -->
45
+ <div class="actions center">
46
+ <%= f.submit t('document.actions.edit'), :class => "button" %>
47
+ </div>
48
+ <% end %>
49
+ </div>
@@ -28,7 +28,7 @@
28
28
 
29
29
  <%= show_view_for document %>
30
30
 
31
- <%= render :partial => "document_info", :locals => {:document => document} %>
31
+ <%= render :partial => "common/document_info", :locals => {:document => document} %>
32
32
 
33
33
  <div id="document_comments">
34
34
  <%= render :partial => 'activities/comments', :locals => { :activity => document.post_activity } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @document } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @picture } %>
@@ -1 +1 @@
1
- <%=render(:partial => 'common_documents/index') %>
1
+ <%=render(:partial => 'common/index') %>
@@ -1,2 +1,2 @@
1
- <%= render :partial => 'common_documents/show',
1
+ <%= render :partial => 'common/show',
2
2
  :locals => { :document => @video } %>
@@ -21,6 +21,8 @@ en:
21
21
  updated_at: "Updated at"
22
22
  description:
23
23
  title: "Description"
24
+ file:
25
+ title: "Upload"
24
26
  title:
25
27
  title: "Title"
26
28
  mine: "My documents"
@@ -43,7 +45,7 @@ en:
43
45
  resource:
44
46
  all: "All Resources"
45
47
  confirm_delete: "Delete resource?"
46
- title: "Resources"
48
+ title: "Repository"
47
49
  mine: "My resources"
48
50
  msg: "Uploaded a resource:"
49
51
  not_mine: "Resources"
@@ -21,6 +21,8 @@ es:
21
21
  updated_at: "Última modificación"
22
22
  description:
23
23
  title: "Descripción"
24
+ file:
25
+ title: "Subir"
24
26
  title:
25
27
  title: "Título"
26
28
  mine: "Mis documentos"
@@ -43,7 +45,7 @@ es:
43
45
  resource:
44
46
  all: "Todos los recursos"
45
47
  confirm_delete: "¿Borrar recursos?"
46
- title: "Recursos"
48
+ title: "Repositorio"
47
49
  mine: "Mis recursos"
48
50
  msg: "Subió un recurso:"
49
51
  not_mine: "Recursos"
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Documents
3
- VERSION = "0.4.0".freeze
3
+ VERSION = "0.4.1".freeze
4
4
  end
5
5
  end
@@ -6,17 +6,22 @@ module SocialStream
6
6
 
7
7
  items << {
8
8
  :key => :resources,
9
- :name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("resource.#{ subject == current_subject ? 'mine' : 'title' }"),
10
- :url => "#",
11
- :options => {:link => {:id => "resources_menu"}},
12
- :items => [
13
- {:key => :resources_documents,:name => image_tag("btn/btn_document.png")+t('document.title'),:url => polymorphic_path([subject, Document.new])},
14
- {:key => :resources_pictures,:name => image_tag("btn/btn_gallery.png")+t('picture.title'),:url => polymorphic_path([subject, Picture.new])},
15
- {:key => :resources_videos,:name => image_tag("btn/btn_video.png")+t('video.title'),:url => polymorphic_path([subject, Video.new])},
16
- {:key => :resources_audios,:name => image_tag("btn/btn_audio.png")+t('audio.title'),:url => polymorphic_path([subject, Audio.new])}
17
- ]
9
+ :name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("resource.title"),
10
+ :url => polymorphic_path([subject, Document.new]),
11
+ :options => {:link => {:id => "resources_menu"}}
18
12
  }
19
13
  end
14
+
15
+ def home_toolbar_items
16
+ items = super
17
+
18
+ items << {
19
+ :key => :resources,
20
+ :name => image_tag("btn/btn_resource.png",:class =>"menu_icon")+t("resource.title"),
21
+ :url => polymorphic_path([current_subject, Document.new]),
22
+ :options => {:link => {:id => "resources_menu"}}
23
+ }
24
+ end
20
25
  end
21
26
  end
22
27
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.9.23')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.9.24')
16
16
  s.add_runtime_dependency('paperclip-ffmpeg', '~> 0.7.0')
17
17
  s.add_runtime_dependency('paperclip','2.3.11')
18
18
  s.add_runtime_dependency('delayed_paperclip','>= 0.7.2')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-documents
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "V\xC3\xADctor S\xC3\xA1nchez Belmar"
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-28 00:00:00 +02:00
19
+ date: 2011-10-31 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 21
30
+ hash: 11
31
31
  segments:
32
32
  - 0
33
33
  - 9
34
- - 23
35
- version: 0.9.23
34
+ - 24
35
+ version: 0.9.24
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -235,7 +235,6 @@ files:
235
235
  - app/assets/stylesheets/show.css.scss
236
236
  - app/assets/stylesheets/social_stream-documents.css
237
237
  - app/controllers/audios_controller.rb
238
- - app/controllers/common_documents_controller.rb
239
238
  - app/controllers/documents_controller.rb
240
239
  - app/controllers/pictures_controller.rb
241
240
  - app/controllers/videos_controller.rb
@@ -257,9 +256,10 @@ files:
257
256
  - app/views/audios/index.html.erb
258
257
  - app/views/audios/index.js.erb
259
258
  - app/views/audios/show.html.erb
260
- - app/views/common_documents/_document_info.html.erb
261
- - app/views/common_documents/_index.html.erb
262
- - app/views/common_documents/_show.html.erb
259
+ - app/views/common/_document_info.html.erb
260
+ - app/views/common/_edit_form.html.erb
261
+ - app/views/common/_index.html.erb
262
+ - app/views/common/_show.html.erb
263
263
  - app/views/documents/_document.html.erb
264
264
  - app/views/documents/_document_focus_search.html.erb
265
265
  - app/views/documents/_document_global_search.html.erb
@@ -1,45 +0,0 @@
1
- class CommonDocumentsController < InheritedResources::Base
2
- respond_to :html, :js
3
-
4
- belongs_to_subjects :optional => true
5
-
6
- before_filter :profile_subject!, :only => :index
7
-
8
- load_and_authorize_resource :except => :index
9
-
10
-
11
- def show
12
- respond_to do |format|
13
- format.html {render :action => :show}
14
- format.all {
15
- path = resource.file.path(params[:style] || params[:format])
16
-
17
- send_file path,
18
- :filename => resource.file_file_name,
19
- :disposition => "inline"
20
- }
21
- end
22
- end
23
-
24
- def destroy
25
- @post_activity = resource.post_activity
26
-
27
- destroy!
28
- end
29
-
30
- private
31
-
32
- def collection
33
- @activities = profile_subject.wall(:profile,
34
- :for => current_subject,
35
- :object_type => Array(self.class.index_object_type)).
36
- page(params[:page]).
37
- per(params[:per])
38
- end
39
-
40
- class << self
41
- def index_object_type
42
- controller_name.classify
43
- end
44
- end
45
- end