Sha256: e04588f195f26f38f72c58e1aaebcec712e9c1edf388910ad96fd4ac17a4c677

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

# -*- encoding: utf-8 -*-

require 'webgen/cli'

module Webgen::CLI

  # The CLI command for starting the webgen webgui.
  class WebguiCommand < CmdParse::Command

    def initialize # :nodoc:
      super('webgui', false)
      self.short_desc = 'Starts the webgen webgui'
    end

    # Render the website.
    def execute(args)
      # some fixes for ramaze-2008.06
      # - fix for Windows bug when win32console is not installed
      # - fix for message displayed on shutdown
      $:.unshift File.join(Webgen.data_dir, 'webgui', 'overrides')
      require 'win32console'
      $:.shift
      require 'ramaze'
      Ramaze::Log.loggers = []
      def Ramaze.shutdown; # :nodoc:
      end

      acquire Webgen.data_dir/:webgui/:controller/'*'
      Ramaze::Global.setup do |g|
        g.root = Webgen.data_dir/:webgui
        g.public_root = Webgen.data_dir/:webgui/:public
        g.view_root = Webgen.data_dir/:webgui/:view
        g.adapter = :webrick
        g.port = 7000
      end

      puts 'Starting webgui on http://localhost:7000, press Control-C to stop'
      Thread.new do
        sleep 2
        puts 'Launching web browser'
        require 'launchy'
        Launchy.open('http://localhost:7000')
      end

      Ramaze.start
      puts 'webgui finished'
    end

  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
gettalong-webgen-0.5.7.20090227 lib/webgen/cli/webgui_command.rb
webgen-0.5.7 lib/webgen/cli/webgui_command.rb