From 6fa67051e1ea70ec51752ef90a2b337cca8a7a16 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Jul 2015 22:54:07 +0800 Subject: [PATCH 001/119] =?UTF-8?q?=E6=9C=AC=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=9A=84=E7=94=A8=E6=88=B7=E5=90=8D=E5=92=8C=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E5=85=8B=E9=9A=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 + config/configuration.yml | 3 +++ config/routes.rb | 3 +++ lib/grack | 1 + lib/trustie.rb | 1 + lib/trustie/grack/auth.rb | 55 ++++++++++++++++++++++++++++++++++++++ lib/trustie/grack/grack.rb | 18 +++++++++++++ 7 files changed, 82 insertions(+) create mode 160000 lib/grack create mode 100644 lib/trustie/grack/auth.rb create mode 100644 lib/trustie/grack/grack.rb diff --git a/Gemfile b/Gemfile index 660a7ff49..cd2607a4f 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'iconv' end +gem 'grack', path:'./lib/grack' gem 'rest-client' gem "mysql2", "= 0.3.18" gem 'redis-rails' diff --git a/config/configuration.yml b/config/configuration.yml index 390754a87..4c786ad28 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -197,9 +197,12 @@ default: #max_concurrent_ajax_uploads: 2 #pic_types: "bmp,jpeg,jpg,png,gif" + repository_root_path: '/Users/guange/repository' + # specific configuration options for production environment # that overrides the default ones production: + repository_root_path: '/home/pdl/redmine-2.3.2-0/apache2/htdocs' cookie_domain: ".trustie.net" rmagick_font_path: /usr/share/fonts/ipa-mincho/ipam.ttf email_delivery: diff --git a/config/routes.rb b/config/routes.rb index b5a244345..16d8da882 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,6 +28,9 @@ RedmineApp::Application.routes.draw do mount Mobile::API => '/api' + # Enable Grack support + mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post] + resources :homework_users resources :no_uses delete 'no_uses', :to => 'no_uses#delete' diff --git a/lib/grack b/lib/grack new file mode 160000 index 000000000..949be9116 --- /dev/null +++ b/lib/grack @@ -0,0 +1 @@ +Subproject commit 949be9116a76b50a6f86baf507dec4c4d7fb34c6 diff --git a/lib/trustie.rb b/lib/trustie.rb index b6cec3c86..3636efd95 100644 --- a/lib/trustie.rb +++ b/lib/trustie.rb @@ -1,2 +1,3 @@ require 'trustie/utils' require 'trustie/utils/image' +require 'trustie/grack/grack' diff --git a/lib/trustie/grack/auth.rb b/lib/trustie/grack/auth.rb new file mode 100644 index 000000000..c27477be2 --- /dev/null +++ b/lib/trustie/grack/auth.rb @@ -0,0 +1,55 @@ +require 'rack/auth/basic' +require 'rack/auth/abstract/handler' +require 'rack/auth/abstract/request' + +module Grack + class Auth < Rack::Auth::Basic + def call(env) + @env = env + @request = Rack::Request.new(env) + @auth = Request.new(env) + + if not @auth.provided? + unauthorized + elsif not @auth.basic? + bad_request + else + result = if (access = valid?(@auth) and access == true) + @env['REMOTE_USER'] = @auth.username + @app.call(env) + else + if access == '404' + render_not_found + elsif access == '403' + #render_no_access + unauthorized + else + unauthorized + end + end + result + end + end# method call + + + def render_not_found + [404, {"Content-Type" => "text/plain"}, ["Not Found"]] + end + + def valid?(auth) + match = @request.path_info.match(/(\/.+\.git)\//) + if match + rep = Repository.where("root_url like ?", "%#{match[1]}") + return "404" if rep.empty? + username, password = auth.credentials + user, last_login_on = User.try_to_login(username, password) + return '403' unless user + if user.member_of?(rep.first.project) || user.admin? + return true + end + end + false + end + end# class Auth +end# module Grack + diff --git a/lib/trustie/grack/grack.rb b/lib/trustie/grack/grack.rb new file mode 100644 index 000000000..1dc4bdc0d --- /dev/null +++ b/lib/trustie/grack/grack.rb @@ -0,0 +1,18 @@ +require_relative 'auth' + +module Trustie + module Grack + + def self.new + Rack::Builder.new do + use ::Grack::Auth + run ::Grack::Server.new( + project_root: Redmine::Configuration['repository_root_path'] || "/home/pdl/redmine-2.3.2-0/apache2/htdocs", + upload_pack: true, + receive_pack:true + ) + end + end + + end +end From acd4f33d7229732a015ea3a8ddb5b5be6fe07595 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Jul 2015 22:56:04 +0800 Subject: [PATCH 002/119] =?UTF-8?q?=E6=B7=BB=E5=8A=A0grack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/grack/.travis.yml | 14 + lib/grack/CHANGELOG | 16 + lib/grack/Gemfile | 10 + lib/grack/Gemfile.lock | 37 +++ lib/grack/README.md | 95 ++++++ lib/grack/Rakefile | 27 ++ lib/grack/bin/console | 6 + lib/grack/bin/testserver | 24 ++ lib/grack/examples/111.git/HEAD | 1 + lib/grack/examples/111.git/config | 6 + lib/grack/examples/111.git/description | 1 + .../111.git/hooks/applypatch-msg.sample | 15 + .../examples/111.git/hooks/commit-msg.sample | 24 ++ .../examples/111.git/hooks/post-update.sample | 8 + .../111.git/hooks/pre-applypatch.sample | 14 + .../examples/111.git/hooks/pre-commit.sample | 49 +++ .../examples/111.git/hooks/pre-push.sample | 53 +++ .../examples/111.git/hooks/pre-rebase.sample | 169 ++++++++++ .../111.git/hooks/prepare-commit-msg.sample | 36 ++ .../examples/111.git/hooks/update.sample | 128 ++++++++ lib/grack/examples/111.git/info/exclude | 6 + lib/grack/examples/111.git/info/refs | 0 .../61/9289f137abd616d94899f2c9b6726de091ac92 | Bin 0 -> 55 bytes .../ce/013625030ba8dba906f756967f9e9ca394464a | Bin 0 -> 21 bytes .../e1/022324d23146d29075a3e7c6f637cb67f091b5 | 3 + lib/grack/examples/111.git/objects/info/packs | 1 + lib/grack/examples/111.git/refs/heads/master | 1 + lib/grack/examples/dispatch.fcgi | 9 + lib/grack/grack.gemspec | 20 ++ lib/grack/install.txt | 60 ++++ lib/grack/lib/grack.rb | 5 + lib/grack/lib/grack/auth.rb | 37 +++ lib/grack/lib/grack/bundle.rb | 19 ++ lib/grack/lib/grack/git.rb | 72 ++++ lib/grack/lib/grack/server.rb | 308 ++++++++++++++++++ lib/grack/lib/grack/version.rb | 3 + lib/grack/tests/main_test.rb | 264 +++++++++++++++ 37 files changed, 1541 insertions(+) create mode 100644 lib/grack/.travis.yml create mode 100644 lib/grack/CHANGELOG create mode 100644 lib/grack/Gemfile create mode 100644 lib/grack/Gemfile.lock create mode 100644 lib/grack/README.md create mode 100644 lib/grack/Rakefile create mode 100644 lib/grack/bin/console create mode 100644 lib/grack/bin/testserver create mode 100644 lib/grack/examples/111.git/HEAD create mode 100644 lib/grack/examples/111.git/config create mode 100644 lib/grack/examples/111.git/description create mode 100644 lib/grack/examples/111.git/hooks/applypatch-msg.sample create mode 100644 lib/grack/examples/111.git/hooks/commit-msg.sample create mode 100644 lib/grack/examples/111.git/hooks/post-update.sample create mode 100644 lib/grack/examples/111.git/hooks/pre-applypatch.sample create mode 100644 lib/grack/examples/111.git/hooks/pre-commit.sample create mode 100644 lib/grack/examples/111.git/hooks/pre-push.sample create mode 100644 lib/grack/examples/111.git/hooks/pre-rebase.sample create mode 100644 lib/grack/examples/111.git/hooks/prepare-commit-msg.sample create mode 100644 lib/grack/examples/111.git/hooks/update.sample create mode 100644 lib/grack/examples/111.git/info/exclude create mode 100644 lib/grack/examples/111.git/info/refs create mode 100644 lib/grack/examples/111.git/objects/61/9289f137abd616d94899f2c9b6726de091ac92 create mode 100644 lib/grack/examples/111.git/objects/ce/013625030ba8dba906f756967f9e9ca394464a create mode 100644 lib/grack/examples/111.git/objects/e1/022324d23146d29075a3e7c6f637cb67f091b5 create mode 100644 lib/grack/examples/111.git/objects/info/packs create mode 100644 lib/grack/examples/111.git/refs/heads/master create mode 100644 lib/grack/examples/dispatch.fcgi create mode 100644 lib/grack/grack.gemspec create mode 100644 lib/grack/install.txt create mode 100644 lib/grack/lib/grack.rb create mode 100644 lib/grack/lib/grack/auth.rb create mode 100644 lib/grack/lib/grack/bundle.rb create mode 100644 lib/grack/lib/grack/git.rb create mode 100644 lib/grack/lib/grack/server.rb create mode 100644 lib/grack/lib/grack/version.rb create mode 100644 lib/grack/tests/main_test.rb diff --git a/lib/grack/.travis.yml b/lib/grack/.travis.yml new file mode 100644 index 000000000..76e67ac43 --- /dev/null +++ b/lib/grack/.travis.yml @@ -0,0 +1,14 @@ +language: ruby +env: + - TRAVIS=true +branches: + only: + - 'master' +rvm: + - 1.9.3-p327 + - 2.0.0 +before_script: + - "bundle install" + - "git submodule init" + - "git submodule update" +script: "bundle exec rake" diff --git a/lib/grack/CHANGELOG b/lib/grack/CHANGELOG new file mode 100644 index 000000000..057db50e1 --- /dev/null +++ b/lib/grack/CHANGELOG @@ -0,0 +1,16 @@ +2.0.2 + - Revert MR that broke smart HTTP clients. + +2.0.1 + - Make sure child processes get reaped after popen, again. + +2.0.0 + - Use safer shell commands and avoid Dir.chdir + - Restrict the environment for shell commands + - Make Grack::Server thread-safe (zimbatm) + - Make sure child processes get reaped after popen + - Verify requested path is actually a Git directory (Ryan Canty) + + +1.1.0 + - Modifies service_rpc to use chunked transfer (https://github.com/gitlabhq/grack/pull/1) diff --git a/lib/grack/Gemfile b/lib/grack/Gemfile new file mode 100644 index 000000000..b7113caa8 --- /dev/null +++ b/lib/grack/Gemfile @@ -0,0 +1,10 @@ +source "http://ruby.taobao.org" + +gemspec + +group :development do + gem 'byebug' + gem 'rake' + gem 'pry' + gem 'rack-test' +end diff --git a/lib/grack/Gemfile.lock b/lib/grack/Gemfile.lock new file mode 100644 index 000000000..52d60f85d --- /dev/null +++ b/lib/grack/Gemfile.lock @@ -0,0 +1,37 @@ +PATH + remote: . + specs: + gitlab-grack (2.0.2) + rack (~> 1.5.1) + +GEM + remote: http://ruby.taobao.org/ + specs: + byebug (4.0.5) + columnize (= 0.9.0) + coderay (1.1.0) + columnize (0.9.0) + metaclass (0.0.1) + method_source (0.8.2) + mocha (0.14.0) + metaclass (~> 0.0.1) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + rack (1.5.2) + rack-test (0.6.2) + rack (>= 1.0) + rake (10.1.0) + slop (3.6.0) + +PLATFORMS + ruby + +DEPENDENCIES + byebug + gitlab-grack! + mocha (~> 0.11) + pry + rack-test + rake diff --git a/lib/grack/README.md b/lib/grack/README.md new file mode 100644 index 000000000..0a1acdaae --- /dev/null +++ b/lib/grack/README.md @@ -0,0 +1,95 @@ +Grack - Ruby/Rack Git Smart-HTTP Server Handler +=============================================== + +[![Build Status](https://travis-ci.org/gitlabhq/grack.png)](https://travis-ci.org/gitlabhq/grack) +[![Code Climate](https://codeclimate.com/github/gitlabhq/grack.png)](https://codeclimate.com/github/gitlabhq/grack) + +This project aims to replace the builtin git-http-backend CGI handler +distributed with C Git with a Rack application. This reason for doing this +is to allow far more webservers to be able to handle Git smart http requests. + +The default git-http-backend only runs as a CGI script, and specifically is +only targeted for Apache 2.x usage (it requires PATH_INFO to be set and +specifically formatted). So, instead of trying to get it to work with +other CGI capable webservers (Lighttpd, etc), we can get it running on nearly +every major and minor webserver out there by making it Rack capable. Rack +applications can run with the following handlers: + +* CGI +* FCGI +* Mongrel (and EventedMongrel and SwiftipliedMongrel) +* WEBrick +* SCGI +* LiteSpeed +* Thin + +These web servers include Rack handlers in their distributions: + +* Ebb +* Fuzed +* Phusion Passenger (which is mod_rack for Apache and for nginx) +* Unicorn +* Puma + +With [Warbler](http://caldersphere.rubyforge.org/warbler/classes/Warbler.html), +and JRuby, we can also generate a WAR file that can be deployed in any Java +web application server (Tomcat, Glassfish, Websphere, JBoss, etc). + +Since the git-http-backend is really just a simple wrapper for the upload-pack +and receive-pack processes with the '--stateless-rpc' option, it does not +actually re-implement very much. + +Dependencies +======================== +* Ruby - http://www.ruby-lang.org +* Rack - http://rack.rubyforge.org +* A Rack-compatible web server +* Git >= 1.7 (currently the 'pu' branch) +* Mocha (only for running the tests) + +Quick Start +======================== + $ gem install rack + $ (edit config.ru to set git project path) + $ rackup --host 127.0.0.1 -p 8080 config.ru + $ git clone http://127.0.0.1:8080/schacon/grit.git + +Contributing +======================== +If you would like to contribute to the Grack project, I prefer to get +pull-requests via GitHub. You should include tests for whatever functionality +you add. Just fork this project, push your changes to your fork and click +the 'pull request' button. To run the tests, you first need to install the +'mocha' mocking library and initialize the submodule. + + $ sudo gem install mocha + $ git submodule init + $ git submodule update + +Then you should be able to run the tests with a 'rake' command. You can also +run coverage tests with 'rake rcov' if you have rcov installed. + +License +======================== + (The MIT License) + + Copyright (c) 2009 Scott Chacon + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + 'Software'), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/grack/Rakefile b/lib/grack/Rakefile new file mode 100644 index 000000000..255246bf4 --- /dev/null +++ b/lib/grack/Rakefile @@ -0,0 +1,27 @@ +#!/usr/bin/env rake +require "bundler/gem_tasks" + +task :default => :test + +desc "Run the tests." +task :test do + Dir.glob("tests/*_test.rb").each do |f| + system "ruby #{f}" + end +end + +desc "Run test coverage." +task :rcov do + system "rcov tests/*_test.rb -i lib/git_http.rb -x rack -x Library -x tests" + system "open coverage/index.html" +end + +namespace :grack do + desc "Start Grack" + task :start do + system('./bin/testserver') + end +end + +desc "Start everything." +multitask :start => [ 'grack:start' ] diff --git a/lib/grack/bin/console b/lib/grack/bin/console new file mode 100644 index 000000000..b9297ffab --- /dev/null +++ b/lib/grack/bin/console @@ -0,0 +1,6 @@ +#! /bin/bash + +set -e + +cd $(dirname "$0")/.. +exec /usr/bin/env bundle exec pry -Ilib -r grack diff --git a/lib/grack/bin/testserver b/lib/grack/bin/testserver new file mode 100644 index 000000000..3c0db5b3f --- /dev/null +++ b/lib/grack/bin/testserver @@ -0,0 +1,24 @@ +#! /usr/bin/env ruby +libdir = File.absolute_path( File.join( File.dirname(__FILE__), '../lib' ) ) +$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) + +Bundler.require(:default, :development) + + +require 'grack' +require 'rack' +root = File.absolute_path( File.join( File.dirname(__FILE__), '../examples' ) ) +app = Grack::Server.new({ + project_root: root, + upload_pack: true, + receive_pack:true +}) + +app1= Rack::Builder.new do + use Grack::Auth do |username, password| + [username, password] == ['123', '455'] + end + run app +end + +Rack::Server.start app: app1, Port: 3001 diff --git a/lib/grack/examples/111.git/HEAD b/lib/grack/examples/111.git/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/lib/grack/examples/111.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/lib/grack/examples/111.git/config b/lib/grack/examples/111.git/config new file mode 100644 index 000000000..e6da23157 --- /dev/null +++ b/lib/grack/examples/111.git/config @@ -0,0 +1,6 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = true + ignorecase = true + precomposeunicode = true diff --git a/lib/grack/examples/111.git/description b/lib/grack/examples/111.git/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/lib/grack/examples/111.git/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/lib/grack/examples/111.git/hooks/applypatch-msg.sample b/lib/grack/examples/111.git/hooks/applypatch-msg.sample new file mode 100644 index 000000000..8b2a2fe84 --- /dev/null +++ b/lib/grack/examples/111.git/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/lib/grack/examples/111.git/hooks/commit-msg.sample b/lib/grack/examples/111.git/hooks/commit-msg.sample new file mode 100644 index 000000000..b58d1184a --- /dev/null +++ b/lib/grack/examples/111.git/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/lib/grack/examples/111.git/hooks/post-update.sample b/lib/grack/examples/111.git/hooks/post-update.sample new file mode 100644 index 000000000..ec17ec193 --- /dev/null +++ b/lib/grack/examples/111.git/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/lib/grack/examples/111.git/hooks/pre-applypatch.sample b/lib/grack/examples/111.git/hooks/pre-applypatch.sample new file mode 100644 index 000000000..b1f187c2e --- /dev/null +++ b/lib/grack/examples/111.git/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} +: diff --git a/lib/grack/examples/111.git/hooks/pre-commit.sample b/lib/grack/examples/111.git/hooks/pre-commit.sample new file mode 100644 index 000000000..68d62d544 --- /dev/null +++ b/lib/grack/examples/111.git/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/lib/grack/examples/111.git/hooks/pre-push.sample b/lib/grack/examples/111.git/hooks/pre-push.sample new file mode 100644 index 000000000..6187dbf43 --- /dev/null +++ b/lib/grack/examples/111.git/hooks/pre-push.sample @@ -0,0 +1,53 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo >&2 "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/lib/grack/examples/111.git/hooks/pre-rebase.sample b/lib/grack/examples/111.git/hooks/pre-rebase.sample new file mode 100644 index 000000000..9773ed4cb --- /dev/null +++ b/lib/grack/examples/111.git/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up-to-date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +exit 0 + +################################################################ + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". diff --git a/lib/grack/examples/111.git/hooks/prepare-commit-msg.sample b/lib/grack/examples/111.git/hooks/prepare-commit-msg.sample new file mode 100644 index 000000000..f093a02ec --- /dev/null +++ b/lib/grack/examples/111.git/hooks/prepare-commit-msg.sample @@ -0,0 +1,36 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first comments out the +# "Conflicts:" part of a merge commit. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +case "$2,$3" in + merge,) + /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; + +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$1" ;; + + *) ;; +esac + +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/lib/grack/examples/111.git/hooks/update.sample b/lib/grack/examples/111.git/hooks/update.sample new file mode 100644 index 000000000..d84758373 --- /dev/null +++ b/lib/grack/examples/111.git/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to blocks unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/lib/grack/examples/111.git/info/exclude b/lib/grack/examples/111.git/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/lib/grack/examples/111.git/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/lib/grack/examples/111.git/info/refs b/lib/grack/examples/111.git/info/refs new file mode 100644 index 000000000..e69de29bb diff --git a/lib/grack/examples/111.git/objects/61/9289f137abd616d94899f2c9b6726de091ac92 b/lib/grack/examples/111.git/objects/61/9289f137abd616d94899f2c9b6726de091ac92 new file mode 100644 index 0000000000000000000000000000000000000000..38a5c446396f5f3443593ccadeb180a1d23fd1a2 GIT binary patch literal 55 zcmV-70LcG%0V^p=O;s?qU@$Z=Ff%bxC`wIC$xYQOsVHGM$7rU?%)R3FO1AG|)9UBV NSv]o@gg +Yku5JM/0 \ No newline at end of file diff --git a/lib/grack/examples/111.git/objects/info/packs b/lib/grack/examples/111.git/objects/info/packs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/lib/grack/examples/111.git/objects/info/packs @@ -0,0 +1 @@ + diff --git a/lib/grack/examples/111.git/refs/heads/master b/lib/grack/examples/111.git/refs/heads/master new file mode 100644 index 000000000..864350cd1 --- /dev/null +++ b/lib/grack/examples/111.git/refs/heads/master @@ -0,0 +1 @@ +e1022324d23146d29075a3e7c6f637cb67f091b5 diff --git a/lib/grack/examples/dispatch.fcgi b/lib/grack/examples/dispatch.fcgi new file mode 100644 index 000000000..5ca764fba --- /dev/null +++ b/lib/grack/examples/dispatch.fcgi @@ -0,0 +1,9 @@ +#! /usr/bin/env ruby +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/lib') +require 'lib/git_http' +config = { + :project_root => "/opt", + :upload_pack => true, + :receive_pack => false, +} +Rack::Handler::FastCGI.run(GitHttp::App.new(config)) \ No newline at end of file diff --git a/lib/grack/grack.gemspec b/lib/grack/grack.gemspec new file mode 100644 index 000000000..e743ce314 --- /dev/null +++ b/lib/grack/grack.gemspec @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- +require File.expand_path('../lib/grack/version', __FILE__) + +Gem::Specification.new do |gem| + gem.authors = ["Scott Chacon"] + gem.email = ["schacon@gmail.com"] + gem.description = %q{Ruby/Rack Git Smart-HTTP Server Handler} + gem.summary = %q{Ruby/Rack Git Smart-HTTP Server Handler} + gem.homepage = "https://github.com/gitlabhq/grack" + + gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + gem.files = `git ls-files`.split("\n") + gem.test_files = `git ls-files -- tests/*`.split("\n") + gem.name = "grack" + gem.require_paths = ["lib"] + gem.version = Grack::VERSION + + gem.add_dependency("rack", "~> 1.4.5") + gem.add_development_dependency("mocha", "~> 0.11") +end diff --git a/lib/grack/install.txt b/lib/grack/install.txt new file mode 100644 index 000000000..c53e1a3e3 --- /dev/null +++ b/lib/grack/install.txt @@ -0,0 +1,60 @@ +Installation +======================== + +** This documentation is not finished yet. I haven't tested all of +these and it's obviously incomplete - these are currently just notes. + +FastCGI +--------------------------------------- +Here is an example config from lighttpd server: +---- +# main fastcgi entry +$HTTP["url"] =~ "^/myapp/.+$" { + fastcgi.server = ( "/myapp" => + ( "localhost" => + ( "bin-path" => "/var/www/localhost/cgi-bin/dispatch.fcgi", + "docroot" => "/var/www/localhost/htdocs/myapp", + "host" => "127.0.0.1", + "port" => 1026, + "check-local" => "disable" + ) + ) + ) +} # HTTP[url] +---- +You can use the examples/dispatch.fcgi file as your dispatcher. + +(Example Apache setup?) + +Installing in a Java application server +--------------------------------------- +# install Warbler +$ sudo gem install warbler +$ cd gitsmart +$ (edit config.ru) +$ warble +$ cp gitsmart.war /path/to/java/autodeploy/dir + +Unicorn +--------------------------------------- +With Unicorn (http://unicorn.bogomips.org/) you can just run 'unicorn' +in the directory with the config.ru file. + +Thin +--------------------------------------- +thin.yml +--- +pid: /home/deploy/myapp/server/thin.pid +log: /home/deploy/myapp/logs/thin.log +timeout: 30 +port: 7654 +max_conns: 1024 +chdir: /home/deploy/myapp/site_files +rackup: /home/deploy/myapp/server/config.ru +max_persistent_conns: 512 +environment: production +address: 127.0.0.1 +servers: 1 +daemonize: true + + diff --git a/lib/grack/lib/grack.rb b/lib/grack/lib/grack.rb new file mode 100644 index 000000000..2c625d227 --- /dev/null +++ b/lib/grack/lib/grack.rb @@ -0,0 +1,5 @@ +require "grack/bundle" + +module Grack + +end diff --git a/lib/grack/lib/grack/auth.rb b/lib/grack/lib/grack/auth.rb new file mode 100644 index 000000000..6a50cbd56 --- /dev/null +++ b/lib/grack/lib/grack/auth.rb @@ -0,0 +1,37 @@ +require 'rack/auth/basic' +require 'rack/auth/abstract/handler' +require 'rack/auth/abstract/request' + +module Grack + class Auth < Rack::Auth::Basic + def call(env) + @env = env + @request = Rack::Request.new(env) + @auth = Request.new(env) + + if not @auth.provided? + unauthorized + elsif not @auth.basic? + bad_request + else + result = if (access = valid?(@auth) and access == true) + @env['REMOTE_USER'] = @auth.username + @app.call(env) + else + if access == '404' + render_not_found + elsif access == '403' + render_no_access + else + unauthorized + end + end + result + end + end# method call + + # def valid? + # false + # end + end# class Auth +end# module Grack diff --git a/lib/grack/lib/grack/bundle.rb b/lib/grack/lib/grack/bundle.rb new file mode 100644 index 000000000..c6a789a4e --- /dev/null +++ b/lib/grack/lib/grack/bundle.rb @@ -0,0 +1,19 @@ +require 'rack/builder' +require 'grack/auth' +require 'grack/server' + +module Grack + module Bundle + extend self + + def new(config) + Rack::Builder.new do + use Grack::Auth do |username, password| + yield(username, password) + end + run Grack::Server.new(config) + end + end + + end +end diff --git a/lib/grack/lib/grack/git.rb b/lib/grack/lib/grack/git.rb new file mode 100644 index 000000000..84695754a --- /dev/null +++ b/lib/grack/lib/grack/git.rb @@ -0,0 +1,72 @@ +module Grack + class Git + attr_reader :repo + + def initialize(git_path, repo_path) + @git_path = git_path + @repo = repo_path + end + + def update_server_info + execute(%W(update-server-info)) + end + + def command(cmd) + [@git_path || 'git'] + cmd + end + + def capture(cmd) + # _Not_ the same as `IO.popen(...).read` + # By using a block we tell IO.popen to close (wait for) the child process + # after we are done reading its output. + IO.popen(popen_env, cmd, popen_options) { |p| p.read } + end + + def execute(cmd) + cmd = command(cmd) + if block_given? + IO.popen(popen_env, cmd, File::RDWR, popen_options) do |pipe| + yield(pipe) + end + else + capture(cmd).chomp + end + end + + def popen_options + { chdir: repo, unsetenv_others: true } + end + + def popen_env + { 'PATH' => ENV['PATH'], 'GL_ID' => ENV['GL_ID'] } + end + + def config_setting(service_name) + service_name = service_name.gsub('-', '') + setting = config("http.#{service_name}") + + if service_name == 'uploadpack' + setting != 'false' + else + setting == 'true' + end + end + + def config(config_name) + execute(%W(config #{config_name})) + end + + def valid_repo? + return false unless File.exists?(repo) && File.realpath(repo) == repo + + match = execute(%W(rev-parse --git-dir)).match(/\.$|\.git$/) + + if match.to_s == '.git' + # Since the parent could be a git repo, we want to make sure the actual repo contains a git dir. + return false unless Dir.entries(repo).include?('.git') + end + + match + end + end +end diff --git a/lib/grack/lib/grack/server.rb b/lib/grack/lib/grack/server.rb new file mode 100644 index 000000000..59e0bc271 --- /dev/null +++ b/lib/grack/lib/grack/server.rb @@ -0,0 +1,308 @@ +require 'zlib' +require 'rack/request' +require 'rack/response' +require 'rack/utils' +require 'time' + +require 'grack/git' + +module Grack + class Server + attr_reader :git + + SERVICES = [ + ["POST", 'service_rpc', "(.*?)/git-upload-pack$", 'upload-pack'], + ["POST", 'service_rpc', "(.*?)/git-receive-pack$", 'receive-pack'], + + ["GET", 'get_info_refs', "(.*?)/info/refs$"], + ["GET", 'get_text_file', "(.*?)/HEAD$"], + ["GET", 'get_text_file', "(.*?)/objects/info/alternates$"], + ["GET", 'get_text_file', "(.*?)/objects/info/http-alternates$"], + ["GET", 'get_info_packs', "(.*?)/objects/info/packs$"], + ["GET", 'get_text_file', "(.*?)/objects/info/[^/]*$"], + ["GET", 'get_loose_object', "(.*?)/objects/[0-9a-f]{2}/[0-9a-f]{38}$"], + ["GET", 'get_pack_file', "(.*?)/objects/pack/pack-[0-9a-f]{40}\\.pack$"], + ["GET", 'get_idx_file', "(.*?)/objects/pack/pack-[0-9a-f]{40}\\.idx$"], + ] + + def initialize(config = false) + set_config(config) + end + + def set_config(config) + @config = config || {} + end + + def set_config_setting(key, value) + @config[key] = value + end + + def call(env) + dup._call(env) + end + + def _call(env) + @env = env + @req = Rack::Request.new(env) + + cmd, path, @reqfile, @rpc = match_routing + + return render_method_not_allowed if cmd == 'not_allowed' + return render_not_found unless cmd + + @git = get_git(path) + return render_not_found unless git.valid_repo? + + self.method(cmd).call + end + + # --------------------------------- + # actual command handling functions + # --------------------------------- + + # Uses chunked (streaming) transfer, otherwise response + # blocks to calculate Content-Length header + # http://en.wikipedia.org/wiki/Chunked_transfer_encoding + + CRLF = "\r\n" + + def service_rpc + return render_no_access unless has_access?(@rpc, true) + + input = read_body + + @res = Rack::Response.new + @res.status = 200 + @res["Content-Type"] = "application/x-git-%s-result" % @rpc + @res["Transfer-Encoding"] = "chunked" + @res["Cache-Control"] = "no-cache" + + @res.finish do + git.execute([@rpc, '--stateless-rpc', git.repo]) do |pipe| + pipe.write(input) + pipe.close_write + + while block = pipe.read(8192) # 8KB at a time + @res.write encode_chunk(block) # stream it to the client + end + + @res.write terminating_chunk + end + end + end + + def encode_chunk(chunk) + size_in_hex = chunk.size.to_s(16) + [size_in_hex, CRLF, chunk, CRLF].join + end + + def terminating_chunk + [0, CRLF, CRLF].join + end + + def get_info_refs + service_name = get_service_type + return dumb_info_refs unless has_access?(service_name) + + refs = git.execute([service_name, '--stateless-rpc', '--advertise-refs', git.repo]) + + @res = Rack::Response.new + @res.status = 200 + @res["Content-Type"] = "application/x-git-%s-advertisement" % service_name + hdr_nocache + + @res.write(pkt_write("# service=git-#{service_name}\n")) + @res.write(pkt_flush) + @res.write(refs) + + @res.finish + end + + def dumb_info_refs + git.update_server_info + send_file(@reqfile, "text/plain; charset=utf-8") do + hdr_nocache + end + end + + def get_info_packs + # objects/info/packs + send_file(@reqfile, "text/plain; charset=utf-8") do + hdr_nocache + end + end + + def get_loose_object + send_file(@reqfile, "application/x-git-loose-object") do + hdr_cache_forever + end + end + + def get_pack_file + send_file(@reqfile, "application/x-git-packed-objects") do + hdr_cache_forever + end + end + + def get_idx_file + send_file(@reqfile, "application/x-git-packed-objects-toc") do + hdr_cache_forever + end + end + + def get_text_file + send_file(@reqfile, "text/plain") do + hdr_nocache + end + end + + # ------------------------ + # logic helping functions + # ------------------------ + + # some of this borrowed from the Rack::File implementation + def send_file(reqfile, content_type) + reqfile = File.join(git.repo, reqfile) + return render_not_found unless File.exists?(reqfile) + + return render_not_found unless reqfile == File.realpath(reqfile) + + # reqfile looks legit: no path traversal, no leading '|' + + @res = Rack::Response.new + @res.status = 200 + @res["Content-Type"] = content_type + @res["Last-Modified"] = File.mtime(reqfile).httpdate + + yield + + if size = File.size?(reqfile) + @res["Content-Length"] = size.to_s + @res.finish do + File.open(reqfile, "rb") do |file| + while part = file.read(8192) + @res.write part + end + end + end + else + body = [File.read(reqfile)] + size = Rack::Utils.bytesize(body.first) + @res["Content-Length"] = size + @res.write body + @res.finish + end + end + + def get_git(path) + root = @config[:project_root] || Dir.pwd + path = File.join(root, path) + Grack::Git.new(@config[:git_path], path) + end + + def get_service_type + service_type = @req.params['service'] + return false unless service_type + return false if service_type[0, 4] != 'git-' + service_type.gsub('git-', '') + end + + def match_routing + cmd = nil + path = nil + + SERVICES.each do |method, handler, match, rpc| + next unless m = Regexp.new(match).match(@req.path_info) + + return ['not_allowed'] unless method == @req.request_method + + cmd = handler + path = m[1] + file = @req.path_info.sub(path + '/', '') + + return [cmd, path, file, rpc] + end + + nil + end + + def has_access?(rpc, check_content_type = false) + if check_content_type + conten_type = "application/x-git-%s-request" % rpc + return false unless @req.content_type == conten_type + end + + return false unless ['upload-pack', 'receive-pack'].include?(rpc) + + if rpc == 'receive-pack' + return @config[:receive_pack] if @config.include?(:receive_pack) + end + + if rpc == 'upload-pack' + return @config[:upload_pack] if @config.include?(:upload_pack) + end + + git.config_setting(rpc) + end + + def read_body + if @env["HTTP_CONTENT_ENCODING"] =~ /gzip/ + Zlib::GzipReader.new(@req.body).read + else + @req.body.read + end + end + + # -------------------------------------- + # HTTP error response handling functions + # -------------------------------------- + + PLAIN_TYPE = { "Content-Type" => "text/plain" } + + def render_method_not_allowed + if @env['SERVER_PROTOCOL'] == "HTTP/1.1" + [405, PLAIN_TYPE, ["Method Not Allowed"]] + else + [400, PLAIN_TYPE, ["Bad Request"]] + end + end + + def render_not_found + [404, PLAIN_TYPE, ["Not Found"]] + end + + def render_no_access + [403, PLAIN_TYPE, ["Forbidden"]] + end + + + # ------------------------------ + # packet-line handling functions + # ------------------------------ + + def pkt_flush + '0000' + end + + def pkt_write(str) + (str.size + 4).to_s(16).rjust(4, '0') + str + end + + # ------------------------ + # header writing functions + # ------------------------ + + def hdr_nocache + @res["Expires"] = "Fri, 01 Jan 1980 00:00:00 GMT" + @res["Pragma"] = "no-cache" + @res["Cache-Control"] = "no-cache, max-age=0, must-revalidate" + end + + def hdr_cache_forever + now = Time.now().to_i + @res["Date"] = now.to_s + @res["Expires"] = (now + 31536000).to_s; + @res["Cache-Control"] = "public, max-age=31536000"; + end + end +end diff --git a/lib/grack/lib/grack/version.rb b/lib/grack/lib/grack/version.rb new file mode 100644 index 000000000..66a1e1b41 --- /dev/null +++ b/lib/grack/lib/grack/version.rb @@ -0,0 +1,3 @@ +module Grack + VERSION = "2.0.2" +end diff --git a/lib/grack/tests/main_test.rb b/lib/grack/tests/main_test.rb new file mode 100644 index 000000000..cf70296ec --- /dev/null +++ b/lib/grack/tests/main_test.rb @@ -0,0 +1,264 @@ +require 'rack' +require 'rack/test' +require 'test/unit' +require 'mocha' +require 'digest/sha1' + +require_relative '../lib/grack/server.rb' +require_relative '../lib/grack/git.rb' +require 'pp' + +class GitHttpTest < Test::Unit::TestCase + include Rack::Test::Methods + + def example + File.expand_path(File.dirname(__FILE__)) + end + + def app + config = { + :project_root => example, + :upload_pack => true, + :receive_pack => true, + } + Grack::Server.new(config) + end + + def test_upload_pack_advertisement + get "/example/info/refs?service=git-upload-pack" + assert_equal 200, r.status + assert_equal "application/x-git-upload-pack-advertisement", r.headers["Content-Type"] + assert_equal "001e# service=git-upload-pack", r.body.split("\n").first + assert_match 'multi_ack_detailed', r.body + end + + def test_no_access_wrong_content_type_up + post "/example/git-upload-pack" + assert_equal 403, r.status + end + + def test_no_access_wrong_content_type_rp + post "/example/git-receive-pack" + assert_equal 403, r.status + end + + def test_no_access_wrong_method_rcp + get "/example/git-upload-pack" + assert_equal 400, r.status + end + + def test_no_access_wrong_command_rcp + post "/example/git-upload-packfile" + assert_equal 404, r.status + end + + def test_no_access_wrong_path_rcp + Grack::Git.any_instance.stubs(:valid_repo?).returns(false) + post "/example-wrong/git-upload-pack" + assert_equal 404, r.status + end + + def test_upload_pack_rpc + Grack::Git.any_instance.stubs(:valid_repo?).returns(true) + IO.stubs(:popen).returns(MockProcess.new) + post "/example/git-upload-pack", {}, {"CONTENT_TYPE" => "application/x-git-upload-pack-request"} + assert_equal 200, r.status + assert_equal "application/x-git-upload-pack-result", r.headers["Content-Type"] + end + + def test_receive_pack_advertisement + get "/example/info/refs?service=git-receive-pack" + assert_equal 200, r.status + assert_equal "application/x-git-receive-pack-advertisement", r.headers["Content-Type"] + assert_equal "001f# service=git-receive-pack", r.body.split("\n").first + assert_match 'report-status', r.body + assert_match 'delete-refs', r.body + assert_match 'ofs-delta', r.body + end + + def test_recieve_pack_rpc + Grack::Git.any_instance.stubs(:valid_repo?).returns(true) + IO.stubs(:popen).yields(MockProcess.new) + post "/example/git-receive-pack", {}, {"CONTENT_TYPE" => "application/x-git-receive-pack-request"} + assert_equal 200, r.status + assert_equal "application/x-git-receive-pack-result", r.headers["Content-Type"] + end + + def test_info_refs_dumb + get "/example/.git/info/refs" + assert_equal 200, r.status + end + + def test_info_packs + get "/example/.git/objects/info/packs" + assert_equal 200, r.status + assert_match /P pack-(.*?).pack/, r.body + end + + def test_loose_objects + path, content = write_test_objects + get "/example/.git/objects/#{path}" + assert_equal 200, r.status + assert_equal content, r.body + remove_test_objects + end + + def test_pack_file + path, content = write_test_objects + get "/example/.git/objects/pack/pack-#{content}.pack" + assert_equal 200, r.status + assert_equal content, r.body + remove_test_objects + end + + def test_index_file + path, content = write_test_objects + get "/example/.git/objects/pack/pack-#{content}.idx" + assert_equal 200, r.status + assert_equal content, r.body + remove_test_objects + end + + def test_text_file + get "/example/.git/HEAD" + assert_equal 200, r.status + assert_equal 41, r.body.size # submodules have detached head + end + + def test_no_size_avail + File.stubs('size?').returns(false) + get "/example/.git/HEAD" + assert_equal 200, r.status + assert_equal 46, r.body.size # submodules have detached head + end + + def test_config_upload_pack_off + a1 = app + a1.set_config_setting(:upload_pack, false) + session = Rack::Test::Session.new(a1) + session.get "/example/info/refs?service=git-upload-pack" + assert_equal 404, session.last_response.status + end + + def test_config_receive_pack_off + a1 = app + a1.set_config_setting(:receive_pack, false) + session = Rack::Test::Session.new(a1) + session.get "/example/info/refs?service=git-receive-pack" + assert_equal 404, session.last_response.status + end + + def test_config_bad_service + get "/example/info/refs?service=git-receive-packfile" + assert_equal 404, r.status + end + + def test_git_config_receive_pack + app1 = Grack::Server.new({:project_root => example}) + app1.instance_variable_set(:@git, Grack::Git.new('git', example )) + session = Rack::Test::Session.new(app1) + git = Grack::Git + git.any_instance.stubs(:config).with('http.receivepack').returns('') + session.get "/example/info/refs?service=git-receive-pack" + assert_equal 404, session.last_response.status + + git.any_instance.stubs(:config).with('http.receivepack').returns('true') + session.get "/example/info/refs?service=git-receive-pack" + assert_equal 200, session.last_response.status + + git.any_instance.stubs(:config).with('http.receivepack').returns('false') + session.get "/example/info/refs?service=git-receive-pack" + assert_equal 404, session.last_response.status + end + + def test_git_config_upload_pack + app1 = Grack::Server.new({:project_root => example}) + # app1.instance_variable_set(:@git, Grack::Git.new('git', example )) + session = Rack::Test::Session.new(app1) + git = Grack::Git + git.any_instance.stubs(:config).with('http.uploadpack').returns('') + session.get "/example/info/refs?service=git-upload-pack" + assert_equal 200, session.last_response.status + + git.any_instance.stubs(:config).with('http.uploadpack').returns('true') + session.get "/example/info/refs?service=git-upload-pack" + assert_equal 200, session.last_response.status + + git.any_instance.stubs(:config).with('http.uploadpack').returns('false') + session.get "/example/info/refs?service=git-upload-pack" + assert_equal 404, session.last_response.status + end + + def test_send_file + app1 = app + app1.instance_variable_set(:@git, Grack::Git.new('git', Dir.pwd)) + # Reject path traversal + assert_equal 404, app1.send_file('tests/../tests', 'text/plain').first + # Reject paths starting with '|', avoid File.read('|touch /tmp/pawned; ls /tmp') + assert_equal 404, app1.send_file('|tests', 'text/plain').first + end + + def test_get_git + # Guard against non-existent directories + git1 = Grack::Git.new('git', 'foobar') + assert_equal false, git1.valid_repo? + # Guard against path traversal + git2 = Grack::Git.new('git', '/../tests') + assert_equal false, git2.valid_repo? + end + + private + + def r + last_response + end + + def write_test_objects + content = Digest::SHA1.hexdigest('gitrocks') + base = File.join(File.expand_path(File.dirname(__FILE__)), 'example', '.git', 'objects') + obj = File.join(base, '20') + Dir.mkdir(obj) rescue nil + file = File.join(obj, content[0, 38]) + File.open(file, 'w') { |f| f.write(content) } + pack = File.join(base, 'pack', "pack-#{content}.pack") + File.open(pack, 'w') { |f| f.write(content) } + idx = File.join(base, 'pack', "pack-#{content}.idx") + File.open(idx, 'w') { |f| f.write(content) } + ["20/#{content[0,38]}", content] + end + + def remove_test_objects + content = Digest::SHA1.hexdigest('gitrocks') + base = File.join(File.expand_path(File.dirname(__FILE__)), 'example', '.git', 'objects') + obj = File.join(base, '20') + file = File.join(obj, content[0, 38]) + pack = File.join(base, 'pack', "pack-#{content}.pack") + idx = File.join(base, 'pack', "pack-#{content}.idx") + File.unlink(file) + File.unlink(pack) + File.unlink(idx) + end + +end + +class MockProcess + def initialize + @counter = 0 + end + + def write(data) + end + + def read(data = nil) + '' + end + + def eof? + @counter += 1 + @counter > 1 ? true : false + end + + def close_write + true + end +end From 88491e7e2a7c13444b30334fca7ce61c747be168 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 1 Jul 2015 22:58:46 +0800 Subject: [PATCH 003/119] =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/grack | 1 - 1 file changed, 1 deletion(-) delete mode 160000 lib/grack diff --git a/lib/grack b/lib/grack deleted file mode 160000 index 949be9116..000000000 --- a/lib/grack +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 949be9116a76b50a6f86baf507dec4c4d7fb34c6 From 8da9805bccbf572704790e475a12bc5e7c3a4899 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 2 Jul 2015 20:10:52 +0800 Subject: [PATCH 004/119] =?UTF-8?q?=E5=85=BC=E5=AE=B9ruby=201.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/grack/lib/grack/git.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/grack/lib/grack/git.rb b/lib/grack/lib/grack/git.rb index 84695754a..cf5362c20 100644 --- a/lib/grack/lib/grack/git.rb +++ b/lib/grack/lib/grack/git.rb @@ -19,14 +19,25 @@ module Grack # _Not_ the same as `IO.popen(...).read` # By using a block we tell IO.popen to close (wait for) the child process # after we are done reading its output. - IO.popen(popen_env, cmd, popen_options) { |p| p.read } + if RUBY_VERSION.start_with?("2") + IO.popen(popen_env, cmd, popen_options) { |p| p.read } + else + IO.popen(cmd, popen_options) { |p| p.read } + end end def execute(cmd) cmd = command(cmd) if block_given? - IO.popen(popen_env, cmd, File::RDWR, popen_options) do |pipe| - yield(pipe) + + if RUBY_VERSION.start_with?("2") + IO.popen(popen_env, cmd, File::RDWR, popen_options) do |pipe| + yield(pipe) + end + else + IO.popen(cmd, File::RDWR, popen_options) do |pipe| + yield(pipe) + end end else capture(cmd).chomp @@ -61,9 +72,11 @@ module Grack match = execute(%W(rev-parse --git-dir)).match(/\.$|\.git$/) - if match.to_s == '.git' - # Since the parent could be a git repo, we want to make sure the actual repo contains a git dir. - return false unless Dir.entries(repo).include?('.git') + if RUBY_VERSION.start_with?("2") + if match.to_s == '.git' + # Since the parent could be a git repo, we want to make sure the actual repo contains a git dir. + return false unless Dir.entries(repo).include?('.git') + end end match From b762ae6bdd16f2efd83dbc0d5f44058b677e255a Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 4 Jul 2015 22:29:25 +0800 Subject: [PATCH 005/119] =?UTF-8?q?=E6=8A=A5=E5=91=8A=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E5=85=8B=E9=9A=86=EF=BC=8C=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=85=B6=E4=BB=96=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E5=85=8B=E9=9A=86=E5=92=8C=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 12 ++-- app/helpers/repositories_helper.rb | 2 +- .../settings/_new_repositories.html.erb | 16 +---- app/views/repositories/show.html.erb | 15 ++-- config/configuration.yml | 2 +- lib/grack/lib/grack/server.rb | 6 +- lib/trustie/grack/auth.rb | 72 +++++++++++++++---- 7 files changed, 80 insertions(+), 45 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 607c9b5db..e73f19143 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -127,19 +127,18 @@ update end else # 原逻辑 ##xianbo + params[:repository_scm] = "Git" @root_path=RepositoriesHelper::ROOT_PATH @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:upassword] || params[:repository][:password] + @repository_tag=params[:repository][:upassword] || params[:repository][:password] || '1234' @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] logger.info "htpasswd -mb "+@root_path+"htdocs/user.passwd "+@repo_name+": "+@repository_tag logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name attrs = pickup_extra_info - if((@repository_tag!="")&¶ms[:repository_scm]=="Git") - params[:repository][:url]=@project_path - end + params[:repository][:url]=@project_path ###xianbo - @repository = Repository.factory(params[:repository_scm]) + @repository = Repository.factory(params[:repository_scm]||"Git") @repository.safe_attributes = params[:repository] if attrs[:attrs_extra].keys.any? @repository.merge_extra_info(attrs[:attrs_extra]) @@ -270,7 +269,8 @@ update @course_tag = params[:course] project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT ip = RepositoriesHelper::REPO_IP_ADDRESS - @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ + # @repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+ + @repos_url = "http://#{Setting.host_name}/#{@repository.login.to_s}/#{@repository.identifier.to_s}.git" @repository.url.slice(project_path_cut, @repository.url.length).to_s if @course_tag == 1 render :action => 'show', :layout => 'base_courses' diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 5cbc3af5a..718085f24 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -19,7 +19,7 @@ module RepositoriesHelper if Rails.env.development? - ROOT_PATH="/tmp/" if Rails.env.development? + ROOT_PATH="/private/tmp/" else ROOT_PATH="/home/pdl/redmine-2.3.2-0/apache2/" end diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index ca771a487..b626b4089 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -62,15 +62,6 @@ <%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post"} do |f| %>
    -
  • - - <%= select_tag('repository_scm', - options_for_select(["Git"],@repository.class.name.demodulize), - :data => {:remote => true, :method => 'get'})%> - <% if @repository && ! @repository.class.scm_available %> - <%= l(:text_scm_command_not_available) %> - <% end %> -
  • <% unless judge_main_repository(@project) %>
  • @@ -84,14 +75,9 @@ <%=l(:text_length_between,:min=>1,:max=>254)< <% end %>
  • -
  • - - <%= f.password_field :upassword, :label=> "", :no_label => true %> - <%= l(:label_upassword_info)%> -
