Paths fix for hosting

master
E. Almqvist 3 years ago
parent 546e417a6d
commit 7e778060c6
  1. 3
      Gemfile
  2. 4
      Gemfile.lock
  3. 2
      src/const.rb
  4. 4
      src/lib/db_models.rb
  5. 2
      src/lib/func.rb
  6. BIN
      src/public/avatars/1.png
  7. 2
      src/routes/user.rb

@ -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"

@ -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

@ -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

@ -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

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 68 KiB

@ -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

Loading…
Cancel
Save