Misc: refactor

master
E. Almqvist 3 years ago
parent 730c957df3
commit 9364de7040
  1. 1
      src/Gemfile
  2. 2
      src/Gemfile.lock
  3. 37
      src/app.rb
  4. 3
      src/const.rb
  5. 6
      src/db_models.rb
  6. 2
      src/views/404.slim
  7. 9
      src/views/stylesheets/style.sass
  8. 12
      src/views/user/profile.slim
  9. 15
      src/views/user/rep.slim

@ -14,3 +14,4 @@ gem "sassc"
gem "colorize" gem "colorize"
gem "bcrypt" gem "bcrypt"
gem "redcarpet" gem "redcarpet"
gem "mini_magick"

@ -4,6 +4,7 @@ GEM
bcrypt (3.1.16) bcrypt (3.1.16)
colorize (0.8.1) colorize (0.8.1)
ffi (1.15.5) ffi (1.15.5)
mini_magick (4.11.0)
multi_json (1.15.0) multi_json (1.15.0)
mustermann (1.1.1) mustermann (1.1.1)
ruby2_keywords (>= 0.0.1) ruby2_keywords (>= 0.0.1)
@ -40,6 +41,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
bcrypt bcrypt
colorize colorize
mini_magick
redcarpet redcarpet
sassc sassc
sinatra sinatra

@ -2,25 +2,28 @@
DEBUG = ARGV[0] == "debug" DEBUG = ARGV[0] == "debug"
require "sinatra" require "sinatra"
require "sinatra/reloader" if DEBUG require "sinatra/reloader" if DEBUG # reload stuff
require "slim" require "slim" # template
require "sqlite3" require "sqlite3" # db
require "sassc" require "sassc" # SASS -> CSS precompiler
require "colorize" require "colorize" # colors for debug
require "bcrypt" require "bcrypt" # password digest
require "redcarpet" require "redcarpet" # markdown renderer
require "mini_magick" # image manipulation
require_relative "config.rb"
require_relative "debug.rb" require_relative "config.rb" # config stuff
require_relative "lib/database.rb" require_relative "debug.rb" # debug methods
require_relative "func.rb" require_relative "lib/database.rb" # database library
require_relative "func.rb" # usefull methods
require_relative "db_init.rb" require_relative "const.rb" # constants
require_relative "db_models.rb"
require_relative "db_init.rb" # db init (pre server init
require_relative "db_models.rb" # db models (i.e. User, Roles etc)
also_reload "lib/*" also_reload "lib/*"
also_reload "func.rb" also_reload "func.rb"
also_reload "const.rb"
also_reload "config.rb" also_reload "config.rb"
also_reload "db_models.rb" also_reload "db_models.rb"
also_reload "db_init.rb" also_reload "db_init.rb"
@ -80,7 +83,7 @@ end
# Settings # Settings
get "/settings" do get "/settings" do
serve :"user/settings", {user: User.find_by_id(params[:id].to_i)} serve :"user/settings"
end end
# API stuff # API stuff

@ -0,0 +1,3 @@
BAD_REP = -1
NEUTRAL_REP = 0
GOOD_REP = 1

@ -21,8 +21,10 @@ class User < EntityModel
"INSERT ROLE HERE" "INSERT ROLE HERE"
end end
def has_bad_rep? def rep_score
@reputation < 0 return BAD_REP if @reputation < 0
return GOOD_REP if @reputation > 0
return NEUTRAL_REP
end end
def bio_html def bio_html

@ -1,2 +1,2 @@
h1 h1.tcenter
| 404 not found :( | 404 not found :(

@ -14,6 +14,7 @@ $fg_error: #f77
$shadow_clr: $bg_alt_clr $shadow_clr: $bg_alt_clr
$green_clr: #5cb85c $green_clr: #5cb85c
$red_clr: #de2a1d $red_clr: #de2a1d
$gray_clr: #aaa
$special_clr: #4776C1 $special_clr: #4776C1
@ -138,6 +139,12 @@ img.icon
height: auto height: auto
opacity: .4 opacity: .4
.tcenter
text-align: center
.hcenter
width: 90%
margin: 0 auto
ul.button-container ul.button-container
display: flex display: flex
@ -208,6 +215,8 @@ ul.button-container
color: $green_clr color: $green_clr
.red .red
color: $red_clr color: $red_clr
.gray
color: $gray_clr
// Profiles // Profiles
#profile-container #profile-container

@ -13,11 +13,11 @@
- unless user.id == session[:userid] - unless user.id == session[:userid]
a.button href="mailto:#{user.email}" a.button href="mailto:#{user.email}"
li Email li Email
a.button href="/profile/#{user.id}/rep"
li Write review
- else - else
a.button href="/settings" a.button href="/settings"
li Settings li Edit profile
a.button href="/profile/#{user.id}/posts"
li Posts
#roles.card #roles.card
h2 Roles h2 Roles
@ -37,10 +37,12 @@
#reputation.card #reputation.card
h2 Reputation h2 Reputation
- unless user.has_bad_rep? - if user.rep_score == GOOD_REP
h3.green = user.reputation_text h3.green = user.reputation_text
- else - elsif user.rep_score == BAD_REP
h3.red = user.reputation_text h3.red = user.reputation_text
- else
h3.gray = user.reputation_text
h4 Based on user reviews h4 Based on user reviews
a.button href="/profile/#{user.id}/rep" a.button href="/profile/#{user.id}/rep"
| + Write a review | + Write a review

@ -2,12 +2,9 @@ div
h1 = "#{user.name}'s reputation reviews" h1 = "#{user.name}'s reputation reviews"
h2 Not implemented yet. h2 Not implemented yet.
#profile-container - if user.rep_score == GOOD_REP
aside h3.green = user.reputation_text
#reputation.card - elsif user.rep_score == BAD_REP
h2 Reputation h3.red = user.reputation_text
- unless user.has_bad_rep? - else
h3.green = user.reputation_text h3.gray = user.reputation_text
- else
h3.red = user.reputation_text
h4 Based on user reviews

Loading…
Cancel
Save