<%=l(:button_save)%> <%=l(:button_cancel)%>
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 474ac638f..5f279f2c2 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -33,8 +33,9 @@

+

git 克隆和提交的用户名和密码为登录用户名和密码

项目代码请设置好正确的编码方式(utf-8),否则中文会出现乱码。

-

通过cmd命令提示符进入代码对应文件夹的根目录,假设当前用户的登录名为user,版本库名称为demo,需要操作的版本库分支为branch。 +

通过cmd命令提示符进入代码对应文件夹的根目录, 如果是首次提交代码,执行如下命令:

@@ -45,19 +46,19 @@

git commit -m "first commit"

git remote add origin - http://user_demo@repository.trustie.net/user/demo.git + <%= @repos_url %>

git config http.postBuffer 524288000 #设置本地post缓存为500MB

-

git push -u origin branch:branch

+

git push -u origin master

已经有本地库,还没有配置远程地址,打开命令行执行如下:

-

git remote add origin http://user_demo@repository.trustie.net/user/demo.git

+

git remote add origin <%= @repos_url %>

git add .

@@ -65,14 +66,14 @@

git config http.postBuffer 524288000 #设置本地post缓存为500MB

-

git push -u origin branch:branch

+

git push -u origin master

已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:

-

git clone http://user_demo@repository.trustie.net/user/demo.git

