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. 83
      src/views/user/profile.slim
  9. 25
      src/views/user/settings.slim

@ -238,6 +238,7 @@ end
# ADMIN USER MANAGEMENT
get "/admin/users/:id/ban" do
auth_denied unless get_current_user.admin?
end
# ADMIN ROLE MANAGEMENT
@ -301,6 +302,9 @@ post "/admin/roles/give" do
user_id = params[:user_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
resp = User_Role_relation.give_role(user_id, role_id)

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

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

@ -1,21 +1,22 @@
h1 Post Auction
.form-container#auction_new
form action="/auctions" method="post" enctype="multipart/form-data"
input type="file" name="image" accept="image"
.content-container
h1 Post Auction
.form-container#auction_new
form action="/auctions" method="post" enctype="multipart/form-data"
input type="file" name="image" accept="image"
label Title
input type="text" name="title" placeholder="Title" pattern="#{TITLE_REGEX_STR}"
label Title
input type="text" name="title" placeholder="Title" pattern="#{TITLE_REGEX_STR}"
label = "Initial Price #{COINS_PREFIX} #{COINS_SUFFIX}"
input type="number" name="init_price" value="#{MIN_INIT_PRICE}" min="#{MIN_INIT_PRICE}"
label = "Initial Price #{COINS_PREFIX} #{COINS_SUFFIX}"
input type="number" name="init_price" value="#{MIN_INIT_PRICE}" min="#{MIN_INIT_PRICE}"
label Auction duration (hours)
input type="number" name="delta_time" value="1" min="1"
label Auction duration (hours)
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
- Category.get_all.each do |category|
input type="checkbox" name="category-#{category.id}" value="#{category.id}" = category.name
label Categories
- Category.get_all.each do |category|
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
h2 = auction.description
.content-container
h1 = auction.title
h2 = auction.description

@ -1,13 +1,14 @@
article.index
h1.tcenter The Auction House
p.tcenter
| 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.
ul.button-container
li.em
a.button href="/auctions" = "Browse Auctions"
li
a.button href="/auctions/new" = "Post Auction"
.content-container
article.index
h1.tcenter The Auction House
p.tcenter
| 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.
ul.button-container
li.em
a.button href="/auctions" = "Browse Auctions"
li
a.button href="/auctions/new" = "Post Auction"
article.index
h1.tcenter.title
| Recent posts
article.index
h1.tcenter.title
| Recent posts

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

@ -1,48 +1,49 @@
#profile-container
aside
#userinfo.card.card-container
h2 = user.name
h3 = user.role
.content-container
#profile-container
aside
#userinfo.card.card-container
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]
a.button href="mailto:#{user.email}"
li Email
a.button href="/profile/#{user.id}/rep"
li Review user
- else
a.button href="/settings"
li Edit profile
ul.button-container
- unless user.id == session[:userid]
a.button href="mailto:#{user.email}"
li Email
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
- 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
h3.gray = user.reputation_text
h4 Based on user reviews
a.button href="/profile/#{user.id}/rep"
| + Write a review
#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
#posts.card
h2 Recent posts
.card-container
//== user.bio_html

@ -1,14 +1,15 @@
#settings
h1.tcenter = "#{session_user.name}'s Settings"
.form-container
form action="/user/update" method="post" enctype="multipart/form-data"
img.avatar_big src="#{session_user.avatar_url}" alt="Your avatar"
label Change avatar
input type="file" name="image" accept="image"
.content-container
#settings
h1.tcenter = "#{session_user.name}'s Settings"
.form-container
form action="/user/update" method="post" enctype="multipart/form-data"
img.avatar_big src="#{session_user.avatar_url}" alt="Your avatar"
label Change avatar
input type="file" name="image" accept="image"
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}"
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}"
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
input type="submit" value="Update"
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
input type="submit" value="Update"

Loading…
Cancel
Save