social_stream 0.11.8 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/base/app/assets/images/btn/download.png +0 -0
  2. data/base/app/assets/javascripts/activities.js.erb +1 -1
  3. data/base/app/assets/javascripts/social_stream-base.js +2 -0
  4. data/base/app/assets/stylesheets/social_stream-base.css +2 -0
  5. data/base/app/views/avatars/index.html.erb +0 -13
  6. data/base/app/views/comments/create.js.erb +3 -0
  7. data/base/app/views/toolbar/_home.html.erb +1 -1
  8. data/base/config/locales/en.yml +1 -0
  9. data/base/config/locales/es.yml +1 -0
  10. data/base/lib/social_stream/base/version.rb +1 -1
  11. data/base/lib/social_stream/controllers/helpers.rb +6 -0
  12. data/base/lib/social_stream/migrations/base.rb +12 -9
  13. data/base/lib/social_stream/migrations/components.rb +1 -1
  14. data/base/social_stream-base.gemspec +1 -1
  15. data/documents/Rakefile +3 -13
  16. data/documents/app/assets/javascripts/documents.js.erb +21 -32
  17. data/documents/app/assets/javascripts/social_stream-documents.js +2 -1
  18. data/documents/app/assets/stylesheets/{documents.css → documents.css.scss} +32 -6
  19. data/documents/app/assets/stylesheets/show.css.scss +75 -0
  20. data/documents/app/assets/stylesheets/social_stream-documents.css +2 -1
  21. data/documents/app/controllers/audios_controller.rb +0 -14
  22. data/documents/app/controllers/common_documents_controller.rb +6 -3
  23. data/documents/app/controllers/documents_controller.rb +9 -3
  24. data/documents/app/controllers/pictures_controller.rb +0 -1
  25. data/documents/app/controllers/videos_controller.rb +0 -15
  26. data/documents/app/helpers/documents_helper.rb +11 -7
  27. data/documents/app/models/audio.rb +1 -1
  28. data/documents/app/models/document.rb +9 -5
  29. data/documents/app/models/picture.rb +1 -1
  30. data/documents/app/models/video.rb +8 -6
  31. data/documents/app/views/audios/_audio.html.erb +2 -2
  32. data/documents/app/views/audios/_audio_processed.html.erb +4 -4
  33. data/documents/app/views/audios/_audio_show.html.erb +62 -0
  34. data/documents/app/views/audios/index.html.erb +1 -1
  35. data/documents/app/views/audios/show.html.erb +2 -2
  36. data/documents/app/views/common_documents/_document_info.html.erb +34 -0
  37. data/documents/app/views/common_documents/_index.html.erb +49 -0
  38. data/documents/app/views/common_documents/_show.html.erb +36 -0
  39. data/documents/app/views/documents/_document.html.erb +2 -6
  40. data/documents/app/views/documents/_document_show.html.erb +7 -0
  41. data/documents/app/views/documents/index.html.erb +1 -1
  42. data/documents/app/views/documents/show.html.erb +2 -2
  43. data/documents/app/views/pictures/_picture.html.erb +13 -12
  44. data/documents/app/views/pictures/_picture_show.html.erb +26 -0
  45. data/documents/app/views/pictures/index.html.erb +1 -1
  46. data/documents/app/views/pictures/show.html.erb +2 -2
  47. data/documents/app/views/videos/_video.html.erb +2 -2
  48. data/documents/app/views/videos/_video_processed.html.erb +4 -3
  49. data/documents/app/views/videos/_video_show.html.erb +64 -0
  50. data/documents/app/views/videos/index.html.erb +1 -1
  51. data/documents/app/views/videos/show.html.erb +2 -2
  52. data/documents/config/locales/en.yml +19 -1
  53. data/documents/config/locales/es.yml +18 -0
  54. data/documents/lib/social_stream/documents/engine.rb +2 -0
  55. data/documents/lib/social_stream/documents/version.rb +1 -1
  56. data/documents/social_stream-documents.gemspec +1 -1
  57. data/documents/spec/controllers/documents_controller_spec.rb +40 -2
  58. data/documents/spec/controllers/pictures_controller_spec.rb +4 -4
  59. data/documents/spec/dummy/config/environments/development.rb +0 -1
  60. data/documents/spec/dummy/config/environments/test.rb +2 -0
  61. data/lib/social_stream/release.rb +26 -4
  62. data/lib/social_stream/version.rb +1 -1
  63. data/presence/app/assets/javascripts/xmpp_client.js +0 -6
  64. data/presence/app/controllers/xmpp_controller.rb +46 -102
  65. data/presence/app/views/xmpp/_chat.html.erb +1 -2
  66. data/presence/ejabberd/conf/{ejabberd.cfg → ejabberd_example.cfg} +3 -7
  67. data/presence/ejabberd/conf/ssconfig_example.cfg +32 -0
  68. data/presence/ejabberd/ejabberd_scripts/authentication_script +7 -3
  69. data/presence/ejabberd/ejabberd_scripts/{compile_module → development_scripts/compile_module} +0 -0
  70. data/presence/ejabberd/ejabberd_scripts/{generate_random_password → development_scripts/generate_random_password} +0 -0
  71. data/presence/ejabberd/ejabberd_scripts/{kill_authentication_script.sh → development_scripts/kill_authentication_script.sh} +0 -0
  72. data/presence/ejabberd/ejabberd_scripts/{reset_logs.sh → development_scripts/reset_logs.sh} +0 -2
  73. data/presence/ejabberd/ejabberd_scripts/{show_config.sh → development_scripts/show_config.sh} +3 -0
  74. data/presence/ejabberd/ejabberd_scripts/{start_ejabberd.sh → development_scripts/start_ejabberd.sh} +0 -0
  75. data/presence/ejabberd/ejabberd_scripts/{stop_ejabberd.sh → development_scripts/stop_ejabberd.sh} +0 -0
  76. data/presence/ejabberd/ejabberd_scripts/emanagement +18 -14
  77. data/presence/ejabberd/mod_sspresence/mod_sspresence.beam +0 -0
  78. data/presence/ejabberd/mod_sspresence/mod_sspresence.erl +11 -7
  79. data/presence/lib/generators/social_stream/presence/templates/initializer.rb +14 -4
  80. data/presence/lib/social_stream/migrations/presence.rb +0 -1
  81. data/presence/lib/social_stream/presence/engine.rb +1 -48
  82. data/presence/lib/social_stream/presence/models/buddy_manager.rb +17 -44
  83. data/presence/lib/social_stream/presence/version.rb +1 -1
  84. data/presence/lib/social_stream/presence/xmpp_server_order.rb +181 -0
  85. data/presence/lib/social_stream-presence.rb +12 -2
  86. data/presence/lib/tasks/presence/synchronize.rake +6 -47
  87. data/social_stream.gemspec +2 -2
  88. metadata +32 -28
  89. data/base/lib/social_stream/migrations/finder.rb +0 -20
  90. data/documents/app/views/common-documents/_index.html.erb +0 -45
  91. data/documents/app/views/toolbar/_uploads_menu.html.erb +0 -21
  92. data/presence/ejabberd/conf/ejabberdctl.cfg +0 -154
  93. data/presence/ejabberd/conf/inetrc +0 -3
  94. data/presence/ejabberd/conf/ssconfig.cfg +0 -32
  95. data/presence/ejabberd/ejabberd_scripts/authentication_script_org +0 -114