+

git clone <%= @repos_url %>

git push

@@ -86,7 +87,7 @@

git remote add trustie - http://user_demo@repository.trustie.net/user/demo.git + <%= @repos_url %>

git add .

diff --git a/config/configuration.yml b/config/configuration.yml index 4c786ad28..ef204a31e 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -197,7 +197,7 @@ default: #max_concurrent_ajax_uploads: 2 #pic_types: "bmp,jpeg,jpg,png,gif" - repository_root_path: '/Users/guange/repository' + repository_root_path: '/tmp/htdocs' # specific configuration options for production environment # that overrides the default ones diff --git a/lib/grack/lib/grack/server.rb b/lib/grack/lib/grack/server.rb index 59e0bc271..6b4fe8801 100644 --- a/lib/grack/lib/grack/server.rb +++ b/lib/grack/lib/grack/server.rb @@ -50,7 +50,7 @@ module Grack return render_method_not_allowed if cmd == 'not_allowed' return render_not_found unless cmd - @git = get_git(path) + @git = get_git(env["REP_PATH"] || path) return render_not_found unless git.valid_repo? self.method(cmd).call @@ -195,8 +195,8 @@ module Grack end def get_git(path) - root = @config[:project_root] || Dir.pwd - path = File.join(root, path) + # root = @config[:project_root] || Dir.pwd + # path = File.join(root, path) Grack::Git.new(@config[:git_path], path) end diff --git a/lib/trustie/grack/auth.rb b/lib/trustie/grack/auth.rb index c27477be2..5464b18ca 100644 --- a/lib/trustie/grack/auth.rb +++ b/lib/trustie/grack/auth.rb @@ -1,9 +1,16 @@ +#coding=utf-8 +# require 'rack/auth/basic' require 'rack/auth/abstract/handler' require 'rack/auth/abstract/request' module Grack + class Auth < Rack::Auth::Basic + DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive } + PUSH_COMMANDS = %w{ git-receive-pack } + + attr_accessor :user, :repository def call(env) @env = env @request = Rack::Request.new(env) @@ -16,6 +23,7 @@ module Grack else result = if (access = valid?(@auth) and access == true) @env['REMOTE_USER'] = @auth.username + env['REP_PATH'] = repository.root_url @app.call(env) else if access == '404' @@ -37,19 +45,59 @@ module Grack end def valid?(auth) - match = @request.path_info.match(/(\/.+\.git)\//) - if match - rep = Repository.where("root_url like ?", "%#{match[1]}") - return "404" if rep.empty? - username, password = auth.credentials - user, last_login_on = User.try_to_login(username, password) - return '403' unless user - if user.member_of?(rep.first.project) || user.admin? - return true - end - end - false + self.repository = auth_rep + return "404" unless repository + username, password = auth.credentials + self.user = auth_user(username, password) + return '403' unless user + access = auth_request + puts "access #{access}" + access end + + def auth_rep + rep = nil + match = @request.path_info.match(/(\/.+\.git)\//) + if match + rep = Repository.where("root_url like ?", "%#{match[1]}").first + end + rep + end + + def auth_user(username, password) + u, last_login_on = User.try_to_login(username, password) + unless u && (u.member_of?(repository.project) || u.admin?) + u = nil + end + u + end + + def auth_request + case git_cmd + when *DOWNLOAD_COMMANDS + user != nil + when *PUSH_COMMANDS + unless user + false + else + ### 只有Manager和Development才有push权限 + repository.project.members.where(user_id: user.id).first.roles.any?{|r| r.name == 'Manager' || r.name == 'Developer'} + end + else + false + end + end + + def git_cmd + if @request.get? + @request.params['service'] + elsif @request.post? + File.basename(@request.path) + else + nil + end + end + end# class Auth end# module Grack From 89b9a5c09dbc269981b9ea5fc094d78cefd2d93a Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Sat, 15 Aug 2015 17:06:41 +0800 Subject: [PATCH 006/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 77 +++++++++++++++++- app/helpers/application_helper.rb | 3 +- app/helpers/users_helper.rb | 23 ++++++ app/models/user.rb | 9 ++- app/views/layouts/base_users_new.html.erb | 12 +++ config/routes.rb | 7 ++ db/schema.rb | 10 +++ public/stylesheets/public.css | 65 ++++++++++++++++ public/stylesheets/public_new.css | 95 +++++++++++++++++++++++ 9 files changed, 297 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 39a467d53..0b3302fae 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -46,7 +46,7 @@ class UsersController < ApplicationController :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, - :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index, + :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] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show @@ -807,6 +807,27 @@ class UsersController < ApplicationController end end + # 上传用户资源 + def user_resource_create + @user = User.find(params[:id]) + #@user.save_attachments(params[:attachments],User.current) + # Container_type为Principal + Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type]) + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + respond_to do |format| + format.js + end + end + + # 删除用户资源 + def user_resource_delete + Attachment.delete(params[:resource_id]) + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + respond_to do |format| + format.js + end + end + def destroy @user.destroy respond_to do |format| @@ -1008,6 +1029,55 @@ class UsersController < ApplicationController @user = User.find(params[:id]) end + # 资源库 分为全部 课程资源 项目资源 附件 + def user_resource + #确定container_type + # @user = User.find(params[:id]) + if(params[:type].nil? || params[:type] == "1") #全部 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + end + elsif params[:type] == "2" #课程资源 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' ").order("created_on desc") + end + elsif params[:type] == "3" #项目资源 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") + end + elsif params[:type] == "4" #附件 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + end + end + @type = params[:type] + respond_to do |format| + format.js + format.html {render :layout => 'base_users_new'} + end + end + + # 根据资源关键字进行搜索 + def resource_search + search = params[:search].to_s.strip.downcase + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and (filename like '%#{search}%') ").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc") + end + respond_to do |format| + format.js + end + end + private def find_user @@ -1021,7 +1091,7 @@ class UsersController < ApplicationController render_404 end - def setting_layout(default_base='base_users') + def setting_layout(default_base='base_users_new') User.current.admin? ? default_base : default_base end @@ -1071,4 +1141,7 @@ class UsersController < ApplicationController impl.save end end + + + end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6ac3c234a..cdcb6fc4d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1852,7 +1852,8 @@ module ApplicationHelper candown = true elsif attachment.container.class.to_s=="StudentWork" candown = true - + elsif attachment.container.class.to_s == "User" + candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id) elsif attachment.container_type == "Bid" && attachment.container && attachment.container.courses course = attachment.container.courses.first candown = User.current.member_of_course?(attachment.container.courses.first) || (course.is_public == 1 && attachment.is_public == 1) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 49865d335..41458bc90 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -29,6 +29,29 @@ module UsersHelper ["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s) end + def get_resource_type type + case type + when 'Course' + '课程资源' + when 'Project' + '项目资源' + when 'Issue' + '缺陷附件' + when 'Message' + '讨论区附件' + when 'Document' + '文档附件' + when 'News' + '通知附件' + when 'HomewCommon' + '作业附件' + when 'StudentWorkScore' + '批改附件' + when 'Principal' + '用户资源' + end + end + def user_mail_notification_options(user) user.valid_notification_options.collect {|o| [l(o.last), o.first]} end diff --git a/app/models/user.rb b/app/models/user.rb index 1cd0675c8..4fae33185 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -150,7 +150,8 @@ class User < Principal nil } - + acts_as_attachable :view_permission => :view_files, + :delete_permission => :manage_files acts_as_customizable ############################added by william acts_as_taggable @@ -239,6 +240,12 @@ class User < Principal self.user_extensions ||= UserExtensions.new end + # User现在可以作为一个Container_type,而Attachment的Container方法会有一个Container.try(:project), + # 所以这里定义一个空方法,保证不报错 + def project + + end + def user_score_attr self.user_score ||= UserScore.new end diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index 09d437da4..f9f065e2a 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -146,6 +146,12 @@ (<%=@user.projects.count%>)
+ <% else%> + <% end %> + <% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/homework.html.erb b/app/views/admin/homework.html.erb index 360ca4e39..7260d68ff 100644 --- a/app/views/admin/homework.html.erb +++ b/app/views/admin/homework.html.erb @@ -27,7 +27,7 @@ - <%@count=0 %> + <%@count=@page*30 %> <% for homework in @homework do %> <% @count+=1 %> @@ -48,7 +48,7 @@ <% end %> - <%=StudentWork.where('homework_common_id=?',homework.id).count %> + <%=link_to(StudentWork.where('homework_common_id=?',homework.id).count, student_work_index_path(:homework => homework.id))%> <%=format_date(homework.end_time) %> @@ -59,4 +59,8 @@
+ + <% html_title(l(:label_user_homework)) -%> diff --git a/app/views/admin/latest_login_users.html.erb b/app/views/admin/latest_login_users.html.erb index dc35daec8..838cc0dcb 100644 --- a/app/views/admin/latest_login_users.html.erb +++ b/app/views/admin/latest_login_users.html.erb @@ -1,7 +1,26 @@ +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>

<%=l(:label_latest_login_user_list)%>

