Layout refactor

master
E. Almqvist 3 years ago
parent 46501c3681
commit e9ebeda3c0
  1. 4
      src/app.rb
  2. 38
      src/views/admin/index.slim
  3. 37
      src/views/auction/index.slim
  4. 31
      src/views/auction/new.slim
  5. 5
      src/views/auction/view.slim
  6. 25
      src/views/index.slim
  7. 2
      src/views/layout.slim
  8. 91
      src/views/user/profile.slim
  9. 25
      src/views/user/settings.slim

@ -238,6 +238,7 @@ end
# ADMIN USER MANAGEMENT # ADMIN USER MANAGEMENT
get "/admin/users/:id/ban" do get "/admin/users/:id/ban" do
auth_denied unless get_current_user.admin?
end end
# ADMIN ROLE MANAGEMENT # ADMIN ROLE MANAGEMENT
@ -302,6 +303,9 @@ post "/admin/roles/give" do
user_id = params[:user_id].to_i user_id = params[:user_id].to_i
role_id = params[:role_id].to_i role_id = params[:role_id].to_i
# Deny giving the "banned role"
auth_denied "You are not permitted to give that role!", 403, "/admin" if role_id == ROLES[:banned][:id]
if user.role_ids.include?(role_id) or user.admin? then if user.role_ids.include?(role_id) or user.admin? then
resp = User_Role_relation.give_role(user_id, role_id) resp = User_Role_relation.give_role(user_id, role_id)

@ -1,5 +1,5 @@
div div
h1 Admin Panel h1.tcenter Admin Panel
nav nav
ul.button-container ul.button-container
li li
@ -23,12 +23,13 @@ div
| #{user.name} | #{user.name}
a.inlbutton href="/admin/users/#{user.id}/edit" a.inlbutton href="/admin/users/#{user.id}/edit"
| [EDIT] | [EDIT]
- if user.banned? - if session_user.admin?
a.green.inlbutton href="/admin/users/#{user.id}/unban" - if user.banned?
| [UNBAN USER] a.green.inlbutton href="/admin/users/#{user.id}/unban"
- else | [UNBAN USER]
a.red.inlbutton href="/admin/users/#{user.id}/ban" - else
| [BAN USER] a.red.inlbutton href="/admin/users/#{user.id}/ban"
| [BAN USER]
article.card.border article.card.border
h2 Add User to Role h2 Add User to Role
@ -45,12 +46,14 @@ div
select name="role_id" select name="role_id"
- if session_user.admin? - if session_user.admin?
- Role.get_all.each do |selrole| - Role.get_all.each do |selrole|
option value="#{selrole.id}" - if selrole.id != ROLES[:banned][:id]
| #{selrole.name} (id=#{selrole.id}) option value="#{selrole.id}"
| #{selrole.name} (id=#{selrole.id})
- else - else
- session_user.roles.each do |selrole| - session_user.roles.each do |selrole|
option value="#{selrole.id}" - if selrole.id != ROLES[:banned][:id]
| #{selrole.name} (id=#{selrole.id}) option value="#{selrole.id}"
| #{selrole.name} (id=#{selrole.id})
input type="submit" value="Add User" input type="submit" value="Add User"
@ -77,9 +80,10 @@ div
h2 Manage Roles h2 Manage Roles
ul.list-container ul.list-container
- data[:roles].each do |role| - data[:roles].each do |role|
li - if not ROLE_IDS.include? role.id
| #{role.name} li
a.inlbutton href="/admin/roles/#{role.id}/edit" | #{role.name}
| [EDIT] a.inlbutton href="/admin/roles/#{role.id}/edit"
a.inlbutton href="/admin/roles/#{role.id}/delete" | [EDIT]
| [DELETE] a.inlbutton href="/admin/roles/#{role.id}/delete"
| [DELETE]

