New styling & admin panel restrictions

master
E. Almqvist 3 years ago
parent 59d33516f8
commit 690fd6613b
  1. 18
      src/app.rb
  2. 16
      src/db_models.rb
  3. BIN
      src/public/avatars/6.png
  4. 71
      src/public/icons/cogwheel.svg
  5. 77
      src/public/icons/settings.svg
  6. 8
      src/views/empty.slim
  7. 22
      src/views/layout.slim
  8. 17
      src/views/stylesheets/style.sass

@ -43,6 +43,15 @@ not_found do
serve :"404"
end
def auth_denied(msg="You are not permitted to do that!")
flash[:error] = msg
redirect "/"
end
def banned
auth_denied "You are banned!"
end
# Routes
get "/style.css" do
sass :"stylesheets/style", style: :compressed
@ -110,6 +119,7 @@ post "/register" do
flash[:error] = ret
redirect "/register"
else # if everything went right then continue
flash[:success] = "Account created! Please login."
redirect "/login"
end
end
@ -130,6 +140,7 @@ end
get "/logout" do
session.clear
flash[:success] = "Successfully logged out!"
redirect "/"
end
@ -202,5 +213,12 @@ end
# Admin panel
get "/admin" do
flags = get_current_user.flags
p flags.to_s(2)
user = get_current_user
banned unless !user.banned?
auth_denied unless user.flags != 0
serve :admin, {flags: flags}
end

@ -146,14 +146,20 @@ class User < EntityModel
# Check if user has flags
# Returns: true or false depending whether the user has those flags
def permitted?(flag, *other_flags)
flags = self.get_flags(@id, self)
flag_mask = flag
flag_mask = PERM_LEVELS[flag]
if other_flags then
other_flags.each {|f| flag_mask |= f}
other_flags.each {|f| flag_mask |= PERM_LEVELS[f]}
end
return flags & flag_mask == flag_mask
return self.flags & flag_mask == flag_mask
end
def admin?
return self.permitted? :admin
end
def banned?
return self.permitted? :banned
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

