diff --git a/Gemfile b/Gemfile index 9945b16..2a8b5c4 100644 --- a/Gemfile +++ b/Gemfile @@ -20,10 +20,11 @@ gem "sinatra-flash", "~> 0.3.0" gem "fileutils", "~> 1.6" -gem "webrick", "~> 1.7" gem "yard-sinatra", github: "chrisb/yard-sinatra" gem "yard", "~> 0.9.27" gem "rdoc", "~> 6.4" + +gem "puma", "~> 5.6" diff --git a/Gemfile.lock b/Gemfile.lock index 26db89a..818f6a6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,8 +25,11 @@ GEM multi_json (1.15.0) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) + nio4r (2.5.8) psych (4.0.3) stringio + puma (5.6.4) + nio4r (~> 2.0) rack (2.2.3) rack-protection (2.2.0) rack @@ -71,6 +74,7 @@ DEPENDENCIES bcrypt colorize fileutils (~> 1.6) + puma (~> 5.6) rdoc (~> 6.4) rmagick (~> 4.2) sassc diff --git a/src/const.rb b/src/const.rb index 3a16c46..da42065 100644 --- a/src/const.rb +++ b/src/const.rb @@ -36,7 +36,7 @@ ROLE_IDS = [] ROLES.each {|_, role| ROLE_IDS << role[:id]} # DB stuff -DB_PATH = "db/main.db" +DB_PATH = File.dirname(__FILE__) + "/db/main.db" # Auction constants MIN_INIT_PRICE = 1 diff --git a/src/lib/db_models.rb b/src/lib/db_models.rb index 56986f3..2e0acfe 100644 --- a/src/lib/db_models.rb +++ b/src/lib/db_models.rb @@ -706,7 +706,7 @@ class Image < EntityModel # @param [Integer] ah_id Auction id # @param [Integer] order Image order on the auction page def self.save(imgdata, ah_id, order) - FileUtils.mkdir_p "./public/auctions/#{ah_id}" + FileUtils.mkdir_p File.dirname(__FILE__) + "/../public/auctions/#{ah_id}" data = { auction_id: ah_id, @@ -718,7 +718,7 @@ class Image < EntityModel if newid then image = Magick::Image.from_blob(imgdata).first image.format = "PNG" - path = "./public/auctions/#{ah_id}/#{order}.png" + path = File.dirname(__FILE__) + "/../public/auctions/#{ah_id}/#{order}.png" File.open(path, 'wb') do |f| image.write(f) { self.quality = 50 } end diff --git a/src/lib/func.rb b/src/lib/func.rb index 033fbd5..dfc1f44 100644 --- a/src/lib/func.rb +++ b/src/lib/func.rb @@ -1,5 +1,5 @@ def get_random_subtitle - subtitles = File.readlines "misc/subtitles.txt" + subtitles = File.readlines(File.dirname(__FILE__) + "/../misc/subtitles.txt") subtitles.sample.chomp end diff --git a/src/public/avatars/1.png b/src/public/avatars/1.png index d8a103c..f0ef8fe 100644 Binary files a/src/public/avatars/1.png and b/src/public/avatars/1.png differ diff --git a/src/routes/user.rb b/src/routes/user.rb index fa180f4..044a304 100644 --- a/src/routes/user.rb +++ b/src/routes/user.rb @@ -131,7 +131,7 @@ post "/user/update" do if params[:image] then imgdata = params[:image][:tempfile] - save_image imgdata.read, "./public/avatars/#{id}.png" # save the image + save_image imgdata.read, File.dirname(__FILE__) + "/../public/avatars/#{id}.png" # save the image data[:avatar_url] = "/avatars/#{id}.png" # update image path end