个人主页

This commit is contained in:
cxt 2016-10-19 18:03:59 +08:00
parent 0a9b6bcdbc
commit e102815f60
41 changed files with 767 additions and 31 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the ArticleHomepages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the Homepages controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,71 @@
class ArticleHomepagesController < ApplicationController
before_filter :find_article_homepage, :only => [:show, :edit, :update, :destroy]
def new
@article = ArticleHomepage.new
respond_to do |format|
format.html {render :layout=>'static_base'}
end
end
def create
if User.current.logged?
@article = ArticleHomepage.new
@article.user = User.current
@article.homepage_id = User.current.homepage.id
@article.title = params[:article_homepage][:title]
@article.content = params[:article_homepage][:content]
if @article.save
if params[:set_homepage]
User.current.homepage.update_attribute(:article_id, @article.id)
end
redirect_to user_homepages_path(:user_id => User.current.id)
end
else
redirect_to signin_path
end
end
def show
respond_to do |format|
format.html {render :layout => 'clear_base'}
end
end
def edit
if User.current.admin? || User.current.id == @article.user_id
respond_to do |format|
format.html { render :layout => 'static_base' }
end
else
render_403
end
end
def update
if User.current.logged?
@article.title = params[:article_homepage][:title]
@article.content = params[:article_homepage][:content]
if @article.save
redirect_to user_homepages_path(:user_id => User.current.id)
end
else
redirect_to signin_path
end
end
def destroy
if @article
if @article.homepage.article_id == @article.id
@article.homepage.update_attribute(:article_id, nil)
end
@article.destroy
redirect_to user_homepages_path(:user_id => User.current.id)
end
end
private
def find_article_homepage
@article = ArticleHomepage.find params[:id]
end
end

View File

@ -0,0 +1,72 @@
class HomepagesController < ApplicationController
before_filter :find_user
def index
if User.current.logged? && User.current == @user
@b_sort = params[:sort] || 1
@b_sort = @b_sort.to_i == 1 ? 2 : 1
sort_type = @b_sort == 1 ? "asc" : "desc"
@articles = @user.homepage.article_homepages.reorder("updated_at #{sort_type}")
@limit = 20
@is_remote = true
@atta_count = @articles.count
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset
@articles = paginateHelper @articles,@limit
respond_to do |format|
format.js
format.html {render :layout=>'new_base_user'}
end
else
render_403
end
end
def show
end
def set_homepage
@homepage = Homepage.find(params[:id])
@homepage.update_attribute(:article_id, params[:article_id])
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
@limit = 20
@is_remote = true
@atta_count = @articles.count
@atta_pages = Paginator.new @atta_count, @limit, 1
@articles = paginateHelper @articles,@limit
if params[:show]
redirect_to homepage_user_path(@user.id)
return
else
respond_to do |format|
format.js
end
end
end
def cancel_homepage
@homepage = Homepage.find(params[:id])
@homepage.update_attribute(:article_id, nil)
@articles = @user.homepage.article_homepages.reorder("updated_at desc")
@limit = 20
@is_remote = true
@atta_count = @articles.count
@atta_pages = Paginator.new @atta_count, @limit, 1
@articles = paginateHelper @articles,@limit
if params[:show]
redirect_to user_homepage_article_homepage_path(:user_id=>@user.id, :homepage_id=>@homepage.id,:id=>params[:article_id].to_i)
return
else
respond_to do |format|
format.js
end
end
end
private
def find_user
@user = User.find(params[:user_id])
end
end

View File

@ -42,7 +42,7 @@ class UsersController < ApplicationController
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list,
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses]
:sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -3579,6 +3579,15 @@ class UsersController < ApplicationController
end
end
def homepage
if @user.base_homepage
@article = @user.base_homepage
respond_to do |format|
format.html {render :layout => 'clear_base'}
end
end
end
private
def find_user

View File

@ -0,0 +1,2 @@
module ArticleHomepagesHelper
end

