update plugins to allow listing via API

This commit is contained in:
Lee Lawlor
2014-10-17 14:51:58 -04:00
parent c527515d4a
commit 1b44dfbd4b
10 changed files with 336 additions and 10 deletions

View File

@ -39,6 +39,9 @@ class ChannelsController < ApplicationController
# list public channels
def public
# error if page 0
respond_with_error(:error_resource_not_found) and return if params[:page] == '0'
@domain = domain
# default blank response
@channels = Channel.where(:id => 0).paginate :page => params[:page]
@ -63,7 +66,6 @@ class ChannelsController < ApplicationController
# normal channel list
else
@header = t(:featured_channels)
respond_with_error(:error_resource_not_found) and return if params[:page] == '0'
@channels = Channel.public_viewable.active.order('ranking desc, updated_at DESC').paginate :page => params[:page]
end

View File

@ -1,5 +1,6 @@
class PluginsController < ApplicationController
before_filter :require_user, :except => [:show_public, :show]
before_filter :authenticate_via_api_key!, :only => [:index]
before_filter :require_user, :except => [:show_public, :show, :public]
before_filter :set_plugins_menu
before_filter :check_permission, :only => ['edit', 'update', 'ajax_update', 'destroy']
@ -11,8 +12,31 @@ class PluginsController < ApplicationController
def new; ; end
def edit; ; end
# get list of public plugins
def public
# error if page 0
respond_with_error(:error_resource_not_found) and return if params[:page] == '0'
# default blank response
@plugins = Plugin.where(:id => 0).paginate :page => params[:page]
# get plugins
@plugins = Plugin.where("public_flag = true").order('updated_at DESC').paginate :page => params[:page]
respond_to do |format|
format.html
format.json { render :json => Plugin.paginated_hash(@plugins).to_json }
format.xml { render :xml => Plugin.paginated_hash(@plugins).to_xml(:root => 'response') }
end
end
def index
@plugins = current_user.plugins
respond_to do |format|
format.html
format.json { render :json => @plugins.to_json(Plugin.public_options) }
format.xml { render :xml => @plugins.to_xml(Plugin.public_options) }
end
end
def public_plugins