Sha256: e902820b6581b51b3bc3261aeb740789530da84ed746f711ea5c59f8bff203bc

Contents?: true

Size: 1.44 KB

Versions: 16

Compression:

Stored size: 1.44 KB

Contents

  require 'uri'
  module Adminsite
    module Generators
      class AddIframeGenerator < Rails::Generators::Base
        source_root File.expand_path("../templates", __FILE__)

        argument :url,
                 :type                    => :string,
                 :desc                    => "The url ex: www.google.com",
                 :required                => true

        argument :controller_name,
                 :type                    => :string,
                 :desc                    => "ex : GoogleSearch ",
                 :required                => false


      def run_generation
        require 'domainatrix'

        url_parsed = Domainatrix.parse(url)
        @url = url_parsed.url
        @domain = url_parsed.domain
        @controller_name = controller_name || "#{@domain}Iframe"

        @file_name = @controller_name.underscore.gsub('/','_')
        puts "file_name: '#{@file_name}'"

       raise "Domain missing or not valid" if @domain.blank?

        puts "my first iframe for domain: '#{@controller_name}' with url: '#{@url}'"
        template  "controllers/admin_iframe_controller.rb", "app/controllers/adminsite/admin/#{@file_name}_controller.rb"

        # Content-Menu
        inject_into_file "app/views/adminsite/admin/shared/_admin_menu.html.haml", :after => /\= yield :admin_menu\n/ do\
          "\n    = menu_item 'IFrameMgt', admin_#{@file_name}_index_path, ['#{@file_name}']\n"
        end

     end
    end
   end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
adminsite-3.2.4 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.2.3 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.2.2 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.2.1 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.2.0 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.1.2 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.1.1 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.1.0 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-3.0.0 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-2.1.2 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-2.1.1 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-2.1.0 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-2.0.3 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-2.0.2 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-2.0.1 lib/generators/adminsite/add_iframe/add_iframe_generator.rb
adminsite-2.0.0 lib/generators/adminsite/add_iframe/add_iframe_generator.rb