View File

@ -0,0 +1,2 @@
module HomepagesHelper
end

View File

@ -9,4 +9,5 @@ module OwnerTypeHelper
HOMEWORKCOMMON = 8
BLOGCOMMENT = 9
SYLLABUS = 10
ArticleHomepage = 11
end

View File

@ -0,0 +1,5 @@
class ArticleHomepage < ActiveRecord::Base
belongs_to :user
belongs_to :homepage
attr_accessible :content, :title, :user_id, :homepage_id
end

5
app/models/homepage.rb Normal file
View File

@ -0,0 +1,5 @@
class Homepage < ActiveRecord::Base
belongs_to :user
has_many :article_homepages
attr_accessible :name, :article_id, :user_id
end

View File

@ -208,6 +208,9 @@ class User < Principal
acts_as_watchable
has_one :user_extensions,:dependent => :destroy
has_one :homepage, :dependent => :destroy
has_many :article_homepages, :dependent => :destroy
## end
# default_scope -> { includes(:user_extensions, :user_score) }
@ -347,6 +350,25 @@ class User < Principal
@blog
end
def homepage
@homepage = Homepage.where("user_id = #{self.id}").all[0]
if @homepage.nil?
#如果某个user的blog不存在那么就创建一条并且跳转
@homepage = Homepage.create(:name=>(User.find(self.id).login), :user_id=>self.id)
@homepage.save
end
@homepage
end
def base_homepage
@base_homepage = nil
@homepage = self.homepage
if @homepage.article_id and ArticleHomepage.where("id=?", @homepage.article_id).count > 0
@base_homepage = ArticleHomepage.where("id=?", @homepage.article_id).first
end
@base_homepage
end
# 查询指派给我的缺陷记录
def count_new_issue_assign_to
self.issue_assigns

View File

@ -0,0 +1,50 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false) %>
<%= javascript_include_tag 'homepage' %>
<% end %>
<div>
<input type="text" name="article_homepage[title]" id="message_subject" class="InputBox" style="width: 99.5%;" maxlength="255" onkeyup="regexTopicSubject();" placeholder="请输入标题,该标题不会在个人主页中显示" value="<%=@article.title %>" />
<p id="subjectmsg"></p>
</div>
<div>
<div class="mt10">
<div id="message_quote" class="wiki" style="width: 92%;word-break: break-all;word-wrap: break-word;margin-left: 40px;"></div>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => @article.nil? ? 0: @article.id,
:owner_type => OwnerTypeHelper::ArticleHomepage,
:width => '100%',
:height => 500,
:minHeight=>500,
:class => 'talk_text fl',
:input_html => { :id => 'message_content',
:class => 'talk_text fl',
:maxlength => 5000 }%>
<div class="cl"></div>
<p id="message_content_span"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div>
<% unless is_edit %>
<div class="mt10">
<input type="checkbox" value="1" id="set_homepage" name="set_homepage"/>
<label for="set_homepage">设为主页</label>
</div>
<% end %>
<div class="cl"></div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_article();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_article();">取消</a>
</div>
<div class="cl"></div>
</div>
<script>
function reset_article(){
window.location.href = "<%=user_homepages_path(:user_id => User.current.id) %>";
}
</script>

View File

