<commit_before>require 'sinatra/base'
require 'tilt/haml'
require 's3browser/store'

module S3Browser
  class Server < Sinatra::Base
    configure :development do
      set :port, 9292
      set :bind, '0.0.0.0'
      enable :logging
      set :store, Store.new
    end

    get '/' do
      buckets = settings.store.buckets
      haml :index, locals: { title: 'S3Browser', buckets: buckets }
    end

    get '/:bucket' do |bucket|
      params['q'] = nil if params['q'] == ''
      objects = settings.store.get(bucket, term: params['q'], sort: params['s'], direction: params['d'])

      haml :bucket, locals: { title: bucket, bucket: bucket, objects: objects, q: params['q'] }
    end

    helpers do
      def bucket
        ENV['AWS_S3_BUCKET']
      end<commit_msg>fix: Move store back to a helper<commit_after>require 'sinatra/base'
require 'tilt/haml'
require 's3browser/store'

module S3Browser
  class Server < Sinatra::Base
    configure :development do
      set :port, 9292
      set :bind, '0.0.0.0'
      enable :logging
    end

    get '/' do
      buckets = store.buckets
      haml :index, locals: { title: 'S3Browser', buckets: buckets }
    end

    get '/:bucket' do |bucket|
      params['q'] = nil if params['q'] == ''
      objects = store.get(bucket, term: params['q'], sort: params['s'], direction: params['d'])

      haml :bucket, locals: { title: bucket, bucket: bucket, objects: objects, q: params['q'] }
    end

    helpers do
      def store
        @@store ||= Store.new
      end

      def bucket
        ENV['AWS_S3_BUCKET']
      end
{'fraction_non_alphanumeric': 0.13740458015267176, 'fraction_numerical': 0.015267175572519083, 'mean_word_length': 2.6496519721577725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1037627', 'n_tokens_mistral': 533, 'n_tokens_neox': 508, 'n_words': 151}