@ -1,71 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="569.613px" height="569.614px" viewBox="0 0 569.613 569.614" style="enable-background:new 0 0 569.613 569.614;"
xml:space="preserve">
<g>
<g>
<path d="M371.49,563.638l113.052-65.854c5.26-3.063,9.088-8.094,10.64-13.975c1.555-5.888,0.701-12.148-2.359-17.405
l-30.769-52.807c4.789-6.524,9.083-13.115,12.972-19.918c3.893-6.799,7.405-13.84,10.606-21.275l61.114-0.221
c6.086-0.021,11.915-2.464,16.202-6.781c4.287-4.32,6.687-10.165,6.665-16.255l-0.48-130.833
c-0.024-6.089-2.464-11.919-6.784-16.206c-4.299-4.269-10.113-6.662-16.166-6.662c-0.03,0-0.062,0-0.089,0l-61.182,0.242
c-6.444-14.462-14.428-28.14-23.871-40.913l30.417-53.143c6.294-11.001,2.481-25.025-8.52-31.316L369.403,5.335
c-5.281-3.023-11.545-3.822-17.424-2.231c-5.872,1.598-10.872,5.462-13.892,10.747L307.665,67
c-15.766-1.662-31.653-1.613-47.363,0.144l-30.796-52.892c-3.063-5.263-8.094-9.091-13.975-10.646
c-5.884-1.551-12.148-0.704-17.408,2.359L85.068,71.823c-10.949,6.38-14.657,20.429-8.28,31.38l30.765,52.831
c-4.761,6.484-9.048,13.076-12.953,19.899c-3.904,6.824-7.417,13.855-10.6,21.255l-61.139,0.235
C10.187,197.472-0.046,207.785,0,220.456L0.48,351.29c0.024,6.086,2.463,11.919,6.784,16.206
c4.299,4.269,10.11,6.661,16.166,6.661c0.028,0,0.058,0,0.086,0l61.203-0.229c6.432,14.452,14.413,28.131,23.868,40.915
l-30.413,53.141c-3.023,5.284-3.825,11.548-2.231,17.423c1.597,5.872,5.462,10.872,10.747,13.896l113.535,64.977
c3.596,2.056,7.513,3.032,11.38,3.032c7.962,0,15.701-4.146,19.942-11.552l30.417-53.149c15.799,1.671,31.684,1.619,47.348-0.144
l30.799,52.89c3.066,5.26,8.094,9.088,13.978,10.643C359.967,567.552,366.23,566.705,371.49,563.638z M341.129,465.911
c-4.902-8.418-14.599-12.815-24.137-10.994c-20.588,3.935-42.174,3.999-63.128,0.202c-9.572-1.735-19.184,2.741-24.015,11.181
l-26.748,46.745l-73.694-42.18l26.75-46.741c4.832-8.439,3.819-19.006-2.521-26.371c-13.978-16.239-24.685-34.594-31.818-54.554
c-3.265-9.131-11.918-15.227-21.61-15.227c-0.027,0-0.058,0-0.085,0l-53.825,0.199l-0.315-84.937l53.819-0.205
c9.722-0.04,18.366-6.197,21.576-15.374c3.69-10.557,7.962-20.019,13.06-28.917c5.101-8.914,11.089-17.387,18.311-25.897
c6.294-7.417,7.225-17.993,2.334-26.396l-27.081-46.509l73.385-42.754l27.078,46.497c4.893,8.4,14.544,12.821,24.095,11.004
c20.716-3.911,42.317-3.978,63.189-0.19c9.557,1.753,19.189-2.742,24.019-11.178l26.753-46.744l73.697,42.179l-26.753,46.742
c-4.826,8.437-3.816,19,2.521,26.368c13.956,16.221,24.669,34.587,31.842,54.59c3.271,9.119,11.919,15.202,21.604,15.202
c0.031,0,0.062,0,0.092,0l53.789-0.214l0.315,84.927l-53.783,0.192c-9.712,0.037-18.351,6.182-21.569,15.347
c-3.746,10.654-8.023,20.131-13.082,28.975c-5.064,8.847-11.067,17.338-18.356,25.958c-6.271,7.418-7.194,17.978-2.305,26.368
l27.078,46.472l-73.391,42.749L341.129,465.911z"/>
<path d="M392.531,346.458c16.472-28.773,20.746-62.24,12.047-94.232s-29.342-58.685-58.115-75.151
c-18.761-10.74-40.05-16.417-61.562-16.417c-44.446,0-85.762,23.944-107.822,62.485c-33.994,59.404-13.327,135.39,46.071,169.386
c18.764,10.737,40.052,16.411,61.564,16.411C329.158,408.943,370.475,385.001,392.531,346.458z M352.696,323.658
c-13.902,24.293-39.955,39.385-67.985,39.385c-13.528,0-26.934-3.58-38.764-10.349c-37.433-21.426-50.456-69.312-29.033-106.751
c13.905-24.291,39.958-39.385,67.987-39.385c13.528,0,26.932,3.58,38.762,10.355c18.136,10.379,31.142,27.197,36.628,47.359
C365.771,284.435,363.075,305.524,352.696,323.658z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.9 KiB

