Class: Muck::IdentityFeedsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/muck/identity_feeds_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/muck/identity_feeds_controller.rb', line 29

def create
  @service = Service.find(params[:service_id])
  @feed = Feed.new(:uri => params[:uri], :login => params[:username])
  feeds = Service.create_feeds_for_service(@service, params[:uri], params[:username], params[:password], current_user.id)
  if feeds.blank?
    success = false
    if params[:username]
      message = I18n.t('muck.raker.no_feeds_from_username')
    else
      message = I18n.t('muck.raker.no_feeds_at_uri')
    end
  else
    success, messages = add_feeds_to_parent(@parent, feeds)
    message = messages.join('<br />')
  end
  respond_to do |format|
    format.html do
      flash[:notice] = message if message
      redirect_to polymorphic_url([@parent, :identity_feeds]) 
    end
    format.pjs do
      flash[:notice] = message if message
      render :template => 'identity_feeds/new', :layout => false
    end
    format.json do
      render :json => {:parent => @parent, :service => @service, :feeds => feeds, :success => success, :message => message }.as_json
    end
  end
end

#destroyObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/controllers/muck/identity_feeds_controller.rb', line 70

def destroy
  feed = @identity_feed.feed
  @identity_feed.destroy
  feed.delete_if_unused(current_user) # Delete the feed if there are no references to it
  respond_to do |format|
    format.html do
      flash[:notice] = t("muck.raker.identity_feed_removed")
      redirect_to polymorphic_url([@identity_feed.ownable, :identity_feeds]) 
    end
    format.js do
      render(:update) do |page|
        page << "jQuery('##{@identity_feed.dom_id}').fadeOut();"
      end
    end
    format.json do
      render :json => { :success => true,
                        :identity_feed => @identity_feed,
                        :message => t("muck.raker.identity_feed_removed") }
    end
  end
end

#editObject



59
60
61
62
63
64
65
# File 'app/controllers/muck/identity_feeds_controller.rb', line 59

def edit
  @identity_feed = IdentityFeed.find(params[:id])
  respond_to do |format|
    format.html { render :template => 'identity_feeds/edit' }
    format.pjs { render :text => get_edit_html(@identity_feed) }
  end
end

#indexObject



12
13
14
15
16
17
18
# File 'app/controllers/muck/identity_feeds_controller.rb', line 12

def index
  @service_categories = ServiceCategory.sorted.find(:all, :include => [:identity_services])
  @user_services = @parent.identity_feeds.find(:all, :include => [{:feed => :service}])
  respond_to do |format|
    format.html { render :template => 'identity_feeds/index' }
  end
end

#newObject



20
21
22
23
24
25
26
27
# File 'app/controllers/muck/identity_feeds_controller.rb', line 20

def new
  @service = Service.find(params[:service_id])
  @feed = Feed.new
  respond_to do |format|
    format.html { render :template => 'identity_feeds/new' }
    format.pjs { render :text => get_new_html(@service, @parent, @feed) }
  end
end

#updateObject



67
68
# File 'app/controllers/muck/identity_feeds_controller.rb', line 67

def update
end