diff --git a/Gemfile b/Gemfile index bf86b10..8e1fa4d 100644 --- a/Gemfile +++ b/Gemfile @@ -84,4 +84,4 @@ gem "rails_live_reload" gem "awesome_print", "~> 1.9" # Environment variables -gem "dotenv-rails", groups: [:development, :test] +gem "dotenv-rails", groups: [ :development, :test ] diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index cca8a00..f41d2ea 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -15,5 +15,4 @@ class AdminController < ApplicationController redirect_to root_path end end - end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fdc6260..27ae6a2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,7 +12,7 @@ class ApplicationController < ActionController::Base def authenticated? current_user.present? end - + def require_authentication unless authenticated? redirect_to root_path, alert: "You must be signed in to access this page." diff --git a/app/controllers/info_controller.rb b/app/controllers/info_controller.rb index 86909de..5ce0cc4 100644 --- a/app/controllers/info_controller.rb +++ b/app/controllers/info_controller.rb @@ -8,4 +8,4 @@ class InfoController < ApplicationController @content = "

Markdown file not found.

" end end -end \ No newline at end of file +end diff --git a/app/controllers/launchpad_controller.rb b/app/controllers/launchpad_controller.rb index d5ff9d1..87bd123 100644 --- a/app/controllers/launchpad_controller.rb +++ b/app/controllers/launchpad_controller.rb @@ -1,5 +1,4 @@ class LaunchpadController < ApplicationController def show - end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 256f14f..97be089 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,6 +1,6 @@ class ProjectsController < ApplicationController - require 'yaml' - require 'redcarpet' + require "yaml" + require "redcarpet" def index @projects = Project.all @@ -18,41 +18,41 @@ class ProjectsController < ApplicationController def load_projects projects = [] - Dir.glob(Rails.root.join('content/projects/*/*/journal.md')).each do |file| + Dir.glob(Rails.root.join("content/projects/*/*/journal.md")).each do |file| content = File.read(file) metadata, _ = parse_frontmatter(content) - + # Extract repo and project name from path - path_parts = file.split('/') + path_parts = file.split("/") repo = path_parts[-3] project_name = path_parts[-2] - + projects << { repo: repo, project_name: project_name, - title: metadata['title'], - author: metadata['author'], - description: metadata['description'], - created_at: metadata['created_at'] + title: metadata["title"], + author: metadata["author"], + description: metadata["description"], + created_at: metadata["created_at"] } end projects.sort_by { |p| p[:created_at] }.reverse end def load_project(repo, project_name) - file_path = Rails.root.join('content/projects', repo, project_name, 'journal.md') + file_path = Rails.root.join("content/projects", repo, project_name, "journal.md") return nil unless File.exist?(file_path) content = File.read(file_path) metadata, markdown_content = parse_frontmatter(content) - + { repo: repo, project_name: project_name, - title: metadata['title'], - author: metadata['author'], - description: metadata['description'], - created_at: metadata['created_at'], + title: metadata["title"], + author: metadata["author"], + description: metadata["description"], + created_at: metadata["created_at"], content: render_markdown(markdown_content) } end @@ -61,9 +61,9 @@ class ProjectsController < ApplicationController if content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m metadata = YAML.safe_load($1) content = content[$2.size..-1] - [metadata, content] + [ metadata, content ] else - [{}, content] + [ {}, content ] end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e4280c2..7310329 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,6 @@ class UsersController < ApplicationController - before_action :set_user, only: %i[ show edit update ] - before_action :require_authentication, only: [:show, :edit, :update, :prize_box] + before_action :require_authentication, only: [ :show, :edit, :update, :prize_box ] # def index @@ -34,12 +33,12 @@ class UsersController < ApplicationController render :edit, status: :unprocessable_entity end end - + def prize_box # No need to set anything special - the view will use current_user end - private + private def set_user @user = User.find(params[:id]) @@ -48,5 +47,4 @@ class UsersController < ApplicationController def user_params params.expect(user: [ :email, :first_name, :last_name, :github, :username ]) end - end diff --git a/app/mailers/session_mailer.rb b/app/mailers/session_mailer.rb index f5f5eab..f9ae957 100644 --- a/app/mailers/session_mailer.rb +++ b/app/mailers/session_mailer.rb @@ -4,7 +4,7 @@ class SessionMailer < ApplicationMailer # include Rails.application.routes.url_helpers # en.session_mailer.login_token.subject - def login_code(email:, login_code:) + def login_code(email:, login_code:) @greeting = "Hi" @login_code = login_code @signin_link = exchange_code_url(code: @login_code) diff --git a/app/models/prize.rb b/app/models/prize.rb index 0d670aa..3701624 100644 --- a/app/models/prize.rb +++ b/app/models/prize.rb @@ -2,4 +2,4 @@ class Prize < ApplicationRecord has_one_attached :image # Stores prize images has_many :user_prizes has_many :users, through: :user_prizes -end \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index 70b764a..d3deb15 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,6 @@ class User < ApplicationRecord - validates :email, uniqueness: true, presence: true, allow_nil: false - + has_many :posts, dependent: :destroy has_many :projects, dependent: :destroy has_many :user_prizes, dependent: :destroy @@ -10,7 +9,7 @@ class User < ApplicationRecord def name "#{first_name} #{last_name}" end - + def prize_box user_prizes.where(claimed: false) end diff --git a/app/models/user_prize.rb b/app/models/user_prize.rb index 06917f0..82088a9 100644 --- a/app/models/user_prize.rb +++ b/app/models/user_prize.rb @@ -13,4 +13,4 @@ class UserPrize < ApplicationRecord def generate_tracking_number "TN-#{SecureRandom.alphanumeric(10).upcase}" end -end \ No newline at end of file +end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index e6b8689..fb1b6cb 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,7 +3,7 @@ # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = "1.0" -Rails.application.config.assets.precompile += %w( *.otf *.ttf *.woff *.woff2 ) +Rails.application.config.assets.precompile += %w[ *.otf *.ttf *.woff *.woff2 ] Rails.application.config.assets.paths << Rails.root.join("app", "assets", "fonts") diff --git a/config/initializers/markdown.rb b/config/initializers/markdown.rb index efb2711..9c1af8a 100644 --- a/config/initializers/markdown.rb +++ b/config/initializers/markdown.rb @@ -9,4 +9,4 @@ module MarkdownHandler end end -ActionView::Template.register_template_handler :md, MarkdownHandler \ No newline at end of file +ActionView::Template.register_template_handler :md, MarkdownHandler