@@ -138,7 +138,7 @@ $(function() {
138
138
  $(".actor_logo_new_comment").hide();
139
139
 
140
140
  //if there are 4 or more commments we only show the last 2 and a link to show the rest
141
- $(".activity_comments").each(function(){
141
+ $("#wall .activity_comments").each(function(){
142
142
  var comments = $(this).children(".subactivity");
143
143
  //check if there are more than 3 comments
144
144
  if (comments.size() > 3){
@@ -4,4 +4,6 @@
4
4
  //= require modernizr
5
5
  //= require jquery.lightbox-with-resize-plugin
6
6
  //
7
+ //= require avatars_for_rails
8
+ //
7
9
  //= require_tree .
@@ -1,3 +1,5 @@
1
1
  /*
2
+ *= require avatars_for_rails
3
+ *
2
4
  *= require_tree .
3
5
  */
@@ -1,18 +1,5 @@
1
1
  <% toolbar :profile => current_subject %>
2
2
 
3
- <% content_for :headers do %>
4
- <%= stylesheet_link_tag "avatars.css", :media => "screen, projection" %>
5
- <%= javascript_include_tag 'jquery.Jcrop.min' %>
6
- <%= javascript_include_tag 'jquery.form' %>
7
- <%= javascript_include_tag 'jquery.fileupload' %>
8
- <%= javascript_include_tag 'jquery.fileupload-ui' %>
9
- <%= javascript_include_tag 'avatars.js' %>
10
-
11
- <%= stylesheet_link_tag "jquery.Jcrop", :media => "screen, projection" %>
12
- <%= stylesheet_link_tag "avatars", :media => "screen, projection" %>
13
- <%= stylesheet_link_tag "jquery.fileupload-ui", :media => "screen, projection" %>
14
- <% end %>
15
-
16
3
  <% content_for :title do%>
17
4
  <%= current_subject.name %>
18
5
  <% end%>
@@ -1,6 +1,9 @@
1
1
  //Display the new comment
2
2
  $("#comments_activity_<%= @comment.post_activity.parent.id %>").append("<%= escape_javascript(render @comment.post_activity) %>");
3
3
  $(".activities_comment_btn").hide();
4
+ $(".input_new_comments").each(function() {
5
+ $(this).focus().val("").blur();
6
+ });
4
7
 
5
8
  setActivityPrivacyTooltips("<%= escape_javascript dom_id(@comment.post_activity) %>");
6
9
 
@@ -7,7 +7,7 @@
7
7
  <%= yield(:toolbar_menu).empty? ? home_toolbar_menu : yield(:toolbar_menu)%>
8
8
  </div>
9
9
 
10
- <% if defined?(SocialStream::Presence) %>
10
+ <% if defined?(SocialStream::Presence) and SocialStream::Presence.enable %>
11
11
  <%= render :partial => 'xmpp/chat' %>
12
12
  <% end %>
13
13
 
@@ -377,6 +377,7 @@ en:
377
377
  relation_public:
378
378
  name: "Public"
379
379
  representation:
380
+ notice: "Your session has changed. Now you are acting on behalf of %{subject}. Use the top-right menu to return to your session"
380
381
  switch: "Switch session"
381
382
  required: "(*) These fields are required"
382
383
  search:
@@ -372,6 +372,7 @@ es:
372
372
  relation_public:
373
373
  name: "Público"
374
374
  representation:
375
+ notice: "Tu sesión ha cambiado. Ahora actúas en nombre de %{subject}. Para regresar a tu sessión, utiliza el menú de arriba a la derecha"
375
376
  switch: "Cambiar sessión"
376
377
  required: "(*) Estos campos son obligatorios"
377
378
  search:
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Base
3
- VERSION = "0.9.22".freeze
3
+ VERSION = "0.9.23".freeze
4
4
  end
5
5
  end
@@ -103,6 +103,12 @@ module SocialStream
103
103
  raise CanCan::AccessDenied.new("Not authorized!", :represent, subject.name)
104
104
  end
105
105
 
106
+ if subject != current_user
107
+ flash[:notice] ||= ""
108
+ flash[:notice] += t('representation.notice',
109
+ :subject => subject.name)
110
+ end
111
+
106
112
  self.current_subject = subject
107
113
  end
108
114
 
@@ -1,12 +1,8 @@
1
- require 'social_stream/migrations/finder'
2
-
3
1
  module SocialStream
4
2
  module Migrations
5
3
  class Base
6
4
  def initialize
7
- find_old_migration 'acts-as-taggable-on',
8
- ["generators", "acts_as_taggable_on", "migration", "templates", "active_record", "migration"]
9
-
5
+ require_old_migration 'acts-as-taggable-on', 'lib/generators/acts_as_taggable_on/migration/templates/active_record/migration'
10
6
  @mailboxer_migration = find_migration 'mailboxer'
11
7
  @base_migration = find_migration 'social_stream-base'
12
8
  end
@@ -43,12 +39,19 @@ module SocialStream
43
39
  protected
44
40
 
45
41
  def find_migration(gem)
46
- path = Gem::GemPathSearcher.new.find(gem).full_gem_path
47
- File.join([path,'db', 'migrate'])
42
+ File.join([get_full_gem_path(gem)], 'db/migrate')
48
43
  end
49
44
 
50
- def find_old_migration(gem, path)
51
- SocialStream::Migrations::Finder.new gem, path
45
+ def require_old_migration(gem,file_path)
46
+ require File.join([get_full_gem_path(gem),file_path])
47
+ end
48
+
49
+ def get_full_gem_path(gem)
50
+ if (Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0'))
51
+ return Gem::Specification.find_by_name(gem).full_gem_path
52
+ else
53
+ return Gem::GemPathSearcher.new.find(gem).full_gem_path
54
+ end
52
55
  end
53
56
  end
54
57
  end
@@ -4,7 +4,7 @@ module SocialStream
4
4
  module Migrations
5
5
  class Components < Base
6
6
  def initialize
7
- @component = find_migration("social_stream-#{ self.class.name.split('::').last.underscore }")
7
+ @component = find_migration "social_stream-#{ self.class.name.split('::').last.underscore }"
8
8
  end
9
9
 
10
10
  def up(options = {})
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  # Slug generation
27
27
  s.add_runtime_dependency('stringex', '~> 1.3.0')
28
28
  # Avatar attachments
29
- s.add_runtime_dependency('avatars_for_rails', '~> 0.1.5')
29
+ s.add_runtime_dependency('avatars_for_rails', '~> 0.2.0')
30
30
  # jQuery
31
31
  s.add_runtime_dependency('jquery-rails', '~> 1.0.9')
32
32
  # Authorization
data/documents/Rakefile CHANGED
@@ -1,33 +1,23 @@
1
1
  # encoding: UTF-8
2
- require 'rubygems'
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- end
2
+ require 'bundler/gem_tasks'
8
3
 
9
- require 'rake'
10
- require 'rake/rdoctask'
4
+ require 'rdoc/task'
11
5
 
12
6
  require 'rspec/core'
13
7
  require 'rspec/core/rake_task'
14
8
 
15
- require 'bundler'
16
-
17
9
  RSpec::Core::RakeTask.new(:spec)
18
10
 
19
11
  task :default => :spec
20
12
 
21
13
  Rake::RDocTask.new(:rdoc) do |rdoc|
22
14
  rdoc.rdoc_dir = 'rdoc'
23
- rdoc.title = 'Socialstream-files'
15
+ rdoc.title = 'SocialStream Documents'
24
16
  rdoc.options << '--line-numbers' << '--inline-source'
25
17
  rdoc.rdoc_files.include('README.rdoc')
26
18
  rdoc.rdoc_files.include('lib/**/*.rb')
27
19
  end
28
20
 
29
- Bundler::GemHelper.install_tasks
30
-
31
21
  # Modify this gem's tags
32
22
  class Bundler::GemHelper
33
23
  def version_tag
@@ -1,35 +1,3 @@
1
- $('.attachment_tile a, .picture_link a').live("click",function(e){
2
- if(this.type ==""){
3
- return true;
4
- }
5
- e.preventDefault();
6
-
7
- var download_link = this;
8
-
9
- /*
10
- if($('.player').length > 0 && $('.attachment_tile.selected').length==1){
11
- removePlayers();
12
- return;
13
- }
14
- */
15
- if(this.type == "Audio"){
16
- removePlayers();
17
- $(this).parent().parent().addClass("selected");
18
- $('body').append("<audio class='player' autoplay='autoplay' id='audio_player' src='"+this+"' controls='controls'></audio>");
19
- $('body').append("<a href='"+download_link+"'><img id='downloadButton' src='<%= asset_path "16/default.png" %>' /></a>");
20
- return;
21
- }
22
- if(this.type == "Video"){
23
- removePlayers();
24
- $(this).parent().parent().addClass("selected");
25
- var show = (this+"").split('/download')[0];
26
- show = show.replace("documents","videos");
27
- $('body').append("<video class='player' autoplay='autoplay' id='video_player' src='"+show+"?style=webm' controls='controls'></video>");
28
- $('body').append("<a href='"+download_link+"'><img id='downloadButton' src='<%= asset_path "16/default.png" %>' /></a>");
29
- return;
30
- }
31
- });
32
-
33
1
  function removePlayers(){
34
2
  $('.attachment_tile').removeClass("selected");
35
3
  $('.player').remove();
@@ -59,3 +27,24 @@ $(".video_thumbnail_play_over").livequery("click",function(){
59
27
  $(this).parent().hide();
60
28
  $("#jpId"+the_id).jPlayer("play", 0);
61
29
  });
30
+
31
+ $(document).ready(function(){
32
+ //if there are 6 or more commments we only show the last 5 and a link to show the rest
33
+ $("#document_comments .activity_comments").each(function(){
34
+ var comments = $(this).children(".subactivity");
35
+ if (comments.size() > 5){
36
+ $(this).prepend("<div class='hide_show_comments'><a href='#' onclick='showAllDocumentComments(\""+
37
+ $(this).attr('id') +"\"); return false;'><%= I18n.t('comment.view_all') %> (" +
38
+ comments.size() + ")</a></div><div class='space_comments'></div>");
39
+ comments.slice(0,comments.size()-5).hide();
40
+ //hide alto space_comments
41
+ $(this).children(".space_comments").slice(0,comments.size()-5).hide();
42
+ }
43
+ });
44
+ });
45
+
46
+ showAllDocumentComments = function(id){
47
+ $("#"+id).children().show("slow");
48
+ //and hide the hide_show_comments
49
+ $("#"+id).children(".hide_show_comments").hide();
50
+ };
@@ -1,2 +1,3 @@
1
1
  //= require jquery.jplayer
2
- //= require_tree .
2
+ //= require_tree .
3
+ //= require jquery.ae.image.resize
@@ -1,3 +1,5 @@
1
+ @import "colors";
2
+
1
3
  .attachment
2
4
  {
3
5
  padding-top: 10px;
@@ -57,19 +59,25 @@
57
59
  }
58
60
 
59
61
  .attachment_tile{
60
- margin: 4px;
61
- margin-bottom: 8px;
62
- width: 80px;
63
- height: 65px;
62
+ margin: 5px;
63
+ width: 90px;
64
+ height: 70px;
64
65
  border-bottom: 2px solid transparent;
65
66
  float: left;
66
67
  text-align: center;
67
68
  overflow: hidden;
69
+ border: 1px solid transparent;
70
+ padding: 5px;
71
+ }
72
+
73
+ .attachment_tile img{
74
+ width: 48px;
75
+ height: 48px;
68
76
  }
69
77
 
78
+
70
79
  .attachment_tile:hover{
71
- background-color: #e0edf2;
72
- border-bottom: 2px solid #2A3890;
80
+ border: 1px solid $main-color;
73
81
  }
74
82
 
75
83
  .attachment_tile.selected{
@@ -87,6 +95,24 @@
87
95
  background-color: #e0edf2;
88
96
  }
89
97
 
98
+ #repository_filter {
99
+ margin-left: 10px;
100
+ }
101
+
102
+ #repository_filter #order_by{
103
+ margin: 5px 5px 5px 15px;
104
+ }
105
+
106
+ #repository_filter input {
107
+ padding: 0 3px 0 22px;
108
+ background: url('btn/search_icon.png') 5px 50% no-repeat white;
109
+ font-size: 11px;
110
+ color: $main-color;
111
+ border: solid 1px $input-border-color;
112
+ height: 25px;
113
+ width: 200px;
114
+ }
115
+
90
116
  .player{
91
117
  position: fixed;
92
118
  border-left: 24px solid #2A3890;
@@ -0,0 +1,75 @@
1
+ @import "colors";
2
+
3
+ .picture.content_size .picture_show img{
4
+ max-width: 500px;
5
+ max-height: 500px;
6
+ margin-left: 30px;
7
+ border: 2px solid black;
8
+ -moz-border-radius: 5px;
9
+ -webkit-border-radius: 5px;
10
+ border-radius: 5px;
11
+ }
12
+
13
+ .video_show div.jp-video-270p{
14
+ padding-left: 40px;
15
+ }
16
+ .audio_show div.jp-audio{
17
+ padding-left: 40px;
18
+ }
19
+ .document_show{
20
+ padding-left: 40px;
21
+ }
22
+
23
+ #document_info .details{
24
+ color: $details-color;
25
+ }
26
+ #document_info #dates, #document_info #date_labels{
27
+ display: inline-block;
28
+ }
29
+
30
+ #document_info {
31
+ margin-top: 10px;
32
+ }
33
+ #document_info .right, #document_info .left{
34
+ }
35
+ #document_info .right{
36
+ float: right;
37
+ margin-right: 30px;
38
+ }
39
+ #document_info .left{
40
+ float: left;
41
+ margin-left: 30px;
42
+ }
43
+ #document_info #actions{
44
+ margin-top: 10px;
45
+ margin-left: 30px;
46
+ }
47
+ #document_info #actions .action{
48
+ margin-right: 10px;
49
+ }
50
+ #document_info #actions .action img{
51
+ width: 16px;
52
+ height: 16px;
53
+ }
54
+
55
+ #document_comments {
56
+ margin-top: 20px;
57
+ padding-top: 10px;
58
+ border-top: thin solid $separation-color;
59
+ }
60
+
61
+ #document_comments .new_comment.new_comment_shown {
62
+ width: 500px;
63
+ }
64
+
65
+ #document_comments .new_comment {
66
+ width: 550px;
67
+ }
68
+
69
+ #document_comments .activity, #document_comments .subactivity {
70
+ background: transparent;
71
+ border: none;
72
+ }
73
+ #document_comments .activity_new_comment {
74
+ display:block;
75
+ }
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  *= require jplayer.blue.monday
3
- *= require_tree .
4
3
  *= require jquery.lightbox
