From 720c75478a1912f3779ab62103a4f534efe617df Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 10 Jul 2014 10:15:20 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=8F=AF=E4=BC=A0=E9=9D=9E=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=96=87=E4=BB=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/avatar/_avatar_form.html.erb | 3 +++ config/configuration.yml | 1 + config/locales/zh.yml | 1 + lib/redmine/configuration.rb | 3 ++- public/javascripts/avatars.js | 26 +++++++++++++++++++++++++- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/views/avatar/_avatar_form.html.erb b/app/views/avatar/_avatar_form.html.erb index 272397c62..a880f32aa 100644 --- a/app/views/avatar/_avatar_form.html.erb +++ b/app/views/avatar/_avatar_form.html.erb @@ -45,6 +45,7 @@ <%= l(:button_upload_photo) %> + <%= file_field_tag 'avatar[image]', :id => nil, @@ -57,6 +58,8 @@ :max_file_size => Setting.attachment_max_size.to_i.kilobytes, :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :file_type => Redmine::Configuration['pic_types'].to_s, + :type_support_message => l(:error_pic_type), :upload_path => upload_avatar_path(:format => 'js'), :description_placeholder => nil ,# l(:label_optional_description) :source_type => source.class.to_s, diff --git a/config/configuration.yml b/config/configuration.yml index a98ea3391..4bdd279aa 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -199,6 +199,7 @@ default: # Maximum number of simultaneous AJAX uploads #max_concurrent_ajax_uploads: 2 + #pic_types: "bmp,jpeg,jpg,png,gif" # specific configuration options for production environment # that overrides the default ones diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 1b3774d65..716889bbc 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1217,6 +1217,7 @@ zh: button_export: 导出 label_export_options: "%{export_format} 导出选项" error_attachment_too_big: 该文件无法上传。超过文件大小限制 (%{max_size}) + error_pic_type: "仅支持如下图片格式:" notice_failed_to_save_time_entries: "无法保存下列所选取的 %{total} 个项目中的 %{count} 工时: %{ids}。" label_x_issues: zero: 0 问题 diff --git a/lib/redmine/configuration.rb b/lib/redmine/configuration.rb index 6723b777e..ba8e91294 100644 --- a/lib/redmine/configuration.rb +++ b/lib/redmine/configuration.rb @@ -21,7 +21,8 @@ module Redmine # Configuration default values @defaults = { 'email_delivery' => nil, - 'max_concurrent_ajax_uploads' => 2 + 'max_concurrent_ajax_uploads' => 2, + 'pic_types' => "bmp,jpeg,jpg,png,gif" } @config = nil diff --git a/public/javascripts/avatars.js b/public/javascripts/avatars.js index 24bc1ee1c..db9a2255e 100644 --- a/public/javascripts/avatars.js +++ b/public/javascripts/avatars.js @@ -140,10 +140,34 @@ function uploadAndAttachFiles(files, inputEl) { if (sizeExceeded) { window.alert(maxFileSizeExceeded); } else { - $.each(files, function() {addFile(inputEl, this, true);}); + uploadAndTypeFiles(files,inputEl); + //$.each(files, function() {addFile(inputEl, this, true);}); } } +function uploadAndTypeFiles(files, inputEl) { + + var enableType = $(inputEl).data('file-type'); + var typeSupportrdMessage = $(inputEl).data('type-support-message'); + if (enableType == null || enableType.trim() == "") + { + $.each(files, function() {addFile(inputEl, this, true);}); + return; + } + var typeSupported = false; + $.each(files, function() { + var a = this.name.split('.'); + var type = a[a.length-1]; + var rs = enableType.indexOf(type); + if(rs >= 0) {typeSupported = true } + }); + if (typeSupported) { + $.each(files, function() {addFile(inputEl, this, true);}); + } else { + window.alert(typeSupportrdMessage + enableType); + } +} + function handleFileDropEvent(e) { $(this).removeClass('fileover'); From b4dd8409eb57b17bce852226dcabaeceb8361a38 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 10 Jul 2014 17:38:04 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=89=98=E7=AE=A1=E5=B9=B3=E5=8F=B0=E9=A6=96=E9=A1=B5=E5=AE=9A?= =?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 30 +++++++++++++++++++ app/controllers/welcome_controller.rb | 2 +- app/helpers/application_helper.rb | 7 ++++- app/models/first_page.rb | 3 ++ app/views/admin/first_page_made.html.erb | 28 +++++++++++++++++ app/views/users/_score_new_index.html.erb | 6 ++-- app/views/users/_show_new_score.html.erb | 12 ++++---- app/views/users/_user_score.html.erb | 2 +- app/views/users/show_new_score.html.erb | 12 ++++---- app/views/welcome/index.html.erb | 12 ++++++-- config/locales/zh.yml | 5 ++++ config/routes.rb | 1 + .../20140710071720_create_first_pages.rb | 17 +++++++++++ db/schema.rb | 10 ++++++- lib/redmine.rb | 1 + test/fixtures/first_pages.yml | 11 +++++++ test/unit/first_page_test.rb | 7 +++++ 17 files changed, 144 insertions(+), 22 deletions(-) create mode 100644 app/models/first_page.rb create mode 100644 app/views/admin/first_page_made.html.erb create mode 100644 db/migrate/20140710071720_create_first_pages.rb create mode 100644 test/fixtures/first_pages.yml create mode 100644 test/unit/first_page_test.rb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 2a3ce15d8..152fb059e 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -234,4 +234,34 @@ class AdminController < ApplicationController format.api end end + + #首页定制 + def first_page_made + if request.get? + @first_page = FirstPage.all.first + elsif request.post? + @first_page = FirstPage.all.first + @first_page.web_title = params[:web_title] + @first_page.description = params[:description] + @first_page.title = params[:title] + if @first_page.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to admin_first_page_made_path + } + format.api { render_api_ok } + end + else + respond_to do |format| + format.html { + first_page_made + render :action => 'first_page_made' + } + format.api { render_validation_errors(@first_page) } + end + end + end + + end end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index bf18332df..0920d2e42 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -21,7 +21,7 @@ class WelcomeController < ApplicationController before_filter :entry_select, :only => [:index] def index - + @first_page = FirstPage.all.first end def robots diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c9dc4fa26..3f873a64d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -625,10 +625,15 @@ module ApplicationHelper end def html_title(*args) + first_page = FirstPage.all.first if args.empty? title = @html_title || [] title << @project.name if @project - title << Setting.app_title unless Setting.app_title == title.last + if first_page.nil? || first_page.web_title.nil? + title << Setting.app_title unless Setting.app_title == title.last + else + title << first_page.web_title unless first_page.web_title == title.last + end title.select {|t| !t.blank? }.join(' - ') else @html_title ||= [] diff --git a/app/models/first_page.rb b/app/models/first_page.rb new file mode 100644 index 000000000..8d8bbcff6 --- /dev/null +++ b/app/models/first_page.rb @@ -0,0 +1,3 @@ +class FirstPage < ActiveRecord::Base + attr_accessible :description, :title, :web_title +end diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb new file mode 100644 index 000000000..9e863d813 --- /dev/null +++ b/app/views/admin/first_page_made.html.erb @@ -0,0 +1,28 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %> +

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> +
+

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index 43687aa78..0f5d96a45 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -28,7 +28,7 @@
= <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> + <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
-
= <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_f %> - + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
-
= <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_f %>
+
= <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_i %> + + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
+
= <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_i %>
diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index c5f15694e..fddca46ac 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -38,7 +38,7 @@ - +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
@@ -49,23 +49,23 @@ <%= link_to l(:label_user_score) , {:controller => 'users', :action => 'score_new_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.total_score).to_f %> + <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= link_to l(:label_user_score_of_collaboration), {:controller => 'users',:action => 'topic_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= link_to l(:label_user_score_of_influence), {:controller => 'users',:action => 'project_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= link_to l(:label_user_score_of_skill), {:controller => 'users',:action => 'activity_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= link_to l(:label_user_score_of_active), {:controller => 'users',:action => 'influence_new_score_index', :remote => true} %> : - <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/users/_user_score.html.erb b/app/views/users/_user_score.html.erb index d047c11d0..53f05a2dd 100644 --- a/app/views/users/_user_score.html.erb +++ b/app/views/users/_user_score.html.erb @@ -1,5 +1,5 @@ <%= l(:label_user_grade)%>: -<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_f, {:controller => 'users', +<%= link_to(format("%.2f" , user.user_score_attr.total_score).to_i, {:controller => 'users', :action => 'show_new_score', :remote => true, :id => user.id diff --git a/app/views/users/show_new_score.html.erb b/app/views/users/show_new_score.html.erb index 07e82fd5f..0efae940c 100644 --- a/app/views/users/show_new_score.html.erb +++ b/app/views/users/show_new_score.html.erb @@ -53,7 +53,7 @@ - +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
@@ -64,23 +64,23 @@ <%= l(:label_user_score) %> : - <%= format("%.2f" , @user.user_score_attr.total_score).to_f %> + <%= format("%.2f" , @user.user_score_attr.total_score).to_i %>
<%= l(:label_user_score_of_collaboration) %> : - <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_i %>
<%= l(:label_user_score_of_influence) %> : - <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_i %>
<%= l(:label_user_score_of_skill) %> : - <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_i %>
<%= l(:label_user_score_of_active) %> : - <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_i %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 345f47739..ffc9706e9 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -30,13 +30,19 @@ +
- <%= image_tag '/images/transparent.png', size: "75x75" %> + + <% if get_avatar?(@first_page) %> + <%= image_tag(url_to_avatar(@first_page), size: "75x75") %> + <% else %> + <%= image_tag '/images/transparent.png', size: "75x75" %> + <% end %> +
- <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_project) %> , <%= l(:label_welcome_trustie_project_description) %> + <%= @first_page.title %> , <%= @first_page.description %>