Recent posts & refactor

master
E. Almqvist 3 years ago
parent 6230a97e6d
commit 3d582d6062
  1. 2
      src/TODO.md
  2. 8
      src/lib/database.rb
  3. 4
      src/lib/db_models.rb
  4. 12
      src/views/auction/index.slim
  5. 2
      src/views/auction/view.slim
  6. 25
      src/views/index.slim
  7. 59
      src/views/stylesheets/style.sass
  8. 27
      src/views/user/profile.slim

@ -1,5 +1,5 @@
# TODO # TODO
- Auction searching at index - Auction searching at index 40%
- Bidding 90% TODO: refactor - Bidding 90% TODO: refactor
- Recent posts (profile & index page) - Recent posts (profile & index page)
---------------- ----------------

@ -114,13 +114,13 @@ class EntityModel
data && self.new(data) data && self.new(data)
end end
def self.get_all_ids def self.get_all_ids filter="", *args
ids = self.get "id" ids = self.get "id", *args
ids.map! {|k, id| id.to_i} ids.map! {|k, id| id.to_i}
end end
def self.get_all def self.get_all filter="", *args
data = self.get "*" data = self.get "*", filter, *args
data && data.map! {|r| self.new(r)} data && data.map! {|r| self.new(r)}
end end
end end

@ -17,6 +17,10 @@ class User < EntityModel
return @avatar_url return @avatar_url
end end
def auctions
Auction.get_all "user_id = ?", @id
end
def role def role
return Role.find_by_id( ROLES[:admin][:id] ).name if self.admin? return Role.find_by_id( ROLES[:admin][:id] ).name if self.admin?

@ -21,15 +21,25 @@
input type="submit" value="Search" input type="submit" value="Search"
a.button href="/auctions" = "Clear Filters" a.button href="/auctions" = "Clear Filters"
article.card article.post-container.card
h2 Results h2 Results
ul.list-container ul.list-container
- auctions.each do |auction| - auctions.each do |auction|
li li
a href="/auctions/#{auction.id}" a href="/auctions/#{auction.id}"
div style="background-image: url(#{auction.images[0].url})" div style="background-image: url(#{auction.images[0].url})"
.info-container
h3 h3
| #{auction.title} | #{auction.title}
- if auction.time_left > 0
| (
span.red
| #{auction.time_left_s}
| )
- if auction.end_time and auction.end_time - Time.now.to_i <= 0 - if auction.end_time and auction.end_time - Time.now.to_i <= 0
span.red span.red
| [Expired] | [Expired]
h4
| #{COINS_PREFIX}#{auction.current_bid}#{COINS_SUFFIX}
p
| #{auction.description}

@ -20,7 +20,7 @@
h2 h2
span span
| #{auction.title} | #{auction.title}
a.inlbutton href="/auctions" a.inlbutton href="javascript:history.back()"
| [Go back] | [Go back]
h3 = auction.description h3 = auction.description
- if auction.categories.length > 0 - if auction.categories.length > 0

@ -9,6 +9,29 @@
li li
a.button href="/auctions/new" = "Post Auction" a.button href="/auctions/new" = "Post Auction"
article.index article
h1.tcenter.title h1.tcenter.title
| Recent posts | Recent posts
article.post-container.card#posts
ul.list-container
- Auction.get_all.reverse[0..1].each do |auction|
li
a href="/auctions/#{auction.id}"
div style="background-image: url(#{auction.images[0].url})"
.info-container
h3
| #{auction.title}
- if auction.time_left > 0
| (
span.red
| #{auction.time_left_s}
| )
- if auction.end_time and auction.end_time - Time.now.to_i <= 0
span.red
| [Expired]
h4
| #{COINS_PREFIX}#{auction.current_bid}#{COINS_SUFFIX}
p
| #{auction.description}

@ -426,9 +426,11 @@ ul.list-container
max-height: 50rem max-height: 50rem
width: 100% width: 100%
.card-container h3.tcenter
margin-bottom: 4rem opacity: .4
padding-bottom: 2rem font-weight: normal
margin: 42% 0
#settings #settings
@ -458,6 +460,11 @@ ul.list-container
a a
margin-left: 1rem margin-left: 1rem
.info-container
display: flex
flex-direction: column
justify-content: center
// Auctions // Auctions
#auctions #auctions
display: flex display: flex
@ -466,12 +473,21 @@ ul.list-container
height: inherit height: inherit
width: 80% width: 80%
padding: 2rem padding: 2rem
max-width: 70rem
a.button a.button
border: $border_size solid $shadow_clr border: $border_size solid $shadow_clr
border-radius: $border_radius border-radius: $border_radius
article aside
width: 40rem
margin-right: 4rem
.form-container
form
padding: 0
width: inherit
article.post-container
height: 90% height: 90%
ul ul
height: 100% height: 100%
@ -484,34 +500,45 @@ ul.list-container
margin-top: 1.2rem margin-top: 1.2rem
border: $border_size solid $border_clr border: $border_size solid $border_clr
border-radius: $border_radius border-radius: $border_radius
min-height: 8rem
height: 100%
transition: .2s border transition: .2s border
a a
display: flex display: grid
grid-template-rows: 1fr
grid-template-columns: 14rem 2fr
grid-template-areas: "im in"
text-decoration: none text-decoration: none
color: $fg_clr color: $fg_clr
flex-direction: row
.info-container
grid-area: in
margin-left: 1rem
h3
font-weight: normal
p
width: 30rem
white-space: nowrap
text-overflow: ellipsis
overflow: hidden
div div
grid-area: im
border-radius: $border_radius border-radius: $border_radius
width: 12rem height: 100%
height: 8rem
background-repeat: no-repeat background-repeat: no-repeat
background-position: center background-position: center
background-size: cover background-size: cover
aside
width: 40rem
margin-right: 4rem
.form-container
form
padding: 0
width: inherit
#auctions_new #auctions_new
display: grid display: grid
#auction-view #auction-view
display: grid display: grid
max-width: 70rem
grid-template-columns: 1fr 1fr grid-template-columns: 1fr 1fr
grid-template-rows: 1fr grid-template-rows: 1fr
grid-template-areas: "im in" "bi bi" grid-template-areas: "im in" "bi bi"

@ -43,7 +43,28 @@
#posts.card #posts.card
h2 Recent posts h2 Recent posts
.card-container - if user.auctions.length > 0
//== user.bio_html article.post-container.card
ul.list-container
- user.auctions.reverse.each do |auction|
li
a href="/auctions/#{auction.id}"
div style="background-image: url(#{auction.images[0].url})"
.info-container
h3
| #{auction.title}
- if auction.time_left > 0
| (
span.red
| #{auction.time_left_s}
| )
- if auction.end_time and auction.end_time - Time.now.to_i <= 0
span.red
| [Expired]
h4
| #{COINS_PREFIX}#{auction.current_bid}#{COINS_SUFFIX}
p
| #{auction.description}
- else
h3.tcenter No activity yet...

Loading…
Cancel
Save