master
E. Almqvist 3 years ago
parent 2efc396773
commit e7ad4b912b
  1. 2
      src/.bundle/config
  2. 2
      src/Gemfile
  3. 24
      src/Gemfile.lock
  4. 3
      src/app.rb
  5. 13
      src/func.rb
  6. 1
      src/lib/database.rb
  7. 10
      src/views/stylesheets/style.sass
  8. 20
      src/views/user/settings.slim

@ -0,0 +1,2 @@
---
BUNDLE_PATH: "vendor/bundle"

@ -15,3 +15,5 @@ gem "colorize"
gem "bcrypt"
gem "redcarpet"
gem "mini_magick"
gem "rmagick", "~> 4.2"

@ -7,24 +7,25 @@ GEM
mini_magick (4.11.0)
multi_json (1.15.0)
mustermann (1.1.1)
ruby2_keywords (>= 0.0.1)
ruby2_keywords (~> 0.0.1)
rack (2.2.3)
rack-protection (2.1.0)
rack-protection (2.2.0)
rack
redcarpet (3.5.1)
rmagick (4.2.4)
ruby2_keywords (0.0.5)
sassc (2.4.0)
ffi (~> 1.9)
sinatra (2.1.0)
mustermann (>= 1.0)
rack (>= 2.2)
rack-protection (= 2.1.0)
tilt (>= 2.0)
sinatra-contrib (2.1.0)
sinatra (2.2.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.2.0)
tilt (~> 2.0)
sinatra-contrib (2.2.0)
multi_json
mustermann (~> 1.0)
rack-protection (= 2.1.0)
sinatra (= 2.1.0)
rack-protection (= 2.2.0)
sinatra (= 2.2.0)
tilt (~> 2.0)
sinatra-reloader (1.0)
sinatra-contrib
@ -43,6 +44,7 @@ DEPENDENCIES
colorize
mini_magick
redcarpet
rmagick (~> 4.2)
sassc
sinatra
sinatra-reloader
@ -50,4 +52,4 @@ DEPENDENCIES
sqlite3
BUNDLED WITH
2.2.26
2.2.28

@ -126,6 +126,9 @@ end
post "/user/update" do
path = "./public/avatars/#{session[:userid]}.png"
data = {
bio_text: params["bio"],
avatar_url: params["avatar_url"]

@ -22,3 +22,16 @@ def serve(template, locals={}, layout: :layout)
# Serve the slim template
slim(template, locals: locals, :layout => layout)
end
# Save image
def save_image params, path
if params[:image] && params[:image][:filename]
filename = params[:image][:filename]
file = params[:image][:tempfile]
# Write file to disk
File.open(path, 'wb') do |f|
f.write(file.read)
end
end
end

@ -47,7 +47,6 @@ class EntityModel
db.execute( q, *args )
rescue SQLite3::SQLException => err
Console.error "SQL exception: #{err}", q
end
end

@ -128,7 +128,7 @@ label.error_msg
font-size: 1rem
font-weight: bold
img.avatar
img.avatar, img.avatar_big
background: $bg_clr
width: 2.15rem
height: 2.15rem
@ -136,6 +136,10 @@ img.avatar
border-radius: 50%
border: 2px solid $border_clr
img.avatar_big
width: 8.15rem
height: 8.15rem
img.icon
width: 1.2rem
height: auto
@ -320,3 +324,7 @@ ul.button-container
#settings
.form-container
form
background-color: $bg_alt_clr
border: $border_size solid $border_clr

@ -1,8 +1,12 @@
h1.tcenter = "#{session_user.name}'s Settings"
.form-container
form action="/user/update" method="post"
label Avatar URL
input type="text" name="avatar_url" placeholder="/avatars/default.png" value="#{session_user.avatar_url}"
label Biography
textarea name="bio" cols="20" rows="5" placeholder="Tell us about yourself!" value="#{session_user.bio_text}"
input type="submit" value="Update"
#settings
h1.tcenter = "#{session_user.name}'s Settings"
.form-container
form action="/user/update" method="post"
img.avatar_big src="#{session_user.avatar_url}" alt="Your avatar"
label Change avatar
input type="file" name="avatar_file"
label Biography
textarea name="bio" cols="20" rows="5" placeholder="Tell us about yourself!" value="#{session_user.bio_text}"
input type="submit" value="Update"

Loading…
Cancel
Save