4
+
5
+ *= require_tree .
5
6
  */
@@ -1,16 +1,2 @@
1
1
  class AudiosController < CommonDocumentsController
2
- respond_to :html,:js
3
-
4
- def show
5
- path = @audio.file.path(params[:style])
6
- if(params[:style].present?) && Document::STYLE_FORMAT[params[:style]]
7
- path = path.split('.')[0]+'.'+Document::STYLE_FORMAT[params[:style]]
8
- end
9
- respond_to do |format|
10
- format.all {send_file path,
11
- :type => Document::STYLE_MIMETYPE[params[:style]], # CANT USE: @video.file_content_type because it is allways video/mp4 and breaks explorer and firefox
12
- :disposition => "inline"}
13
- end
14
- end
15
-
16
2
  end
@@ -1,18 +1,21 @@
1
1
  class CommonDocumentsController < InheritedResources::Base
2
+ respond_to :html, :js
3
+
2
4
  belongs_to_subjects :optional => true
3
5
 
4
6
  before_filter :profile_subject!, :only => :index
5
7
 
6
8
  load_and_authorize_resource :except => :index
7
9
 
8
- def show
9
- path = resource.file.path(params[:style])
10
10
 
11
+ def show
11
12
  respond_to do |format|
13
+ format.html {render :action => :show}
12
14
  format.all {
15
+ path = resource.file.path(params[:style] || params[:format])
16
+
13
17
  send_file path,
14
18
  :filename => resource.file_file_name,
15
- :type => resource.file_content_type,
16
19
  :disposition => "inline"
17
20
  }
