class PluginsController < ApplicationController model :plugin def index Plugin.with_scope(:find => {:conditions => (params[:name] ? ['plugins.name = ?', params[:name]] : nil), :include => :releases}) do @plugin_pages, @plugins = paginate :plugins, :per_page => 15, :order => 'plugins.name ASC' respond_to do |format| format.html format.xml { render :xml => Plugin.find(:all).to_xml } end end end def new @plugin = Plugin.new(params[:plugin]) render :action => 'new', :layout => 'one_column' end def edit @plugin = Plugin.find(params[:id]) render :action => 'edit', :layout => 'one_column' end def update @plugin = Plugin.find(params[:id]) if @plugin.update_attributes(params[:plugin]) flash[:notice] = 'Plugin updated successfully' redirect_to :action => 'show', :id => @plugin.id else flash[:error] = 'There were problems updating this plugin:' render :action => 'edit', :layout => 'one_column' end end def create @plugin = Plugin.new(params[:plugin]) if @plugin.save respond_to do |format| format.html do unless @plugin.latest_release.has_meta_file? flash[:warning] = 'Your plugin was added successfully but we were not able to find an about.yml file for the latest release of your plugin. Please use this form to supply some additional details.' redirect_to edit_release_url(@plugin, @plugin.latest_release) and return end redirect_to plugin_url(@plugin) end format.xml { render :xml => @plugin.to_xml } end else respond_to do |format| format.html { render :action => 'new', :layout => 'one_column' } end end end def show @plugin = Plugin.find(params[:id]) respond_to do |format| format.html format.xml { render :xml => @plugin.to_xml(:include => :releases) } end end def search search_terms = params[:search_terms].split(" ").collect{ |term| "*#{term}*" }.join(" ") @plugins = Plugin.find_by_contents(search_terms) end end