From b1f363cd62958d8a66632671d604bb03199c30c1 Mon Sep 17 00:00:00 2001 From: Debian Date: Mon, 7 Sep 2020 06:45:11 +0000 Subject: [PATCH 1/8] Dockerfile update --- Dockerfile | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38fba1095..0426bcf20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,4 @@ -# Dockerfile from -# -# https://intercityup.com/blog/how-i-build-a-docker-image-for-my-rails-app.html -# -# See more documentation at the passenger-docker GitHub repo: -# -# https://github.com/phusion/passenger-docker -# -# -FROM phusion/passenger-ruby22:0.9.15 - -MAINTAINER Autolab Development Team "autolab-dev@andrew.cmu.edu" +FROM phusion/passenger-ruby26 # Set correct environment variables. ENV HOME /root @@ -18,11 +7,11 @@ ENV HOME /root CMD ["/sbin/my_init"] # Start Nginx / Passenger -RUN rm -f /etc/service/nginx/down +#RUN rm -f /etc/service/nginx/down # Remove the default site -RUN rm /etc/nginx/sites-enabled/default +#RUN rm /etc/nginx/sites-enabled/default # Add the nginx info -ADD docker/nginx.conf /etc/nginx/sites-enabled/webapp.conf +#ADD docker/nginx.conf /etc/nginx/sites-enabled/webapp.conf # Prepare folders RUN mkdir /home/app/webapp @@ -46,8 +35,8 @@ RUN mkdir -p /home/app/webapp/log && \ chmod 0664 /home/app/webapp/log/production.log # precompile the Rails assets -WORKDIR /home/app/webapp -RUN RAILS_ENV=production bundle exec rake assets:precompile +#WORKDIR /home/app/webapp +#RUN RAILS_ENV=production bundle exec rake assets:precompile # Clean up APT when done. RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From addba545b9ea16a9f08c852129de626bf6e4540c Mon Sep 17 00:00:00 2001 From: Brandon Franzke Date: Thu, 10 Sep 2020 08:02:48 +0000 Subject: [PATCH 2/8] cleanup Dockerfile --- Dockerfile | 17 +---------------- Gemfile | 2 ++ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0426bcf20..c07a99e0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,16 +3,6 @@ FROM phusion/passenger-ruby26 # Set correct environment variables. ENV HOME /root -# Use baseimage-docker's init system. -CMD ["/sbin/my_init"] - -# Start Nginx / Passenger -#RUN rm -f /etc/service/nginx/down -# Remove the default site -#RUN rm /etc/nginx/sites-enabled/default -# Add the nginx info -#ADD docker/nginx.conf /etc/nginx/sites-enabled/webapp.conf - # Prepare folders RUN mkdir /home/app/webapp @@ -25,9 +15,6 @@ RUN bundle install # Add the rails app ADD . /home/app/webapp -# Move the database configuration into place -ADD config/database.docker.yml /home/app/webapp/config/database.yml - # Create the log files RUN mkdir -p /home/app/webapp/log && \ touch /home/app/webapp/log/production.log && \ @@ -35,9 +22,7 @@ RUN mkdir -p /home/app/webapp/log && \ chmod 0664 /home/app/webapp/log/production.log # precompile the Rails assets -#WORKDIR /home/app/webapp -#RUN RAILS_ENV=production bundle exec rake assets:precompile +WORKDIR /home/app/webapp # Clean up APT when done. RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - diff --git a/Gemfile b/Gemfile index 3de084e3c..dbf0c70ab 100644 --- a/Gemfile +++ b/Gemfile @@ -134,3 +134,5 @@ gem "jstz-rails3-plus", ">= 1.0" # For getting file types gem 'mimemagic', '>= 0.3.5' + +gem 'tzinfo-data' From 571c6a971dfbf8af8a66e5c541c9776e1b05100b Mon Sep 17 00:00:00 2001 From: Debian Date: Fri, 11 Sep 2020 21:50:50 +0000 Subject: [PATCH 3/8] precompile and include bootstrap-datetimepicker --- .../stylesheets/{application.scss => application.scss.erb} | 2 +- config/initializers/assets.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename app/assets/stylesheets/{application.scss => application.scss.erb} (84%) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss.erb similarity index 84% rename from app/assets/stylesheets/application.scss rename to app/assets/stylesheets/application.scss.erb index 5e6229e31..c8cd8a86e 100755 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss.erb @@ -5,4 +5,4 @@ $secondary-color: #dd2222 !default; @import "bootstrap-sprockets"; /* Deviation from official README due to https://github.com/TrevorS/bootstrap3-datetimepicker-rails/issues/48 */ -@import "bootstrap-datetimepicker.css"; \ No newline at end of file +@import "<%= asset_path 'bootstrap-datetimepicker.css' %>"; diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index e9aefe222..94c9ea13c 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -36,6 +36,7 @@ Rails.application.config.assets.precompile += %w( eventdrops.css ) Rails.application.config.assets.precompile += %w( metricsgraphics.css ) Rails.application.config.assets.precompile += %w( users.css.scss ) +Rails.application.config.assets.precompile += %w( bootstrap-datetimepicker.css ) Rails.application.config.assets.precompile += %w( annotations.js ) Rails.application.config.assets.precompile += %w( chroma.min.js ) @@ -71,3 +72,4 @@ Rails.application.config.assets.precompile += %w( jquery.stickytableheaders.js ) Rails.application.config.assets.precompile += %w( pdf.js ) Rails.application.config.assets.precompile += %w( table_floating_header.js ) +Rails.application.config.assets.precompile += %w( bootstrap-datetimepicker.js ) From 2d289735f89f9846523a4107d7e195b278e29856 Mon Sep 17 00:00:00 2001 From: Brandon Franzke Date: Fri, 19 Feb 2021 06:50:52 +0000 Subject: [PATCH 4/8] read autograder feedback file with binary to allow unicode/utf-8/etc --- app/helpers/assessment_autograde_core.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/assessment_autograde_core.rb b/app/helpers/assessment_autograde_core.rb index ed24c2f31..ba133775d 100644 --- a/app/helpers/assessment_autograde_core.rb +++ b/app/helpers/assessment_autograde_core.rb @@ -310,7 +310,7 @@ def autogradeDone(submissions, feedback) feedback_file = File.join(ass_dir, @assessment.handin_directory, filename) COURSE_LOGGER.log("Looking for Feedbackfile:" + feedback_file) - File.open(feedback_file, "w") do |f| + File.open(feedback_file, "wb") do |f| f.write(feedback) end end From afbe07e506a5e5c88456efdc08f8d7b52da37ee4 Mon Sep 17 00:00:00 2001 From: Brandon Franzke Date: Wed, 5 Jan 2022 12:12:46 +0000 Subject: [PATCH 5/8] remove double tzinfo-data Gem --- Gemfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 91b6185b8..573629285 100644 --- a/Gemfile +++ b/Gemfile @@ -152,9 +152,7 @@ gem 'sprockets-rails', '>=3.2.1' gem "jstz-rails3-plus", ">= 1.0" # For getting file types -gem 'mimemagic', '>= 0.4.2' - -gem 'tzinfo-data' +gem 'mimemagic', '>= 0.3.7' # For encrypting API tokens gem 'lockbox' From 4ff61111b1a503839281b0b2e529358549c07a8e Mon Sep 17 00:00:00 2001 From: Brandon Franzke Date: Thu, 17 Aug 2023 07:52:08 +0000 Subject: [PATCH 6/8] remove precompile from Docker build (handled later) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 067865015..50b7b8ec1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,7 +60,7 @@ RUN chown -R app:app . # precompile the Rails assets ENV SECRET_KEY_BASE="ekz0nrn_DPG6ucv5ukw" -RUN RAILS_ENV=production bundle exec rails assets:precompile +#RUN RAILS_ENV=production bundle exec rails assets:precompile # Clean up APT when done. USER root From 1fe0ad817f198a3c05a8842e3d1c6d27ad249276 Mon Sep 17 00:00:00 2001 From: Brandon Franzke <25210059+b-grablabs@users.noreply.github.com> Date: Thu, 25 Jan 2024 03:11:58 -0800 Subject: [PATCH 7/8] add minimal user portal to override existing github Oauth-token (e.g. personal access token, PAT) --- app/controllers/users_controller.rb | 21 +++++++++++++++++++-- app/views/users/github_update.erb | 13 +++++++++++++ app/views/users/show.html.erb | 6 ++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100755 app/views/users/github_update.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e187c5409..35a77a46a 100755 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,8 +5,9 @@ class UsersController < ApplicationController skip_before_action :update_persistent_announcements before_action :set_gh_oauth_client, only: [:github_oauth, :github_oauth_callback] before_action :set_user, - only: [:github_oauth, :github_revoke, :lti_launch_initialize, - :lti_launch_link_course] + only: [:github_oauth, :github_revoke, + :show_github_update_form, :submit_github_update_form, + :lti_launch_initialize, :lti_launch_link_course] # GET /users action_auth_level :index, :student @@ -249,6 +250,22 @@ def lti_launch_link_course flash[:success] = "#{course.name} successfully linked." redirect_to(course) end + + action_auth_level :github_update, :student + def show_github_update_form + @github_integration = GithubIntegration.find_by(user_id: @user.id) + render('github_update') + end + + action_auth_level :github_update_form, :student + def submit_github_update_form + github_integration = GithubIntegration.find_by(user_id: @user.id) + + access_token = params[:access_token] + github_integration.update!(access_token:) + flash[:success] = "Updated Github Token" + redirect_to(user_path) + end action_auth_level :github_oauth, :student def github_oauth diff --git a/app/views/users/github_update.erb b/app/views/users/github_update.erb new file mode 100755 index 000000000..d98d88cf6 --- /dev/null +++ b/app/views/users/github_update.erb @@ -0,0 +1,13 @@ +<% @title = "Github Access Token" %> + +