@ -0,0 +1,54 @@
<div class="homepageContentContainer" style="margin-top: 25px;">
<div class="homepageContent">
<div class="postContainer mb10 pr">
<% if User.current && User.current == @article.user %>
<div class="homepagePostSetting" id="message_setting_<%= @article.id%>" style="top: -25px;">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<% if @article.id == @article.homepage.article_id %>
<%= link_to(
l(:button_cancel_base_homepage),
{:controller => 'homepages',:action => 'cancel_homepage',:user_id=>@article.user_id,:id=>@article.homepage_id, :article_id => @article.id, :show => 1},
:method => :post,
:class => 'postOptionLink'
)%>
<% else %>
<%= link_to(
l(:button_set_base_homepage),
{:controller => 'homepages',:action => 'set_homepage',:user_id=>@article.user_id,:id=>@article.homepage_id, :article_id => @article.id, :show => 1},
:method => :post,
:class => 'postOptionLink'
) %>
<% end %>
</li>
<li>
<%= link_to(
l(:button_edit),
{:controller => 'article_homepages',:action => 'edit', :id => @article.id},
:class => 'postOptionLink'
) %>
</li>
<li>
<%= link_to(
l(:button_delete),
{:controller => 'article_homepages',:action => 'destroy', :id => @article.id},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) %>
</li>
</ul>
</li>
</ul>
</div>
<% end %>
<div class="cl"></div>
<div class="break_word" style="padding: 5px 5px 0 0">
<%=@article.content.html_safe %>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,18 @@
<div class="homepageContentContainer">
<div class="homepageContent">
<div class="postContainer mb10">
<%= labelled_form_for @article, :url =>{:controller=>'article_homepages',:action => 'update'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'article_form', :locals => {:is_edit => true, :f => f} %>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
setTimeout(function(){
elocalStorage(message_content_editor,'article_homepage_edit_<%=User.current.id %>');
}, 10000);
});
</script>

View File

@ -0,0 +1,18 @@
<div class="homepageContentContainer">
<div class="homepageContent">
<div class="postContainer mb10">
<%= labelled_form_for @article, :url =>{:controller=>'article_homepages',:action => 'create'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'article_form', :locals => {:is_edit => false, :f => f} %>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
setTimeout(function(){
elocalStorage(message_content_editor,'article_homepage_<%=User.current.id %>');
}, 10000);
});
</script>

View File

@ -0,0 +1 @@
<%= render :partial => 'article_show' %>

View File

@ -3,7 +3,7 @@
<%= javascript_include_tag 'blog' %>
<% end %>
<div class="resources mt10">
<div class="resources">
<div id="new_course_topic">
<div class="homepagePostBrief c_grey">
<div>

View File

@ -0,0 +1,99 @@
<div class="cl"> </div>
<div id="blog-list">
<div class="listbox mt10">
<h2 class="list-h2 fl">个人主页列表</h2>
<div class="fr">
<%=link_to '新 建', new_article_homepage_path(), :target => "_blank", :class => 'BlueCirBtn' %>
</div>
<div class="cl"></div>
<div class="category">
<span class="grayTxt">排序:</span>
<%= link_to "时间", {:controller => 'homepages', :action => 'index', :id =>@user, :sort => @b_sort}, :class => "sortTxt", :remote => true %>
<%= link_to "", {:controller => 'homepages', :action => 'index', :id =>@user, :sort => @b_sort}, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %>
<div class="cl"></div>
</div>
<div class="bloglistbox">
<% if @articles.any? %>
<% @articles.each do |activity| %>
<ul class="list-file pr" onmouseover='$("#message_setting_<%= activity.id%>").show();' onmouseout='$("#message_setting_<%= activity.id%>").hide();'>
<li><span class="item_list fl"></span>
<%= link_to activity.title.to_s.html_safe, user_homepage_article_homepage_path(:user_id=>activity.user_id, :homepage_id=>activity.homepage_id,:id=>activity), :class=> "list-title fl", :target => '_blank' %>
<% if activity.homepage.article_id and activity.id == activity.homepage.article_id %>
<span class="red_homework_btn_cir ml5">主页</span>
<% end %>
<div class="cl"></div>
</li>
<li class="ml15">
<span class="grayTxt">更新:<%= format_time(activity.updated_at) %></span>
</li>
<div class="cl"></div>
<div class="homepagePostSetting" id="message_setting_<%= activity.id%>" style="display: none">
<ul>
<li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText">
<li>
<% if activity.id == activity.homepage.article_id %>
<%= link_to(
l(:button_cancel_base_homepage),
{:controller => 'homepages',:action => 'cancel_homepage',:user_id=>activity.user_id,:id=>activity.homepage_id, :article_id => activity.id},
:method => :post,
:remote => true,
:class => 'postOptionLink'
) if User.current && User.current.id == activity.homepage.user_id %>
<% else %>
<%= link_to(
l(:button_set_base_homepage),
{:controller => 'homepages',:action => 'set_homepage',:user_id=>activity.user_id,:id=>activity.homepage_id, :article_id => activity.id},
:method => :post,
:remote => true,
:class => 'postOptionLink'
) if User.current && User.current.id == activity.homepage.user_id %>
<% end %>
</li>
<li>
<%= link_to(
l(:button_edit),
{:controller => 'article_homepages',:action => 'edit', :id => activity.id},
:class => 'postOptionLink'
) if User.current.admin? || User.current.id == activity.user_id %>
</li>
<li>
<%= link_to(
l(:button_delete),
{:controller => 'article_homepages',:action => 'destroy', :id => activity.id},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
) if User.current.admin? || User.current.id == activity.user_id %>
</li>
</ul>
</li>
</ul>
</div>
</ul>
<% end %>
<div>
<ul class="wlist" id="pages" >
<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
</ul>
<div class="cl"></div>
</div>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
//如果右边的博客列表比左边的高度低则将右边的高度设为与左边对齐
$(function() {
var leftHeight = $("#LSide").height() - $(".fontGrey5").height() - 10;
var rightHeight = $(".homepageRight").height();
if (rightHeight < leftHeight) {
var diffHeight = leftHeight - rightHeight;
var tmpHeight = $(".listbox").height() + diffHeight;
$(".listbox").css("height", tmpHeight);
}
});
</script>

