run rubocop

This commit is contained in:
aqua 2025-05-12 15:31:38 -04:00
parent 610abcdfd6
commit a6711a9a55
13 changed files with 31 additions and 36 deletions

View file

@ -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 ]

View file

@ -15,5 +15,4 @@ class AdminController < ApplicationController
redirect_to root_path
end
end
end

View file

@ -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."

View file

@ -8,4 +8,4 @@ class InfoController < ApplicationController
@content = "<p>Markdown file not found.</p>"
end
end
end
end

View file

@ -1,5 +1,4 @@
class LaunchpadController < ApplicationController
def show
end
end

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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
end

View file

@ -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

View file

@ -13,4 +13,4 @@ class UserPrize < ApplicationRecord
def generate_tracking_number
"TN-#{SecureRandom.alphanumeric(10).upcase}"
end
end
end

View file

@ -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")

View file

@ -9,4 +9,4 @@ module MarkdownHandler
end
end
ActionView::Template.register_template_handler :md, MarkdownHandler
ActionView::Template.register_template_handler :md, MarkdownHandler