+<%= form_tag({}, :method => :get) do %> +
+ + <%= l(:label_filter_plural) %> + + + <%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%> + <%= calendar_for('startdate')%> + + <%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%> + <%= calendar_for('enddate')%>   + <%= submit_tag l(:button_apply), :class => "small", :name => nil %> + <%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_users'}, :class => 'icon icon-reload' %> +
+<% end %> +  + +
@@ -27,7 +46,7 @@ - <% @count=0 %> + <% @count=@page * 30 %> <% for user in @user do %> <% @count +=1 %> @@ -70,4 +89,8 @@
+ + <% html_title(l(:label_latest_login_user_list)) -%> diff --git a/app/views/admin/leave_messages.html.erb b/app/views/admin/leave_messages.html.erb index 975c60b15..360e9b864 100644 --- a/app/views/admin/leave_messages.html.erb +++ b/app/views/admin/leave_messages.html.erb @@ -31,7 +31,7 @@ - <% @count=0%> + <% @count = @page * 30 %> <% for journal in @jour -%> <% @count=@count + 1 %> "> @@ -49,20 +49,39 @@ <%= journal.jour_id %> - - <%= link_to(journal.try(:user).try(:realname).truncate(6, omission: '...'), user_path(journal.user)) %> + <%= journal.try(:user)%><% else %><%=journal.try(:user).try(:realname) %><% end %>'> + <% if journal.try(:user).try(:realname) == ' '%> + <%= link_to(journal.try(:user), user_path(journal.user)) %> + <% else %> + <%= link_to(journal.try(:user).try(:realname), user_path(journal.user)) %> + <% end %> <%= format_date(journal.created_on) %> - - <%= journal.notes.truncate(15, omission: '...') %> + + <%case journal.jour_type %> + <% when 'Principal' %> + <%= link_to(journal.notes.html_safe, feedback_path(journal.jour_id)) %> + <% when 'Course' %> + <%= link_to(journal.notes.html_safe, course_feedback_path(journal.jour_id)) %> + <% end %> <% if(journal.m_reply_count) %> - <%=journal.m_reply_count%> + <%case journal.jour_type %> + <% when 'Principal' %> + <%= link_to(journal.m_reply_count, feedback_path(journal.jour_id)) %> + <% when 'Course' %> + <%= link_to(journal.m_reply_count, course_feedback_path(journal.jour_id)) %> + <% end %> <% else %> - <%=0 %> + <%case journal.jour_type %> + <% when 'Principal' %> + <%= link_to(0, feedback_path(journal.jour_id)) %> + <% when 'Course' %> + <%= link_to(0, course_feedback_path(journal.jour_id)) %> + <% end %> <% end %> @@ -71,9 +90,7 @@ <% html_title(l(:label_leave_message_list)) -%> diff --git a/app/views/admin/messages_list.html.erb b/app/views/admin/messages_list.html.erb index 77cdbbc69..e0c84279d 100644 --- a/app/views/admin/messages_list.html.erb +++ b/app/views/admin/messages_list.html.erb @@ -29,7 +29,7 @@ - <% @count=0%> + <% @count=@page * 30%> <% for memo in @memo -%> <% @count=@count + 1 %> "> @@ -50,20 +50,18 @@ <%= format_date(memo.created_at) %> - <%= memo.subject %> + <%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %> - <%=memo.replies_count %> + <%= link_to(memo.replies_count, forum_memo_path(memo.forum, memo)) %> <% end %> - + <% html_title(l(:label_message_plural)) -%> diff --git a/app/views/admin/notices.html.erb b/app/views/admin/notices.html.erb index 56f212720..f03a7b97a 100644 --- a/app/views/admin/notices.html.erb +++ b/app/views/admin/notices.html.erb @@ -33,7 +33,7 @@ - <% @count=0%> + <% @count=@page * 30%> <% for news in @news -%> <% @count=@count + 1 %> "> @@ -63,7 +63,7 @@ <%= link_to(news.title, news_path(news)) %> - <%=news.comments_count %> + <%= link_to(news.comments_count, news_path(news)) %> <% end %> @@ -71,4 +71,8 @@ + + <% html_title(l(:label_notification_list)) -%> diff --git a/app/views/admin/project_messages.html.erb b/app/views/admin/project_messages.html.erb index af2978422..dc44a7cba 100644 --- a/app/views/admin/project_messages.html.erb +++ b/app/views/admin/project_messages.html.erb @@ -29,7 +29,7 @@ - <% @count=0%> + <% @count=@page * 30 %> <% for project in @project_ms -%> <% @count=@count + 1 %> @@ -51,10 +51,10 @@ <%= format_date(project.created_on) %> - <%= project.subject %> + <%= link_to(project.subject, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %> - <%=project.replies_count %> + <%= link_to(project.replies_count, project_boards_path(Board.where('id=?',project.board_id).first.project_id)) %> @@ -63,4 +63,8 @@ + + <% html_title(l(:label_message_plural)) -%> diff --git a/db/schema.rb b/db/schema.rb index 8d78a9ca0..841bcc7e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -474,13 +474,6 @@ ActiveRecord::Schema.define(:version => 20150815030833) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -893,6 +886,7 @@ ActiveRecord::Schema.define(:version => 20150815030833) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" + t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" From 3e4f726855de4448c0fa8e6d7f2a2984d81a785c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 18 Aug 2015 14:43:15 +0800 Subject: [PATCH 023/119] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=95=99=E8=A8=80?= =?UTF-8?q?=E3=80=81=E6=8C=87=E6=B4=BE=E7=BB=99=E6=88=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 3 +++ app/views/users/user_messages.html.erb | 34 +++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 770d7d049..dbcbdefa6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -126,6 +126,9 @@ class UsersController < ApplicationController when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil + when 'journal' + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + @user_course_messages = nil end respond_to do |format| format.html{render :layout=>'base_users_new'} diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 2e7b110bf..c23ad3716 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -14,6 +14,7 @@
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • +
  • <%= link_to "问题更新",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'journal'} %>
  • @@ -76,9 +77,36 @@ <% unless @user_forge_messages.nil? %> <% @user_forge_messages.each do |ufm| %> - <% if ufm.forge_message_type == "Issue" %> - 22222 - <% end %> + <% if ufm.forge_message_type == "Issue" %> + + <% end %> + <% if ufm.forge_message_type == "Journal" %> + + <% end %> <% end %> <% end %> <% else %> From 9c4e89177f68967aa0537dc390737c6ea6ad463a Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 18 Aug 2015 14:44:46 +0800 Subject: [PATCH 024/119] =?UTF-8?q?=E7=95=99=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index c23ad3716..77b7d5898 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -14,7 +14,7 @@
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • -
  • <%= link_to "问题更新",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'journal'} %>
  • +
  • <%= link_to "我的留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'journal'} %>
  • From 7219586b1e1cfb34b258052f6ab7ecaf3bfda01e Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 18 Aug 2015 15:25:36 +0800 Subject: [PATCH 025/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 37 ++++++++++++++--- .../users/_resource_search_form.html.erb | 7 ++++ app/views/users/_resources_list.html.erb | 2 +- app/views/users/rename_resource.js.erb | 1 + app/views/users/resource_preview.js.erb | 2 + app/views/users/user_resource.html.erb | 41 ++++++++++--------- app/views/users/user_resource.js.erb | 1 + 7 files changed, 65 insertions(+), 26 deletions(-) create mode 100644 app/views/users/_resource_search_form.html.erb create mode 100644 app/views/users/rename_resource.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0df07acff..6bbfbd12b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -40,7 +40,8 @@ class UsersController < ApplicationController :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist] + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist, + :user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,:resource_preview,:resource_search] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, @@ -1139,11 +1140,37 @@ class UsersController < ApplicationController # 根据资源关键字进行搜索 def resource_search search = params[:search].to_s.strip.downcase - if User.current.id == params[:id] - @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and (filename like '%#{search}%') ").order("created_on desc") - else - @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc") + # if User.current.id == params[:id] + # @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and (filename like '%#{search}%') ").order("created_on desc") + # else + # @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc") + # end + if(params[:type].nil? || params[:type] == "1") #全部 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc") + end + elsif params[:type] == "2" #课程资源 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course' and (filename like '%#{search}%')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' and (filename like '%#{search}%') ").order("created_on desc") + end + elsif params[:type] == "3" #项目资源 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like '%#{search}%') ").order("created_on desc") + end + elsif params[:type] == "4" #附件 + if User.current.id == params[:id] + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + end end + @type = params[:type] respond_to do |format| format.js end diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb new file mode 100644 index 000000000..0c48514b3 --- /dev/null +++ b/app/views/users/_resource_search_form.html.erb @@ -0,0 +1,7 @@ +<%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>user.id), + :remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> + + <%= hidden_field_tag(:type,type) %> + <%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %> + +<% end %> \ No newline at end of file diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 078ee2c94..6f9ba0fee 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -5,7 +5,7 @@
  • <%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename), - :title => attach.filename+"\n"+attach.description.to_s,:class=>'resourcesBlack'%> + :title => attach.filename,:class=>'resourcesBlack'%>
  • <%= number_to_human_size(attach.filesize) %>
  • <%= get_resource_type(attach.container_type)%>
  • diff --git a/app/views/users/rename_resource.js.erb b/app/views/users/rename_resource.js.erb new file mode 100644 index 000000000..5556fb313 --- /dev/null +++ b/app/views/users/rename_resource.js.erb @@ -0,0 +1 @@ +alert(1) \ No newline at end of file diff --git a/app/views/users/resource_preview.js.erb b/app/views/users/resource_preview.js.erb index a38d46374..c3e1fb3ab 100644 --- a/app/views/users/resource_preview.js.erb +++ b/app/views/users/resource_preview.js.erb @@ -1,3 +1,5 @@ <% if @preview_able %> top.location.href = '<%=download_named_attachment_path(@file.id, @file.filename, preview: true) %>' +<% else %> +window.alert('该资源不可预览') <% end %> \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index d9b992129..1c54fc67e 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -71,13 +71,9 @@ -
    - <%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>@user.id), - :remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> - - <%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %> - - <% end %> +
    + <%= render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} %> +
    @@ -168,7 +164,7 @@ $(".resourcesList").click(function(e) { } //将当前行改变为白色 line.children().css("background-color", 'white'); - //当前行恢复编辑状态 + //当前行恢复编辑状态到链接状态 if(ele.nodeName != 'INPUT') { restore(); } @@ -210,6 +206,7 @@ $(".resourcesList").click(function(e) { '"/> '+ '<% end %>'); $("#res_name").focus(); + document.getElementById('res_name').scrollIntoView() } String.prototype.trim = function() { var str = this, @@ -219,38 +216,42 @@ $(".resourcesList").click(function(e) { while (ws.test(str.charAt(--i))); return str.slice(0, i + 1); } + + //恢复编辑状态到链接状态 + //如果当前是编辑状态,任何的不在输入框里的单击右键事件都需要将编辑状态变回链接状态 + //如果是编辑状态,且做了修改,那么久要进行修改,并且将修改值经过处理替换到页面显示 function restore(){ + //上一行不为空 且链接不为空 if( last_line != null && res_link != null && res_link != '') { - name = $("#res_name").val().trim(); - if(name != res_name.trim()){ + name = $("#res_name") ? $("#res_name").val().trim() : $("#res_name") ; + if( name && name != res_name.trim()){ if(confirm('确定修改为 '+name)){ - //$("#res_name_form").submit(); -// $.ajax({ -// type:'post', -// url:'<%#=rename_resource_user_path(@user) %>', -// data: $("#res_name_form").serialize() -// }); $.post( '<%=rename_resource_user_path(@user) %>', $("#res_name_form").serialize(), function (data){ - if(data =='sucess'){ + if(data =='sucess'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 last_line.children().first().html(res_link); last_line.children().first().children().attr('title',name); - last_line.children().first().children().html(name); + last_line.children().first().children().html(name.length > 17? name.substring(0,17)+'...' : name); }else{ last_line.children().first().html(res_link); + res_link = null; //如果修改失败,恢复之后将res_link置空 } }, 'text' ); }else{ - //last_line.children().first().html(res_link); + last_line.children().first().html(res_link); + res_link = null; //如果没有做修改,恢复之后将res_link置空 } }else { last_line.children().first().html(res_link); + res_link = null;//如果没有做修改,恢复之后将res_link置空 } + + } } @@ -261,7 +262,7 @@ $(".resourcesList").click(function(e) { } line.children().css("background-color", 'white'); id = line.children().last().html(); - if (confirm('确定要删除资源' + line.children().first().children().attr('title').trim() + '么')){ + if (confirm('确定要删除资源"' + line.children().first().children().attr('title').trim() + '"么?')){ $.ajax({ type: 'post', url: '<%= user_resource_delete_user_path(@user)%>' + '?resource_id=' + id diff --git a/app/views/users/user_resource.js.erb b/app/views/users/user_resource.js.erb index 69fc3dd43..d69a769af 100644 --- a/app/views/users/user_resource.js.erb +++ b/app/views/users/user_resource.js.erb @@ -1 +1,2 @@ +$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); \ No newline at end of file From 6b5547462338521b53a9da9548a488b699e76de5 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 18 Aug 2015 15:27:16 +0800 Subject: [PATCH 026/119] =?UTF-8?q?=E4=BD=9C=E5=93=81=E8=A2=AB=E8=AF=84?= =?UTF-8?q?=E9=98=85=20=E4=BD=9C=E5=93=81=E8=A2=AB=E5=9B=9E=E5=A4=8D=20?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 4 ++++ app/models/journals_for_message.rb | 13 ++++++++++++- app/models/student_works_score.rb | 11 +++++++++++ app/views/users/user_messages.html.erb | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 770d7d049..3e50f3131 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -97,6 +97,8 @@ class UsersController < ApplicationController end # 用户消息 + # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅 + # issue:问题; def user_messages unless User.current.logged? render_403 @@ -123,6 +125,8 @@ class UsersController < ApplicationController @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") when 'poll' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") + when 'works_reviewers' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index bcae58174..da19ba1f2 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -58,9 +58,11 @@ class JournalsForMessage < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy + # 消息关联 + has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy validates :notes, presence: true, if: :is_homework_jour? - after_create :act_as_activity, :act_as_course_activity + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message after_create :reset_counters! after_destroy :reset_counters! after_save :be_user_score @@ -186,4 +188,13 @@ class JournalsForMessage < ActiveRecord::Base self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id) end end + + # 课程作品留言消息通知 + def act_as_course_message + if self.jour_type == 'StudentWorksScore' + if self.user_id != self.jour.user_id + self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.student_work.homework_common.course.id) + end + end + end end diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb index 8fa14f8de..639722389 100644 --- a/app/models/student_works_score.rb +++ b/app/models/student_works_score.rb @@ -5,6 +5,17 @@ class StudentWorksScore < ActiveRecord::Base belongs_to :user belongs_to :student_work has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy acts_as_attachable + + after_create :act_as_course_message + + # 评阅作品消息提示 + def act_as_course_message + if self.student_work + receiver = self.student_work.user + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false) + end + end end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 2e7b110bf..93e0fe967 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -22,7 +22,7 @@
    <% if @new_message_count >0 %> <% unless @user_course_messages.nil? %> - <% @user_course_messages.each do |ucm| %> + <% @user_course_messages.each do |ucm| %> <% if ucm.course_message_type == "News" %>
    • <%= image_tag(url_to_avatar(ucm.course_message.author), :width => "30", :height => "30") %>
    • From 32aef6f2891fd0fd50edd29b2ea88dc6c941c402 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 18 Aug 2015 15:36:15 +0800 Subject: [PATCH 027/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_resource.html.erb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 1c54fc67e..98984b3f9 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -28,8 +28,6 @@ function closeModal() { - //hideModal($("#popbox_upload")); - //$("#attachments_fields").html(''); $("#upload_box").css("display","none"); } @@ -48,19 +46,15 @@
      • - <%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
      • - <%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
      • - <%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
      • - <%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesGrey' %>
      @@ -73,7 +67,6 @@ 上传资源
    <%= render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} %> -
    From 375c016783b00bbbae617181011af267593b797c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 18 Aug 2015 15:42:36 +0800 Subject: [PATCH 028/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_resource.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 98984b3f9..f5a6c57f0 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -199,7 +199,7 @@ $(".resourcesList").click(function(e) { '"/> '+ '<% end %>'); $("#res_name").focus(); - document.getElementById('res_name').scrollIntoView() + $("html,body").animate({scrollTop:$("#res_name").offset().top},1000) } String.prototype.trim = function() { var str = this, From 5f2965540655e8f440f249ba1e6c1502531683d1 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 18 Aug 2015 16:35:19 +0800 Subject: [PATCH 029/119] =?UTF-8?q?issue=E7=8A=B6=E6=80=81=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 125 +++++++++++++------------ 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index af2ebd902..03cdda8ad 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -14,69 +14,69 @@
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • -
  • <%= link_to "我的留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'journal'} %>
  • +
  • <%= link_to "我的留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • - <% if @new_message_count >0 %> - <% unless @user_course_messages.nil? %> - <% @user_course_messages.each do |ucm| %> - <% if ucm.course_message_type == "News" %> - + <% if @new_message_count >0 %> + <% unless @user_course_messages.nil? %> + <% @user_course_messages.each do |ucm| %> + <% if ucm.course_message_type == "News" %> + + <% end %> + <% if ucm.course_message_type == "HomeworkCommon" %> + + <% end %> + <% if ucm.course_message_type == "Poll" %> + + <% end %> + <% if ucm.course_message_type == "Message" %> + + <% end %> +
    + <% end %> <% end %> - <% if ucm.course_message_type == "HomeworkCommon" %> - - <% end %> - <% if ucm.course_message_type == "Poll" %> - - <% end %> - <% if ucm.course_message_type == "Message" %> - - <% end %> -
    - <% end %> - <% end %> - - <% unless @user_forge_messages.nil? %> - <% @user_forge_messages.each do |ufm| %> + + <% unless @user_forge_messages.nil? %> + <% @user_forge_messages.each do |ufm| %> <% if ufm.forge_message_type == "Issue" %> <% end %> + <% end %> + <% end %> + <% else %> +
    暂无消息!
    <% end %> - <% end %> - <% else %> -
    暂无消息!
    - <% end %>
    From 90661066d36e8e81069c6d0bc242095a855f6e84 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 18 Aug 2015 16:53:26 +0800 Subject: [PATCH 030/119] =?UTF-8?q?=E5=8C=BA=E5=88=86=E8=AF=BE=E7=A8=8B/?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA=E5=8C=BA=20=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E9=A1=B9=E7=9B=AE/=E6=96=B0=E9=97=BB=20=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++++-- app/views/users/user_messages.html.erb | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d1073c8c3..00ce151cf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -117,16 +117,20 @@ class UsersController < ApplicationController when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") @user_forge_messages = nil - when 'message' + when 'course_message' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + when 'forge_message' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") - when 'news' + when 'course_news' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") + when 'forge_news' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") when 'poll' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") when 'works_reviewers' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") + when 'works_reply' + @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 03cdda8ad..a4cc521ff 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -9,12 +9,17 @@
  • <%= link_to "全部",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
  • <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
  • -
  • <%= link_to "讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'message'} %>
  • -
  • <%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'news'} %>
  • +
  • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
  • +
  • <%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • +
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • +
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • +
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • -
  • <%= link_to "我的留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • +
  • <%= link_to "问题更新",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • +
  • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
  • +
  • <%= link_to "项目新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
  • From ae6260571b4d4321cf68d433f8d0c793dd9d0c94 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 18 Aug 2015 16:57:41 +0800 Subject: [PATCH 031/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++---- app/views/users/user_resource.html.erb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6bbfbd12b..c3c5da9cf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1106,25 +1106,25 @@ class UsersController < ApplicationController #确定container_type # @user = User.find(params[:id]) if(params[:type].nil? || params[:type] == "1") #全部 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") end elsif params[:type] == "2" #课程资源 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' ").order("created_on desc") end elsif params[:type] == "3" #项目资源 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") end elsif params[:type] == "4" #附件 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index f5a6c57f0..09bee5ac6 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -199,7 +199,7 @@ $(".resourcesList").click(function(e) { '"/> '+ '<% end %>'); $("#res_name").focus(); - $("html,body").animate({scrollTop:$("#res_name").offset().top},1000) + $("html,body").animate({scrollTop:$("#res_name").offset().top},1000) } String.prototype.trim = function() { var str = this, From 652f5fa6e130a1d316530557803a4716fb1a7672 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 18 Aug 2015 17:00:58 +0800 Subject: [PATCH 032/119] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=9A=84=E7=95=99=E8=A8=80=E5=88=97=E8=A1=A8=E3=80=81?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E3=80=81=E6=9C=80=E8=BF=91=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8=E7=9A=84=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/admin/course_messages.html.erb | 4 ++-- app/views/admin/latest_login_users.html.erb | 6 +++--- app/views/admin/leave_messages.html.erb | 4 ++-- app/views/admin/messages_list.html.erb | 10 +++++++--- app/views/admin/project_messages.html.erb | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/views/admin/course_messages.html.erb b/app/views/admin/course_messages.html.erb index 3db0a3e11..c9e69357f 100644 --- a/app/views/admin/course_messages.html.erb +++ b/app/views/admin/course_messages.html.erb @@ -11,8 +11,8 @@ 序号 - - 来源 + + 来源(课程ID) 作者 diff --git a/app/views/admin/latest_login_users.html.erb b/app/views/admin/latest_login_users.html.erb index 838cc0dcb..89514726a 100644 --- a/app/views/admin/latest_login_users.html.erb +++ b/app/views/admin/latest_login_users.html.erb @@ -9,10 +9,10 @@ <%= l(:label_filter_plural) %> - <%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%> - <%= calendar_for('startdate')%> + <%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange=>"$('#ui-datepicker-div').hide()", :style=>"float:left"%> + <%= calendar_for('startdate')%>    - <%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"regexDeadLine();", :style=>"float:left"%> + <%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"$('#ui-datepicker-div').hide()", :style=>"float:left"%> <%= calendar_for('enddate')%>   <%= submit_tag l(:button_apply), :class => "small", :name => nil %> <%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_users'}, :class => 'icon icon-reload' %> diff --git a/app/views/admin/leave_messages.html.erb b/app/views/admin/leave_messages.html.erb index 360e9b864..dee8b7443 100644 --- a/app/views/admin/leave_messages.html.erb +++ b/app/views/admin/leave_messages.html.erb @@ -13,8 +13,8 @@ 类型 - - 来源 + + 来源(课程或用户ID) 留言人 diff --git a/app/views/admin/messages_list.html.erb b/app/views/admin/messages_list.html.erb index e0c84279d..ca84baa24 100644 --- a/app/views/admin/messages_list.html.erb +++ b/app/views/admin/messages_list.html.erb @@ -11,8 +11,8 @@ 序号 - - 来源 + + 来源(贴吧ID) 作者 @@ -50,7 +50,11 @@ <%= format_date(memo.created_at) %> - <%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %> + <% if memo.parent_id.nil? || memo.subject.starts_with?('RE:')%> + <%= link_to(memo.subject, forum_memo_path(memo.forum, memo)) %> + <% else %> + <%= link_to("RE:"+memo.subject, forum_memo_path(memo.forum, memo)) %> + <% end %> <%= link_to(memo.replies_count, forum_memo_path(memo.forum, memo)) %> diff --git a/app/views/admin/project_messages.html.erb b/app/views/admin/project_messages.html.erb index dc44a7cba..a5639eba7 100644 --- a/app/views/admin/project_messages.html.erb +++ b/app/views/admin/project_messages.html.erb @@ -11,8 +11,8 @@ 序号 - - 来源 + + 来源(项目ID) 作者 From 43d57074e51277b505fc7d7f7ed781c2a81cb2a8 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 18 Aug 2015 17:26:39 +0800 Subject: [PATCH 033/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/users/user_resource.html.erb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c3c5da9cf..2caae19e1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -894,7 +894,7 @@ class UsersController < ApplicationController # format.js # end if @flag - render :text=>'sucess' + render :text=> download_named_attachment_path(@attachment.id, @attachment.filename) else render :text=>'fail' end diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 09bee5ac6..1cad8f2de 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -158,7 +158,7 @@ $(".resourcesList").click(function(e) { //将当前行改变为白色 line.children().css("background-color", 'white'); //当前行恢复编辑状态到链接状态 - if(ele.nodeName != 'INPUT') { + if(ele && ele.nodeName != 'INPUT') { restore(); } line = null; @@ -224,9 +224,10 @@ $(".resourcesList").click(function(e) { '<%=rename_resource_user_path(@user) %>', $("#res_name_form").serialize(), function (data){ - if(data =='sucess'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 + if(data != 'fail'){//修改成功,那么将链接恢复,并且将链接的显示内容改变。链接可以不变 last_line.children().first().html(res_link); last_line.children().first().children().attr('title',name); + last_line.children().first().children().attr('href',data); last_line.children().first().children().html(name.length > 17? name.substring(0,17)+'...' : name); }else{ last_line.children().first().html(res_link); From 3836cfb40ba4bcd3b07b3a8dfb7698f24dddb3d6 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 18 Aug 2015 17:45:14 +0800 Subject: [PATCH 034/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_resource_search_form.html.erb | 2 +- app/views/users/user_resource.html.erb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb index 0c48514b3..725167b65 100644 --- a/app/views/users/_resource_search_form.html.erb +++ b/app/views/users/_resource_search_form.html.erb @@ -1,6 +1,6 @@ <%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>user.id), :remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> - + <%= hidden_field_tag(:type,type) %> <%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %> diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 1cad8f2de..621b0c17d 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -216,7 +216,10 @@ $(".resourcesList").click(function(e) { function restore(){ //上一行不为空 且链接不为空 if( last_line != null && res_link != null && res_link != '') { - name = $("#res_name") ? $("#res_name").val().trim() : $("#res_name") ; + name = $("#res_name").lenght != 0 && $("#res_name").val() != undefined ? $("#res_name").val().trim() : undefined ; + if (name == undefined || name === 'undefined' ){ //只要res_name没有值,那么就不是编辑状态 + return; + } if( name && name != res_name.trim()){ if(confirm('确定修改为 '+name)){ From e7f818deb9e62b599ab126b781eedbeef148a4bb Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 19 Aug 2015 09:20:39 +0800 Subject: [PATCH 035/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2caae19e1..bc9394716 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1146,25 +1146,25 @@ class UsersController < ApplicationController # @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc") # end if(params[:type].nil? || params[:type] == "1") #全部 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "2" #课程资源 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course' and (filename like '%#{search}%')").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "3" #项目资源 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "4" #附件 - if User.current.id == params[:id] + if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") From d657e9f3cc44e2964828eb6dd173eb9cd7c1bf38 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 11:06:39 +0800 Subject: [PATCH 036/119] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E8=B4=B4=E5=90=A7=20=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 11 ++-- app/models/forum.rb | 1 + app/models/forum_message.rb | 11 ++++ app/models/memo.rb | 30 ++++++++++- app/models/user.rb | 4 +- .../20150818091800_create_forum_messages.rb | 13 +++++ db/schema.rb | 50 ++++++++++++++++++- spec/factories/forum_messages.rb | 10 ++++ spec/models/forum_message_spec.rb | 5 ++ 9 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 app/models/forum_message.rb create mode 100644 db/migrate/20150818091800_create_forum_messages.rb create mode 100644 spec/factories/forum_messages.rb create mode 100644 spec/models/forum_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 00ce151cf..d77ccb958 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -97,8 +97,8 @@ class UsersController < ApplicationController end # 用户消息 - # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅 - # issue:问题; + # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复 + # issue:问题;journal:缺陷状态更新; forum:公共贴吧 def user_messages unless User.current.logged? render_403 @@ -114,6 +114,7 @@ class UsersController < ApplicationController when nil @user_course_messages = @user.course_messages.reverse @user_forge_messages = @user.forge_messages.reverse + @user_forum_messages = @user.forum_messages.reverse when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") @user_forge_messages = nil @@ -134,9 +135,11 @@ class UsersController < ApplicationController when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") @user_course_messages = nil - when 'journal' - @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Journal", @user).order("created_at desc") + when 'journal' # 缺陷状态更新、留言 + @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_course_messages = nil + when 'forum' + @user_forum_messages = ForumMessage.where("memo_message_type =? and user_id =?", "Forum", @user).order("created_at desc") end respond_to do |format| format.html{render :layout=>'base_users_new'} diff --git a/app/models/forum.rb b/app/models/forum.rb index 2af1abf9e..530639f81 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -39,6 +39,7 @@ class Forum < ActiveRecord::Base logger.debug "send mail for forum add." Mailer.run.forum_add(self) if Setting.notified_events.include?('forum_add') end + # Updates topic_count, memo_count and last_memo_id attributes for +board_id+ def self.reset_counters!(forum_id) forum_id = forum_id.to_i diff --git a/app/models/forum_message.rb b/app/models/forum_message.rb new file mode 100644 index 000000000..c7b07e164 --- /dev/null +++ b/app/models/forum_message.rb @@ -0,0 +1,11 @@ +class ForumMessage < ActiveRecord::Base + attr_accessible :forum_id, :memo_message_id, :memo_message_type, :user_id, :viewed + + belongs_to :memo + belongs_to :user + + validates :user_id,presence: true + validates :forum_id,presence: true + validates :memo_message_id,presence: true + validates :memo_message_type, presence: true +end diff --git a/app/models/memo.rb b/app/models/memo.rb index e0abaa19f..e4dabf131 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -16,6 +16,8 @@ class Memo < ActiveRecord::Base acts_as_attachable has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + # 消息 + has_many :forum_messages, dependent: :destroy belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id' # acts_as_searchable :column => ['subject', 'content'], # #:include => { :forum => :p} @@ -44,7 +46,7 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters!, :send_mail + after_create :add_author_as_watcher, :reset_counters!, :send_mail, :send_message # after_update :update_memos_forum after_destroy :reset_counters!,:delete_kindeditor_assets#,:down_user_score -- 公共区发帖暂不计入得分 # after_create :send_notification @@ -59,6 +61,32 @@ class Memo < ActiveRecord::Base Mailer.run.forum_message_added(self) if Setting.notified_events.include?('forum_message_added') end + # 公共贴吧消息记录 + # 原则:贴吧创始人;发帖人,wanglingchun(特殊用户) + def send_message + receivers = [] + u = User.find(6) + receivers << u + # 主贴 + if self.parent_id.nil? + if self.author_id != self.forum.creator_id # 发帖人不是吧主 + receivers << self.forum.creator + end + else # 回帖 + # 添加吧主 + if self.author_id != self.forum.creator_id + receivers << self.forum.creator + end + # 添加发帖人 + if self.author_id != self.parent.author_id + receivers << self.parent.author + end + end + receivers.each do |r| + self.forum_messages << ForumMessage.new(:user_id => r.id, :forum_id => self.forum_id, :memo_message_id => self.id, :memo_message_type => "Forum", :viewed => false) + end + end + def cannot_reply_to_locked_topic errors.add :base, l(:label_memo_locked) if root.locked? && self != root end diff --git a/app/models/user.rb b/app/models/user.rb index 9f88ff53a..82ecdbd47 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -127,10 +127,10 @@ class User < Principal has_many :messages, :foreign_key => 'author_id' has_one :user_score, :dependent => :destroy has_many :documents # 项目中关联的文档再次与人关联 -# 关联虚拟表 +# 关联消息表 has_many :forge_messages has_many :course_messages -# end + has_many :forum_messages # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" diff --git a/db/migrate/20150818091800_create_forum_messages.rb b/db/migrate/20150818091800_create_forum_messages.rb new file mode 100644 index 000000000..20ad1ca51 --- /dev/null +++ b/db/migrate/20150818091800_create_forum_messages.rb @@ -0,0 +1,13 @@ +class CreateForumMessages < ActiveRecord::Migration + def change + create_table :forum_messages do |t| + t.integer :user_id + t.integer :forum_id + t.integer :memo_message_id + t.string :memo_message_type + t.integer :viewed + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index db9b9ff9b..5471381d7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150810064247) do +ActiveRecord::Schema.define(:version => 20150818091800) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -325,6 +325,15 @@ ActiveRecord::Schema.define(:version => 20150810064247) do t.datetime "updated_on", :null => false end + create_table "course_activities", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_act_id" + t.string "course_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "course_attachments", :force => true do |t| t.string "filename" t.string "disk_filename" @@ -357,6 +366,16 @@ ActiveRecord::Schema.define(:version => 20150810064247) do t.datetime "updated_at", :null => false end + create_table "course_messages", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_message_id" + t.string "course_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "course_statuses", :force => true do |t| t.integer "changesets_count" t.integer "watchers_count" @@ -455,6 +474,13 @@ ActiveRecord::Schema.define(:version => 20150810064247) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -536,6 +562,26 @@ ActiveRecord::Schema.define(:version => 20150810064247) do add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + create_table "forge_messages", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_message_id" + t.string "forge_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "forum_messages", :force => true do |t| + t.integer "user_id" + t.integer "forum_id" + t.integer "memo_message_id" + t.string "memo_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "forums", :force => true do |t| t.string "name", :null => false t.text "description" @@ -857,7 +903,6 @@ ActiveRecord::Schema.define(:version => 20150810064247) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" - t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -1461,6 +1506,7 @@ ActiveRecord::Schema.define(:version => 20150810064247) do t.string "identity_url" t.string "mail_notification", :default => "", :null => false t.string "salt", :limit => 64 + t.integer "gid" end add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" diff --git a/spec/factories/forum_messages.rb b/spec/factories/forum_messages.rb new file mode 100644 index 000000000..adb114d3c --- /dev/null +++ b/spec/factories/forum_messages.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :forum_message do + user_id 1 +forum_id 1 +memo_message_id 1 +memo_message_type "MyString" +viewed 1 + end + +end diff --git a/spec/models/forum_message_spec.rb b/spec/models/forum_message_spec.rb new file mode 100644 index 000000000..e0159c3ca --- /dev/null +++ b/spec/models/forum_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ForumMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From ff3edf4d5e56e335e9cbaaeb0b536a42c3252545 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 19 Aug 2015 11:12:47 +0800 Subject: [PATCH 037/119] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 52 ++++++++++++++++++++++++++ public/stylesheets/public_new.css | 4 +- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a4cc521ff..089dca32f 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -76,6 +76,26 @@ <% end %> <% end %> + <% if ucm.course_message_type == "StudentWorksScore" %> + + <% end %> + <% if ucm.course_message_type == "JournalsForMessage" %> + + <% end %>
    <% end %> <% end %> @@ -113,6 +133,38 @@
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • <% end %> + <% if ufm.forge_message_type == "Message" %> + + <% end %> + <% if ufm.forge_message_type == "News" %> + + <% end %> <% end %> <% end %> <% else %> diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index fb7e6fbf4..6837a5466 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -589,7 +589,7 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .homepageNewsPortrait {width:40px; display:block; margin-top:7px;} .homepageNewsPublisher {width:80px; max-width:80px; margin-right:10px; font-size:12px; color:#15bccf; display:block; padding-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} -.homepageNewsTypeNotRead {width:95px; font-size:12px; font-weight:bold; color:#4B4B4B; display:block;} +.homepageNewsTypeNotRead {width:95px; font-size:13px; font-weight:bold; color:#4B4B4B; display:block;} .homepageNewsContent {width:395px; max-width:395px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} @@ -598,7 +598,7 @@ a.newsGrey {color:#4b4b4b;} a.newsGrey:hover {color:#000000;} a.newsBlue {color:#15bccf;} a.newsBlue:hover {color:#0781b4;} -a.newsBlack {color:#4B4B4B; font-weight:bold;} +a.newsBlack {color:#4B4B4B; font-weight:bold; font-size:13px;} a.newsBlack:hover {color:#0781b4;} a.resourcesGrey {font-size:12px; color:#888888;} a.resourcesGrey:hover {font-size:12px; color:#15bccf;} From 2d282f73cb51286716fbc3900e37a2763a8cf193 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 11:21:48 +0800 Subject: [PATCH 038/119] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/message.rb b/app/models/message.rb index 4cc233eb5..37129885f 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -232,7 +232,6 @@ class Message < ActiveRecord::Base self.project.members.each do |m| if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) - self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) end end end From 0ef7d5f0fa23ac6f4e099770c8197242a4fc2228 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 19 Aug 2015 12:04:06 +0800 Subject: [PATCH 039/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bc9394716..c523bbb3d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -14,6 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + class UsersController < ApplicationController layout :setting_layout @@ -1109,13 +1111,18 @@ class UsersController < ApplicationController if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + + "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' ").order("created_on desc") + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+ + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") end elsif params[:type] == "3" #项目资源 if User.current.id.to_i == params[:id].to_i @@ -1140,22 +1147,24 @@ class UsersController < ApplicationController # 根据资源关键字进行搜索 def resource_search search = params[:search].to_s.strip.downcase - # if User.current.id == params[:id] - # @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and (filename like '%#{search}%') ").order("created_on desc") - # else - # @attachments = Attachment.where("author_id = #{params[:id]} and container_type not in ('Version','PhoneAppVersion','StudentWork') and is_public = 1 and (filename like '%#{search}%') ").order("created_on desc") - # end if(params[:type].nil? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc") + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ + " or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')})) )" + + " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course' and (filename like '%#{search}%')").order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' and (filename like '%#{search}%') ").order("created_on desc") + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')})) )"+ + " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "3" #项目资源 if User.current.id.to_i == params[:id].to_i From 425e0dd89a953885f844e277730d4865ed633181 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 19 Aug 2015 15:03:04 +0800 Subject: [PATCH 040/119] =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E6=B6=88=E6=81=AF=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20=E9=83=A8=E5=88=86=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 17 ++++++++-- app/views/users/user_messages.html.erb | 44 +++++++++++++++++--------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d77ccb958..bc3719685 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -115,31 +115,42 @@ class UsersController < ApplicationController @user_course_messages = @user.course_messages.reverse @user_forge_messages = @user.forge_messages.reverse @user_forum_messages = @user.forum_messages.reverse + @user_course_messages_count = @user_course_messages.count + @user_forge_messages_count = @user_forum_messages.count when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") - @user_forge_messages = nil + @user_course_messages_count = @user_course_messages.count when 'course_message' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") + @user_course_messages_count = @user_course_messages.count when 'forge_message' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") when 'course_news' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") + @user_course_messages_count = @user_course_messages.count when 'forge_news' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") when 'poll' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") + @user_course_messages_count = @user_course_messages.count when 'works_reviewers' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "StudentWorksScore", @user).order("created_at desc") + @user_course_messages_count = @user_course_messages.count when 'works_reply' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "JournalsForMessage", @user).order("created_at desc") + @user_course_messages_count = @user_course_messages.count when 'issue' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Issue", @user).order("created_at desc") - @user_course_messages = nil + @user_forge_messages_count = @user_forge_messages.count when 'journal' # 缺陷状态更新、留言 @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") - @user_course_messages = nil + @user_forge_messages_count = @user_forge_messages.count when 'forum' @user_forum_messages = ForumMessage.where("memo_message_type =? and user_id =?", "Forum", @user).order("created_at desc") + @user_forum_messages_count = @user_forum_messages.count + else + render_404 + return end respond_to do |format| format.html{render :layout=>'base_users_new'} diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 089dca32f..233b5bcb2 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -7,19 +7,31 @@
  • @@ -82,7 +94,7 @@
  • "><%= ucm.course_message.user %>
  • ">作品评阅
  • - <%= link_to ucm.course_message.comment, nil,:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%= link_to ucm.course_message.comment, student_work_path(ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %> %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -92,7 +104,7 @@
  • "><%= ucm.course_message.user %>
  • ">作品讨论
  • - <%= link_to ucm.course_message.notes, nil,:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%= link_to ucm.course_message.notes, student_work_path(ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -167,6 +179,8 @@ <% end %> <% end %> <% end %> + <% unless @user_forum_messages.nil? %> + <% end %> <% else %>
    暂无消息!
    <% end %> From 929da7512da5d1c17d8e913b7e7937424faabead Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 19 Aug 2015 17:13:57 +0800 Subject: [PATCH 041/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 33 ++++++++- .../users/_resource_search_form.html.erb | 2 +- .../users/_resource_share_popup.html.erb | 15 +++- app/views/users/_resources_list.html.erb | 5 +- app/views/users/user_resource.html.erb | 58 +++++++++------- public/stylesheets/images/homepage_icon.png | Bin 0 -> 6829 bytes public/stylesheets/images/nav_icon.png | Bin 0 -> 3204 bytes public/stylesheets/public_new.css | 65 ++++++++++++++---- 8 files changed, 133 insertions(+), 45 deletions(-) create mode 100644 public/stylesheets/images/homepage_icon.png create mode 100644 public/stylesheets/images/nav_icon.png diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c523bbb3d..e4109e5bb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -825,7 +825,38 @@ class UsersController < ApplicationController # 删除用户资源 def user_resource_delete Attachment.delete(params[:resource_id]) - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + #@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + if(params[:type].nil? || params[:type] == "1") #全部 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + else + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + + "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + end + elsif params[:type] == "2" #课程资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") + else + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+ + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + end + elsif params[:type] == "3" #项目资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") + end + elsif params[:type] == "4" #附件 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + end + end + @type = params[:type] respond_to do |format| format.js end diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb index 725167b65..5f854cba0 100644 --- a/app/views/users/_resource_search_form.html.erb +++ b/app/views/users/_resource_search_form.html.erb @@ -2,6 +2,6 @@ :remote=>true ,:method => 'post',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> <%= hidden_field_tag(:type,type) %> - <%= submit_tag '',:class=>'searchIcon',:style=>'border-style:none' %> + <%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %> <% end %> \ No newline at end of file diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb index 01ac79075..cad94056c 100644 --- a/app/views/users/_resource_share_popup.html.erb +++ b/app/views/users/_resource_share_popup.html.erb @@ -1,8 +1,17 @@ -
    将资源移动至 -
    +
    +
    将资源发送至
    +
    + +
    +
    +
    +
    <%= form_tag search_user_course_user_path(user),:method => 'get', :remote=>true,:id=>'search_user_course_form',:class=>'resourcesSearchBox' do %> <%= hidden_field_tag(:send_id, @send_id) %> @@ -17,7 +26,7 @@ <%= hidden_field_tag(:send_id, @send_id) %> <% if !courses.empty? %> <% courses.each do |course| %> -
      +
      • diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 6f9ba0fee..b344c737d 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -1,7 +1,10 @@ <% if attachments.nil? || attachments.empty? %> <% else %> <% attachments.each do |attach| %> -
          +
            +
          • + +
          • <%= link_to truncate(attach.filename,:length=>18), download_named_attachment_path(attach.id, attach.filename), diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 621b0c17d..5867c463f 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -40,22 +40,22 @@ }
            -
            -
            资源
            +
            +
            资源库
              • - <%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesTypeAll resourcesGrey' %>
              • - <%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'homepagePostTypeAssignment postTypeGrey' %>
              • - <%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'homepagePostTypeQuiz postTypeGrey' %>
              • - <%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesGrey' %> + <%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %>
            • @@ -63,14 +63,14 @@
            <%= render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} %>
              +
            • 资源名称
            • 大小
            • 类别
            • @@ -78,11 +78,21 @@
            • 上传时间
            -
            -
              - +
              <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> -
            +
            +
            +
            + +
            + 全选 + 删除 +
            +
            选择 10 个资源
            +
            + 发送 +
            +
          • -
          • <%= course.name%>
          • +
          • <%= truncate(course.name,:length=>18)%>
          <% end %> diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb index 903212798..c5b9f8fbe 100644 --- a/app/views/users/add_exist_file_to_course.js.erb +++ b/app/views/users/add_exist_file_to_course.js.erb @@ -1 +1,2 @@ +alert('发送成功') closeModal(); \ No newline at end of file diff --git a/app/views/users/add_exist_file_to_project.js.erb b/app/views/users/add_exist_file_to_project.js.erb new file mode 100644 index 000000000..6ed846821 --- /dev/null +++ b/app/views/users/add_exist_file_to_project.js.erb @@ -0,0 +1,2 @@ +alert('发送成功'); +closeModal(); \ No newline at end of file diff --git a/app/views/users/search_user_project.js.erb b/app/views/users/search_user_project.js.erb new file mode 100644 index 000000000..c22e4ad6d --- /dev/null +++ b/app/views/users/search_user_project.js.erb @@ -0,0 +1,11 @@ +var screenWidth = $(window).width(); +var screenHeight = $(window).height(); //当前浏览器窗口的 宽高 +var scrolltop = $(document).scrollTop();//获取当前窗口距离页面顶部高度 +var objLeft = (screenWidth - 2)/2.5 ; //2 可以根据需要修改 +var objTop = (screenHeight - 100)/2 + scrolltop; //100可以根据需要修改 +var popupHeight = $(".resourceSharePopup").outerHeight(true); +$(".resourceSharePopup").css("marginTop",-popupHeight/2); + +$("#upload_box").css('left',objLeft).css('top',objTop); +$("#upload_box").html('<%= escape_javascript( render :partial => "resource_share_for_project_popup" ,:locals => {:projects=>@projects,:user=>@user})%>'); +$("#upload_box").css('display','block'); \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 5867c463f..6938e389e 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -3,7 +3,11 @@ <%= stylesheet_link_tag 'project' %> <%= stylesheet_link_tag 'leftside' %> <%= javascript_include_tag 'attachments'%> - + + + + + diff --git a/config/routes.rb b/config/routes.rb index c77a1e892..1318a495e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -350,8 +350,10 @@ RedmineApp::Application.routes.draw do post "user_resource_delete" get "search_user_course" post "add_exist_file_to_course" + post "add_exist_file_to_project" get 'resource_preview' post 'rename_resource' + get 'search_user_project' # end end end From 88fe0a69f46179dcacf48b7393194df92201db24 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 20 Aug 2015 10:38:14 +0800 Subject: [PATCH 047/119] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 40 ++++++++++++++++++-------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 37dbfa3f7..a40a54e95 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -12,9 +12,15 @@ <% unless @user_course_messages_count > 0 %>
        • <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
        • <% end %> -
        • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
        • -
        • <%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
        • -
        • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
        • + <% unless @user_course_messages_count > 0 %> +
        • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
        • + <% end %> + <% unless @user_course_messages_count > 0 %> +
        • <%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
        • + <% end %> + <% unless @user_course_messages_count > 0 %> +
        • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
        • + <% end %> <% unless @user_course_messages_count > 0 %>
        • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
        • <% end %> @@ -22,14 +28,24 @@ <% end %> <%# 项目相关消息 %> <% unless @user_forge_messages.nil? %> -
        • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
        • -
        • <%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
        • -
        • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
        • -
        • <%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
        • + <% unless @user_forge_messages_count > 0 %> +
        • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
        • + <% end %> + <% unless @user_forge_messages_count > 0 %> +
        • <%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
        • + <% end %> + <% unless @user_forge_messages_count > 0 %> +
        • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
        • + <% end %> + <% unless @user_forge_messages_count > 0 %> +
        • <%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
        • + <% end %> <% end %> <%# 公共贴吧 %> <% unless @user_forum_messages.nil? %> + <% unless @user_memo_messages_count > 0 %>
        • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
        • + <% end %> <% end %> <%# 用户留言 %>
        @@ -179,9 +195,9 @@ <% end %> <% end %> <% end %> - <% unless @user_forum_messages.nil? %> - <% @user_forum_messages.each do |urm| %> - <% if urm.memo_message_type == "Forum" %> + <% unless @user_memo_messages.nil? %> + <% @user_memo_messages.each do |urm| %> + <% if urm.memo_type == "Memo" %> From 192f16ba795d91cb59f246f0e4fa80c929a63098 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 10:38:22 +0800 Subject: [PATCH 048/119] =?UTF-8?q?=E4=BF=AE=E6=94=B9memo=E7=B1=BB=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84=E7=94=A8=E6=88=B7=E7=95=99?= =?UTF-8?q?=E8=A8=80=E8=A1=A8=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/journals_for_message.rb | 3 ++- app/models/user_feedback_message.rb | 10 ++++++++++ spec/factories/user_feedback_messages.rb | 9 +++++++++ spec/models/user_feedback_message_spec.rb | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 app/models/user_feedback_message.rb create mode 100644 spec/factories/user_feedback_messages.rb create mode 100644 spec/models/user_feedback_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5badac36e..74c3afaa7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -147,7 +147,7 @@ class UsersController < ApplicationController @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_forge_messages_count = @user_forge_messages.count when 'forum' - @user_memo_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") + @user_memo_messages = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") @user_memo_messages_count = @user_memo_messages.count else render_404 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 818bdaa74..305e7742f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -209,7 +209,8 @@ class JournalsForMessage < ActiveRecord::Base end else # 留言回复 # 添加留言回复人 - if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 + # reply_to = User.find(self.reply_id) + if self.user_id != self.parent.user_id && self.user_id != self.reply_id # 如果回帖人不是用户自己 receivers << User.find(self.reply_id) end if self.user_id != self.parent.jour_id diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb new file mode 100644 index 000000000..98b53e973 --- /dev/null +++ b/app/models/user_feedback_message.rb @@ -0,0 +1,10 @@ +class UserFeedbackMessage < ActiveRecord::Base + attr_accessible :journals_for_message_id, :journals_for_message_type, :user_id, :viewed + + belongs_to :journals_for_message + belongs_to :user + + validates :user_id,presence: true + validates :journals_for_message_id,presence: true + validates :journals_for_message_type, presence: true +end diff --git a/spec/factories/user_feedback_messages.rb b/spec/factories/user_feedback_messages.rb new file mode 100644 index 000000000..26a768dad --- /dev/null +++ b/spec/factories/user_feedback_messages.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :user_feedback_message do + user_id 1 +journals_for_message_id 1 +journals_for_message_type "MyString" +viewed 1 + end + +end diff --git a/spec/models/user_feedback_message_spec.rb b/spec/models/user_feedback_message_spec.rb new file mode 100644 index 000000000..4ea61c36a --- /dev/null +++ b/spec/models/user_feedback_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserFeedbackMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From b5682adcd3aa7c524200ccba0e17e9f1a566586d Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 10:50:40 +0800 Subject: [PATCH 049/119] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 1 + app/models/journals_for_message.rb | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 74c3afaa7..6c91fd805 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -131,6 +131,7 @@ class UsersController < ApplicationController @user_course_messages_count = @user_course_messages.count when 'forge_news' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc") + @user_forge_messages_count = @user_forge_messages.count when 'poll' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc") @user_course_messages_count = @user_course_messages.count diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 305e7742f..ce58fdc69 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -210,12 +210,13 @@ class JournalsForMessage < ActiveRecord::Base else # 留言回复 # 添加留言回复人 # reply_to = User.find(self.reply_id) - if self.user_id != self.parent.user_id && self.user_id != self.reply_id # 如果回帖人不是用户自己 + if self.user_id != self.parent.user_id && self.user_id != self.reply_id && self.user_id != self.jour_id# 如果回帖人不是用户自己 receivers << User.find(self.reply_id) - end - if self.user_id != self.parent.jour_id receivers << self.parent.jour end + # if self.user_id != self.parent.jour_id + # receivers << self.parent.jour + # end end if self.jour_type == 'Principal' if self.user_id != self.jour_id From 107a5686d1cb522ea149f1ca4df8d4f6af4f400c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 20 Aug 2015 11:37:32 +0800 Subject: [PATCH 050/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E5=85=A8?= =?UTF-8?q?=E9=80=89=E5=8F=8D=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_resources_list.html.erb | 2 +- app/views/users/user_resource.html.erb | 70 +++++++++++++++++++++++- 2 files changed, 69 insertions(+), 3 deletions(-) diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index b344c737d..7a18a037b 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -3,7 +3,7 @@ <% attachments.each do |attach| %>
        • - +
        • diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 6938e389e..1ead2447c 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -87,12 +87,12 @@
    - +
    全选 删除
    -
    选择 10 个资源
    +
    选择 0 个资源
    @@ -179,6 +179,72 @@ $(".resourcesList").click(function(e) { } line = null; }); + //只要有一个选中了就是true + function checkboxSelected(){ + selected = false; + $("#resources_list").find("input[name='checkbox1']").each(function(){ + if($(this).attr('checked') == true){ + selected = true; + } + }); + return selected; + } + //只有全选才是true + function checkboxAllSelected(){ + allSelected = true; + $("#resources_list").find("input[name='checkbox1']").each(function(){ + if($(this).attr('checked') == undefined){ + allSelected = false; + } + }); + return allSelected; + } + //只有全部不选才是true + function checkboxAllDeselected(){ + allDeselected = true; + $("#resources_list").find("input[name='checkbox1']").each(function(){ + if($(this).attr('checked') == 'checked'){ + allDeselected = false; + } + }); + return allDeselected; + } + //查看所有的checkbox状态,并且按情况更改$("#checkboxAll")的状态 + function checkAllBox(checkbox){ + //只有选中当前checkbox且这个时候所有的checkbox都被选中了,$("#checkboxAll")才是被选中状态,其余都是非选中状态 + if(checkbox.attr('checked') == 'checked' && checkboxAllSelected()){ + $("#checkboxAll").attr('checked',true); + }else{ + $("#checkboxAll").attr('checked',false); + } + $("#res_count").html(getCheckBoxSeletedCount()); + + } + //获取当前checkbox选中的数目 + function getCheckBoxSeletedCount(){ + var i = 0; + $("#resources_list").find("input[name='checkbox1']").each(function(){ + if($(this).attr('checked') == 'checked'){ + i ++; + } + }); + return i; + } + $("#checkboxAll").click(function(e){ + + if($(this).attr('checked')){ + $("#resources_list").find("input[name='checkbox1']").each(function(){ + $(this).attr('checked',true); + }); + $("#res_count").html('<%= @attachments.size%>'); + }else{ + $("#resources_list").find("input[name='checkbox1']").each(function(){ + $(this).attr('checked',false); + }); + $("#res_count").html(0); + } + }); + function show_send(){ $("#contextMenu").hide(); document.oncontextmenu = function() {return true;} From 84182171f5d6d4082f33634edb9e9f0a19d09a2d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 20 Aug 2015 12:41:53 +0800 Subject: [PATCH 051/119] =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a40a54e95..2e53dfe6e 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -9,42 +9,44 @@
  • <%= link_to "全部",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user} %>
  • <%# 课程相关消息 %> <% unless @user_course_messages.nil? %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> + <% if @user_course_messages_count > 0 %>
  • <%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %>
  • <% end %> - <% unless @user_course_messages_count > 0 %> -
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • + <% if @user_course_messages_count > 0 %> +
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • + <% end %> + <% if @user_course_messages_count > 0 %> +
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • <% end %> -
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • <% end %> <%# 项目相关消息 %> <% unless @user_forge_messages.nil? %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %>
  • <% end %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %>
  • <% end %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %>
  • <% end %> - <% unless @user_forge_messages_count > 0 %> + <% if @user_forge_messages_count > 0 %>
  • <%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %>
  • <% end %> <% end %> <%# 公共贴吧 %> - <% unless @user_forum_messages.nil? %> - <% unless @user_memo_messages_count > 0 %> -
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • + <% unless @user_memo_messages.nil? %> + <% if @user_memo_messages_count > 0 %> +
  • <%= link_to "发布了xiang帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • <% end %> <% end %> <%# 用户留言 %> From e4dda89c075b51f98cb855697bb4af04893962d5 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 12:44:32 +0800 Subject: [PATCH 052/119] =?UTF-8?q?=E6=B6=88=E6=81=AF---=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=95=99=E8=A8=80=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++++- app/models/journals_for_message.rb | 29 ++++++++++++++------------ app/views/users/user_messages.html.erb | 28 ++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 15 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6c91fd805..686ffbb89 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,7 +98,7 @@ class UsersController < ApplicationController # 用户消息 # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复 - # issue:问题;journal:缺陷状态更新; forum:公共贴吧 + # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言 def user_messages unless User.current.logged? render_403 @@ -115,9 +115,11 @@ class UsersController < ApplicationController @user_course_messages = @user.course_messages.reverse @user_forge_messages = @user.forge_messages.reverse @user_memo_messages = @user.memo_messages.reverse + @user_feedback_messages = @user.user_feedback_messages.reverse @user_course_messages_count = @user_course_messages.count @user_forge_messages_count = @user_forge_messages.count @user_memo_messages_count = @user_memo_messages.count + @user_feedback_messages_count = @user_feedback_messages.count when 'homework' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc") @user_course_messages_count = @user_course_messages.count @@ -126,6 +128,7 @@ class UsersController < ApplicationController @user_course_messages_count = @user_course_messages.count when 'forge_message' @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user).order("created_at desc") + @user_forge_messages_count = @user_forge_messages.count when 'course_news' @user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "News", @user).order("created_at desc") @user_course_messages_count = @user_course_messages.count @@ -150,6 +153,9 @@ class UsersController < ApplicationController when 'forum' @user_memo_messages = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") @user_memo_messages_count = @user_memo_messages.count + when 'user_feedback' + @user_feedback_messages = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "Principal", @user).order("created_at desc") + @user_feedback_messages_count = @user_feedback_messages.count else render_404 return diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index ce58fdc69..2c397ffcf 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -209,21 +209,24 @@ class JournalsForMessage < ActiveRecord::Base end else # 留言回复 # 添加留言回复人 - # reply_to = User.find(self.reply_id) - if self.user_id != self.parent.user_id && self.user_id != self.reply_id && self.user_id != self.jour_id# 如果回帖人不是用户自己 - receivers << User.find(self.reply_id) - receivers << self.parent.jour - end - # if self.user_id != self.parent.jour_id - # receivers << self.parent.jour - # end - end - if self.jour_type == 'Principal' - if self.user_id != self.jour_id - receivers.each do |r| - self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) + reply_to = User.find(self.reply_id) + if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 + receivers << self.parent.jour + if self.reply_id != self.parent.user_id + receivers << reply_to + end + else # 用户自己回复别人的,别人收到消息通知 + if self.user_id != self.reply_id # 过滤掉自己回复自己的 + receivers << reply_to end end end + if self.jour_type == 'Principal' + + receivers.each do |r| + self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) + end + + end end end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a40a54e95..cb7fb0e60 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -25,6 +25,7 @@
  • <%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %>
  • <% end %>
  • <%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %>
  • + <% end %> <%# 项目相关消息 %> <% unless @user_forge_messages.nil? %> @@ -44,10 +45,15 @@ <%# 公共贴吧 %> <% unless @user_forum_messages.nil? %> <% unless @user_memo_messages_count > 0 %> -
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • +
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • <% end %> <% end %> <%# 用户留言 %> + <% unless @user_forge_messages.nil? %> + <% unless @user_forge_messages_count > 0 %> +
  • <%= link_to "用户留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'user_feedback'} %>
  • + <% end %> + <% end %> @@ -214,6 +220,26 @@ <% end %> <% end %> <% end %> + <%# 用户留言消息 %> + <% unless @user_feedback_messages.nil? %> + <% @user_forge_messages.each do |urm| %> + <% if urm.memo_type == "Memo" %> + + <% end %> + <% end %> + <% end %> <% else %>
    暂无消息!
    <% end %> From ee09a105d2eba38fa53250cb8302c2224bf155ba Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 20 Aug 2015 12:46:31 +0800 Subject: [PATCH 053/119] =?UTF-8?q?=E8=B4=B4=E5=90=A7=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 2e53dfe6e..c34a31a3c 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -46,7 +46,7 @@ <%# 公共贴吧 %> <% unless @user_memo_messages.nil? %> <% if @user_memo_messages_count > 0 %> -
  • <%= link_to "发布了xiang帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • +
  • <%= link_to "发布了帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %>
  • <% end %> <% end %> <%# 用户留言 %> From 6b847e27d98db77189acb5b784771ff3f644cfee Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 14:00:31 +0800 Subject: [PATCH 054/119] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 4 ++-- app/views/users/user_messages.html.erb | 30 ++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 2c397ffcf..bb59f612d 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -210,8 +210,8 @@ class JournalsForMessage < ActiveRecord::Base else # 留言回复 # 添加留言回复人 reply_to = User.find(self.reply_id) - if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 - receivers << self.parent.jour + if self.user_id != self.parent.user_id && self.user_id != self.parent.jour_id # 如果回帖人不是用户自己 + receivers << self.parent.user if self.reply_id != self.parent.user_id receivers << reply_to end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 80deeb8f6..adfc6290b 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -51,8 +51,8 @@ <% end %> <% end %> <%# 用户留言 %> - <% unless @user_forge_messages.nil? %> - <% unless @user_forge_messages_count > 0 %> + <% unless @user_feedback_messages.nil? %> + <% if @user_feedback_messages_count > 0 %>
  • <%= link_to "用户留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'user_feedback'} %>
  • <% end %> <% end %> @@ -224,20 +224,28 @@ <% end %> <%# 用户留言消息 %> <% unless @user_feedback_messages.nil? %> - <% @user_forge_messages.each do |urm| %> - <% if urm.memo_type == "Memo" %> + <% @user_feedback_messages.each do |ufm| %> + <% if ufm.journals_for_message_type == "Principal" %> <% end %> <% end %> From f97a55e16438e0408b2b5939fcc03b7bb42e97d2 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 20 Aug 2015 14:01:33 +0800 Subject: [PATCH 055/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 9 ++++- app/views/users/_resources_list.html.erb | 2 +- app/views/users/user_resource.html.erb | 47 +++++++++++++++++------- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 76ce9efaf..f62286973 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -823,9 +823,16 @@ class UsersController < ApplicationController end end - # 删除用户资源 + # 删除用户资源,分为批量删除 和 单个删除 def user_resource_delete + if params[:resource_id].present? Attachment.delete(params[:resource_id]) + elsif params[:checkbox1].present? + params[:checkbox1].each do |id| + Attachment.delete(id) + end + end + #@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") if(params[:type].nil? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 7a18a037b..62e819b43 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -3,7 +3,7 @@ <% attachments.each do |attach| %>
    • - +
    • diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 1ead2447c..7b173409a 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -82,22 +82,26 @@
    • 上传时间
    +
    + <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> +
    - +
    - 全选 - 删除 + 全选 + 删除
    选择 0 个资源
    +
    -
    From 7deafac2802284ae99078d41d5e200f39d6d36ad Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 21 Aug 2015 10:02:26 +0800 Subject: [PATCH 068/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 22 +++++++++++++--------- app/views/layouts/base_users_new.html.erb | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b4cb04019..76e287a43 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -838,7 +838,7 @@ class UsersController < ApplicationController if User.current.id.to_i == params[:id].to_i @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个公开资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") @@ -1237,20 +1237,22 @@ class UsersController < ApplicationController # @user = User.find(params[:id]) if(params[:type].nil? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") + user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源 @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + - "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') ").order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+ - "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") end elsif params[:type] == "3" #项目资源 if User.current.id.to_i == params[:id].to_i @@ -1284,12 +1286,14 @@ class UsersController < ApplicationController search = params[:search].to_s.strip.downcase if(params[:type].nil? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%') ").order("created_on desc") + user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 + @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + " or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ - " or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')})) )" + + " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')})) )" + " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "2" #课程资源 @@ -1298,7 +1302,7 @@ class UsersController < ApplicationController else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ - "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')})) )"+ + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')})) )"+ " and (filename like '%#{search}%') ").order("created_on desc") end elsif params[:type] == "3" #项目资源 diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index f9f065e2a..be75f53f1 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -149,7 +149,7 @@ @@ -169,7 +169,7 @@ <% end %> From 9b827a698cc4b2f003e22a3bec4b52303c725be9 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 10:02:58 +0800 Subject: [PATCH 069/119] =?UTF-8?q?=E9=BC=A0=E6=A0=87=E7=BB=8F=E8=BF=87?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E6=98=BE=E7=A4=BA=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E7=9A=84=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_messages.html.erb | 46 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 602e3c5c9..c9b17d09f 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -42,7 +42,9 @@
  • "><%= ucm.course_message.author %>
  • ">发布通知
  • - <%= link_to "#{ucm.course_message.title.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id },:class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
  • + <%= link_to "#{ucm.course_message.title.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.id }, + :class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}", + :title => "#{ucm.course_message.title.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -52,7 +54,9 @@
  • <%= ucm.course_message.author %>
  • ">回复了通知
  • - <%= link_to "#{ucm.course_message.comments.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.commented.id },:class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
  • + <%= link_to "#{ucm.course_message.comments.html_safe}", {:controller => 'news', :action => 'show', :id => ucm.course_message.commented.id }, + :class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}", + :title => "#{ucm.course_message.comments.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -62,7 +66,7 @@
  • <%= ucm.course_message.user %>
  • 发布作业
  • - <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id),:class => "newsGrey" %>
  • + <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id),:class => "newsGrey", :title => "#{ucm.course_message.name}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -72,7 +76,9 @@
  • "><%= ucm.course_message.user %>
  • ">发布问卷
  • - <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id), + :class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ucm.course_message.polls_name}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -83,12 +89,16 @@ <% if ucm.course_message.parent_id.nil? %>
  • ">发布帖子
  • - <%=link_to ucm.course_message.subject.html_safe, course_boards_path(ucm.course_message.course,:parent_id => ucm.course_message.parent_id ? ucm.course_message.parent_id : ucm.course_message.id, :topic_id => ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%=link_to ucm.course_message.subject.html_safe, course_boards_path(ucm.course_message.course,:parent_id => ucm.course_message.parent_id ? ucm.course_message.parent_id : ucm.course_message.id, + :topic_id => ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ucm.course_message.subject.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% else %>
  • ">回复帖子
  • - <%=link_to ucm.course_message.subject.html_safe, course_boards_path(ucm.course_message.course,:parent_id => ucm.course_message.parent_id ? ucm.course_message.parent_id : ucm.course_message.id, :topic_id => ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%=link_to ucm.course_message.subject.html_safe, course_boards_path(ucm.course_message.course,:parent_id => ucm.course_message.parent_id ? ucm.course_message.parent_id : ucm.course_message.id, + :topic_id => ucm.course_message.id),:class=>"#{ucm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ucm.course_message.subject.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -99,7 +109,7 @@
  • <%= ucm.course_message.user %>
  • 评阅了作品
  • - <%= link_to ucm.course_message.comment.html_safe, student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey" %>
  • + <%= link_to ucm.course_message.comment.html_safe, student_work_index_path(:homework => ucm.course_message.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.comment.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -109,7 +119,7 @@
  • <%= ucm.course_message.user %>
  • 回复了作品
  • - <%= link_to ucm.course_message.notes.html_safe, student_work_index_path(:homework => ucm.course_message.jour.student_work.homework_common_id),:class=>"newsGrey" %>
  • + <%= link_to ucm.course_message.notes.html_safe, student_work_index_path(:homework => ucm.course_message.jour.student_work.homework_common_id),:class=>"newsGrey",:title => "#{ucm.course_message.notes.html_safe}" %>
  • <%= time_tag(ucm.course_message.created_on).html_safe %>
  • <% end %> @@ -129,7 +139,7 @@
  • ">指派问题给我
  • - <%= link_to ("#{ufm.forge_message.subject.html_safe}"), issue_path(:id => ufm.forge_message.id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to ("#{ufm.forge_message.subject.html_safe}"), issue_path(:id => ufm.forge_message.id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}",:title => "#{ufm.forge_message.subject.html_safe}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -145,7 +155,9 @@
  • "> <%= ufm.forge_message.notes.empty? ? "更新了问题状态" : "在问题中留言了" %>
  • - <%= link_to ("#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }"), issue_path(:id => ufm.forge_message.journalized_id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + <%= link_to ("#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }"), + issue_path(:id => ufm.forge_message.journalized_id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}", + :title => "#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -157,7 +169,10 @@
  • "><%= ufm.forge_message.parent_id.nil? ? "发布帖子" : "回复帖子" %>
  • - <%=link_to ufm.forge_message.subject.html_safe, project_boards_path(ufm.forge_message.project,:parent_id => ufm.forge_message.parent_id ? ufm.forge_message.parent_id : ufm.forge_message.id, :topic_id => ufm.forge_message.id),:class=>"#{ufm.viewed==0?"newsBlack":"newsGrey"}" %>
  • + <%=link_to ufm.forge_message.subject.html_safe, project_boards_path(ufm.forge_message.project, + :parent_id => ufm.forge_message.parent_id ? ufm.forge_message.parent_id : ufm.forge_message.id, + :topic_id => ufm.forge_message.id),:class=>"#{ufm.viewed==0?"newsBlack":"newsGrey"}", + :title => "#{ufm.forge_message.subject.html_safe}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -172,7 +187,7 @@
  • 发布新闻
  • - <%= link_to ("#{ufm.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ufm.forge_message.id}, :class => "newsGrey" %> + <%= link_to ("#{ufm.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ufm.forge_message.id}, :class => "newsGrey", :title => "#{ufm.forge_message.title.html_safe}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -183,7 +198,8 @@
  • <%= ufm.forge_message.author %>
  • 回复了新闻
  • - <%= link_to "#{ufm.forge_message.comments.html_safe}", {:controller => 'news', :action => 'show', :id => ufm.forge_message.commented.id },:class =>"#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
  • + <%= link_to "#{ufm.forge_message.comments.html_safe}", + {:controller => 'news', :action => 'show', :id => ufm.forge_message.commented.id },:class =>"#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}", :title => "#{ufm.forge_message.comments.html_safe}"%>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • <% end %> @@ -202,7 +218,7 @@
  • 回复了贴吧帖子
  • - <%= link_to urm.memo.content.html_safe, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "newsGrey" %> + <%= link_to urm.memo.content.html_safe, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "newsGrey" , :title => "#{urm.memo.content.html_safe}" %>
  • <%= time_tag(urm.memo.created_at).html_safe %>
  • @@ -222,7 +238,7 @@
  • <%= ufm.journals_for_message.reply_id == 0 ? "给你留言了" : "回复了你的留言" %>
  • - <%= link_to ufm.journals_for_message.notes.html_safe, feedback_path(ufm.journals_for_message.jour_id), :class => "newsGrey" %> + <%= link_to ufm.journals_for_message.notes.html_safe, feedback_path(ufm.journals_for_message.jour_id), :class => "newsGrey", :title => "#{ufm.journals_for_message.notes.html_safe}" %>
  • <%= time_tag(ufm.journals_for_message.created_on).html_safe %>
  • From 3c6484269d999110a30df3d7ad7349ba26a465bc Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 21 Aug 2015 10:14:04 +0800 Subject: [PATCH 070/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E5=88=A0=E9=99=A4=E4=B8=8A=E4=BC=A0=E8=80=85=E4=B8=BA?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=9A=84=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 78 ++++++++++++--------- app/views/users/user_resource_delete.js.erb | 3 +- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 76e287a43..5d569e247 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -823,48 +823,56 @@ class UsersController < ApplicationController end end - # 删除用户资源,分为批量删除 和 单个删除 + # 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源 def user_resource_delete if params[:resource_id].present? - Attachment.delete(params[:resource_id]) + Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) elsif params[:checkbox1].present? params[:checkbox1].each do |id| - Attachment.delete(id) + Attachment.where("author_id = #{User.current.id}").delete(id) end end - #@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") - if(params[:type].nil? || params[:type] == "1") #全部 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon') ").order("created_on desc") - else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个公开资源的课程是不是在 这个user的所有我可见的课程中 - @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + - "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + - "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") - end - elsif params[:type] == "2" #课程资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Course'").order("created_on desc") - else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 - @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+ - "or (container_type = 'Course' and is_public <> -1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") - end - elsif params[:type] == "3" #项目资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") - end - elsif params[:type] == "4" #附件 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") - end - end - @type = params[:type] + if(params[:type].nil? || params[:type] == "1") #全部 + if User.current.id.to_i == params[:id].to_i + user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + else + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " + + "and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + end + elsif params[:type] == "2" #课程资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') ").order("created_on desc") + else + user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course')"+ + "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.join(',')}))").order("created_on desc") + end + elsif params[:type] == "3" #项目资源 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") + end + elsif params[:type] == "4" #附件 + if User.current.id.to_i == params[:id].to_i + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + else + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") + end + end + @type = params[:type] + @limit = 10 + @is_remote = true + @obj_count = @attachments.count + @obj_pages = Paginator.new @obj_count, @limit, params['page'] || 1 + @offset ||= @obj_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @attachments = paginateHelper @attachments,10 respond_to do |format| format.js end diff --git a/app/views/users/user_resource_delete.js.erb b/app/views/users/user_resource_delete.js.erb index 69fc3dd43..1a7469f25 100644 --- a/app/views/users/user_resource_delete.js.erb +++ b/app/views/users/user_resource_delete.js.erb @@ -1 +1,2 @@ -$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); \ No newline at end of file +$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#pages").html('<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file From cf243d47e5ba5d2581ec718913462bab234e47a4 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 21 Aug 2015 10:28:29 +0800 Subject: [PATCH 071/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E5=88=A0=E9=99=A4=E4=B8=8A=E4=BC=A0=E8=80=85=E4=B8=BA?= =?UTF-8?q?=E8=87=AA=E5=B7=B1=E7=9A=84=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_resources_list.html.erb | 1 + app/views/users/user_resource.html.erb | 48 ++++++++++++++---------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index 0099ba40b..fd72c99e4 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -14,6 +14,7 @@
  • <%= number_to_human_size(attach.filesize) %>
  • <%= get_resource_type(attach.container_type)%>
  • <%=User.find(attach.author_id).realname %>
  • +
  • <%= attach.author_id %>
  • <%= format_date(attach.created_on) %>
  • <%= attach.id %>
  • diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index fad50d683..19cfe2407 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -113,10 +113,10 @@ <%= render :partial => 'upload_resource' ,:locals => {:user=>@user}%> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 4975229eb..d96fd1036 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -213,4 +213,9 @@
    + + + +
    +
    \ No newline at end of file diff --git a/public/javascripts/user.js b/public/javascripts/user.js index b032221f8..a26b6b94a 100644 --- a/public/javascripts/user.js +++ b/public/javascripts/user.js @@ -1,262 +1,5 @@ -//个人动态 $(function(){ - function init_editor(params){ - var editor = params.kindutil.create(params.textarea, { - resizeType : 1,minWidth:"1px",width:"100%",height:"80px", - items:['emoticons'], - afterChange:function(){//按键事件 - nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); - }, - afterCreate:function(){ - var toolbar = $("div[class='ke-toolbar']",params.div_form); - $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); - params.toolbar_container.append(toolbar); - } - }).loadPlugin('paste'); - return editor; - } - - function nh_check_field(params){ - var result=true; - if(params.content!=undefined){ - if(params.content.isEmpty()){ - result=false; - } - if(params.content.html()!=params.textarea.html() || params.issubmit==true){ - params.textarea.html(params.content.html()); - params.content.sync(); - if(params.content.isEmpty()){ - params.contentmsg.html('内容不能为空'); - params.contentmsg.css({color:'#ff0000'}); - }else{ - params.contentmsg.html('填写正确'); - params.contentmsg.css({color:'#008000'}); - } - params.contentmsg.show(); - } - } - return result; - } - function init_form(params){ - params.form.submit(function(){ - var flag = false; - if(params.form.attr('data-remote') != undefined ){ - flag = true - } - var is_checked = nh_check_field({ - issubmit:true, - content:params.editor, - contentmsg:params.contentmsg, - textarea:params.textarea - }); - if(is_checked){ - if(flag){ - return true; - }else{ - $(this)[0].submit(); - return false; - } - } - return false; - }); - } - function nh_reset_form(params){ - params.form[0].reset(); - params.textarea.empty(); - if(params.editor != undefined){ - params.editor.html(params.textarea.html()); - } - params.contentmsg.hide(); - } - - KindEditor.ready(function(K){ - $("a[nhname='reply_btn']").live('click',function(){ - var params = {}; - params.kindutil = K; - params.container = $(this).parent().parent('div'); - params.div_form = $("div[nhname='div_form']",params.container); - params.form = $("form",params.div_form); - params.textarea = $("textarea[name='user_notes']",params.div_form); - params.textarea.prev('div').css("height","60px"); - params.contentmsg = $("p[nhname='contentmsg']",params.div_form); - params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); - params.cancel_btn = $("a[nhname='cancel_btn']",params.div_form); - params.submit_btn = $("a[nhname='submit_btn']",params.div_form); - if(params.textarea.data('init') == undefined){ - params.editor = init_editor(params); - init_form(params); - params.cancel_btn.click(function(){ - nh_reset_form(params); - toggleAndSettingWordsVal(params.div_form, params.textarea); - }); - params.submit_btn.click(function(){ - params.form.submit(); - }); - params.textarea.data('init',1); - } - params.cancel_btn.click(); - setTimeout(function(){ - if(!params.div_form.is(':hidden')){ - params.textarea.show(); - params.textarea.focus(); - params.textarea.hide(); - } - },300); - }); - - $("a[nhname='sub_reply_btn']").live('click',function(){ - var params = {}; - params.kindutil = K; - params.container = $(this).parent().parent('div'); - params.div_form = $("div[nhname='sub_div_form']",params.container); - params.form = $("form",params.div_form); - params.textarea = $("textarea[name='user_notes']",params.div_form); - params.textarea.prev('div').css("height","60px"); - params.contentmsg = $("p[nhname='sub_contentmsg']",params.div_form); - params.toolbar_container = $("div[nhname='sub_toolbar_container']",params.div_form); - params.cancel_btn = $("a[nhname='sub_cancel_btn']",params.div_form); - params.submit_btn = $("a[nhname='sub_submit_btn']",params.div_form); - if(params.textarea.data('init') == undefined){ - params.editor = init_editor(params); - init_form(params); - params.cancel_btn.click(function(){ - nh_reset_form(params); - toggleAndSettingWordsVal(params.div_form, params.textarea); - }); - params.submit_btn.click(function(){ - params.form.submit(); - }); - params.textarea.data('init',1); - } - params.cancel_btn.click(); - setTimeout(function(){ - if(!params.div_form.is(':hidden')){ - params.textarea.show(); - params.textarea.focus(); - params.textarea.hide(); - } - },300); - }); - - $("div[nhname='new_message']").each(function(){ - var params = {}; - params.kindutil = K; - params.div_form = $(this); - params.form = $("form",params.div_form); - if(params.form==undefined || params.form.length==0){ - return; - } - params.textarea = $("textarea[nhname='new_message_textarea']",params.div_form); - params.contentmsg = $("p[nhname='contentmsg']",params.div_form); - params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); - params.cancel_btn = $("#new_message_cancel_btn"); - params.submit_btn = $("#new_message_submit_btn"); - - if(params.textarea.data('init') == undefined){ - params.editor = init_editor(params); - init_form(params); - params.cancel_btn.click(function(){ - nh_reset_form(params); - }); - params.submit_btn.click(function(){ - params.form.submit(); - }); - params.textarea.data('init',1); - $(this).show(); - } - }); - }); -}); -function init_list_more_div(params){ - var p=params; - p.exbtn.click(function(){ - var isclose = p.container.data('isclose'); - var hasmore = p.container.data('hasmore'); - if(isclose == '1'){ - $("div[nhname='rec']",p.container).show(); - p.container.data('isclose','0'); - change_status_4_list_more_div(params); - return; - } - if(hasmore == '0'){ - change_status_4_list_more_div(params,'get'); - return; - } - var url = p.container.data('url'); - if($("div[nhname='rec']",p.container).length > 0){ - var lastid = $("div[nhname='rec']",p.container).filter(':last').data('id'); - url += "?lastid="+lastid; - var lasttime = $("div[nhname='rec']",p.container).filter(':last').data('time'); - if(lasttime != undefined){ - url += "&lasttime="+lasttime; - } - } - $.ajax( {url:url,dataType:'text',success:function(data){ - var html = $("
    "+data+"
    "); - var lens = $("div[nhname='rec']",html).length; - if(lens < p.size){ - p.container.data('hasmore','0'); - } - if(lens>0){ - var currpage = parseInt(p.container.data('currpage'))+1; - p.container.data('currpage',currpage); - p.container.append(html.html()) - } - change_status_4_list_more_div(params,'get'); - p.div.show(); - }} ); - }); - p.clbtn.click(function(){ - var i=0; - $("div[nhname='rec']",p.container).each(function(){ - i++; - if(i> p.size){ - $(this).hide(); - } - }); - p.container.data('isclose','1'); - change_status_4_list_more_div(params); - }); - p.exbtn.click(); -} -function change_status_4_list_more_div(params,opt){ - var p=params; - if($("div[nhname='rec']",p.container).length == 0 && opt != 'get'){ - p.exbtn.click(); - return; - } - var show_lens = $("div[nhname='rec']",p.container).length - $("div[nhname='rec']",p.container).filter(':hidden').length; - if( show_lens > p.size ){ - p.clbtn.show(); - }else{ - p.clbtn.hide(); - } - if($("div[nhname='rec']",p.container).length == 0){ - p.exbtn.html(p.nodatamsg); - }else if( p.container.data('hasmore') == '1' || p.container.data('isclose')=='1' ){ - p.exbtn.html('点击展开更多'); - }else{ - p.exbtn.html('没有更多了'); - } -} -function init_list_more_div_params(div){ - var params = {}; - params.div = div; - params.container = $("div[nhname='container']",div); - params.exbtn = $("a[nhname='expand']",div); - params.clbtn = $("a[nhname='close']",div); - params.size = params.container.data('pagesize'); - params.nodatamsg = params.container.data('nodatamsg'); - if( params.size == undefined ){ - params.size = 13; - } - return params; -} -$(function(){ - $("div[nhname='list_more_div']").each(function(){ - var params = init_list_more_div_params($(this)); - init_list_more_div(params) - }); + $("#RSide").css("min-height",$("#LSide").height()-40).css("padding","10px"); }); $(function(){ diff --git a/public/stylesheets/new_public.css b/public/stylesheets/new_public.css index 17057eabb..9bcfc4dc0 100644 --- a/public/stylesheets/new_public.css +++ b/public/stylesheets/new_public.css @@ -10,6 +10,8 @@ a:hover,a:active{color:#000;} /*常用*/ .hidden{overflow:hidden; white-space: nowrap; text-overflow:ellipsis;} +.none{display: none;} +.rside_back{ width:670px; margin-left:10px; background:#fff; margin-bottom:10px;} .break_word{ word-break:break-all; word-wrap: break-word;} select,input,textarea{ border:1px solid #64bdd9; background:#fff; color:#000; padding-left:5px; } .sub_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #707070; color:#000; border-radius:3px; padding:1px 10px; background:#dbdbdb;} @@ -281,10 +283,6 @@ a.topnav_login_box:hover {color:#a1ebff;} a.search_btn{ display:block; background:#15bccf; color:#fff; width:60px; height:24px; text-align:center; padding-top:3px;} a:hover.search_btn{ background: #0fa9bb;} .search_text{ border:1px solid #15bccf; background:#fff; width:220px; height:25px; padding-left:5px; } -/*主类容左右分栏*/ -#LSide{ width:240px; } -#RSide{ width:730px; margin-left:10px; background:#fff; padding:10px; margin-bottom:10px;} - /*资源库*/ .resources {width:730px; background-color:#ffffff; padding:10px;} @@ -511,7 +509,7 @@ a.postOptionLink:hover {color:#ffffff; background-color:#15bccf;} .postAttSize {color:#888888; font-size:12px;} a.postGrey {color:#484848;} a.postGrey:hover {color:#000000;} -a.gz_btn{display:block; background:url(../images/pic_uersall.png) -318px -25px no-repeat; width:53px; height:18px; border:1px solid #cdcdcd; color:#333333; padding:0px 0 0 18px;margin-top: 2px;} +a.gz_btn{display:block; background:url(../images/pic_uersall.png) -318px -25px no-repeat; width:53px; height:18px; border:1px solid #cdcdcd; color:#333333; padding:0px 0 0 18px;margin-top: 2px;margin-right: 15px;} a:hover.gz_btn{ color:#ff5722;} From 11d6298efa7253be8934131a41485ecc4e88222d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 21 Aug 2015 14:37:19 +0800 Subject: [PATCH 084/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=20=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=90=8Ecss=E6=A0=B7=E5=BC=8F=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 8 +- public/stylesheets/public_new.css | 178 +++++++++++++++--------------- 2 files changed, 96 insertions(+), 90 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 5fcdda1c5..d5ef9f1c5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -474,6 +474,13 @@ ActiveRecord::Schema.define(:version => 20150815030833) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -896,7 +903,6 @@ ActiveRecord::Schema.define(:version => 20150815030833) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" - t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 43f6288c5..b1426f9bc 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -588,100 +588,100 @@ input.sendSourceText {font-size:14px;color:#ffffff;background-color:#64bdd9;} /*资源库*/ -.resources {width:730px; background-color:#ffffff;} -.resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;} -.bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;} -.resourcesSelect {width:40px; height:40px; float:right; position:relative;} -.resourcesSelected {width:25px; height:20px;} -.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;} -.resourcesIcon:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;} -.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;} -a.resourcesGrey {font-size:12px; color:#888888;} -a.resourcesGrey:hover {font-size:12px; color:#15bccf;} -.resourcesBanner ul li:hover ul.resourcesType {display:block;} -ul li:hover ul {display:block;} -.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;} -.uploadIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;} -a.uploadText {color:#ffffff; font-size:14px;} -.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;} -.searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;} -.searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;} -.resourcesSearchBanner {height:34px; margin-bottom:10px;} -.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;} -.resourcesListCheckbox {width:40px; height:40px; line-height:40px; text-align:center; vertical-align:middle;} -.resourcesCheckbox {padding:0px; margin:0px; margin-top:14px; width:12px; height:12px;} -.resourcesListName {width:135px; height:40px; line-height:40px; text-align:left;} -.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;} -.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;} -.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;} -.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;} -.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;} -a.resourcesBlack {font-size:12px; color:#4c4c4c;} -a.resourcesBlack:hover {font-size:12px; color:#000000;} -.dropdown-menu { - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 80px; - padding: 5px 0; - margin: 2px 0 0; - font-size: 12px; - text-align: left; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); - box-shadow: 0 6px 12px rgba(0, 0, 0, .175); -} -.dropdown-menu > li > a { - display: block; - padding: 3px 20px; - clear: both; - font-weight: normal; - line-height: 1.5; - color:#616060; - white-space: nowrap; -} -.dropdown-menu > li > a:hover{ - color: #ffffff; - text-decoration: none; - background-color: #64bdd9; - outline:none; -} +/*.resources {width:730px; background-color:#ffffff;}*/ +/*.resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;}*/ +/*.bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;}*/ +/*.resourcesSelect {width:40px; height:40px; float:right; position:relative;}*/ +/*.resourcesSelected {width:25px; height:20px;}*/ +/*.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}*/ +/*.resourcesIcon:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}*/ +/*.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}*/ +/*a.resourcesGrey {font-size:12px; color:#888888;}*/ +/*a.resourcesGrey:hover {font-size:12px; color:#15bccf;}*/ +/*.resourcesBanner ul li:hover ul.resourcesType {display:block;}*/ +/*ul li:hover ul {display:block;}*/ +/*.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}*/ +/*.uploadIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;}*/ +/*a.uploadText {color:#ffffff; font-size:14px;}*/ +/*.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;}*/ +/*.searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;}*/ +/*.searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;}*/ +/*.resourcesSearchBanner {height:34px; margin-bottom:10px;}*/ +/*.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}*/ +/*.resourcesListCheckbox {width:40px; height:40px; line-height:40px; text-align:center; vertical-align:middle;}*/ +/*.resourcesCheckbox {padding:0px; margin:0px; margin-top:14px; width:12px; height:12px;}*/ +/*.resourcesListName {width:135px; height:40px; line-height:40px; text-align:left;}*/ +/*.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}*/ +/*a.resourcesBlack {font-size:12px; color:#4c4c4c;}*/ +/*a.resourcesBlack:hover {font-size:12px; color:#000000;}*/ +/*.dropdown-menu {*/ + /*position: absolute;*/ + /*top: 100%;*/ + /*left: 0;*/ + /*z-index: 1000;*/ + /*display: none;*/ + /*float: left;*/ + /*min-width: 80px;*/ + /*padding: 5px 0;*/ + /*margin: 2px 0 0;*/ + /*font-size: 12px;*/ + /*text-align: left;*/ + /*background-color: #fff;*/ + /*-webkit-background-clip: padding-box;*/ + /*background-clip: padding-box;*/ + /*border: 1px solid #ccc;*/ + /*border-radius: 4px;*/ + /*-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);*/ + /*box-shadow: 0 6px 12px rgba(0, 0, 0, .175);*/ +/*}*/ +/*.dropdown-menu > li > a {*/ + /*display: block;*/ + /*padding: 3px 20px;*/ + /*clear: both;*/ + /*font-weight: normal;*/ + /*line-height: 1.5;*/ + /*color:#616060;*/ + /*white-space: nowrap;*/ +/*}*/ +/*.dropdown-menu > li > a:hover{*/ + /*color: #ffffff;*/ + /*text-decoration: none;*/ + /*background-color: #64bdd9;*/ + /*outline:none;*/ +/*}*/ /*发送资源弹窗*/ /*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/ -.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;} -.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} -.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} -.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;} -.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;} -.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;} -.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;} -.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;} -.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;} -.sendCourseName {font-size:12px; color:#5f6060;} -.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;} -.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left} -a.sendSourceText {font-size:14px; color:#ffffff;} +/*.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}*/ +/*.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}*/ +/*.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;}*/ +/*.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;}*/ +/*.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}*/ +/*.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;}*/ +/*.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;}*/ +/*.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;}*/ +/*.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;}*/ +/*.sendCourseName {font-size:12px; color:#5f6060;}*/ +/*.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;}*/ +/*.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left}*/ +/*a.sendSourceText {font-size:14px; color:#ffffff;}*/ /*上传资源弹窗*/ -.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} -.uploadText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} -.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;} -.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;} -a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;} -.chooseFile {color:#ffffff; display:block; margin-left:32px;} -.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;} -.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;} -.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;} -.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;} -.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;} +/*.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;}*/ +/*.uploadText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}*/ +/*.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;}*/ +/*.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;}*/ +/*a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;}*/ +/*.chooseFile {color:#ffffff; display:block; margin-left:32px;}*/ +/*.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;}*/ +/*.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;}*/ +/*.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;}*/ +/*.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;}*/ +/*.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;}*/ /*新个人主页框架css*/ From 8ef6225084530047f2d4045675baa466bf534f56 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 21 Aug 2015 15:23:03 +0800 Subject: [PATCH 085/119] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E3=80=81=E5=8F=96=E6=B6=88=E5=85=B3?= =?UTF-8?q?=E6=B3=A8=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_user_watch_btn.html.erb | 14 ++---- app/views/layouts/new_base_user.html.erb | 13 ++---- app/views/users/show.html.erb | 2 +- app/views/watchers/_set_watcher.js.erb | 54 +++------------------- public/javascripts/user.js | 9 ++++ 5 files changed, 25 insertions(+), 67 deletions(-) diff --git a/app/views/layouts/_user_watch_btn.html.erb b/app/views/layouts/_user_watch_btn.html.erb index 578319b68..5f9c550b7 100644 --- a/app/views/layouts/_user_watch_btn.html.erb +++ b/app/views/layouts/_user_watch_btn.html.erb @@ -1,11 +1,7 @@ <% if User.current.logged?%> - <% if User.current == target%> - 编辑资料 - <%else%> - <%if(target.watched_by?(User.current))%> - 取消关注 - <% else %> - 添加关注 - <% end %> - <% end%> + <%if(target.watched_by?(User.current))%> + <%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollow", :method => "delete",:remote => "true", :title => "取消关注"%> + <% else %> + <%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollowCancel", :method => "post",:remote => "true", :title => "添加关注"%> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 429bfdd6c..f0c9bcad1 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -29,7 +29,7 @@
    -
    +
    <%= image_tag(url_to_avatar(@user),width:"206", height: "206", :id=>'nh_user_tx') %> <% if User.current.logged?%> <% if User.current == @user%> @@ -39,13 +39,8 @@
    <% else %> -
    - - <%if(@user.watched_by?(User.current))%> - <%= link_to "",watch_path(:object_type=> 'user',:object_id=>@user.id,:target_id=>@user.id),:class => "homepageFollow", :method => "delete",:remote => "true", :title => "取消关注"%> - <% else %> - <%= link_to "",watch_path(:object_type=> 'user',:object_id=>@user.id,:target_id=>@user.id),:class => "homepageFollow", :method => "post",:remote => "true", :title => "添加关注"%> - <% end %> +
    + <%= render :partial => 'layouts/user_watch_btn', :locals => {:target => @user} %>
    <% end %> <% end%> @@ -89,7 +84,7 @@
    - <%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber"%> + <%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber", :id => "user_fans_number"%>
    粉丝
    diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index d96fd1036..02791d02d 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -215,7 +215,7 @@
    - +
    \ No newline at end of file diff --git a/app/views/watchers/_set_watcher.js.erb b/app/views/watchers/_set_watcher.js.erb index da794d18b..1efa8a4a1 100644 --- a/app/views/watchers/_set_watcher.js.erb +++ b/app/views/watchers/_set_watcher.js.erb @@ -1,57 +1,15 @@ <% if( params[:object_type] == 'user') %> + //点击头像下面的添加关注按钮 <% if( params[:target_id] == params[:object_id] ) %> - <% target = User.find_by_id(params[:target_id]) %> - //btn - var btn_html = "<%= escape_javascript( render( :partial => 'layouts/user_watch_btn', :locals => {:target => target} ) )%>"; - $('#user_watch_id').replaceWith(btn_html); - //count - $("*[nh_name='fans_count']").html("<%= target.watcher_users.count.to_s %>"); - //left list - var list_left_html = "<%= escape_javascript( render( :partial => 'layouts/user_fans_list', :locals => {:user => target} ) )%>"; - $('#fans_nav_list').replaceWith(list_left_html); - //list - if( $("#nh_fans_list") != undefined && $("#nh_fans_list").length != 0 ){ - <% if( opt == 'add') %> - var list_html = "<%= escape_javascript( render( :partial => 'users/user_fans_item', :locals => {:item=>User.current,:target => target} ) )%>"; - $("#nh_fans_list").after(list_html); - $("#nodata").hide(); - <% else %> - $("#fans_item_<%= User.current.id %>",$("#nh_fans_list").parent('div')).remove(); - if( $('>div',$("#nh_fans_list").parent('div')).length == 1 ){ - $("#nodata").show(); - } - <% end %> - } - + $("#watch_user_btn").html("<%= escape_javascript render(:partial => "layouts/user_watch_btn", :locals => {:target => watched.first}) %>"); + $("#user_fans_number").html("<%= watched.first.watcher_users.count.to_s%>"); + //在当前用户的粉丝、关注页面 <% elsif( params[:target_id] == User.current.id.to_s )%> - <% target = User.find_by_id(params[:target_id]) %> - <% item = User.find_by_id(params[:object_id]) %> - //count - $("*[nh_name='watcher_count']").html("<%= User.watched_by(target.id).count.to_s %>"); - //left list - var list_left_html = "<%= escape_javascript( render( :partial => 'layouts/user_watch_list', :locals => {:user => target} ) )%>"; - $('#watcher_nav_list').replaceWith(list_left_html); - //list - if( $("#nh_wacth_list") != undefined && $("#nh_wacth_list").length != 0 ){ - <% if( opt == 'delete') %> - $("#fans_item_<%= item.id %>",$("#nh_wacth_list").parent('div')).remove(); - if( $('>div',$("#nh_wacth_list").parent('div')).length == 1 ){ - $("#nodata").show(); - } - <% end %> - }else if($("#nh_fans_list") != undefined && $("#nh_fans_list").length != 0){ - var list_html = "<%= escape_javascript( render( :partial => 'users/user_fans_item', :locals => {:item=>item,:target => target} ) )%>"; - $('#fans_item_<%= item.id %>').replaceWith(list_html); - } + //在其他用户的粉丝、关注页面 <% else %> - <% target = User.find_by_id(params[:target_id]) %> - <% item = User.find_by_id(params[:object_id]) %> - //list - var list_html = "<%= escape_javascript( render( :partial => 'users/user_fans_item', :locals => {:item=>item,:target => target} ) )%>"; - $('#fans_item_<%= item.id %>').replaceWith(list_html); - <% end %> + <% end %> <% else %> <% selector = ".#{watcher_css(watched)}" %> diff --git a/public/javascripts/user.js b/public/javascripts/user.js index a26b6b94a..c97f617a5 100644 --- a/public/javascripts/user.js +++ b/public/javascripts/user.js @@ -1,5 +1,14 @@ $(function(){ $("#RSide").css("min-height",$("#LSide").height()-40).css("padding","10px"); + + //头像相关 + $("#homepage_portrait_image").live("mouseover",function(){ + $("#edit_user_file_btn").show(); + $("#watch_user_btn").show(); + }).live("mouseout",function(){ + $("#edit_user_file_btn").hide(); + $("#watch_user_btn").hide(); + }); }); $(function(){ From 5594295c9e61a45356e3261e035b50cdd47c99f1 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 21 Aug 2015 15:27:01 +0800 Subject: [PATCH 086/119] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=AD=96=E7=95=A5=20=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/users_helper.rb | 8 ++++++++ app/models/issue.rb | 11 ++++++++++- app/models/journal.rb | 8 +++++--- app/views/users/user_messages.html.erb | 8 ++++---- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 49865d335..48019e597 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -402,6 +402,14 @@ module UsersHelper return str.html_safe end + def get_issue_des_update(journal) + arr = details_to_strings(journal.details,true) + arr << journal.notes + str = '' + arr.each { |item| str = str+item } + return str + end + def get_activity_act_showname(activity) case activity.act_type when "HomeworkCommon" diff --git a/app/models/issue.rb b/app/models/issue.rb index 66627c00a..1724e3484 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -83,7 +83,7 @@ class Issue < ActiveRecord::Base # fq after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message - after_update :be_user_score + after_update :be_user_score, :act_as_forge_message_update after_destroy :down_user_score # after_create :be_user_score # end @@ -150,6 +150,15 @@ class Issue < ActiveRecord::Base :viewed => false) end end + + # 更新缺陷 + def act_as_forge_message_update + unless self.author_id == self.assigned_to_id + self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, + :project_id => self.project_id, + :viewed => false) + end + end # Returns a SQL conditions string used to find all issues visible by the specified user diff --git a/app/models/journal.rb b/app/models/journal.rb index c705b1a09..a5bea92af 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -171,9 +171,11 @@ class Journal < ActiveRecord::Base # 缺陷状态更改,消息提醒 def act_as_forge_message - self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id, - :project_id => self.issue.project_id, - :viewed => false) + if self.user_id != self.issue.author_id + self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id, + :project_id => self.issue.project_id, + :viewed => false) + end end # 更新用户分数 -by zjc diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 17ee0957a..c1b57aabb 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -153,11 +153,11 @@ "><%= ufm.forge_message.user %>
  • "> - <%= ufm.forge_message.notes.empty? ? "更新了问题状态" : "在问题中留言了" %>
  • + 更新了问题
  • - <%= link_to ("#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }"), + <%= link_to get_issue_des_update(ufm.forge_message), issue_path(:id => ufm.forge_message.journalized_id), :class => "#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}", - :title => "#{ufm.forge_message.notes.empty? ? ufm.forge_message.issue.subject.html_safe : ufm.forge_message.notes.html_safe }" %> + :title => "#{get_issue_des_update(ufm.forge_message)}" %>
  • <%= time_tag(ufm.forge_message.created_on).html_safe %>
  • @@ -216,7 +216,7 @@
  • <%= urm.memo.author %>
  • -
  • 回复了贴吧帖子
  • +
  • 新建贴吧帖子
  • <%= link_to urm.memo.content.html_safe, forum_memo_path(urm.memo.forum_id, urm.memo.parent_id ? urm.memo.parent_id: urm.memo.id),:class => "newsGrey" , :title => "#{urm.memo.content.html_safe}" %>
  • From d942cc31233227cd6839dc5ed62b0ce295a7cf32 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 21 Aug 2015 15:40:38 +0800 Subject: [PATCH 087/119] =?UTF-8?q?=E6=80=A7=E5=88=AB=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/new_base_user.html.erb | 11 +++++++---- public/stylesheets/new_public.css | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index f0c9bcad1..5a2a7ac6b 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -18,6 +18,7 @@
    -
    - - -
    -
    \ No newline at end of file From 5628a435783deb788c7bf91dcab0d19a3d782a42 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 24 Aug 2015 13:54:15 +0800 Subject: [PATCH 109/119] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E5=92=8C?= =?UTF-8?q?=E6=96=B0=E7=89=88=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83=E6=95=B4?= =?UTF-8?q?=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/views/layouts/_logined_header.html.erb | 2 +- ..._resource_share_for_project_popup.html.erb | 3 +- .../users/_resource_share_popup.html.erb | 5 +- app/views/users/user_resource.html.erb | 4 +- app/views/users/user_resource_create.js.erb | 3 +- public/stylesheets/new_public.css | 233 ++++++++++++++---- 7 files changed, 196 insertions(+), 56 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 16616d0c8..19ddefe96 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1424,7 +1424,7 @@ class UsersController < ApplicationController @attachments = paginateHelper @attachments,15 respond_to do |format| format.js - format.html {render :layout => 'base_users_new'} + format.html {render :layout => 'new_base_user'} end end diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index cb93ca7fa..27f6f8345 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -8,7 +8,7 @@ 首页 + 资源库 diff --git a/app/views/users/_resource_share_for_project_popup.html.erb b/app/views/users/_resource_share_for_project_popup.html.erb index 9cd744c9a..01a2375c1 100644 --- a/app/views/users/_resource_share_for_project_popup.html.erb +++ b/app/views/users/_resource_share_for_project_popup.html.erb @@ -26,6 +26,7 @@ <%= hidden_field_tag(:send_id, send_id) %> <%= hidden_field_tag(:send_ids, send_ids) %> +
    <% if !projects.empty? %> <% projects.each do |project| %>
      @@ -35,7 +36,7 @@
    • <%= truncate( project.name,:length=>18)%>
    <% end %> - +
    diff --git a/app/views/users/_resource_share_popup.html.erb b/app/views/users/_resource_share_popup.html.erb index ea1ada447..7f1c5a005 100644 --- a/app/views/users/_resource_share_popup.html.erb +++ b/app/views/users/_resource_share_popup.html.erb @@ -26,6 +26,7 @@ <%= hidden_field_tag(:send_id, send_id) %> <%= hidden_field_tag(:send_ids, send_ids) %> +
    <% if !courses.empty? %> <% courses.each do |course| %>
      @@ -35,14 +36,14 @@
    • <%= truncate(course.name,:length=>18)%>
    <% end %> - +
    <%= submit_tag '确定',:class=>'sendSourceText',:onfocus=>'this.blur();' %>
    - +
    <% end %> diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 3c4ea18ca..254afb79f 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -92,8 +92,8 @@
    - 全选 - 删除 + 全选 + 删除
    选择 0 个资源
    diff --git a/app/views/users/user_resource_create.js.erb b/app/views/users/user_resource_create.js.erb index 16ec4d82a..ba3efbdfb 100644 --- a/app/views/users/user_resource_create.js.erb +++ b/app/views/users/user_resource_create.js.erb @@ -1,5 +1,4 @@ closeModal(); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); - -$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); \ No newline at end of file +//这里不能将翻页的更新 \ No newline at end of file diff --git a/public/stylesheets/new_public.css b/public/stylesheets/new_public.css index 17b17f59f..87e9be920 100644 --- a/public/stylesheets/new_public.css +++ b/public/stylesheets/new_public.css @@ -285,55 +285,173 @@ a:hover.search_btn{ background: #0fa9bb;} .search_text{ border:1px solid #15bccf; background:#fff; width:220px; height:25px; padding-left:5px; } /*资源库*/ -.resources {width:730px; background-color:#ffffff; padding:10px;} +/*.resources {width:730px; background-color:#ffffff; padding:10px;}*/ +/*.resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;}*/ +/*.bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;}*/ +/*.resourcesSelect {width:30px; height:34px; float:right; position:relative; margin-top:-6px;}*/ +/*.resourcesSelected {width:25px; height:20px; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat;}*/ +/*.resourcesSelected:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}*/ +/*.resourcesIcon {margin-top:15px; display:block; width:25px; height:20px;}*/ +/*.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}*/ +/*a.resourcesGrey {font-size:12px; color:#888888;}*/ +/*a.resourcesGrey:hover {font-size:12px; color:#15bccf;}*/ +/*.resourcesBanner ul li:hover ul.resourcesType {display:block;}*/ +/*ul li:hover ul {display:block;}*/ +/*.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;}*/ +/*.uploadIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;}*/ +/*a.uploadText {color:#ffffff; font-size:14px;}*/ +/*.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;}*/ +/*.searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;}*/ +/*.searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;}*/ +/*.resourcesSearchBanner {height:34px; margin-bottom:10px;}*/ +/*.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}*/ +/*.resourcesListCheckbox {width:40px; height:40px; line-height:40px; text-align:center; vertical-align:middle;}*/ +/*.resourcesCheckbox {padding:0px; margin:0px; margin-top:14px; width:12px; height:12px;}*/ +/*.resourcesListName {width:135px; height:40px; line-height:40px; text-align:left;}*/ +/*.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}*/ +/*a.resourcesBlack {font-size:12px; color:#4c4c4c;}*/ +/*a.resourcesBlack:hover {font-size:12px; color:#000000;}*/ +/*.dropdown-menu {*/ + /*position: absolute;*/ + /*top: 100%;*/ + /*left: 0;*/ + /*z-index: 1000;*/ + /*display: none;*/ + /*float: left;*/ + /*min-width: 80px;*/ + /*padding: 5px 0;*/ + /*margin: 2px 0 0;*/ + /*font-size: 12px;*/ + /*text-align: left;*/ + /*background-color: #fff;*/ + /*-webkit-background-clip: padding-box;*/ + /*background-clip: padding-box;*/ + /*border: 1px solid #ccc;*/ + /*border-radius: 4px;*/ + /*-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175);*/ + /*box-shadow: 0 6px 12px rgba(0, 0, 0, .175);*/ +/*}*/ +/*.dropdown-menu > li > a {*/ + /*display: block;*/ + /*padding: 3px 20px;*/ + /*clear: both;*/ + /*font-weight: normal;*/ + /*line-height: 1.5;*/ + /*color:#616060;*/ + /*white-space: nowrap;*/ +/*}*/ +/*.dropdown-menu > li > a:hover{*/ + /*color: #ffffff;*/ + /*text-decoration: none;*/ + /*background-color: #64bdd9;*/ + /*outline:none;*/ +/*}*/ + +/*发送资源弹窗*/ +/*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/ +/*.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}*/ +/*.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}*/ +/*.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;}*/ +/*.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;}*/ +/*.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}*/ +/*.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;}*/ +/*.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;}*/ +/*.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;}*/ +/*.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;}*/ +/*.sendCourseName {font-size:12px; color:#5f6060;}*/ +/*.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;}*/ +/*.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left}*/ +/*a.sendSourceText {font-size:14px; color:#ffffff;}*/ + +/*上传资源弹窗*/ +/*.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;}*/ +/*.uploadText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;}*/ +/*.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;}*/ +/*.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;}*/ +/*a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;}*/ +/*.chooseFile {color:#ffffff; display:block; margin-left:32px;}*/ +/*.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;}*/ +/*.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;}*/ +/*.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;}*/ +/*.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;}*/ +/*.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;}*/ + +/*资源库*/ +.resources {width:728px; background-color:#ffffff; padding:10px; border:1px solid #dddddd;float: right} +/*.resources {width:730px; background-color:#ffffff; padding:10px;float: right}*/ .resourcesBanner {width:730px; height:40px; background-color:#eaeaea; margin-bottom:10px;} .bannerName {background:#64bdd9; color:#ffffff; height:40px; line-height:40px; width:90px; text-align:center; font-weight:normal; vertical-align:middle; font-size: 16px; float:left;} .resourcesSelect {width:30px; height:34px; float:right; position:relative; margin-top:-6px;} .resourcesSelected {width:25px; height:20px; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat;} .resourcesSelected:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;} .resourcesIcon {margin-top:15px; display:block; width:25px; height:20px;} -.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;} +/*.resourcesIcon {margin-top:15px; display:block; position:relative; background:url(images/resource_icon_list.png) 0px 0px no-repeat; width:25px; height:20px;}*/ +/*.resourcesIcon:hover { background:url(images/resource_icon_list.png) 0px -25px no-repeat;}*/ +/*.resourcesType {width:50px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-30px; font-size:12px; color:#888888; display:none;}*/ a.resourcesGrey {font-size:12px; color:#888888;} a.resourcesGrey:hover {font-size:12px; color:#15bccf;} .resourcesBanner ul li:hover ul.resourcesType {display:block;} ul li:hover ul {display:block;} .resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;} +.resourcesUploadBox:hover {background-color:#0781b4;} .uploadIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:30px; height:30px; margin-left:-3px;} a.uploadText {color:#ffffff; font-size:14px;} -.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:right; background-color:#ffffff;} +.resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:left; background-color:#ffffff;} .searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;} .searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;} -.resourcesSearchBanner {height:34px; margin-bottom:10px;} -.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;} -.resourcesListCheckbox {width:40px; height:40px; line-height:40px; text-align:center; vertical-align:middle;} -.resourcesCheckbox {padding:0px; margin:0px; margin-top:14px; width:12px; height:12px;} -.resourcesListName {width:135px; height:40px; line-height:40px; text-align:left;} -.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;} +/*.resourcesSearchBanner {height:34px; margin-bottom:10px;}*/ +.resourcesSearchBanner {width:710px; height:34px; margin-bottom:10px; margin-top:15px; margin-left:auto; margin-right:auto;} +/*.resourcesListTab {width:730px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a;}*/ +.resourcesListTab {width:710px; height:40px; background-color:#f6f6f6; border-bottom:1px solid #eaeaea; font-size:14px; color:#7a7a7a; margin-left:auto; margin-right:auto;} +/*.resourcesListName {width:175px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListSize {width:110px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;}*/ +/*.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;}*/ +.resourcesListName {width:160px; height:40px; line-height:40px; text-align:left;} +.resourcesListSize {width:105px; height:40px; line-height:40px; text-align:center;} .resourcesListType {width:150px; height:40px; line-height:40px; text-align:center;} -.resourcesListUploader {width:130px; height:40px; line-height:40px; text-align:center;} -.resourcesListTime {width:165px; height:40px; line-height:40px; text-align:center;} -.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;} -a.resourcesBlack {font-size:12px; color:#4c4c4c;} +.resourcesListUploader {width:180px; height:40px; line-height:40px; text-align:center;} +.resourcesListTime {width:95px; height:40px; line-height:40px; text-align:center;} +/*.resourcesList {width:730px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px;}*/ +a.resourcesBlack {font-size:12px; color:#4c4c4c;white-space: nowrap;text-align: left} a.resourcesBlack:hover {font-size:12px; color:#000000;} +.resourcesListCheckbox {width:20px; height:40px; line-height:40px; text-align:center; vertical-align:middle;} +.resourcesCheckbox {padding:0px; margin:0px; margin-top:14px; width:12px; height:12px;} +.resourcesList {width:710px; height:39px; background-color:#ffffff; border-bottom:1px dashed #eaeaea; color:#9a9a9a; font-size:12px; margin-left:auto; margin-right:auto;} +.resourcesListOption {width:710px; height:40px; line-height:40px; vertical-align:middle; margin-left:auto; margin-right:auto; background-color:#f6f6f6;} +.resourcesCheckAll {width:20px; height:40px; line-height:40px; text-align:center; vertical-align:middle; float:left;} +.resourcesSelectSend {float:right;} +/*.resourcesSelectSendButton {width:75px; height:28px; background-color:#ffffff; line-height:28px; vertical-align:middle; margin-top:5px; margin-right:10px; margin-left:15px; text-align:center; border:1px solid #15bccf; border-radius:5px; float:right;}*/ +.resourcesSelectSendButton {width:75px; height:28px; background-color:#ffffff; line-height:28px; vertical-align:middle; margin-top:5px; margin-right:10px; margin-left:15px; text-align:center; border:1px solid #15bccf; border-radius:5px; float:right;} +a.sendButtonBlue {color:#15bccf;} +a.sendButtonBlue:hover {color:#ffffff;} +.resourcesSelectSendButton:hover {background-color:#15bccf;} +.db {display:block;} + .dropdown-menu { - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 80px; - padding: 5px 0; - margin: 2px 0 0; - font-size: 12px; - text-align: left; - background-color: #fff; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 1px solid #ccc; - border-radius: 4px; - -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); - box-shadow: 0 6px 12px rgba(0, 0, 0, .175); + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 80px; + padding: 5px 0; + margin: 2px 0 0; + font-size: 12px; + text-align: left; + background-color: #fff; + -webkit-background-clip: padding-box; + background-clip: padding-box; + border: 1px solid #ccc; + border-radius: 4px; + -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); + box-shadow: 0 6px 12px rgba(0, 0, 0, .175); } .dropdown-menu > li > a { display: block; @@ -350,11 +468,39 @@ a.resourcesBlack:hover {font-size:12px; color:#000000;} background-color: #64bdd9; outline:none; } +.homepageRightBanner {width:720px; height:34px; margin:0px auto; border-bottom:1px solid #e9e9e9;} +.NewsBannerName {font-size:16px; color:#4b4b4b; display:block; background:url(images/homepage_icon.png) -18px -230px no-repeat; width:150px; float:left; padding-left:15px; margin-top:4px;} +a.resourcesTypeAll {background:url(images/homepage_icon.png) -180px -89px no-repeat; padding-left:23px;} +a.resourcesTypeAtt {background:url(images/homepage_icon.png) -180px -49px no-repeat; padding-left:23px;} +.resourcesType {width:75px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 20px; left:-90px; font-size:12px; color:#888888; display:none; line-height:2;} +.resourcesUploadBox {float:right; width:103px; height:34px; background-color:#64bdd9; line-height:34px; vertical-align:middle; text-align:center; margin-left:12px;} +.resourcesUploadBox:hover {background-color:#0781b4;} +/* 个人主页右边部分*/ +.homepageSearchIcon {width:30px; height:32px; background:url(images/nav_icon.png) -8px 3px no-repeat; float:left;} +a.homepagePostTypeQuiz {background:url(images/homepage_icon.png) -90px -124px no-repeat; padding-left:23px;} +a.homepagePostTypeAssignment {background:url(images/homepage_icon.png) -93px -318px no-repeat; padding-left:23px;} +a.replyGrey {color:#888888; display:inline-block;} +a.replyGrey:hover {color:#4b4b4b;} + +/*上传资源弹窗*/ +.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} +.uploadDialogText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} +.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative} +.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;} +a.uploadBoxIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:81px; height:30px; padding-left:22px; font-size:14px; color:#ffffff;} +a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;} +.chooseFile {color:#ffffff; display:block; margin-left:32px;} +.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;} +.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;} +.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;} +.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;} +.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;} /*发送资源弹窗*/ /*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/ +/*.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;}*/ .resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;} -.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} +.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:100px; display:inline-block;} .resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} .resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;} .resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;} @@ -366,19 +512,10 @@ a.resourcesBlack:hover {font-size:12px; color:#000000;} .courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;} .courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left} a.sendSourceText {font-size:14px; color:#ffffff;} - -/*上传资源弹窗*/ -.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} -.uploadText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} -.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;} -.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;} -a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;} -.chooseFile {color:#ffffff; display:block; margin-left:32px;} -.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;} -.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;} -.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;} -.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;} -.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;} +input.sendSourceText {font-size:14px;color:#ffffff;background-color:#64bdd9;} +.resourcesSendTo {float:left; height:20px; margin-top:15px;} +.resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;} +.courseReferContainer {float:left; max-height:120px;margin-right:16px; overflow:scroll; overflow-x:hidden;} /*新个人主页框架css*/ @@ -445,10 +582,12 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} -a.newsGrey {color:#4b4b4b;} -a.newsGrey:hover {color:#000000;} +a.newsGrey1 {color:#4b4b4b;} +a.newsGrey1:hover {color:#000000;} a.replyGrey {color:#888888; display:block;} a.replyGrey:hover {color:#4b4b4b;} +a.replyGrey1 {color:#888888;} +a.replyGrey1:hover {color:#4b4b4b;} a.newsBlue {color:#15bccf;} a.newsBlue:hover {color:#0781b4;} a.menuGrey {color:#808080;} From 2d75fea96b9d504cfbf2ccea7ca7342c8d59a878 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 24 Aug 2015 14:44:22 +0800 Subject: [PATCH 110/119] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=9B=B4=E5=A4=9A=E6=8C=89=E9=92=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 35 +++------------ app/views/layouts/_user_courses.html.erb | 12 +++++ app/views/layouts/new_base_user.html.erb | 33 ++++---------- app/views/users/user_courses4show.html.erb | 16 ------- app/views/users/user_courses4show.js.erb | 1 + public/javascripts/new_user.js | 51 +++++++++++++++------- public/stylesheets/new_public.css | 2 +- 7 files changed, 62 insertions(+), 88 deletions(-) create mode 100644 app/views/layouts/_user_courses.html.erb delete mode 100644 app/views/users/user_courses4show.html.erb create mode 100644 app/views/users/user_courses4show.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 59823ec8f..6bdd3d6fc 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -473,40 +473,15 @@ class UsersController < ApplicationController end end + #显示更多用户课程 def user_courses4show - query = Course.joins("join members m on #{Course.table_name}.id=m.course_id") - query = query.where("m.user_id = ?",@user.id).order("#{Course.table_name}.id desc") - if User.current == @user #看自己 - else - if @user.user_extensions!=nil && @user.user_extensions.identity == 0 #看老师 - query = query.joins("join member_roles r on m.id = r.member_id") - query = query.where("r.role_id in(3,7,9)") - end - query = query.where(Course.table_name+".is_public = 1") - end - - if params[:lastid]!=nil && !params[:lastid].empty? - query = query.where(" #{Course.table_name}.id < ?",params[:lastid],) - end - @list = query.limit(8) - - render :layout=>nil + @page = params[:page].to_i + 1 + @courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) end + + #显示更多用户项目 def user_projects4show - query = Project.joins("join members m on #{Project.table_name}.id=m.project_id") - query = query.where("m.user_id = ? and #{Project.table_name}.project_type=?",@user.id,Project::ProjectType_project) - if User.current == @user #看自己 - else - query = query.where(Project.table_name+".is_public = 1") - # TODO or exists (select 1 from project c2,members m2 where c2.id=m2.course_id and c2.id=#{Project.table_name}.id and m2.user_id= User.current.id) - end - if params[:lastid]!=nil && !params[:lastid].empty? - query = query.where("( (#{Project.table_name}.updated_on=? and #{Project.table_name}.id < ?) or #{Project.table_name}.updated_onnil end def user_course_activities diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb new file mode 100644 index 000000000..393e3d48f --- /dev/null +++ b/app/views/layouts/_user_courses.html.erb @@ -0,0 +1,12 @@ +<% courses.each do |course|%> +
  • + <%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey"%> +
  • +<% end %> + +<% if courses.size == 5%> +
  • + + +
  • +<% end%> \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 419fa70ce..15af50332 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -102,18 +102,7 @@
      <% courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5)%> - <% courses.each do |course|%> -
    • - course.id, :host=>Setting.host_course) %>" class="coursesLineGrey"> - <%= course.name %> - -
    • - <% end %> - <% if courses.size == 5%> -
    • - -
    • - <% end%> + <%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %>
    @@ -124,19 +113,13 @@
      - <% projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%> - <% projects.each do |project|%> -
    • - project.id, :host=>Setting.host_name) %>" class="coursesLineGrey"> - <%= project.name %> - -
    • - <% end %> - <% if projects.size == 5%> -
    • - -
    • - <% end%> + <%# projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%> + <%#= render :partial => 'layouts/user_item', :locals => {:items => courses,:is_course => false} %> + <%# if projects.size == 5%> + + <%# end%>
    diff --git a/app/views/users/user_courses4show.html.erb b/app/views/users/user_courses4show.html.erb deleted file mode 100644 index 7aab1b2a5..000000000 --- a/app/views/users/user_courses4show.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% for item in @list %> - - -<% end %> diff --git a/app/views/users/user_courses4show.js.erb b/app/views/users/user_courses4show.js.erb new file mode 100644 index 000000000..12696e232 --- /dev/null +++ b/app/views/users/user_courses4show.js.erb @@ -0,0 +1 @@ +$("#user_show_more_course").replaceWith("<%= escape_javascript( render :partial => 'layouts/user_courses',:locals => {:courses => @courses,:user => @user, :page => @page} )%>"); diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index 44f719a0b..ae94e48a7 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -1,6 +1,4 @@ $(function(){ - $("#RSide").css("min-height",$("#LSide").height()-40).css("padding","10px"); - //头像相关 $("#homepage_portrait_image").live("mouseover",function(){ $("#edit_user_file_btn").show(); @@ -29,18 +27,39 @@ function edit_user_introduction(url){ ); } -$(function(){ - $(".newsType").mouseover(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"}); - }); - $(".newsType").mouseout(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"}); - }); - $(".resourcesSelected").mouseover(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"}); - }); - $(".resourcesSelected").mouseout(function(){ - $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"}); - }); -}); +//显示更多的课程 +function show_more_course(url){ + $.get( + url, + { page: $("#course_page_num").val() }, + function (data) { + } + ); +} + +//显示更多的项目 +function show_more_project(url){ + $.get( + url, + { brief_introduction: $("#user_brief_introduction_edit").val() }, + function (data) { + + } + ); +} +// +//$(function(){ +// $(".newsType").mouseover(function(){ +// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"}); +// }); +// $(".newsType").mouseout(function(){ +// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"}); +// }); +// $(".resourcesSelected").mouseover(function(){ +// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px -25px no-repeat"}); +// }); +// $(".resourcesSelected").mouseout(function(){ +// $(".resourcesIcon").css({background:"url(images/resource_icon_list.png) 0px 0px no-repeat"}); +// }); +//}); //个人动态 end \ No newline at end of file diff --git a/public/stylesheets/new_public.css b/public/stylesheets/new_public.css index 7e3e92923..0f684f5a0 100644 --- a/public/stylesheets/new_public.css +++ b/public/stylesheets/new_public.css @@ -415,7 +415,7 @@ a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no- .homepageImageSexWomen {width: 20px;height: 20px;background: url(../images/homepage_icon.png) -10px -149px no-repeat;float: left;} .homepageSignatureTextarea {width:207px; height:80px; max-width:207px; max-height:80px; border:1px solid #d9d9d9; outline:none; margin:0px 0px 12px 15px;;} .homepageSignature {font-size:12px; color:#888888; margin-left:15px; margin-top:10px; margin-bottom:12px; width:208px;} -.homepageImageBlock {margin:0 auto; width:78px; float:left; text-align:center; display:inline-block;} +.homepageImageBlock {margin:0 auto; width:75px; float:left; text-align:center; display:inline-block;} .homepageImageNumber {font-size:12px; color:#484848;} a.homepageImageNumber:hover {color:#15bccf;} .homepageImageText {font-size:12px; color:#888888;} From 12b89e2c8130991509f82927ddb457d0e13f8b7d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 24 Aug 2015 14:53:30 +0800 Subject: [PATCH 111/119] =?UTF-8?q?=E5=8F=AF=E6=8B=96=E5=8A=A8=E7=9A=84?= =?UTF-8?q?=E6=A1=86=E6=9A=82=E6=97=B6=E5=81=9A=E4=B8=8D=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_resource.html.erb | 48 ++++++++++++++++++++++++++ public/stylesheets/new_public.css | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 254afb79f..c36fdc293 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -447,6 +447,54 @@ $(".resourcesList").click(function(e) { lastSendType = sendType; } +// var iWidth = document.documentElement.clientWidth; +// var iHeight = document.documentElement.clientHeight; +// var moveX = 0; +// var moveY = 0; +// var moveTop = 0; +// var moveLeft = 0; +// var moveable = false; +// var docMouseMoveEvent = document.onmousemove; +// var docMouseUpEvent = document.onmouseup; +// $("#upload_box").mousedown(function() { +// var evt = getEvent(); +// moveable = true; +// moveX = evt.clientX; +// moveY = evt.clientY; +// +// moveTop = parseInt($("#upload_box").css('top')); +// moveLeft = parseInt($("#upload_box").css('left')); +// +// $(document).mousemove( function() { +// if (moveable) { +// var evt = getEvent(); +// var x = moveLeft + evt.clientX - moveX; +// var y = moveTop + evt.clientY - moveY; +// if ( x > 0 &&( x + 322 < iWidth) && y > 0 && (y + 257 < iHeight) ) { +// $("#upload_box").css('left', x + "px"); +// $("#upload_box").css('top', y + "px"); +// console.log( moveX) +// console.log( moveY) +// } +// } +// }); +// $(document).mouseup (function () { +// if (moveable) { +// document.onmousemove = docMouseMoveEvent; +// document.onmouseup = docMouseUpEvent; +// moveable = false; +// moveX = 0; +// moveY = 0; +// moveTop = 0; +// moveLeft = 0; +// } +// }); +// }); +// +// // 获得事件Event对象,用于兼容IE和FireFox +// function getEvent() { +// return window.event || arguments.callee.caller.arguments[0]; +// } diff --git a/public/stylesheets/new_public.css b/public/stylesheets/new_public.css index 87e9be920..40b049b7e 100644 --- a/public/stylesheets/new_public.css +++ b/public/stylesheets/new_public.css @@ -515,7 +515,7 @@ a.sendSourceText {font-size:14px; color:#ffffff;} input.sendSourceText {font-size:14px;color:#ffffff;background-color:#64bdd9;} .resourcesSendTo {float:left; height:20px; margin-top:15px;} .resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;} -.courseReferContainer {float:left; max-height:120px;margin-right:16px; overflow:scroll; overflow-x:hidden;} +.courseReferContainer {float:left; max-height:120px;margin-right:16px;margin-bottom:10px; overflow:scroll; overflow-x:hidden;} /*新个人主页框架css*/ From 7f2f2c5d40dbec858f45027f7189644598f8ef4c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 24 Aug 2015 14:53:35 +0800 Subject: [PATCH 112/119] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E9=A1=B9=E7=9B=AE=E6=9B=B4=E5=A4=9A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 3 ++- app/views/layouts/_user_projects.html.erb | 11 +++++++++++ app/views/layouts/new_base_user.html.erb | 9 ++------- app/views/users/user_projects4show.html.erb | 16 ---------------- app/views/users/user_projects4show.js.erb | 1 + public/javascripts/new_user.js | 2 +- 6 files changed, 17 insertions(+), 25 deletions(-) create mode 100644 app/views/layouts/_user_projects.html.erb delete mode 100644 app/views/users/user_projects4show.html.erb create mode 100644 app/views/users/user_projects4show.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6bdd3d6fc..2af2b9c42 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -481,7 +481,8 @@ class UsersController < ApplicationController #显示更多用户项目 def user_projects4show - + @page = params[:page].to_i + 1 + @projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5).offset(@page * 5) end def user_course_activities diff --git a/app/views/layouts/_user_projects.html.erb b/app/views/layouts/_user_projects.html.erb new file mode 100644 index 000000000..864b6888c --- /dev/null +++ b/app/views/layouts/_user_projects.html.erb @@ -0,0 +1,11 @@ +<% projects.each do |project|%> +
  • + <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey"%> +
  • +<% end %> +<% if projects.size == 5%> +
  • + + +
  • +<% end%> \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 15af50332..4d85ef1b3 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -113,13 +113,8 @@
      - <%# projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%> - <%#= render :partial => 'layouts/user_item', :locals => {:items => courses,:is_course => false} %> - <%# if projects.size == 5%> - - <%# end%> + <% projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%> + <%= render :partial => 'layouts/user_projects', :locals => {:projects => projects,:user => @user, :page => 0} %>
    diff --git a/app/views/users/user_projects4show.html.erb b/app/views/users/user_projects4show.html.erb deleted file mode 100644 index 3c709bd5d..000000000 --- a/app/views/users/user_projects4show.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% for item in @list %> - -<% end %> diff --git a/app/views/users/user_projects4show.js.erb b/app/views/users/user_projects4show.js.erb new file mode 100644 index 000000000..c19a79c81 --- /dev/null +++ b/app/views/users/user_projects4show.js.erb @@ -0,0 +1 @@ +$("#user_show_more_project").replaceWith("<%= escape_javascript( render :partial => 'layouts/user_projects',:locals => {:projects => @projects,:user => @user, :page => @page} )%>"); diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index ae94e48a7..e89b7374b 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -41,7 +41,7 @@ function show_more_course(url){ function show_more_project(url){ $.get( url, - { brief_introduction: $("#user_brief_introduction_edit").val() }, + { page: $("#project_page_num").val() }, function (data) { } From fe91442c96ee3e07ffd4565cb3ccfb36050b538a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 24 Aug 2015 15:18:07 +0800 Subject: [PATCH 113/119] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=B7=B2=E5=85=B3=E9=97=AD=E8=AF=BE=E7=A8=8B=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_user_courses.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index 393e3d48f..d5f0507f1 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -1,6 +1,6 @@ <% courses.each do |course|%>
  • - <%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey"%> + <%= link_to (course_endTime_timeout?(course) ? "[已关闭] #{course.name}" : "#{course.name}").html_safe, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey"%>
  • <% end %> From dabef542fecb985a60473127cd8cab81961aa200 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 24 Aug 2015 15:30:11 +0800 Subject: [PATCH 114/119] =?UTF-8?q?=E6=9B=B4=E6=96=B0css=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=AE=9E=E7=8E=B0=E6=9C=AA=E7=99=BB=E9=99=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=97=B6=E9=9D=99=E6=80=81=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_logined_header.html.erb | 2 +- app/views/layouts/_unlogin_header.html.erb | 60 +++++---- public/stylesheets/new_public.css | 146 ++++++++++++++------- 3 files changed, 134 insertions(+), 74 deletions(-) diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index cb93ca7fa..c91b452dc 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -18,7 +18,7 @@
    -
    + -