Skip to content

Commit

Permalink
Merge pull request #1 from rauversion/standardrb-fix
Browse files Browse the repository at this point in the history
standard rb fix/link
  • Loading branch information
michelson committed Aug 24, 2023
2 parents 7f64cb8 + 85f4609 commit 308e826
Show file tree
Hide file tree
Showing 191 changed files with 1,142 additions and 1,259 deletions.
31 changes: 13 additions & 18 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ gem "jbuilder"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"


gem "kredis", "~> 1.5"

gem "geocoder", "~> 1.8"
Expand All @@ -51,7 +50,7 @@ gem "groupdate", "~> 6.3"
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false
Expand All @@ -69,7 +68,7 @@ gem "aws-sdk-s3", "~> 1.48"
gem "friendly_id", "~> 5.4"
gem "standardrb", "~> 1.0"
# gem "active_storage_validations", "~> 0.9.8"
gem 'activestorage-validator'
gem "activestorage-validator"
gem "socialization", "~> 2.0"
gem "kaminari"
gem "store_attribute", "~> 1.0"
Expand All @@ -80,19 +79,18 @@ gem "omniauth-rails_csrf_protection"
gem "omniauth", "~> 2.0"
# gem 'omniauth-zoom'
# gem "omniauth-github"
gem 'omniauth-twitter'
gem "omniauth-twitter"
# gem 'omniauth-stripe'
gem 'omniauth-discord'
gem 'omniauth-twitch'
gem 'dotenv-rails', groups: [:development, :test]

gem "omniauth-discord"
gem "omniauth-twitch"
gem "dotenv-rails", groups: [:development, :test]

gem "ruby-openai", "~> 4.2"
gem "qdrant-ruby", "~> 0.9.2"
# gem "pgvector", "~> 0.2"

# gem "plain-rails", path: "/Users/michelson/Documents/rubyonrails/plain"
gem "plain-rails", github: "chaskiq/plain", branch: "documents" #path: "/Users/michelson/Documents/rubyonrails/plain"
gem "plain-rails", github: "chaskiq/plain", branch: "documents" # path: "/Users/michelson/Documents/rubyonrails/plain"
# gem "plain-rails", "0.1.2" #, path: "/Users/michelson/Documents/rubyonrails/plain"

# sentry
Expand All @@ -101,15 +99,12 @@ gem "sentry-ruby"
gem "sentry-rails"
gem "sentry-sidekiq"


group :development, :test do
gem "pry"
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
gem "debug", platforms: %i[mri mingw x64_mingw]
end



group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
Expand All @@ -126,16 +121,16 @@ group :test do
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
gem 'shoulda-matchers', '~> 5.0'
gem 'faker'
gem "shoulda-matchers", "~> 5.0"
gem "faker"
end

# Or, run against the main branch
# (requires main-branch versions of all related RSpec libraries)
group :development, :test do
gem "factory_bot_rails"
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'main'
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: "main"
end
end

Expand All @@ -152,8 +147,8 @@ gem "http", "~> 5.1"
gem "ruby-oembed", "~> 0.16.1"

gem "sidekiq", "~> 7.1"
gem 'sidekiq-grouping'
gem 'sidekiq-limit_fetch'
gem "sidekiq-grouping"
gem "sidekiq-limit_fetch"

gem "rubyzip", "~> 2.3"

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/api/v1/audio_direct_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def create

def direct_upload_json(blob)
blob.as_json(root: false, methods: :signed_id)
.merge(service_url: rails_blob_path(blob))
.merge(direct_upload: {
url: blob.service_url_for_direct_upload,
headers: blob.service_headers_for_direct_upload
})
.merge(service_url: rails_blob_path(blob))
.merge(direct_upload: {
url: blob.service_url_for_direct_upload,
headers: blob.service_headers_for_direct_upload
})
end
end
10 changes: 5 additions & 5 deletions app/controllers/api/v1/direct_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def create

def direct_upload_json(blob)
blob.as_json(root: false, methods: :signed_id)
.merge(service_url: rails_blob_path(blob))
.merge(direct_upload: {
url: blob.service_url_for_direct_upload,
headers: blob.service_headers_for_direct_upload
})
.merge(service_url: rails_blob_path(blob))
.merge(direct_upload: {
url: blob.service_url_for_direct_upload,
headers: blob.service_headers_for_direct_upload
})
end
end
6 changes: 2 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class ApplicationController < ActionController::Base

before_action do
ActiveStorage::Current.url_options = { protocol: request.protocol, host: request.host, port: request.port }
#ActiveStorage::Current.url_options = { protocol: "http://", host: "localhost", port: "3000" }
ActiveStorage::Current.url_options = {protocol: request.protocol, host: request.host, port: request.port}
# ActiveStorage::Current.url_options = { protocol: "http://", host: "localhost", port: "3000" }
end

before_action :set_locale
Expand All @@ -27,5 +26,4 @@ def become
redirect_to root_url, error: "not allowed"
end
end