18
21
  end
@@ -1,5 +1,5 @@
1
1
  class DocumentsController < CommonDocumentsController
2
- respond_to :html,:js,:png,:jpeg,:bmp,:gif
2
+ respond_to :html, :js
3
3
 
4
4
  SEND_FILE_METHOD = :default
5
5
 
@@ -12,9 +12,15 @@ class DocumentsController < CommonDocumentsController
12
12
  #TODO: we have to add the mimetype as in videos_controller
13
13
  def download
14
14
  path = @document.file.path(params[:style])
15
+
15
16
  head(:bad_request) and return unless File.exist?(path)
16
- send_file_options = {:filename=>@document.file_file_name, :type => @document.file_content_type}
17
17
 
18
+ send_file_options = {
19
+ :filename => @document.file_file_name,
20
+ :type => @document.file_content_type
21
+ }
22
+
23
+ # Ask Victor about the rationale of this:
18
24
  case SEND_FILE_METHOD
19
25
  when :apache then send_file_options[:x_sendfile] = true
20
26
  when :nginx then head(:x_accel_redirect => path.gsub(Rails.root, ''))
@@ -25,7 +31,7 @@ class DocumentsController < CommonDocumentsController
25
31
 
26
32
  class << self
27
33
  def index_object_type
28
- [:Audio,:Video,:Picture,:Document]
34
+ [ :Audio, :Video, :Picture, :Document ]
29
35
  end
