Sha256: 46fbdb0ae73018e29d952806ff3902707e4ac79a46e6e12b64fae33b5fcb34d1

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

VITREOUS_FOLDER = ENV['VITREOUS_FOLDER']

module Vitreous
  module Share
    class LocalStructure
      def self.base_uri
        "/local/file"
      end
    end
  end
end

module Vitreous
  module Standalone
    class App < Sinatra::Base 
      if( test? )
        set :raise_errors, true
        set :show_exceptions, false
      end
      
      # assets
      get "/assets/*" do |asset|
        send_file "#{VITREOUS_FOLDER}/template/assets/#{asset}"
      end
      
      get '/structure' do
        content_type :json
        JSON.pretty_generate( create_index )
      end
  
      # file
      get "#{Vitreous::Share::LocalStructure.base_uri}/*" do |file|
        send_file "#{VITREOUS_FOLDER}/website/#{file}"
      end
  
      # element
      get '/*' do |resource|
        result = 
          Vitreous::Share::Render.render(
            :resource  => "/#{resource}",
            :index     => create_index,
            :assets    => '/assets',
            :templates => "#{VITREOUS_FOLDER}/template"
          )   
          
        status result.status
        result.body
      end
      
      def create_index
        structure = Vitreous::Share::LocalStructure.new( "/#{VITREOUS_FOLDER}/website" )
        indexer   = Vitreous::Share::Indexer.new( structure.generate )
        
        indexer.generate
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vitreous_standalone-0.0.23 lib/vitreous/standalone/app.rb
vitreous_standalone-0.0.19 lib/vitreous/standalone/app.rb
vitreous_standalone-0.0.17 lib/vitreous/standalone/app.rb