Github Update Access Token

+<% if @github_integration %> + <%= form_with url: github_update_user_path do |form| %> +
+ <%= form.text_field :access_token, required: true %> + <%= form.label :access_token, "Access Token" %> + Helpful description here +
+ <%= form.submit "Update Token", { class: "btn primary" } %> + <% end %> +<% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c9d20bf76..b7a2ab1ff 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -63,6 +63,12 @@ <% end %> <% if GithubIntegration.connected %> <% if @user.github_integration && @user.github_integration.is_connected %> + <%= link_to github_update_user_path(@user) do %> + + Update Github Token + + <% end %> + <%= link_to github_revoke_user_path(@user), data: { method: "post" } do %> Revoke Github Token From 6c2033199f6fe5421e4ba66ae76bd7e3edcd568f Mon Sep 17 00:00:00 2001 From: Brandon Franzke <25210059+b-grablabs@users.noreply.github.com> Date: Thu, 25 Jan 2024 03:17:40 -0800 Subject: [PATCH 8/8] initial github integration by personal tokens (PAT) --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index f77d186d3..29380170a 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -79,6 +79,8 @@ get "lti_launch_initialize", on: :member post "lti_launch_link_course", on: :member post "github_revoke", on: :member + get "github_update", on: :member, to: 'users#show_github_update_form' + post 'github_update', on: :member, to: 'users#submit_github_update_form' get "github_oauth_callback", on: :collection match "update_password_for_user", on: :member, via: [:get, :put] post "change_password_for_user", on: :member