30
36
  end
31
37
  end
@@ -1,3 +1,2 @@
1
1
  class PicturesController < CommonDocumentsController
2
- respond_to :html,:js
3
2
  end
@@ -1,17 +1,2 @@
1
1
  class VideosController < CommonDocumentsController
2
- respond_to :html,:js
3
-
4
-
5
-
6
- def show
7
- path = @video.file.path(params[:style])
8
- if(params[:style].present?) && Document::STYLE_FORMAT[params[:style]]
9
- path = path.split('.')[0]+'.'+Document::STYLE_FORMAT[params[:style]]
10
- end
11
- respond_to do |format|
12
- format.all {send_file path,
13
- :type => Document::STYLE_MIMETYPE[params[:style]], # CANT USE: @video.file_content_type because it is allways video/mp4 and breaks explorer and firefox
14
- :disposition => "inline"}
15
- end
16
- end
17
2
  end
@@ -11,16 +11,20 @@ module DocumentsHelper
11
11
  def thumb_file_for(document, size)
12
12
  document.thumb(size, self)
13
13
  end
14
-
14
+
15
+ def image_tag_for (document)
16
+ image_tag download_document_path document,
17
+ :id => dom_id(document) + "_img"
18
+ end
19
+
15
20
  def link_for_wall(document)
