mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
allow sharing documents
This commit is contained in:
parent
a11ad387e8
commit
bfec7797ab
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 %>
|
||||
<strong>Error loading stream item</strong>
|
||||
<% end %>
|
||||
<blockquote>
|
||||
ID: <%= share.id %>
|
||||
</blockquote>
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
<div class="stream-item">
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<span class="right">
|
||||
<%= render partial: 'content_page_shares/action_dropdown', locals: { share: share, content: content } %>
|
||||
</span>
|
||||
<%= 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" %>.
|
||||
<span class="right">
|
||||
<%= link_to [share.user, share], class: 'grey-text' do %>
|
||||
<%= time_ago_in_words share.created_at %> ago
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-container hoverable card row clearfix">
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="card-image">
|
||||
<%= link_to [share.user, share] do %>
|
||||
<%= image_tag content.random_public_image(format: :small) %>
|
||||
<% end %>
|
||||
<span class="card-title">
|
||||
<%= link_to content do %>
|
||||
<i class="material-icons tiny <%= content.class.color %>-text"><%= content.class.icon %></i>
|
||||
<span class="white-text bordered-text"><%= content.name %></i>
|
||||
<% end %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="card-content discussion-container">
|
||||
<div class="metadata">
|
||||
<%= 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 %>
|
||||
<span class="helper-text">
|
||||
said
|
||||
<%= link_to [share.user, share] do %><%= time_ago_in_words share.shared_at %> ago<% end %>:
|
||||
</span>
|
||||
</div>
|
||||
<blockquote class="original-comment">
|
||||
<%= simple_format share.message %>
|
||||
</blockquote>
|
||||
|
||||
<%= render partial: 'share_comments/form', locals: { share: share } %>
|
||||
<br /><br />
|
||||
|
||||
<div class="uppercase grey-text center"><%= pluralize share.share_comments.count, 'comment' %></div>
|
||||
<div class="row">
|
||||
<% share.share_comments.each do |comment| %>
|
||||
<%= render partial: 'share_comments/show', locals: { comment: comment, share: share } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if share.share_comments.count > 10 %>
|
||||
<%= render partial: 'share_comments/form', locals: { share: share } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -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 %>
|
||||
<strong>Error loading stream item</strong>
|
||||
<% end %>
|
||||
|
||||
@ -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 %>
|
||||
<strong>Error loading stream item</strong>
|
||||
<% end %>
|
||||
|
||||
@ -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 %>
|
||||
<strong>Error loading stream item</strong>
|
||||
<% end %>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user