Sha256: b85f0ad72599edf6339d5b1184ad8cb4a33d11373a0b9b530298008835a3cf22

Contents?: true

Size: 1.67 KB

Versions: 18

Compression:

Stored size: 1.67 KB

Contents

class Admin::PageDialogsController < Admin::DialogsController

  require 'net/http'

  crudify :page

  def link_to
    @pages = Page.paginate :page => params[:page],
                             :conditions => 'parent_id is null',
                             :order => 'position ASC',
                             :per_page => Page.per_page(dialog=true)

    @resources = Resource.paginate :page => params[:resource_page], :order => 'created_at DESC', :per_page => Resource.per_page(dialog=true)
  end

  def test_url
    unless params[:url].blank?
      url = URI.parse(params[:url])

      http = Net::HTTP.new(url.host)
      request = Net::HTTP::Get.new(url.path.blank? ? "/" : url.path)

      response = http.request request

      render :text => case response
        when Net::HTTPSuccess, Net::HTTPRedirection
          "<img src='/images/refinery/icons/tick.png' alt='valid url' title='valid url' width='16' height='16' />"
        else
          "<img src='/images/refinery/icons/cross.png' alt='invalid url' title='invalid url' width='16' height='16' />"
        end
    end

    rescue
      render :text => "<img src='/images/refinery/icons/cross.png' alt='invalid url' title='invalid url' width='16' height='16' />"
  end

  def test_email
    unless params[:email].blank?
      valid = params[:email] =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
      render :text => if valid
        "<img src='/images/refinery/icons/tick.png' alt='valid email address' title='valid email address' width='16' height='16' />"
      else
        "<img src='/images/refinery/icons/cross.png' alt='invalid email address' title='invalid email address' width='16' height='16' />"
      end
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
refinerycms-0.9.5.31 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.30 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.29 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.28 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.27 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.26 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.25 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.24 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.23 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.22 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.21 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.20 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.19 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.18 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.17 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.16 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.15 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb
refinerycms-0.9.5.14 vendor/plugins/pages/app/controllers/admin/page_dialogs_controller.rb