end
34 changes: 16 additions & 18 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
class ArticlesController < ApplicationController

before_action :authenticate_user!, except: [:index, :show ]
before_action :authenticate_user!, except: [:index, :show]

def index
@articles = Post.published.order("id desc")
.with_attached_cover
.includes(user: { avatar_attachment: :blob })
.page(1).per(7)
.with_attached_cover
.includes(user: {avatar_attachment: :blob})
.page(1).per(7)

@latest_articles = Post.published.order("id desc")
.with_attached_cover
.includes(user: { avatar_attachment: :blob })
.page(2).per(7)
.with_attached_cover
.includes(user: {avatar_attachment: :blob})
.page(2).per(7)

@category = Category.friendly.find("news")
@news = Post.published.friendly.where(category_id: @category)
.with_attached_cover
.includes(user: { avatar_attachment: :blob })
.order("id desc").page(1).per(7)
.with_attached_cover
.includes(user: {avatar_attachment: :blob})
.order("id desc").page(1).per(7)
end

def new
Expand Down Expand Up @@ -56,15 +55,14 @@ def update
end

def mine

@tab = params[:tab] || "all"
case @tab
@posts = case @tab
when "published"
@posts = current_user.posts.published
current_user.posts.published
when "draft"
@posts = current_user.posts.draft
current_user.posts.draft
else
@posts = current_user.posts
current_user.posts
end

@posts.page(params[:page]).per(10)
Expand All @@ -75,7 +73,7 @@ def mine
def article_params
params.require(:post).permit(
:id, :title, :private,
:cover,
:cover,
:category_id, :state, :excerpt, body: {}
)
end
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class CommentsController < ApplicationController

before_action :authenticate_user!, except: [:index, :show ]
before_action :authenticate_user!, except: [:index, :show]

def create
if params[:track_id]
Expand Down
27 changes: 12 additions & 15 deletions app/controllers/embeds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,75 @@ class EmbedsController < ApplicationController

before_action :remove_frame_options_header


def show
@track = Track.friendly.find(params[:track_id]) if params[:track_id].present?
@playlist = Playlist.friendly.find(params[:playlist_id]) if params[:playlist_id].present?
end


# def show
# @track = Track.find_public_track_with_user(params[:track_id])
# return render status: 404, plain: 'This track is private or not found' unless @track
#
#
# render :show
# end

def show_playlist
@playlist = Playlist.find_public(params[:playlist_id])
return render status: 404, plain: 'This playlist is private or not found' unless @playlist
return render status: 404, plain: "This playlist is private or not found" unless @playlist

render :show_playlist
end

def private_playlist
@playlist = Playlist.find_by_signed_id(params[:playlist_id])
return render status: 404, plain: 'This playlist is private or not found' unless @playlist
return render status: 404, plain: "This playlist is private or not found" unless @playlist

render :show_playlist
end

def oembed_show
@track = Track.friendly.find(params[:track_id])
return render status: 404, plain: 'This track is private or not found' unless @track
return render status: 404, plain: "This track is private or not found" unless @track

render json: data_for_oembed_track(@track)
end

def oembed_private_show
@track = Track.find_signed(params[:track_id])
return render status: 404, plain: 'This track is private or not found' unless @track
return render status: 404, plain: "This track is private or not found" unless @track

render json: data_for_oembed_track(@track)
end

def private_track
@track = Track.find_signed(params[:track_id])
return render status: 404, plain: 'This track is private or not found' unless @track
return render status: 404, plain: "This track is private or not found" unless @track

render :show
end

def private_playlist
@playlist = Playlist.find_signed(params[:playlist_id])
return render status: 404, plain: 'This playlist is private or not found' unless @playlist
return render status: 404, plain: "This playlist is private or not found" unless @playlist

render :show
end

private

def remove_frame_options_header
response.headers.except! 'X-Frame-Options'
response.headers.except! "X-Frame-Options"
end

def data_for_oembed_track(track)
url = "#{private_embed_url(track.signed_id)}"
{
version: 1,
type: 'rich',
provider_name: 'Rauversion',
type: "rich",
provider_name: "Rauversion",
provider_url: root_url,
height: 450,
width: '100%',
width: "100%",
title: "#{track.title} by #{track.user.username}",
description: track.description,
thumbnail_url: track.cover_url(:medium),
Expand All @@ -82,5 +80,4 @@ def data_for_oembed_track(track)
author_url: user_url(track.user)
}
end

end
4 changes: 1 addition & 3 deletions app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class ErrorsController < ApplicationController
layout "errors"


def not_found
render "404"
end
Expand All @@ -13,5 +12,4 @@ def fatal
def not_allowed
render "422"
end

end
end
3 changes: 1 addition & 2 deletions app/controllers/event_hosts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class EventHostsController < ApplicationController

before_action :authenticate_user!, except: [:index, :show ]
before_action :authenticate_user!, except: [:index, :show]

def new
@event = current_user.events.friendly.find(params[:event_id])
Expand Down
Loading

0 comments on commit 308e826

Please sign in to comment.