View File

@ -0,0 +1,8 @@
<% if !@articles.empty? && @user.base_homepage.nil? %>
<p class="nodata mt10 mb0" style="text-align: left;">您还没有设置个人主页,其他用户无法查看哦</p>
<% end %>
<% if !@articles.empty? %>
<%= render :partial => 'article_list' %>
<% else %>
<p class="nodata mt10" style="text-align: left;">您还没有创建属于自己的个人主页。<%=link_to '新建', new_user_homepage_article_homepage_path(:user_id=> @user.id, :homepage_id => @user.homepage.id), :target => "_blank", :class => 'linkBlue' %></p>
<% end%>

View File

@ -0,0 +1 @@
$("#user_homepages").html('<%= escape_javascript(render :partial => 'articles') %>');

View File

@ -0,0 +1,12 @@
<div class="homepageRight mt0">
<div class="homepageRightBanner">
<div class="f16 fl fontGrey3">
个人主页
</div>
</div>
<div class="cl"></div>
<div id="user_homepages">
<%= render :partial => 'articles' %>
</div>
</div>

View File

@ -0,0 +1 @@
$("#blog-list").replaceWith('<%= escape_javascript( render :partial => 'articles') %>');

View File

@ -0,0 +1 @@
$("#user_homepages").html('<%= escape_javascript(render :partial => 'articles') %>');

View File