16
21
  format = Mime::Type.lookup(document.file_content_type)
17
- url_for(document)+"."+format.to_sym.to_s+"?style=thumb0"
22
+
23
+ polymorphic_path(document, :format => format, :style => 'thumb0')
18
24
  end
19
25
 
20
- def wrap_file_name(name)
21
- name
22
- if(name.length > 12)
23
- name[0,12]+"..."
24
- end
26
+ def show_view_for(document)
27
+ render :partial => document.class.to_s.pluralize.downcase + '/' + document.class.to_s.downcase + "_show",
28
+ :locals => {document.class.to_s.downcase.to_sym => document}
25
29
  end
26
30
  end
@@ -1,7 +1,7 @@
1
1
  class Audio < Document
2
2
  has_attached_file :file,
3
3
  :url => '/:class/:id.:extension',
4
- :path => ':rails_root/documents/:class/:id_partition/:style.:extension',
4
+ :path => ':rails_root/documents/:class/:id_partition/:style',
5
5
  :styles => {:webma => {:format => 'webm'}
6
6
  },:processors => [:ffmpeg]
7
7
 
@@ -3,16 +3,14 @@ class Document < ActiveRecord::Base
3
3
 
4
4
  IMAGE_FORMATS = ["doc","ppt","xls","rar","zip","mpeg","plain","pdf"]
