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 "bcrypt"
gem "redcarpet"
gem "mini_magick"

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

@ -2,25 +2,28 @@
DEBUG = ARGV[0] == "debug"
require "sinatra"
require "sinatra/reloader" if DEBUG
require "slim"
require "sqlite3"
require "sassc"
require "colorize"
require "bcrypt"
require "redcarpet"
require_relative "config.rb"
require_relative "debug.rb"
require_relative "lib/database.rb"
require_relative "func.rb"
require_relative "db_init.rb"
require_relative "db_models.rb"
require "sinatra"
require "sinatra/reloader" if DEBUG # reload stuff
require "slim" # template
require "sqlite3" # db
require "sassc" # SASS -> CSS precompiler
require "colorize" # colors for debug
require "bcrypt" # password digest
require "redcarpet" # markdown renderer
require "mini_magick" # image manipulation
require_relative "config.rb" # config stuff
require_relative "debug.rb" # debug methods
require_relative "lib/database.rb" # database library
require_relative "func.rb" # usefull methods
require_relative "const.rb" # constants
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 "func.rb"
also_reload "const.rb"
also_reload "config.rb"
also_reload "db_models.rb"
also_reload "db_init.rb"
@ -80,7 +83,7 @@ end
# Settings
get "/settings" do
serve :"user/settings", {user: User.find_by_id(params[:id].to_i)}
serve :"user/settings"
end
# 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"
end
def has_bad_rep?
@reputation < 0
def rep_score
return BAD_REP if @reputation < 0
return GOOD_REP if @reputation > 0
return NEUTRAL_REP
end
def bio_html

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

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

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

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

Loading…
Cancel
Save