@ -1,22 +1,23 @@
#auctions .content-container
aside #auctions
h2 Search Filters aside
.form-container h2 Search Filters
form action="/auctions" method="get" .form-container
label Keywords form action="/auctions" method="get"
input type="search" name="title" placeholder="Keywords (ex: computer, teapot)" label Keywords
input type="search" name="title" placeholder="Keywords (ex: computer, teapot)"
label Price range label Price range
input type="range" name="price_rng" input type="range" name="price_rng"
label Is Open? label Is Open?
input type="checkbox" name="isopen" value="1" input type="checkbox" name="isopen" value="1"
input type="submit" value="Search" input type="submit" value="Search"
article article
h2 Results h2 Results
ul ul
- auctions.each do |auction| - auctions.each do |auction|
li li
| #{auction["title"]} | #{auction["title"]}

@ -1,21 +1,22 @@
h1 Post Auction .content-container
.form-container#auction_new h1 Post Auction
form action="/auctions" method="post" enctype="multipart/form-data" .form-container#auction_new
input type="file" name="image" accept="image" form action="/auctions" method="post" enctype="multipart/form-data"
input type="file" name="image" accept="image"
label Title label Title
input type="text" name="title" placeholder="Title" pattern="#{TITLE_REGEX_STR}" input type="text" name="title" placeholder="Title" pattern="#{TITLE_REGEX_STR}"
label = "Initial Price #{COINS_PREFIX} #{COINS_SUFFIX}" label = "Initial Price #{COINS_PREFIX} #{COINS_SUFFIX}"
input type="number" name="init_price" value="#{MIN_INIT_PRICE}" min="#{MIN_INIT_PRICE}" input type="number" name="init_price" value="#{MIN_INIT_PRICE}" min="#{MIN_INIT_PRICE}"
label Auction duration (hours) label Auction duration (hours)
input type="number" name="delta_time" value="1" min="1" input type="number" name="delta_time" value="1" min="1"
textarea name="description" cols="20" rows="5" title="Content length must be between #{MIN_DESC_LEN} and #{MAX_DESC_LEN} characters" pattern="#{DESC_REGEX_STR}" maxlength="#{MAX_DESC_LEN}" placeholder="Description" textarea name="description" cols="20" rows="5" title="Content length must be between #{MIN_DESC_LEN} and #{MAX_DESC_LEN} characters" pattern="#{DESC_REGEX_STR}" maxlength="#{MAX_DESC_LEN}" placeholder="Description"
label Categories label Categories
- Category.get_all.each do |category| - Category.get_all.each do |category|
input type="checkbox" name="category-#{category.id}" value="#{category.id}" = category.name input type="checkbox" name="category-#{category.id}" value="#{category.id}" = category.name
input type="submit" value="Post" input type="submit" value="Post"

@ -1,2 +1,3 @@
h1 = auction.title .content-container
h2 = auction.description h1 = auction.title
h2 = auction.description

@ -1,13 +1,14 @@
article.index .content-container
h1.tcenter The Auction House article.index
p.tcenter h1.tcenter The Auction House
| Welcome to the Auction House! With our convenient online auction platform, you can easily browse through listings and find great deals on everything from clothes to electronics. p.tcenter
ul.button-container | Welcome to the Auction House! With our convenient online auction platform, you can easily browse through listings and find great deals on everything from clothes to electronics.
li.em ul.button-container
a.button href="/auctions" = "Browse Auctions" li.em
li a.button href="/auctions" = "Browse Auctions"
a.button href="/auctions/new" = "Post Auction" li
a.button href="/auctions/new" = "Post Auction"
article.index article.index
h1.tcenter.title h1.tcenter.title
| Recent posts | Recent posts

@ -44,6 +44,6 @@ html lang="en"
- flash.each do |k, v| - flash.each do |k, v|
div class="flash-#{k}" div class="flash-#{k}"
| #{v} | #{v}
.content-container.fade-in .fade-in
==yield ==yield

