Websites/app/controllers/yiff_rest/api_v2/manage_controller.rb
Donovan Daniels b1c702e3cd
Add image management ui
poorly tested but it worked well enough, I'm sure I'll be patching bugs over the next few weeks
Also remove turbo because it sucks
Also changed the way we handle hosts in dev
2024-05-06 03:25:17 -05:00

39 lines
1.0 KiB
Ruby

# frozen_string_literal: true
module YiffRest
module APIV2
class ManageController < ApplicationController
before_action :validate_discord, except: %i[logout]
before_action :prepare_user, except: %i[logout]
def index
@categories = APIImage.categories
end
def show
@category = APIImage.categories.find { |c| c.db == params[:id] }
raise(ActiveRecord::RecordNotFound) if @category.blank?
@count = APIImage.cached_count(params[:id])
@pagy, @images = pagy(APIImage.where(category: params[:id]).search(search_params).order(created_at: :desc), size: [1, 2, 2, 1])
end
def sync
APIImage.sync_all
redirect_to(yiff_rest_api_v2_manage_index_path, notice: "Images will soon be synced.")
end
def logout
session.delete("discord_user")
CurrentUser.user = nil
redirect_to(yiff_rest_root_path, notice: "You have been logged out.")
end
private
def site_title
"YiffyAPI V2 - Manage Images"
end
end
end
end