@ -1,11 +1,25 @@
<% if User.current.logged?%>
<% if User.current == target%>
<%= link_to("编辑个人资料", my_account_path, :class => "user_editinfo")%>
<% else%>
<%if(target.watched_by?(User.current))%>
<%= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "delete",:remote => "true", :title => "取消关注"%>
<% else %>
<%= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "post",:remote => "true", :title => "添加关注"%>
<% end %>
<% end%>
<% end %>
<ul>
<% if User.current.logged?%>
<% if User.current == target%>
<li style="width: 119px; float: left; border-right: 1px solid #ddd;"><%= link_to("编辑基本资料", my_account_path, :class => "user_editinfo") %></li>
<li style="width: 118px; float: left;"><%= link_to '个人主页', user_homepages_path(:user_id => @user.id) , :class => "user_editinfo" %></li>
<li class="cl"></li>
<% else%>
<li style="width: 119px; float: left; border-right: 1px solid #ddd;">
<% if @user.base_homepage.nil? %>
<a href="javascript:void(0)" class ="user_editinfo" style="color: #cccccc" title="该用户暂未设置主页">主页</a>
<% else %>
<%=link_to "主页", homepage_user_path(@user), :class => 'user_editinfo', :target => '_blank' %>
<% end %>
</li>
<li style="width: 118px; float: left;">
<%if(target.watched_by?(User.current))%>
<%= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "delete",:remote => "true", :title => "取消关注"%>
<% else %>
<%= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "user_editinfo", :method => "post",:remote => "true", :title => "添加关注"%>
<% end %>
</li>
<li class="cl"></li>
<% end%>
<% end %>
</ul>

View File

@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="<%= current_language %>">
<head>
<meta charset="utf-8" />
<title><%=h html_title %></title>
<meta name="description" content="<%= Redmine::Info.app_name %>" />
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan','prettify', :media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "jquery.leanModal.min",'prettify' %>
<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<%= stylesheet_link_tag 'css/common','css/structure','css/public','css/popup', :media => 'all'%>
<!-- MathJax的配置 -->
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<!-- 配置 在生成的公式图片上去掉Math定义的右键菜单$$ $$ \( \) \[ \] 中的公式给予显示-->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
showMathMenu: false,
showMathMenuMSIE: false,
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
</head>
<body>
<div class="cl"></div>
<div>
<%= yield %>
<div style="clear:both;"></div>
</div>
<div class="cl"></div>
<div id="ajax-modal" style="display:none;"></div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>
</html>

View File

@ -179,7 +179,18 @@
<label class="ml10"><%= check_box_tag 'no_self_notified', 1, @user.pref[:no_self_notified], :style => "height:14px;" %>不要发送对我自己提交的修改的通知</label>
</li>
<!--<li><input name="brief_introduction" class="w450" type="text" maxlength="255" value="<%#= (@user.user_extensions.nil?) ? '' : @user.user_extensions.brief_introduction %>"></li>-->
<li style="height:auto;"><textarea name="description" class="w450 h200" maxlength="255" style="resize:none;"><%= (@user.user_extensions.nil?) ? '' : @user.user_extensions.description %></textarea></li>
<li style="height:auto;">
<% if @user.homepage && !@user.homepage.article_homepages.empty? %>
<% if @user.base_homepage %>
<%=link_to '查看', homepage_user_path(@user), :class => 'linkBlue',:target => '_blank' %>
<% else %>
<%=link_to '查看', user_homepages_path(:user_id => @user.id),:target => '_blank', :class => 'linkBlue' %>
<% end %>
<% else %>
<p class="nodata" style="height: 22px; font-size: 14px; text-align: left; line-height: 20px;">您还没有创建属于自己的个人主页。<%=link_to '新建', new_user_homepage_article_homepage_path(:user_id=> @user.id, :homepage_id => @user.homepage.id), :target => "_blank", :class => 'linkBlue' %></p>
<% end %>
<!--<textarea name="description" class="w450 h200" maxlength="255" style="resize:none;"><%#= (@user.user_extensions.nil?) ? '' : @user.user_extensions.description %></textarea>-->
</li>
<li style="display:none;"><%= f.select :language, :Chinese => :zh, :English => :en %></li>
<li class="ml2">
<a href="javascript:void(0);" id="my_account_form_link" class="blue_btn fl" onclick="my_account_form_submit();" style="background: #3b94d6; padding: 0 25px;">确定</a>

View File

@ -0,0 +1 @@
<%= render :partial => 'article_homepages/article_show' %>

View File

@ -911,6 +911,8 @@ zh:
button_edit: 编辑
button_delete: 删除
button_approve: 批准
button_set_base_homepage: 设为主页
button_cancel_base_homepage: 取消主页
button_set_homepage: 设为首页
button_cancel_homepage: 取消首页
button_edit_homepage: 编辑首页