5
5
 
6
- STYLE_FORMAT = {"webm" =>"webm", "flv"=>"flv", "thumb"=>"png", "thumb0"=>"png", "webma"=>"webm"}
7
-
8
- STYLE_MIMETYPE = {"webm" =>"video/webm", "flv"=>"video/x-flv", "thumb"=>"image/png", "thumb0"=>"image/png", "mp3"=>"audio/mpeg", "webma"=>"audio/webm"}
9
-
10
6
  has_attached_file :file,
11
7
  :url => '/:class/:id.:extension',
12
- :path => ':rails_root/documents/:class/:id_partition/:style.:extension'
8
+ :path => ':rails_root/documents/:class/:id_partition/:style/:filename.:extension'
13
9
 
14
10
  validates_attachment_presence :file
15
11
 
12
+ before_create :set_title_and_description
13
+
16
14
  define_index do
17
15
  indexes title
18
16
  indexes file_file_name, :as => :file_name
@@ -67,5 +65,11 @@ class Document < ActiveRecord::Base
67
65
  "#{ size.to_s }/default.png"
68
66
  end
69
67
  end
68
+
69
+ protected
70
+
71
+ def set_title_and_description
72
+ self.title = self.file_file_name
73
+ end
70
74
 
71
75
  end
@@ -1,7 +1,7 @@
1
1
  class Picture < Document
