Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Student home: if cookie, link to /home for sign-in/header/hamburger #16393

Merged
merged 1 commit into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions dashboard/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@ def health_check
GALLERY_PER_PAGE = 5

def index
redirect_to '/courses'
if request.cookies['pm'] == 'student_homepage'
redirect_to '/home'
else
redirect_to '/courses'
end
end

# Show /home for teachers.
# Show /home for teachers. (And for students if cookie set appropriately.)
#
# Signed out: redirect to code.org
# Signed in teacher or have student_homepage cookie: render this page
# Signed in student: redirect to studio.code.org/courses
Expand Down
2 changes: 2 additions & 0 deletions dashboard/app/views/layouts/_header.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
hamburger_options[:language] = request.language
hamburger_options[:show_gallery] = true
hamburger_options[:loc_prefix] = "nav.header."
hamburger_options[:page_mode] = request.cookies['pm']

header_contents_options = {}
header_contents_options[:user_type] = user_type
header_contents_options[:language] = request.language
header_contents_options[:loc_prefix] = "nav.header."
header_contents_options[:page_mode] = request.cookies['pm']

should_show_progress = script_level || @stage_extras

Expand Down
12 changes: 10 additions & 2 deletions lib/cdo/hamburger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def self.get_hamburger_contents(options)
{title: "project_gallery", url: CDO.studio_url("/projects"), id: "hamburger-student-projects"}
].each do |entry|
entry[:title] = I18n.t("#{loc_prefix}#{entry[:title]}")
end.freeze
end
if options[:page_mode] == "student_homepage"
student_entries.unshift({title: I18n.t("#{loc_prefix}home"), url: CDO.studio_url("/home"), id: "hamburger-student-home"})
end
student_entries.freeze

signed_out_entries = [
{title: "courses", url: CDO.studio_url("/courses")},
Expand Down Expand Up @@ -290,10 +294,14 @@ def self.get_header_contents(options)
{title: I18n.t("#{loc_prefix}professional_learning"), url: CDO.studio_url("/my-professional-learning"), id: "header-teacher-professional-learning"}
]
elsif options[:user_type] == "student"
[
contents = [
{title: I18n.t("#{loc_prefix}courses"), url: CDO.studio_url("/courses"), id: "header-student-courses"},
{title: I18n.t("#{loc_prefix}project_gallery"), url: CDO.studio_url("/projects"), id: "header-student-projects"}
]
if options[:page_mode] == "student_homepage"
contents.unshift({title: I18n.t("#{loc_prefix}home"), url: CDO.studio_url("/home"), id: "header-student-home"})
end
contents
elsif options[:language] == "en"
[
{title: I18n.t("#{loc_prefix}learn"), url: CDO.code_org_url("/student"), id: "header-en-learn"},
Expand Down
2 changes: 2 additions & 0 deletions pegasus/sites.v3/code.org/views/header2.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
hamburger_options[:language] = request.language
hamburger_options[:show_gallery] = true
hamburger_options[:loc_prefix] = "header_"
hamburger_options[:page_mode] = request.cookies['pm']

header_contents_options = {}
header_contents_options[:user_type] = user_type
header_contents_options[:language] = request.language
header_contents_options[:loc_prefix] = "header_"
header_contents_options[:page_mode] = request.cookies['pm']

require 'cdo/hamburger'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
%img#logo{:src=>'/images/logo.png'}

- if request.language == "en"
= view :hamburger, user_type: user_type, level: nil, script_level: nil, language: request.language,show_gallery: false, loc_prefix: "header_"
= view :hamburger, user_type: user_type, level: nil, script_level: nil, language: request.language, show_gallery: false, loc_prefix: "header_"
2 changes: 1 addition & 1 deletion shared/haml/hamburger.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:ruby
options = { level: level, script_level: script_level, language: language, user_type: user_type, loc_prefix: loc_prefix, request: request }
options = { level: level, script_level: script_level, language: language, user_type: user_type, loc_prefix: loc_prefix, request: request, page_mode: page_mode }

contents = Hamburger.get_hamburger_contents(options)

Expand Down