View File

@ -671,6 +671,7 @@ RedmineApp::Application.routes.draw do
get 'search_m_r_homeworks'
get 'expand_courses'
get 'cancel_or_collect'
get 'homepage'
# end
end
#resources :blogs
@ -682,12 +683,32 @@ RedmineApp::Application.routes.draw do
end
end
end
resources :homepages do
resources :article_homepages do
member do
end
end
end
end
resources :blog_comments do
collection do
get :search
end
end
resource :homepages do
member do
post 'set_homepage'
post 'cancel_homepage'
end
collection do
end
end
resources :article_homepages do
member do
end
end
match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback"
match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get
#消息

View File

@ -0,0 +1,21 @@
class CreateHomepages < ActiveRecord::Migration
def change
create_table :homepages do |t|
t.string :name
t.integer :article_id
t.references :user
t.timestamps
end
add_index :homepages, :user_id
count = User.all.count / 30 + 2
transaction do
for i in 1 ... count do i
User.page(i).per(30).each do |user|
Homepage.create(:user_id => user.id, :name => user.login)
end
end
end
end
end

View File

@ -0,0 +1,27 @@
# encoding: utf-8
class CreateArticleHomepages < ActiveRecord::Migration
def change
create_table :article_homepages do |t|
t.string :title
t.text :content
t.references :user
t.references :homepage
t.timestamps
end
add_index :article_homepages, :user_id
add_index :article_homepages, :homepage_id
count = User.all.count / 30 + 2
transaction do
for i in 1 ... count do i
User.page(i).per(30).each do |user|
if user.user_extensions && !user.user_extensions.description.nil? && user.user_extensions.description != ""
article = ArticleHomepage.create(:user_id => user.id,:title => '个人简介', :content => user.user_extensions.description, :homepage_id => user.homepage.id)
user.homepage.update_column('article_id', article.id)
end
end
end
end
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160921062340) do
ActiveRecord::Schema.define(:version => 20161019020422) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -117,6 +117,18 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "apply_user_id"
end
create_table "article_homepages", :force => true do |t|
t.string "title"
t.text "content"
t.integer "user_id"
t.integer "homepage_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "article_homepages", ["homepage_id"], :name => "index_article_homepages_on_homepage_id"
add_index "article_homepages", ["user_id"], :name => "index_article_homepages_on_user_id"
create_table "at_messages", :force => true do |t|
t.integer "user_id"
t.integer "at_message_id"
@ -142,7 +154,7 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "downloads", :default => 0
t.integer "author_id"
t.datetime "created_on"
t.string "description"
t.text "description"
t.string "disk_directory"
t.integer "attachtype"
t.integer "is_public"
@ -165,7 +177,7 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "downloads", :default => 0, :null => false
t.integer "author_id", :default => 0, :null => false
t.datetime "created_on"
t.string "description"
t.text "description"
t.string "disk_directory"
t.integer "attachtype", :default => 1
t.integer "is_public", :default => 1
@ -249,8 +261,11 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "reply_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "root_id"
end
add_index "blog_comments", ["root_id"], :name => "index_blog_comments_on_root_id"
create_table "blogs", :force => true do |t|
t.string "name", :default => "", :null => false
t.text "description"
@ -569,8 +584,8 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.string "code"
t.integer "time"
t.string "extra"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "location"
t.string "term"
t.string "string"
@ -580,25 +595,26 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.string "class_period"
t.integer "school_id"
t.text "description"
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "status", :default => 1
t.integer "attachmenttype", :default => 2
t.integer "lft"
t.integer "rgt"
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "is_public", :limit => 1, :default => 1
t.integer "inherit_members", :limit => 1, :default => 1
t.integer "open_student", :default => 0
t.integer "outline", :default => 0
t.integer "publish_resource", :default => 0
t.integer "is_delete", :default => 0
t.integer "end_time"
t.string "end_term"
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "is_excellent", :default => 0
t.integer "excellent_option", :default => 0
t.integer "is_copy", :default => 0
t.integer "visits", :default => 0
t.integer "syllabus_id"
t.string "invite_code"
t.string "qrcode"
t.integer "qrcode_expiretime", :default => 0
end
add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true
@ -866,6 +882,16 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true
create_table "homepages", :force => true do |t|
t.string "name"
t.integer "article_id"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "homepages", ["user_id"], :name => "index_homepages_on_user_id"
create_table "homework_attaches", :force => true do |t|
t.integer "bid_id"
t.integer "user_id"
@ -1111,8 +1137,11 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "m_reply_id"
t.integer "is_comprehensive_evaluation"
t.integer "private", :default => 0
t.integer "root_id"
end
add_index "journals_for_messages", ["root_id"], :name => "index_journals_for_messages_on_root_id"
create_table "kindeditor_assets", :force => true do |t|
t.string "asset"
t.integer "file_size"
@ -1203,6 +1232,7 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "reply_id"
t.integer "quotes"
t.integer "status", :default => 0
t.integer "root_id"
end
add_index "messages", ["author_id"], :name => "index_messages_on_author_id"
@ -1210,6 +1240,7 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
add_index "messages", ["created_on"], :name => "index_messages_on_created_on"
add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id"
add_index "messages", ["parent_id"], :name => "messages_parent_id"
add_index "messages", ["root_id"], :name => "index_messages_on_root_id"
create_table "news", :force => true do |t|
t.integer "project_id"
@ -1336,8 +1367,11 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "sticky", :default => 0
t.integer "org_subfield_id"
t.integer "status", :default => 0
t.integer "root_id"
end
add_index "org_document_comments", ["root_id"], :name => "index_org_document_comments_on_root_id"
create_table "org_member_roles", :force => true do |t|
t.integer "org_member_id"
t.integer "role_id"
@ -1563,6 +1597,7 @@ ActiveRecord::Schema.define(:version => 20160921062340) do
t.integer "hot", :default => 0
t.string "invite_code"
t.string "qrcode"
t.integer "qrcode_expiretime", :default => 0
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"

