From 818c58c1eed986faa2e41d4ed203ad04dbcfc539 Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Tue, 26 Jun 2012 17:46:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=20for=20=E6=96=B0=E8=81=9E=E8=88=87?= =?UTF-8?q?=E5=85=AC=E5=91=8AQA=20=091.8.=E6=96=B0=E8=81=9E=E6=88=96?= =?UTF-8?q?=E5=85=AC=E5=91=8A=E7=9A=84=E3=80=8C=E6=AA=94=E6=A1=88=E5=AE=A4?= =?UTF-8?q?=E3=80=8D=E4=B8=8A=E5=82=B3=E5=9C=96=E7=89=87=E5=BE=8C=E5=86=8D?= =?UTF-8?q?=E8=A1=8C=E7=B7=A8=E8=BC=AF=E6=99=82=EF=BC=8C=E5=9C=96=E7=89=87?= =?UTF-8?q?=E7=84=A1=E6=B3=95=E6=AD=A3=E5=B8=B8=E9=A1=AF=E7=A4=BA=EF=BC=88?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E5=8F=AF=E4=BB=A5=E6=AD=A3=E5=B8=B8=E8=A2=AB?= =?UTF-8?q?=E7=B7=A8=E8=BC=AF=E8=AA=BF=E6=95=B4=E4=B8=A6=E6=96=BC=E5=89=8D?= =?UTF-8?q?=E5=8F=B0=E9=A1=AF=E7=A4=BA=EF=BC=89=20=092.add=20=20=E4=B8=8A?= =?UTF-8?q?=E5=82=B3=E6=AA=94=E6=A1=88=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?= =?UTF-8?q?:=203MB=20=093.=E5=85=AC=E5=91=8A=E7=9A=84=E7=99=BC=E4=BD=88?= =?UTF-8?q?=E5=96=AE=E4=BD=8D=E7=82=BA=E4=BD=95=E6=98=AF=E9=A1=AF=E7=A4=BA?= =?UTF-8?q?=E5=96=AE=E4=BD=8D=E4=BB=A3=E7=A2=BC=EF=BC=9AM00=EF=BC=9F?= =?UTF-8?q?=E6=87=89=E9=A1=AF=E7=A4=BA=E7=99=BC=E5=B8=83=E5=96=AE=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/gridfs_controller.rb | 2 +- app/controllers/sessions_controller.rb | 2 +- config/locales/en.yml | 5 +++- config/locales/zh_tw.yml | 3 ++ config/routes.rb | 3 +- .../announcement/back_end/bulletins_helper.rb | 17 +++++++++++ .../news/back_end/news_bulletins_helper.rb | 3 +- .../back_end/news_bulletins/_form.html.erb | 30 +++++++++++-------- .../_form_news_bulletin_file.html.erb | 3 +- 9 files changed, 48 insertions(+), 20 deletions(-) diff --git a/app/controllers/gridfs_controller.rb b/app/controllers/gridfs_controller.rb index 4be7ec17..b7f926b1 100644 --- a/app/controllers/gridfs_controller.rb +++ b/app/controllers/gridfs_controller.rb @@ -3,7 +3,7 @@ require 'mongo' class GridfsController < ActionController::Metal def serve - gridfs_path = env["PATH_INFO"].gsub("/gridfs/", "").force_encoding("UTF-8") + gridfs_path = (params[:path]+'.'+params[:format]).gsub("/gridfs/", "").force_encoding("UTF-8") begin gridfs_file = Mongo::GridFileSystem.new(Mongoid.database).open(gridfs_path, 'r') self.response_body = gridfs_file.read diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index a6925aa4..77680e5b 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -15,7 +15,7 @@ class SessionsController < Devise::SessionsController if $nccu_ldap_connection.bind logger.info "=LDAP Binded password ok..." result =check_auth_with_ldap(login_uid,login_password) - if result #&& login_password!='' + if result && login_password!='' logger.info "==LDAP password passed..." nccu_id = get_nccu_id_from_mid_site(login_uid) resource = nccu_id.nil? ? nil : (User.first(conditions:{ nccu_ldap_uid: nccu_id })) diff --git a/config/locales/en.yml b/config/locales/en.yml index fd08be49..054d1c23 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -289,4 +289,7 @@ en: modal: close: Close preview: Preview - + sys: + not_previewable: "Preview not support" + limit_of_upload_file_size: "Upload file must be less than: %{best_size}" + diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 0eb12ba1..930f5902 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -508,3 +508,6 @@ zh_tw: modal: close: "關閉" preview: "預覽" + sys: + not_previewable: "不支援預覽" + limit_of_upload_file_size: "上傳檔案大小限制: %{best_size}" diff --git a/config/routes.rb b/config/routes.rb index 75fa6142..40e82749 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -140,7 +140,8 @@ Orbit::Application.routes.draw do } # routes for gridfs files - match "/gridfs/*path" => "gridfs#serve" + match "/gridfs/*path" => "gridfs#serve" + # match "/images/*path" => "gridfs#serve_images" # match "/admin/pages/images/*path" => "gridfs#serve_images" diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb index 88920b9e..8a67bfe7 100644 --- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -20,4 +20,21 @@ module Panel::Announcement::BackEnd::BulletinsHelper end end + def file_picture_preview_setting(file_path) + res= "" + ext = File.extname(file_path) + unless file_path.nil? + case ext + when ".jpg",".png",".gif" + #res = '' + #res.html_safe + {"data-content" => "#{image_tag file_path}" } + else + {"data-content" => t("sys.not_previewable") } + end + end + end + end \ No newline at end of file diff --git a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb index e2765c33..d448b5ff 100644 --- a/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb +++ b/vendor/built_in_modules/news/app/helpers/panel/news/back_end/news_bulletins_helper.rb @@ -14,9 +14,8 @@ module Panel::News::BackEnd::NewsBulletinsHelper def show_news_bulletin_title_at_index (news_bulletin) if news_bulletin.is_checked? - link_to news_bulletin.title[I18n.locale], panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => news_bulletin.news_bulletin_category.id) rescue '' - else + else news_bulletin.title[I18n.locale] end end diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb index 837ebffe..f3d1753b 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form.html.erb @@ -237,6 +237,8 @@
<%= hidden_field_tag 'news_bulletin_file_field_count', @news_bulletin.news_bulletin_files.count %> <%= t(:add) %> +

<%= t("sys.limit_of_upload_file_size",:best_size => '3MB') %>

+
@@ -249,10 +251,9 @@ <%= render :partial => 'form_news_bulletin_file', :object => news_bulletin_file, :locals => {:f => f, :i => i} %> <% end %> <% end %> - + - @@ -275,17 +276,20 @@ <% content_for :page_specific_javascript do %> <%= javascript_include_tag "inc/jquery.imagesloaded.js" %> <% end %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form_news_bulletin_file.html.erb b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form_news_bulletin_file.html.erb index 27867f49..da05812a 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form_news_bulletin_file.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_form_news_bulletin_file.html.erb @@ -4,7 +4,8 @@
<%= f.file_field :file %> - <%= form_news_bulletin_file.file.file ? ( link_to t(:view), form_news_bulletin_file.file.url, {:class => 'btn', :target => '_blank', :title => t(:view)} ) : '' %> + <%#= file_picture_preview_setting(form_news_bulletin_file.file.url) %> + <%= form_news_bulletin_file.file.file ? ( link_to t(:view), form_news_bulletin_file.file.url, {:class => 'for_preview btn', :target => '_blank', :title => t(:view)}.merge(file_picture_preview_setting(form_news_bulletin_file.file.url)) ) : '' %>