2
2
  has_attached_file :file,
3
3
  :url => '/:class/:id.:extension',
4
- :path => ':rails_root/documents/:class/:id_partition/:style.:extension',
4
+ :path => ':rails_root/documents/:class/:id_partition/:style',
5
5
  :styles => {:thumb => ["48x48#"],
6
6
  :thumb0 => ["130x80#"]
7
7
  }
@@ -1,12 +1,14 @@
1
1
  class Video < Document
2
2
  has_attached_file :file,
3
3
  :url => '/:class/:id.:extension',
4
- :path => ':rails_root/documents/:class/:id_partition/:style.:extension',
5
- :styles => {:webm => {:format => 'webm'},
6
- :flv => { :format => 'flv' },
7
- :thumb => {:geometry => "48x48" , :format => 'png', :time => 5},
8
- :thumb0 => {:geometry => "130x80", :format => 'png', :time => 5}
9
- },:processors => [:ffmpeg]
4
+ :path => ':rails_root/documents/:class/:id_partition/:style',
5
+ :styles => {
6
+ :webm => {:format => 'webm'},
7
+ :flv => { :format => 'flv' },
8
+ :thumb => {:geometry => "48x48" , :format => 'png', :time => 5},
9
+ :thumb0 => {:geometry => "130x80", :format => 'png', :time => 5}
10
+ },
11
+ :processors => [:ffmpeg]
10
12
 
11
13
  process_in_background :file
12
14
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  $("#jpId<%=audio.id%>").jPlayer( {
4
4
  ready: function () {
5
- $(this).jPlayer("setMedia", {
6
- webma: "<%= audio_path(audio) + "?style=webma" %>" // Defines the webma url
5
+ $(this).jPlayer("setMedia", {
6
+ webma: "<%= audio_url(audio, :format => 'webma') %>" // Defines the webma url
7
7
  });
8
8
  },
9
9
  supplied: "webma",
@@ -1,12 +1,12 @@
1
1
  <div class="attachment_thumb">
2
2
  <%= link_to thumb_for(audio, 16),
3
- {:controller => "documents", :action => "download", :id => audio},
4
- :class => "" %>
3
+ audio_path(audio),
4
+ :class => "" %>
5
5
  </div>
6
6
  <div class="attachment_text">
7
7
  <%= t('audio.msg') %><%= link_to "\""+audio.file_file_name+"\"",
8
- {:controller => "documents", :action => "download", :id => audio},
9
- :class => "attachment_text_link" %>
8
+ audio_path(audio),
9
+ :class => "attachment_text_link" %>
10
10
  </div>
11
11
  <div id="jpId<%= audio.id%>" class="jpId_size0"></div>
12
12
  <div class="jp-audio">