Class: Arcabouco::WebServer

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/arcabouco/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWebServer



23
24
25
26
# File 'lib/arcabouco/server.rb', line 23

def initialize()
  self.base_dir = Arcabouco.root
  super
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



19
20
21
# File 'lib/arcabouco/server.rb', line 19

def base_dir
  @base_dir
end

Instance Method Details

#content_for_indexObject



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/arcabouco/server.rb', line 50

def content_for_index

  application_preload_html = ""
  application_preloader_filename = File.join Arcabouco.root, 'app', 'templates', 'application_preloader.html'
  if File.file?(application_preloader_filename)
    application_preload_html = File.read application_preloader_filename
  end

  main_js = Uglifier.compile(File.read(File.join(Arcabouco.gem_root,'templates','bootstrap_code.js')))
  

  erb :"#{relative_to}/index.html", locals: { :assets => $environment, :application_name => Arcabouco.application_name, :application_preload_html => application_preload_html, :main_js => main_js }, layout: false, cache: false
end

#relative_toObject



28
29
30
31
# File 'lib/arcabouco/server.rb', line 28

def relative_to
  "../" + Pathname.new(File.expand_path('../templates', File.dirname(__FILE__))).relative_path_from(Pathname.new(Arcabouco.root)).to_s
  # Pathname.new(File.expand_path('../templates', File.dirname(__FILE__))).relative_path_from(Pathname.new(Arcabouco.root)).to_s
end