diff --git a/app/controllers/content_page_shares_controller.rb b/app/controllers/content_page_shares_controller.rb index 61f905fb..31265662 100644 --- a/app/controllers/content_page_shares_controller.rb +++ b/app/controllers/content_page_shares_controller.rb @@ -31,7 +31,7 @@ class ContentPageSharesController < ApplicationController if @share.save redirect_to [@share.user, @share], notice: 'Content page share was successfully created.' else - render :new + raise @share.errors.inspect end end diff --git a/app/models/content_page_share.rb b/app/models/content_page_share.rb index 7d97c56b..d6e3f2e3 100644 --- a/app/models/content_page_share.rb +++ b/app/models/content_page_share.rb @@ -1,7 +1,7 @@ class ContentPageShare < ApplicationRecord belongs_to :user - belongs_to :content_page, polymorphic: true - belongs_to :secondary_content_page, polymorphic: true + belongs_to :content_page, polymorphic: true, optional: true + belongs_to :secondary_content_page, polymorphic: true, optional: true has_many :share_comments, dependent: :destroy diff --git a/app/views/admin/reported_shares.html.erb b/app/views/admin/reported_shares.html.erb index 07520580..2a8ac7de 100644 --- a/app/views/admin/reported_shares.html.erb +++ b/app/views/admin/reported_shares.html.erb @@ -1,5 +1,15 @@ <% @feed.each do |share| %> - <%= render partial: 'content_page_shares/stream_page_share', locals: { share: share, content: share.content_page } %> + <% if Rails.application.config.content_types[:all].map(&:name).include?(share.content_page_type) %> + <%= render partial: 'content_page_shares/stream_page_share', locals: { share: share, content: share.content_page } %> + <% elsif share.content_page_type == Thredded::Topic.name %> + <%= render partial: 'content_page_shares/stream_discussion', locals: { share: share, content: share.content_page } %> + <% elsif share.content_page_type == PageCollection.name %> + <%= render partial: 'content_page_shares/stream_page_collection', locals: { share: share, content: share.content_page } %> + <% elsif share.content_page_type == Document.name %> + <%= render partial: 'content_page_shares/stream_document_share', locals: { share: share, content: share.content_page } %> + <% else %> + Error loading stream item + <% end %>
ID: <%= share.id %>
diff --git a/app/views/content_page_shares/_stream_document_share.html.erb b/app/views/content_page_shares/_stream_document_share.html.erb new file mode 100644 index 00000000..e6147d2c --- /dev/null +++ b/app/views/content_page_shares/_stream_document_share.html.erb @@ -0,0 +1,69 @@ +
+
+
+ + <%= render partial: 'content_page_shares/action_dropdown', locals: { share: share, content: content } %> + + <%= link_to share.user, class: "#{User.color}-text" do %> + <%= image_tag share.user.image_url(size=20), class: 'left circle avatar' %> + <%= share.user.display_name %> + <% end %> + shared a + <%= content.class.name.downcase %>: + <%= link_to content.name, content, class: "#{content.class.color}-text text-darken-1" %>. + + <%= link_to [share.user, share], class: 'grey-text' do %> + <%= time_ago_in_words share.created_at %> ago + <% end %> + +
+
+ +
+
+
+ <%= link_to [share.user, share] do %> + <%= image_tag content.random_public_image(format: :small) %> + <% end %> + + <%= link_to content do %> + <%= content.class.icon %> + <%= content.name %> + <% end %> + +
+
+ +
+
+ +
+ <%= simple_format share.message %> +
+ + <%= render partial: 'share_comments/form', locals: { share: share } %> +

+ +
<%= pluralize share.share_comments.count, 'comment' %>
+
+ <% share.share_comments.each do |comment| %> + <%= render partial: 'share_comments/show', locals: { comment: comment, share: share } %> + <% end %> +
+ + <% if share.share_comments.count > 10 %> + <%= render partial: 'share_comments/form', locals: { share: share } %> + <% end %> +
+
+
+
\ No newline at end of file diff --git a/app/views/stream/global.html.erb b/app/views/stream/global.html.erb index 5ec3d824..90010e28 100644 --- a/app/views/stream/global.html.erb +++ b/app/views/stream/global.html.erb @@ -11,6 +11,10 @@ <%= render partial: 'content_page_shares/stream_page_share', locals: { share: share, content: share.content_page } %> <% elsif share.content_page_type == Thredded::Topic.name %> <%= render partial: 'content_page_shares/stream_discussion', locals: { share: share, content: share.content_page } %> + <% elsif share.content_page_type == PageCollection.name %> + <%= render partial: 'content_page_shares/stream_page_collection', locals: { share: share, content: share.content_page } %> + <% elsif share.content_page_type == Document.name %> + <%= render partial: 'content_page_shares/stream_document_share', locals: { share: share, content: share.content_page } %> <% else %> Error loading stream item <% end %> diff --git a/app/views/stream/index.html.erb b/app/views/stream/index.html.erb index 3f6aa02b..c0783262 100644 --- a/app/views/stream/index.html.erb +++ b/app/views/stream/index.html.erb @@ -15,6 +15,8 @@ <%= render partial: 'content_page_shares/stream_discussion', locals: { share: share, content: share.content_page } %> <% elsif share.content_page_type == PageCollection.name %> <%= render partial: 'content_page_shares/stream_page_collection', locals: { share: share, content: share.content_page } %> + <% elsif share.content_page_type == Document.name %> + <%= render partial: 'content_page_shares/stream_document_share', locals: { share: share, content: share.content_page } %> <% else %> Error loading stream item <% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 38b23fb1..8254a2eb 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -73,7 +73,9 @@ <% elsif share.content_page_type == Thredded::Topic.name %> <%= render partial: 'content_page_shares/stream_discussion', locals: { share: share, content: share.content_page } %> <% elsif share.content_page_type == PageCollection.name %> - page collection + <%= render partial: 'content_page_shares/stream_page_collection', locals: { share: share, content: share.content_page } %> + <% elsif share.content_page_type == Document.name %> + <%= render partial: 'content_page_shares/stream_document_share', locals: { share: share, content: share.content_page } %> <% else %> Error loading stream item <% end %>