diff --git a/Gemfile b/Gemfile
index 4c5c99a..8acd07d 100644
--- a/Gemfile
+++ b/Gemfile
@@ -84,8 +84,11 @@ end
#ask
gem 'gotcha'
-#desktop
-gem 'angularjs-rails', '~> 1.2.20'
-gem 'angular-ui-bootstrap-rails', '~> 0.11.0'
-gem 'jquery_mousewheel_rails', '~> 3.1.11.3'
+#caching
+gem 'mongoid-observers'
+
+#desktop
+# gem 'angularjs-rails', '~> 1.2.20'
+# gem 'angular-ui-bootstrap-rails', '~> 0.11.0'
+# gem 'jquery_mousewheel_rails', '~> 3.1.11.3'
diff --git a/app/assets/stylesheets/group_page.css b/app/assets/stylesheets/group_page.css
new file mode 100644
index 0000000..358927f
--- /dev/null
+++ b/app/assets/stylesheets/group_page.css
@@ -0,0 +1,249 @@
+@charset "utf-8";
+body {
+ background: #f3f3f3;
+}
+
+#main-wrap {
+ padding-top: 0;
+}
+
+*,
+*:before,
+*:after {
+ box-sizing: border-box;
+}
+
+.group-page {}
+
+.group-page-banner-image-wrap {
+ position: relative;
+ max-height: 280px;
+ overflow: hidden;
+}
+
+.group-page-view-switch {
+ position: absolute;
+ right: 2rem;
+ top: 2rem;
+}
+
+.group-page-banner-image {
+ max-width: 100%;
+ width: 100%;
+ height: auto;
+}
+
+.group-page-bar {
+ overflow: hidden;
+ background: #171717;
+ padding: 20px 2rem;
+ text-align: center;
+}
+
+.group-page-title {
+ padding: 6px 0;
+ color: #fff;
+ margin-bottom: 12px;
+}
+
+.group-page-setion {
+ padding: 30px 2rem;
+ overflow: hidden;
+ max-width: 1350px;
+ margin: auto;
+}
+
+.gorup-page-info-wrap {
+ display: block;
+ font-size: .9rem;
+ float: right;
+ padding: 5px .5rem;
+ border: 2px solid #cdcdcd;
+ cursor: pointer;
+}
+
+.group-page-description-wrap {
+ clear: both;
+}
+
+.gorup-page-info-wrap {
+ text-align: right;
+ margin-bottom: 10px;
+}
+
+.group-page-status-wrap {
+ float: right;
+ font-size: 0.75rem;
+ color: #fff;
+ background: #1d9e20;
+ padding: 2px .4rem;
+ border-radius: .2rem;
+ margin-bottom: 10px;
+}
+.group-page-status-wrap.close-eye{
+ background: #c71932;
+ margin-left: 5px;
+}
+
+.group-page-description-wrap {
+ padding: 16px 1.2rem 16px;
+ margin-bottom: 15px;
+ box-shadow: inset 0 0 8px #aaa;
+ border-radius: .2rem;
+}
+
+.group-page-description {
+ clear: both;
+ text-align: justify;
+}
+
+.group-page-post {
+ clear: both;
+ text-align: center;
+ overflow: hidden;
+ margin-bottom: 40px;
+ background: #fff;
+ padding: 28px 1.5rem;
+ border-radius: .2rem;
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .2);
+}
+
+.group-page-post-link{
+ text-decoration: none;
+ color: #000;
+}
+
+.group-page-post:hover {
+ box-shadow: 0 1px 25px 0 rgba(0, 0, 0, .2);
+}
+
+.group-page-post-link:hover {
+ color: #000;
+ text-decoration: none;
+}
+
+.group-page-post-image-wrap {
+ display: inline-block;
+ margin-bottom: 12px;
+}
+
+.group-page-post-image {
+ max-width: 100%;
+ width: 100%;
+ margin-top: 12px;
+ /*border-radius: 50%;*/
+ height: auto;
+}
+
+.group-page-post-content {
+ margin-bottom: .5rem;
+}
+
+.group-page-post-title {
+ font-weight: normal;
+ font-size: 1.5rem;
+ line-height: 1;
+ margin-bottom: 12px;
+}
+
+.group-page-post-meta-wrap {
+ color: #aaa;
+}
+
+.group-page-post-author,
+.group-page-post-postdate {
+ margin-right: .5rem;
+}
+/* scroll view */
+.group-page.scroll {
+ padding-top: 7rem;
+}
+.group-page.scroll .group-page-banner-image-wrap {
+ height: 70px;
+ overflow: hidden;
+ position: fixed;
+ top: 0;
+}
+
+.group-page.scroll .group-page-title {
+ margin-bottom: 0;
+}
+
+.group-page.scroll .group-page-title {
+ font-size: 18px;
+}
+
+.group-page.scroll .group-page-new-post {
+ margin-top: 6px;
+}
+
+.group-page.scroll .group-page-new-post {
+ display: inline-block;
+ vertical-align: top;
+}
+
+.group-page.scroll .group-page-view-switch {
+ position: static;
+ display: inline-block;
+ margin: 6px .5rem 0 0;
+}
+
+.group-page.scroll .btn {
+ padding: 2px 5px;
+}
+
+.group-page li a {
+ text-decoration: none;
+}
+
+.group-page .group-page-feed-view .active {
+ color: #fff;
+}
+/* 600px */
+
+@media screen and (min-width: 37.5rem) {
+ .group-page-post {
+ text-align: left;
+ margin-bottom: 15px;
+ }
+ .group-page-post-image-wrap {
+ float: left;
+ width: 12%;
+ margin-right: 4%;
+ min-width: 100px;
+ }
+ .group-page-post-content-wrap {
+ float: left;
+ width: 72%;
+ }
+ .group-page.scroll .group-page-view-switch {
+ margin: 6px .5rem 0 0;
+ }
+ .group-page.scroll .group-page-bar {
+ padding: 0 5rem 0 2rem;
+ position: fixed;
+ top: 70px;
+ width: 100%;
+ }
+}
+/* 760px */
+
+@media screen and (min-width: 47.5rem) {
+ .group-page-post-content-wrap {
+ width: 80%;
+ }
+ .group-page-bar {
+ text-align: left;
+ }
+ .group-page-title {
+ float: left;
+ margin: 0;
+ padding: 0;
+ }
+ .group-page-new-post {
+ float: right;
+ }
+ .group-page-view-switch {
+ float: right;
+ }
+}
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb
index b35a517..c0b9381 100644
--- a/app/controllers/admin/groups_controller.rb
+++ b/app/controllers/admin/groups_controller.rb
@@ -1,13 +1,44 @@
class Admin::GroupsController < OrbitMemberController
def index
- @groups = Group.all
+ @groups = current_user.groups
+ end
+
+ def public_groups
+ @groups = Group.open
end
def categories
@categories = GroupCategory.all
end
+ def newpost
+ @no_breadcrumb = true
+ uid = params[:group_id].split("-").last
+ @group = Group.find_by(:uid => uid)
+ @grouppost = GroupPost.new
+ end
+
+ def createpost
+ uid = params[:group_id].split("-").last
+ group = Group.find_by(:uid => uid)
+ gp = GroupPost.new(post_params)
+ gp.group = group
+ gp.save
+ redirect_to admin_group_path(group)
+ end
+
+ def showpost
+
+ end
+
+ def show
+ @no_breadcrumb = true
+ @no_filter = true
+ uid = params[:id].split("-").last
+ @group = Group.find_by(:uid => uid)
+ end
+
def create_category
gc = GroupCategory.new(category_params)
gc.save
@@ -45,6 +76,12 @@ class Admin::GroupsController < OrbitMemberController
params.require(:category).permit!
end
+ def post_params
+ p = params.require(:group_post).permit!
+ p["author"] = current_user.id
+ p
+ end
+
def group_params
p = params.require(:group).permit!
p["user_ids"] << current_user.id.to_s
diff --git a/app/models/group.rb b/app/models/group.rb
index a8ef047..426f0ad 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -11,6 +11,10 @@ class Group
belongs_to :group_category
has_and_belongs_to_many :users
-
+ has_many :group_posts
+
+ scope :closed, ->{ where(privacy: "closed") }
+ scope :open, ->{ where(privacy: "open") }
+
end
\ No newline at end of file
diff --git a/app/models/group_post.rb b/app/models/group_post.rb
new file mode 100644
index 0000000..4177b46
--- /dev/null
+++ b/app/models/group_post.rb
@@ -0,0 +1,14 @@
+class GroupPost
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include Slug
+
+ field :title, as: :slug_title, type: String
+ field :content
+ field :read_by, type: Array, default: []
+ field :author, type: BSON::ObjectId
+ mount_uploader :image, ImageUploader
+
+ belongs_to :group
+
+end
\ No newline at end of file
diff --git a/app/views/admin/groups/_group.html.erb b/app/views/admin/groups/_group.html.erb
index b9c37b6..6c63166 100644
--- a/app/views/admin/groups/_group.html.erb
+++ b/app/views/admin/groups/_group.html.erb
@@ -1,15 +1,22 @@
-<% current_user_is_group_admin = group.admins.include?(current_user.id.to_s) ? true : false %>
+<%
+ current_user_is_group_admin = group.admins.include?(current_user.id.to_s) ? true : false
+ if !current_user_is_group_admin
+ current_user_is_group_member = group.users.include?(current_user) ? true : false
+ else
+ current_user_is_group_member = true
+ end
+%>
-
">
+
">
<%= link_to(content_tag(:i, nil, :class => 'icon-edit'),"#",:class=>"edit" ) if current_user_is_group_admin %>
<%= image_tag(group.image) %>
-
<%= link_to group.title, "#" %>
+
<%= link_to group.title, admin_group_path(group) %>
<%
author = ""
group.admins.each_with_index do |admin,i|
@@ -23,6 +30,10 @@
Admin : <%= author %>
+
+ Privacy :
+ "><%= group.privacy %>
+
<%= group.description %>
diff --git a/app/views/admin/groups/_create_group_form.html.erb b/app/views/admin/groups/_group_form.html.erb
similarity index 100%
rename from app/views/admin/groups/_create_group_form.html.erb
rename to app/views/admin/groups/_group_form.html.erb
diff --git a/app/views/admin/groups/_post.html.erb b/app/views/admin/groups/_post.html.erb
new file mode 100644
index 0000000..3dd2f2f
--- /dev/null
+++ b/app/views/admin/groups/_post.html.erb
@@ -0,0 +1,36 @@
+
+
+
+ <% if !post.image.nil? %>
+
+ <% else %>
+
+ <% end %>
+
+
+
+ <%= post.title %>
+
+
+ <% content = strip_tags post.content %>
+ <%= content[0..250] %>
+ <%= "..." if content.length > 350 %>
+
+
+
+ <%
+ user = User.find(post.author) rescue nil
+ if !user.nil?
+ author = (user.member_profile.name == "" ? user.user_name : user.member_profile.name rescue "")
+ %>
+ <%= author %>
+ <% end %>
+
+
+ <% date = DateTime.parse(post.created_at.to_s).strftime("%d %B") %>
+ <%= date %>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/groups/_post_form.html.erb b/app/views/admin/groups/_post_form.html.erb
new file mode 100644
index 0000000..ef73c89
--- /dev/null
+++ b/app/views/admin/groups/_post_form.html.erb
@@ -0,0 +1,81 @@
+<% content_for :page_specific_css do %>
+ <%= stylesheet_link_tag "lib/main-forms" %>
+ <%= stylesheet_link_tag "lib/fileupload" %>
+ <%= stylesheet_link_tag "lib/main-list" %>
+<% end %>
+<% content_for :page_specific_javascript do %>
+ <%= javascript_include_tag "lib/bootstrap-fileupload" %>
+ <%= javascript_include_tag "lib/file-type" %>
+ <%= javascript_include_tag "lib/module-area" %>
+<% end %>
+
+
+
+
+ <%= f.submit t('submit'), class: 'btn btn-primary' %>
+ <%= link_to t('cancel'), admin_groups_path, :class=>"btn" %>
+
\ No newline at end of file
diff --git a/app/views/admin/groups/newpost.html.erb b/app/views/admin/groups/newpost.html.erb
new file mode 100644
index 0000000..ec91e4f
--- /dev/null
+++ b/app/views/admin/groups/newpost.html.erb
@@ -0,0 +1,5 @@
+<%= form_for @grouppost, :url => admin_group_createpost_path(@group), :html => { :multipart => true , :class=>"form-horizontal main-forms"} do |f| %>
+
+ <%= render :partial => "post_form", locals: {f: f} %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/groups/public_groups.html.erb b/app/views/admin/groups/public_groups.html.erb
new file mode 100644
index 0000000..216ea65
--- /dev/null
+++ b/app/views/admin/groups/public_groups.html.erb
@@ -0,0 +1,15 @@
+<% content_for :page_specific_css do -%>
+ <%= stylesheet_link_tag "lib/wrap-nav" %>
+ <%= stylesheet_link_tag "lib/main-list" %>
+ <%= stylesheet_link_tag "lib/filter" %>
+ <%= stylesheet_link_tag "lib/member" %>
+<% end -%>
+<% content_for :page_specific_javascript do -%>
+ <%= javascript_include_tag "lib/jquery.lite.image.resize.js" %>
+ <%= javascript_include_tag "lib/member/list-view.js" %>
+<% end -%>
+
+
+ <%= render :partial=>"group",:collection=> @groups %>
+
+
\ No newline at end of file
diff --git a/app/views/admin/groups/show.html.erb b/app/views/admin/groups/show.html.erb
new file mode 100644
index 0000000..1853d04
--- /dev/null
+++ b/app/views/admin/groups/show.html.erb
@@ -0,0 +1,75 @@
+<% content_for :page_specific_css do -%>
+ <%= stylesheet_link_tag "group_page" %>
+<% end -%>
+
+
+
+
+
+
+
+
<%= @group.title %>
+
New Post
+
+
+
+
+
+ Info
+
+
+ <% if @group.privacy == "closed" %>
+
+ Closed
+
+ <% else %>
+
+ Open
+
+ <% end %>
+
Group Description
+
<%= @group.description %>
+
+
+ <%= render :partial => "post", :collection => @group.group_posts.desc(:created_at) %>
+
+
+
+
diff --git a/app/views/admin/groups/showpost.html.erb b/app/views/admin/groups/showpost.html.erb
new file mode 100644
index 0000000..5adc4b3
--- /dev/null
+++ b/app/views/admin/groups/showpost.html.erb
@@ -0,0 +1 @@
+this is post for <%= params[:id] %>
\ No newline at end of file
diff --git a/app/views/admin/members/_side_bar.html.erb b/app/views/admin/members/_side_bar.html.erb
index a45cf1e..97539fc 100644
--- a/app/views/admin/members/_side_bar.html.erb
+++ b/app/views/admin/members/_side_bar.html.erb
@@ -9,6 +9,9 @@
<%= content_tag :li, :class => active_for_controllers('members','roles','member_infos') do -%>
<%= link_to( ( content_tag(:span, content_tag(:i, nil, :class => 'icons-user'))), admin_members_path) %>
<% end -%>
+ <%= content_tag :li, :class => active_for_controllers('groups') do -%>
+ <%= link_to( ( content_tag(:span, content_tag(:i, nil, :class => 'icons-layout'))), admin_groups_path) %>
+ <% end -%>
<% if (current_user.is_admin? rescue false) %>
<%= content_tag :li, :class => active_for_controllers('plugins') do -%>
<%= link_to( ( content_tag(:span, content_tag(:i, nil, :class => 'icons-graduation'))),admin_personal_plugins_path) %>
@@ -16,10 +19,8 @@
<%= content_tag :li, :class => active_for_controllers('plugins') do -%>
<%= link_to( ( content_tag(:span, content_tag(:i, nil, :class => 'icons-pie'))), '#') %>
<% end -%>
- <%= content_tag :li, :class => active_for_controllers('groups') do -%>
- <%= link_to( ( content_tag(:span, content_tag(:i, nil, :class => 'icons-layout'))), admin_groups_path) %>
- <% end -%>
- <% end -%>
+ <% end -%>
+
<% end -%>
@@ -36,6 +37,15 @@
<%= content_tag :li, link_to((content_tag(:span, t(:unapproved_members) + " (" + User.unapproved.count.to_s + ")")), admin_members_unapproved_members_path), :class => active_for_action('members', 'unapproved_members') if (current_user.is_admin? rescue nil) %>
<% end -%>
+
+
<%= t(:groups) %>
+ <%= content_tag :ul, :class => ("nav nav-list ") do -%>
+ <%= content_tag :li, link_to((content_tag(:span, "My Groups")), admin_groups_path), :class => active_for_action('groups', 'index') %>
+ <%= content_tag :li, link_to((content_tag(:span, "Public Groups")), admin_groups_public_path), :class => active_for_action('groups','public_groups') %>
+ <%= content_tag :li, link_to((content_tag(:span, "Create New Group")), new_admin_group_path), :class => active_for_action('groups','new') %>
+ <%= content_tag :li, link_to((content_tag(:span, "Categories")), admin_groups_categories_path), :class => active_for_action('groups','categories') if current_user.is_admin? %>
+ <% end -%>
+
<%= t(:academic_info) %>
<%= content_tag :ul, :class => ("nav nav-list ") do -%>
@@ -47,14 +57,6 @@
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('members', 'roles','member_infos')) do -%>
<% end -%>
-
-
<%= t(:groups) %>
- <%= content_tag :ul, :class => ("nav nav-list ") do -%>
- <%= content_tag :li, link_to((content_tag(:span, "My Groups")), admin_groups_path), :class => active_for_action('groups', 'index') %>
- <%= content_tag :li, link_to((content_tag(:span, "Categories")), admin_groups_categories_path), :class => active_for_action('groups','categories') %>
- <%= content_tag :li, link_to((content_tag(:span, "Create New Group")), new_admin_group_path), :class => active_for_action('groups','new') %>
- <% end -%>
-
diff --git a/app/views/layouts/member.html.erb b/app/views/layouts/member.html.erb
index 36097d4..5a065b9 100644
--- a/app/views/layouts/member.html.erb
+++ b/app/views/layouts/member.html.erb
@@ -15,8 +15,12 @@
<%= render_orbit_bar unless @no_orbit_bar %>
<%= render :partial => 'admin/members/side_bar' unless @no_side_bar %>
+ <% unless @no_filter && @no_breadcrumb %>
-
+ <% unless @no_filter %>
+
+ <% end %>
+ <% unless @no_breadcrumb %>
<% if !@role.blank? %>
<%= link_to( t("role"), admin_roles_path ) %> /
@@ -29,8 +33,10 @@
All
<% end %>
+ <% end %>
<%= yield :right_nav %>
+ <% end %>
<%= yield %>
<%= javascript_include_tag "lib/pageslide.js" %>
diff --git a/config/routes.rb b/config/routes.rb
index 48cbcff..0a197dd 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -123,9 +123,12 @@ Orbit::Application.routes.draw do
# GROUPS START HERE
get "groups/categories" => 'groups#categories'
post "groups/create_category" => 'groups#create_category'
+ get "groups/public" => 'groups#public_groups'
+ get "posts/:id" => 'groups#showpost'
- resources :groups do
-
+ resources :groups do
+ get "newpost" => 'groups#newpost'
+ post "createpost" => 'groups#createpost'
end