Progress
new MediaAttachment video style :playable for mp4 to make videojs work with multiple files, hiding albums, hiding bookmark collections. may need tweaks on mediaattachment for mov and other formats : todo :
This commit is contained in:
65
app/controllers/api/v1/album_lists_controller.rb
Normal file
65
app/controllers/api/v1/album_lists_controller.rb
Normal file
@@ -0,0 +1,65 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::AlbumListsController < Api::BaseController
|
||||
before_action :require_user!
|
||||
|
||||
before_action :set_account, only: [:show]
|
||||
after_action :insert_pagination_headers, only: :show
|
||||
|
||||
def show
|
||||
@albums = load_albums
|
||||
render json: @albums, each_serializer: REST::AlbumSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_albums
|
||||
paginated_albums
|
||||
end
|
||||
|
||||
def paginated_albums
|
||||
@paginated_albums = MediaAttachmentAlbum.where(account: @account)
|
||||
.paginate_by_max_id(
|
||||
limit_param(DEFAULT_ACCOUNTS_LIMIT),
|
||||
params[:max_id],
|
||||
params[:since_id]
|
||||
)
|
||||
end
|
||||
|
||||
def insert_pagination_headers
|
||||
set_pagination_headers(next_path, prev_path)
|
||||
end
|
||||
|
||||
def next_path
|
||||
if records_continue?
|
||||
api_v1_album_list_url params[:id], pagination_params(max_id: pagination_max_id)
|
||||
end
|
||||
end
|
||||
|
||||
def prev_path
|
||||
unless paginated_albums.empty?
|
||||
api_v1_album_list_url params[:id], pagination_params(since_id: pagination_since_id)
|
||||
end
|
||||
end
|
||||
|
||||
def pagination_max_id
|
||||
paginated_albums.last.id
|
||||
end
|
||||
|
||||
def pagination_since_id
|
||||
paginated_albums.first.id
|
||||
end
|
||||
|
||||
def records_continue?
|
||||
paginated_albums.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
|
||||
end
|
||||
|
||||
def pagination_params(core_params)
|
||||
params.slice(:limit).permit(:limit).merge(core_params)
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,15 +2,11 @@
|
||||
|
||||
class Api::V1::AlbumsController < Api::BaseController
|
||||
before_action :require_user!
|
||||
before_action :set_albums, only: :index
|
||||
|
||||
before_action :set_album, only: [:show, :update, :destroy]
|
||||
|
||||
def index
|
||||
render json: @albums, each_serializer: REST::AlbumSerializer
|
||||
end
|
||||
|
||||
def create
|
||||
@album = "" #current_account.custom_filters.create!(resource_params)
|
||||
@album = current_account.media_attachment_albums.create!(resource_params)
|
||||
render json: @album, serializer: REST::AlbumSerializer
|
||||
end
|
||||
|
||||
@@ -30,15 +26,11 @@ class Api::V1::AlbumsController < Api::BaseController
|
||||
|
||||
private
|
||||
|
||||
def set_albums
|
||||
@albums = "" #current_account.custom_filters
|
||||
end
|
||||
|
||||
def set_album
|
||||
@album = "" # current_account.custom_filters.find(params[:id])
|
||||
@album = current_account.media_attachment_albums.find(params[:id])
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.permit(:title, :description, :visibility)
|
||||
params.permit(:title, :description)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user