@ -1,6 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" width="50px" height="50px">
<g id="surface37011060">
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 22.207031 2 C 21.714844 2 21.296875 2.355469 21.21875 2.835938 L 20.246094 8.792969 C 19.078125 9.132812 17.960938 9.59375 16.910156 10.164062 L 11.996094 6.652344 C 11.597656 6.371094 11.054688 6.414062 10.707031 6.757812 L 6.816406 10.644531 C 6.476562 10.988281 6.429688 11.53125 6.707031 11.925781 L 10.164062 16.871094 C 9.582031 17.929688 9.113281 19.050781 8.765625 20.230469 L 2.835938 21.21875 C 2.355469 21.300781 2 21.714844 2.003906 22.207031 L 2.003906 27.707031 C 2 28.191406 2.347656 28.605469 2.824219 28.691406 L 8.757812 29.742188 C 9.105469 30.921875 9.574219 32.042969 10.152344 33.101562 L 6.652344 38 C 6.371094 38.394531 6.414062 38.9375 6.757812 39.285156 L 10.648438 43.175781 C 10.992188 43.519531 11.53125 43.566406 11.925781 43.289062 L 16.882812 39.820312 C 17.9375 40.394531 19.054688 40.859375 20.226562 41.203125 L 21.21875 47.164062 C 21.300781 47.644531 21.714844 48 22.203125 48 L 27.703125 48 C 28.191406 48 28.605469 47.652344 28.691406 47.175781 L 29.75 41.1875 C 30.921875 40.839844 32.035156 40.371094 33.082031 39.792969 L 38.070312 43.292969 C 38.46875 43.570312 39.007812 43.523438 39.351562 43.179688 L 43.238281 39.289062 C 43.585938 38.941406 43.628906 38.394531 43.34375 37.996094 L 39.785156 33.058594 C 40.355469 32.015625 40.8125 30.910156 41.152344 29.75 L 47.171875 28.695312 C 47.648438 28.609375 48 28.191406 47.996094 27.707031 L 47.996094 22.207031 C 47.996094 21.71875 47.644531 21.300781 47.160156 21.222656 L 41.152344 20.238281 C 40.808594 19.078125 40.351562 17.976562 39.78125 16.933594 L 43.289062 11.933594 C 43.566406 11.535156 43.519531 10.996094 43.175781 10.652344 L 39.285156 6.765625 C 38.941406 6.417969 38.394531 6.375 37.996094 6.660156 L 33.070312 10.203125 C 32.023438 9.625 30.910156 9.15625 29.738281 8.8125 L 28.691406 2.828125 C 28.609375 2.347656 28.191406 2 27.703125 2 Z M 23.058594 4 L 26.867188 4 L 27.863281 9.683594 C 27.929688 10.074219 28.21875 10.386719 28.605469 10.484375 C 30.066406 10.847656 31.441406 11.425781 32.695312 12.183594 C 33.035156 12.394531 33.46875 12.375 33.796875 12.144531 L 38.476562 8.777344 L 41.167969 11.472656 L 37.835938 16.222656 C 37.609375 16.542969 37.59375 16.972656 37.796875 17.308594 C 38.546875 18.5625 39.117188 19.925781 39.480469 21.378906 C 39.578125 21.769531 39.898438 22.058594 40.289062 22.125 L 45.996094 23.058594 L 45.996094 26.867188 L 40.277344 27.871094 C 39.890625 27.941406 39.578125 28.234375 39.480469 28.617188 C 39.121094 30.070312 38.550781 31.433594 37.800781 32.683594 C 37.59375 33.027344 37.613281 33.460938 37.84375 33.785156 L 41.222656 38.472656 L 38.53125 41.167969 L 33.792969 37.84375 C 33.464844 37.617188 33.035156 37.601562 32.699219 37.808594 C 31.449219 38.566406 30.074219 39.148438 28.617188 39.515625 C 28.234375 39.613281 27.945312 39.925781 27.878906 40.3125 L 26.867188 46 L 23.054688 46 L 22.113281 40.335938 C 22.046875 39.945312 21.753906 39.628906 21.367188 39.53125 C 19.902344 39.171875 18.523438 38.59375 17.261719 37.835938 C 16.921875 37.632812 16.496094 37.648438 16.171875 37.875 L 11.46875 41.167969 L 8.773438 38.46875 L 12.097656 33.824219 C 12.328125 33.5 12.347656 33.066406 12.136719 32.722656 C 11.371094 31.457031 10.792969 30.078125 10.425781 28.609375 C 10.332031 28.226562 10.019531 27.9375 9.632812 27.867188 L 4 26.867188 L 4 23.050781 L 9.628906 22.117188 C 10.023438 22.050781 10.339844 21.757812 10.433594 21.371094 C 10.804688 19.898438 11.382812 18.519531 12.144531 17.253906 C 12.351562 16.917969 12.339844 16.488281 12.109375 16.164062 L 8.824219 11.46875 L 11.523438 8.773438 L 16.183594 12.105469 C 16.507812 12.335938 16.941406 12.351562 17.28125 12.148438 C 18.535156 11.394531 19.917969 10.820312 21.382812 10.460938 C 21.773438 10.367188 22.070312 10.046875 22.132812 9.652344 Z M 25 17 C 20.59375 17 17 20.59375 17 25 C 17 29.40625 20.59375 33 25 33 C 29.40625 33 33 29.40625 33 25 C 33 20.59375 29.40625 17 25 17 Z M 25 19 C 28.324219 19 31 21.675781 31 25 C 31 28.324219 28.324219 31 25 31 C 21.675781 31 19 28.324219 19 25 C 19 21.675781 21.675781 19 25 19 Z M 25 19 "/>
</g>
</svg>
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="569.613px" height="569.614px" viewBox="0 0 569.613 569.614" style="enable-background:new 0 0 569.613 569.614;"
xml:space="preserve">
<g>
<g>
<path d="M371.49,563.638l113.052-65.854c5.26-3.063,9.088-8.094,10.64-13.975c1.555-5.888,0.701-12.148-2.359-17.405
l-30.769-52.807c4.789-6.524,9.083-13.115,12.972-19.918c3.893-6.799,7.405-13.84,10.606-21.275l61.114-0.221
c6.086-0.021,11.915-2.464,16.202-6.781c4.287-4.32,6.687-10.165,6.665-16.255l-0.48-130.833
c-0.024-6.089-2.464-11.919-6.784-16.206c-4.299-4.269-10.113-6.662-16.166-6.662c-0.03,0-0.062,0-0.089,0l-61.182,0.242
c-6.444-14.462-14.428-28.14-23.871-40.913l30.417-53.143c6.294-11.001,2.481-25.025-8.52-31.316L369.403,5.335
c-5.281-3.023-11.545-3.822-17.424-2.231c-5.872,1.598-10.872,5.462-13.892,10.747L307.665,67
c-15.766-1.662-31.653-1.613-47.363,0.144l-30.796-52.892c-3.063-5.263-8.094-9.091-13.975-10.646
c-5.884-1.551-12.148-0.704-17.408,2.359L85.068,71.823c-10.949,6.38-14.657,20.429-8.28,31.38l30.765,52.831
c-4.761,6.484-9.048,13.076-12.953,19.899c-3.904,6.824-7.417,13.855-10.6,21.255l-61.139,0.235
C10.187,197.472-0.046,207.785,0,220.456L0.48,351.29c0.024,6.086,2.463,11.919,6.784,16.206
c4.299,4.269,10.11,6.661,16.166,6.661c0.028,0,0.058,0,0.086,0l61.203-0.229c6.432,14.452,14.413,28.131,23.868,40.915
l-30.413,53.141c-3.023,5.284-3.825,11.548-2.231,17.423c1.597,5.872,5.462,10.872,10.747,13.896l113.535,64.977
c3.596,2.056,7.513,3.032,11.38,3.032c7.962,0,15.701-4.146,19.942-11.552l30.417-53.149c15.799,1.671,31.684,1.619,47.348-0.144
l30.799,52.89c3.066,5.26,8.094,9.088,13.978,10.643C359.967,567.552,366.23,566.705,371.49,563.638z M341.129,465.911
c-4.902-8.418-14.599-12.815-24.137-10.994c-20.588,3.935-42.174,3.999-63.128,0.202c-9.572-1.735-19.184,2.741-24.015,11.181
l-26.748,46.745l-73.694-42.18l26.75-46.741c4.832-8.439,3.819-19.006-2.521-26.371c-13.978-16.239-24.685-34.594-31.818-54.554
c-3.265-9.131-11.918-15.227-21.61-15.227c-0.027,0-0.058,0-0.085,0l-53.825,0.199l-0.315-84.937l53.819-0.205
c9.722-0.04,18.366-6.197,21.576-15.374c3.69-10.557,7.962-20.019,13.06-28.917c5.101-8.914,11.089-17.387,18.311-25.897
c6.294-7.417,7.225-17.993,2.334-26.396l-27.081-46.509l73.385-42.754l27.078,46.497c4.893,8.4,14.544,12.821,24.095,11.004
c20.716-3.911,42.317-3.978,63.189-0.19c9.557,1.753,19.189-2.742,24.019-11.178l26.753-46.744l73.697,42.179l-26.753,46.742
c-4.826,8.437-3.816,19,2.521,26.368c13.956,16.221,24.669,34.587,31.842,54.59c3.271,9.119,11.919,15.202,21.604,15.202
c0.031,0,0.062,0,0.092,0l53.789-0.214l0.315,84.927l-53.783,0.192c-9.712,0.037-18.351,6.182-21.569,15.347
c-3.746,10.654-8.023,20.131-13.082,28.975c-5.064,8.847-11.067,17.338-18.356,25.958c-6.271,7.418-7.194,17.978-2.305,26.368
l27.078,46.472l-73.391,42.749L341.129,465.911z"/>
<path d="M392.531,346.458c16.472-28.773,20.746-62.24,12.047-94.232s-29.342-58.685-58.115-75.151
c-18.761-10.74-40.05-16.417-61.562-16.417c-44.446,0-85.762,23.944-107.822,62.485c-33.994,59.404-13.327,135.39,46.071,169.386
c18.764,10.737,40.052,16.411,61.564,16.411C329.158,408.943,370.475,385.001,392.531,346.458z M352.696,323.658
c-13.902,24.293-39.955,39.385-67.985,39.385c-13.528,0-26.934-3.58-38.764-10.349c-37.433-21.426-50.456-69.312-29.033-106.751
c13.905-24.291,39.958-39.385,67.987-39.385c13.528,0,26.932,3.58,38.762,10.355c18.136,10.379,31.142,27.197,36.628,47.359
C365.771,284.435,363.075,305.524,352.696,323.658z"/>
</g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