View File

@ -0,0 +1,54 @@
function regexTopicSubject() {
var name = $("#message_subject").val();
if(name.length ==0)
{
$("#subjectmsg").text("标题不能为空");
$("#subjectmsg").css('color','#ff0000');
$("#message_subject").focus();
return false;
}
else if(name.length <= 255)
{
$("#subjectmsg").text("填写正确");
$("#subjectmsg").css('color','#008000');
return true;
}
else
{
$("#subjectmsg").text("标题超过255个字符");
$("#subjectmsg").css('color','#ff0000');
$("#message_subject").focus();
return false;
}
}
function submit_article()
{
if(regexTopicSubject() && regexTopicDescription())
{
message_content_editor.sync();
$("#message-form").submit();
}
}
function regexTopicDescription()
{
var name = message_content_editor.html();
if(message_content_editor.isEmpty())
{
$("#message_content_span").text("描述不能为空");
$("#message_content_span").css('color','#ff0000');
return false;
}
else if(name.length >=20000){
$("#message_content_span").text("描述最多20000个汉字(或40000个英文字符)");
$("#message_content_span").css('color','#ff0000');
return false;
}
else
{
$("#message_content_span").text("填写正确");
$("#message_content_span").css('color','#008000');
return true;
}
}

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ArticleHomepagesController, :type => :controller do
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe HomepagesController, :type => :controller do
end

View File

@ -0,0 +1,10 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :article_homepage do
title "MyString"
content "MyText"
user nil
homepage nil
end
end

View File

@ -0,0 +1,10 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :homepage do
title "MyString"
content "MyText"
default 1
user nil
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe ArticleHomepage, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Homepage, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end