Skip to content

Commit

Permalink
group page: display a Twitter like 'share box' (for members) and disp…
Browse files Browse the repository at this point in the history
…lay related shared objects with links for managing them
  • Loading branch information
Boon Low committed May 14, 2010
1 parent be5ed92 commit 22c9a36
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/controllers/groups_controller.rb
Expand Up @@ -33,6 +33,27 @@ def search
end

def show
# redirect to user profile if attempt to access User own private group is made
# - Homepage group subclass if only used as a container of objects which
# are staged in the profile page instead, for the time being.
redirect_to '/' + User.find(@group.user_id).login if @group.type && @group.type=='Homepage'

@order = params[:order] || 'created_at'
@page = params[:page] || '1'
@asc = params[:asc] || 'desc'

# All shared objects related to this group
if @group.author == current_user
query_conditions= ['shared_to_id = ?', @group.id]
else
if current_user
query_conditions=['shared_to_id = ? AND (state = ? OR user_id = ?)', @group.id, "published", current_user.id]
else
query_conditions=['shared_to_id = ? AND state = ?', @group.id, "published"]
end
end
@sharings = Share.find(:all, :conditions => query_conditions, :order => "#{@order} #{@asc}").paginate :per_page => 10, :page => @page
store_location
end

def members
Expand Down
40 changes: 40 additions & 0 deletions app/views/groups/show.html.erb
Expand Up @@ -15,8 +15,48 @@
<div class="text">
<p><%= @group.description %></p>
</div>

<% if current_user and @group.members.include?(current_user) %>
<div>
<% form_for :shared_object, @shared_object, :url => member_create_shared_object_path(@group.id), :html => {:method => "post"} do |f| -%>
<fieldset>
<h2>Share, New Post <span style="font-weight:normal;font-size:80%;"> - message, blog, link etc.</span></h2>
<p>
<%= f.text_area :content, :class=>"fieldbox", :style=>"width:450px; height:100px;" -%>
<div style="margin:10px 0 0 0">
<%= submit_tag 'Share this!', :class => 'button mainaction' %>
<span style="margin:0 0 0 20px;">
<%= link_to 'Create using full editor', member_new_shared_object_path(@group.id) %>
</span>
</div>
</p>
</fieldset>
<% end -%>
</div>
<% elsif current_user %>
<div class="portletK">
<p><%= link_to I18n.t('tog_social.groups.site.join'), join_group_path(@group) %> to post something here.. </p>
</div>

<% end %>
</div> <!-- /.detail1 -->

<% for sharing in @sharings %>

<div id="sharing_<%= sharing.id %>" style="background-color:#ddd; padding: 1em 1em 0 1em; margin: 1em 0 0 0;">
<%= render :partial => '/shared/shared_object_properties_actions', :locals => {:sharing => sharing, :profile => @profile} %>
</div>

<div style="background-color:#eee; padding: 1em;">
<% if !sharing.shareable.title.blank? %>
<h3><%= link_to sharing.shareable.title, shared_object_path(sharing.shareable.id) %></h3>
<% end %>
<%= sanitize(textilize(sharing.shareable.content[0..500]), :tags => (Tog::Plugins.settings :tog_core, 'sanitized.comments.allowed_tags').split, :attributes => (Tog::Plugins.settings :tog_core, 'sanitized.comments.allowed_attributes').split) %> <%= link_to("More..", shared_object_path(sharing.shareable.id)) unless sharing.shareable.content.size < 500 %>
</div>

<% end %>
<% content_for :sidebar do %>

<div class="portlet portletC" id="portlet_moreLinks">
Expand Down

0 comments on commit 22c9a36

Please sign in to comment.