@ -5,9 +5,9 @@ html lang="en"
link rel="stylesheet" href="/style.css"
title The Auction House
body
div class="flash" onclick="this.remove();"
- flash.each do |k, v|
div class="flash-#{k}"
| #{v}
.content-container
div class="flash" onclick="this.remove();"
- flash.each do |k, v|
div class="flash-#{k}"
| #{v}
==yield

@ -22,16 +22,28 @@ html lang="en"
| SIGN UP
- else
li.coins = "#{COINS_PREFIX}#{session_user.balance}#{COINS_SUFFIX}"
- if session_user.admin? && !session_user.banned?
li
a.inlbutton href="/admin" target="_self"
img.icon src="/icons/shield.svg" alt="Admin Panel"
li
a.inlbutton href="/settings" target="_self"
img.icon src="/icons/settings.svg" alt="Settings"
li
a.inlbutton href="/logout" target="_self"
img.icon src="/icons/logout.svg" alt="Log out"
li
a.inlbutton href="/profile" target="_self"
img.avatar src="#{session_user.avatar}" alt="Profile"
.content-container
div class="flash" onclick="this.remove();"
- flash.each do |k, v|
div class="flash-#{k}"
| #{v}
div class="flash" onclick="this.remove();"
- flash.each do |k, v|
div class="flash-#{k}"
| #{v}
.content-container.fade-in
==yield

@ -42,6 +42,9 @@ html
width: auto
height: 100%
.fade-in
animation: fade-in .4s ease-in alternate
// Layout
body
margin: 0
@ -145,10 +148,12 @@ a.button:hover
position: fixed
text-align: center
top: 4rem
left: 50%
transform: translateX(-50%)
font-size: 1rem
font-weight: bold
animation: flash .2s ease-in alternate
background: $bg_alt_clr
animation: fade-in .9s ease-in alternate
background: $bg_clr
transition: .4s opacity
&-error
@ -180,8 +185,11 @@ img.avatar_big
height: 8.15rem
img.icon
width: 1.2rem
width: 1rem
height: auto
opacity: .75
img.icon-invert
-webkit-filter: invert(100%)
filter: invert(100%)
@ -395,9 +403,8 @@ ul.button-container
flex-direction: column
// Animation keyframes
@keyframes flash
@keyframes fade-in
0%
opacity: 0
100%
opacity: 1

Loading…
Cancel
Save