@ -1,48 +1,49 @@
#profile-container .content-container
aside #profile-container
#userinfo.card.card-container aside
h2 = user.name #userinfo.card.card-container
h3 = user.role h2 = user.name
h3 = user.role
.avatar-container
img.avatar src="#{user.avatar}" alt="#{user.name}'s avatar" .avatar-container
img.avatar src="#{user.avatar}" alt="#{user.name}'s avatar"
h4 = user.bio_text
h4 = user.bio_text
ul.button-container
- unless user.id == session[:userid] ul.button-container
a.button href="mailto:#{user.email}" - unless user.id == session[:userid]
li Email a.button href="mailto:#{user.email}"
a.button href="/profile/#{user.id}/rep" li Email
li Review user a.button href="/profile/#{user.id}/rep"
li Review user
- else
a.button href="/settings"
li Edit profile
- if user.roles.length >= 1
#roles.card
h2 Roles
.card-container
ul.button-container
- user.roles.each do |role|
li
label style="color: #{role.color};" = role.name
#reputation.card
h2 Reputation
- if user.rep_score == GOOD_REP
h3.green = user.reputation_text
- elsif user.rep_score == BAD_REP
h3.red = user.reputation_text
- else - else
a.button href="/settings" h3.gray = user.reputation_text
li Edit profile h4 Based on user reviews
a.button href="/profile/#{user.id}/rep"
- if user.roles.length >= 1 | + Write a review
#roles.card
h2 Roles #posts.card
.card-container h2 Recent posts
ul.button-container .card-container
- user.roles.each do |role| //== user.bio_html
li
label style="color: #{role.color};" = role.name
#reputation.card
h2 Reputation
- 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
h4 Based on user reviews
a.button href="/profile/#{user.id}/rep"
| + Write a review
#posts.card
h2 Recent posts
.card-container
//== user.bio_html

@ -1,14 +1,15 @@
#settings .content-container
h1.tcenter = "#{session_user.name}'s Settings" #settings
.form-container h1.tcenter = "#{session_user.name}'s Settings"
form action="/user/update" method="post" enctype="multipart/form-data" .form-container
img.avatar_big src="#{session_user.avatar_url}" alt="Your avatar" form action="/user/update" method="post" enctype="multipart/form-data"
label Change avatar img.avatar_big src="#{session_user.avatar_url}" alt="Your avatar"
input type="file" name="image" accept="image" label Change avatar
input type="file" name="image" accept="image"
label Display name label Display name
input type="text" oninput="this.reportValidity()" title="May only contain alphabetical characters and must be between #{MIN_NAME_LEN} and #{MAX_NAME_LEN} characters long" maxlength="#{MAX_NAME_LEN}" name="displayname" value="#{session_user.name}" pattern="#{NAME_REGEX_STR}" input type="text" oninput="this.reportValidity()" title="May only contain alphabetical characters and must be between #{MIN_NAME_LEN} and #{MAX_NAME_LEN} characters long" maxlength="#{MAX_NAME_LEN}" name="displayname" value="#{session_user.name}" pattern="#{NAME_REGEX_STR}"
label Biography label Biography
textarea name="bio" cols="20" rows="5" title="Content length must be between #{MIN_BIO_LEN} and #{MAX_BIO_LEN} characters" pattern="#{BIO_REGEX_STR}" maxlength="#{MAX_BIO_LEN}" placeholder="Tell us about yourself!" value="#{session_user.bio_text}" = session_user.bio_text textarea name="bio" cols="20" rows="5" title="Content length must be between #{MIN_BIO_LEN} and #{MAX_BIO_LEN} characters" pattern="#{BIO_REGEX_STR}" maxlength="#{MAX_BIO_LEN}" placeholder="Tell us about yourself!" value="#{session_user.bio_text}" = session_user.bio_text
input type="submit" value="Update" input type="submit" value="Update"

Loading…
Cancel
Save