From b020b8e13f10d32058a5a9cc92f327cb25005187 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Tue, 11 Feb 2014 14:42:12 +0800 Subject: [PATCH] ntu_ga --- app/assets/javascripts/orbit-bar-search.js | 10 +++++ app/assets/stylesheets/member_select.css | 1 - app/controllers/sessions_controller.rb | 40 +++++++++++++++++++ app/helpers/application_helper.rb | 11 +++-- .../member_selects/_modal_select.html.erb | 4 +- .../member_selects/_promoter_front.html.erb | 14 +++++++ .../member_selects/_selection_box.html.erb | 1 + app/views/devise/sessions/new.html.erb | 7 ++-- app/views/layouts/_right_menu.html.erb | 18 ++++++++- built_in_extensions.rb | 13 +++--- config/locales/en.yml | 1 + config/locales/ntu.en.yml | 17 ++++++++ config/locales/ntu.zh_tw.yml | 17 ++++++++ config/locales/zh_tw.yml | 1 + config/routes.rb | 5 +++ 15 files changed, 144 insertions(+), 16 deletions(-) create mode 100644 app/assets/javascripts/orbit-bar-search.js create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/views/admin/member_selects/_promoter_front.html.erb create mode 100644 config/locales/ntu.en.yml create mode 100644 config/locales/ntu.zh_tw.yml diff --git a/app/assets/javascripts/orbit-bar-search.js b/app/assets/javascripts/orbit-bar-search.js new file mode 100644 index 0000000..e0d9bf9 --- /dev/null +++ b/app/assets/javascripts/orbit-bar-search.js @@ -0,0 +1,10 @@ +$(document).ajaxStop(function() { + $('.nav').find('.dropdown').on({ + mouseleave: function() { + $(this).removeClass("open"); + }, + mouseenter: function() { + $(this).addClass("open") + } + }); +}); \ No newline at end of file diff --git a/app/assets/stylesheets/member_select.css b/app/assets/stylesheets/member_select.css index 0d4e9df..775bf93 100644 --- a/app/assets/stylesheets/member_select.css +++ b/app/assets/stylesheets/member_select.css @@ -85,7 +85,6 @@ width: auto; } - /* Check Box Card */ .checkbox-card { margin: 0; diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000..927719b --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,40 @@ +# encoding: utf-8 + +class SessionsController < Devise::SessionsController + prepend_before_filter :require_no_authentication, :only => [ :new, :create ] + + + def create + @site = Site.first + + private_key = OpenSSL::PKey::RSA.new(@site.private_key) + wresult = private_key.private_decrypt(request.params['wresult']) + + @ids = wresult.split("@") + + login_uid = @ids[0] + + resource = User.first(conditions:{user_id: login_uid}) + + if !resource.blank? + resource_name = resource.class.to_s.downcase + sign_in(resource_name, resource) + session[:user_id_type] = "myntu" + redirect_to after_sign_in_path_for(resource) + else + flash[:error] = "很抱歉,您無此權限或帳號登入本站,請洽本站管理員
Sorry, you don't have the account or authority to login. Please contact the website administrator." + redirect_to :root + end + end + + def destroy + @user_id_type = session[:user_id_type] + sign_out + if @user_id_type == "myntu" + redirect_to "https://adfs.ntu.edu.tw/adfs/ls/?wa=wsignout1.0&wreply=https://galogin.ntu.edu.tw" + else + redirect_to root_path + end + end + +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8bd19c1..e6f5a6b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -194,8 +194,8 @@ module ApplicationHelper stylesheets << "\n" stylesheets << "\n" if page.design.css_reset # stylesheets << "\n" - # stylesheets << "\n" - stylesheets << "\n" + # stylesheets << "\n" + stylesheets << "\n" stylesheets << "\n" if page.design.css_default theme = page.design.themes.detect{ |d| d.id == page.theme_id } stylesheets << "\n" if theme @@ -204,9 +204,12 @@ module ApplicationHelper def page_javascripts(page, edit=nil) javascripts = '' + unless edit + javascripts << "\n" + end # javascripts << "\n" # javascripts << "\n" - javascripts << "\n" + javascripts << "\n" page.design.javascripts.each do |js| javascripts << "" end @@ -303,7 +306,7 @@ module ApplicationHelper # NTU link def get_link(site_number) - "http://#{request.host}:2#{site_number}00" + "http://#{site_number}.#{request.domain(3)}" end def sortable(column, title = nil, options = {}) diff --git a/app/views/admin/member_selects/_modal_select.html.erb b/app/views/admin/member_selects/_modal_select.html.erb index e8d14e7..99f4f02 100644 --- a/app/views/admin/member_selects/_modal_select.html.erb +++ b/app/views/admin/member_selects/_modal_select.html.erb @@ -28,7 +28,7 @@
<%= submit_tag t(:submit), class: "btn btn-primary" %> - <%= hidden_field_tag field, @field %> + <%= hidden_field_tag field, @field %>
<% end %> @@ -54,7 +54,7 @@
<%= submit_tag t(:submit), class: "btn btn-primary" %> - <%= hidden_field_tag field, @field %> + <%= hidden_field_tag field, @field %>
<% end %> diff --git a/app/views/admin/member_selects/_promoter_front.html.erb b/app/views/admin/member_selects/_promoter_front.html.erb new file mode 100644 index 0000000..f8bec0f --- /dev/null +++ b/app/views/admin/member_selects/_promoter_front.html.erb @@ -0,0 +1,14 @@ +<% unless users.blank? %> +
+

<%= t(:promoter) %>:

+ +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/member_selects/_selection_box.html.erb b/app/views/admin/member_selects/_selection_box.html.erb index 428cc04..837bc4d 100644 --- a/app/views/admin/member_selects/_selection_box.html.erb +++ b/app/views/admin/member_selects/_selection_box.html.erb @@ -1,4 +1,5 @@ <% content_for :page_specific_javascript do -%> + <%= javascript_include_tag "member-selection" %> <%= javascript_include_tag "lib/jquery.nanoscroller" %> <%= javascript_include_tag "lib/checkbox.card" %> <% end -%> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 1b77fce..476b61f 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -12,10 +12,11 @@ - +
diff --git a/app/views/layouts/_right_menu.html.erb b/app/views/layouts/_right_menu.html.erb index e90dab1..d61751d 100644 --- a/app/views/layouts/_right_menu.html.erb +++ b/app/views/layouts/_right_menu.html.erb @@ -7,6 +7,16 @@
+ + +
  • <%= link_to content_tag(:i, nil, class: 'icons-screen') + ' ' + t(:desktop), desktop_path, tabindex: '-1' %>
  • <% end %> -
  • <%= link_to content_tag(:i, nil, class: 'icons-logout') + ' ' + t(:logout), destroy_user_session_path, tabindex: '-1' %>
  • +
  • <%= link_to content_tag(:i, nil, class: 'icons-logout') + ' ' + t(:logout), user_logout_path, tabindex: '-1' %>
  • <%= t(:help) %>
  • @@ -50,6 +60,12 @@