Class: Webgen::CLI::WebguiCommand
- Inherits:
-
CmdParse::Command
- Object
- CmdParse::Command
- Webgen::CLI::WebguiCommand
- Defined in:
- lib/webgen/cli/webgui_command.rb
Overview
The CLI command for starting the webgen webgui.
Instance Method Summary collapse
-
#execute(args) ⇒ Object
Render the website.
-
#initialize ⇒ WebguiCommand
constructor
:nodoc:.
Constructor Details
#initialize ⇒ WebguiCommand
:nodoc:
15 16 17 18 |
# File 'lib/webgen/cli/webgui_command.rb', line 15 def initialize # :nodoc: super('webgui', false) self.short_desc = 'Starts the webgen webgui' end |
Instance Method Details
#execute(args) ⇒ Object
Render the website.
21 22 23 24 25 26 27 28 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 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/webgen/cli/webgui_command.rb', line 21 def execute(args) # some fixes for ramaze-2009.02 # - fix for Windows when win32console is not installed # - fix for message displayed on shutdown # - fix for warning message $:.unshift File.join(Webgen.data_dir, 'webgui', 'overrides') require 'win32console' $:.shift silence_warnings do begin require 'ramaze' rescue LoadError puts "The Ramaze web framework which is needed for the webgui was not found." puts "You can install it via 'gem install ramaze --version 2009.02'" return end end def Ramaze.shutdown; # :nodoc: end Ramaze::acquire(File.join(Webgen.data_dir, 'webgui', 'controller', '*')) Ramaze::Log.loggers = [] Ramaze::Global.setup do |g| g.root = File.join(Webgen.data_dir, 'webgui') g.public_root = File.join(Webgen.data_dir, 'webgui', 'public') g.view_root = File.join(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 begin require 'launchy' sleep 2 puts 'Launching web browser' Launchy.open('http://localhost:7000') rescue LoadError puts "Can't open browser because the launchy library was not found." puts "You can install it via 'gem install launchy'" puts "Please open a browser window and enter 'http://localhost:7000' into the address bar!" end end Ramaze.start puts 'webgui finished' end |