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
- Auction searching at index
- Auction searching at index 40%
- Bidding 90% TODO: refactor
- Recent posts (profile & index page)
----------------

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

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

@ -21,15 +21,25 @@
input type="submit" value="Search"
a.button href="/auctions" = "Clear Filters"
article.card
article.post-container.card
h2 Results
ul.list-container
- auctions.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}

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

@ -9,6 +9,29 @@
li
a.button href="/auctions/new" = "Post Auction"
article.index
article
h1.tcenter.title
| 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
width: 100%
.card-container
margin-bottom: 4rem
padding-bottom: 2rem
h3.tcenter
opacity: .4
font-weight: normal
margin: 42% 0
#settings
@ -458,6 +460,11 @@ ul.list-container
a
margin-left: 1rem
.info-container
display: flex
flex-direction: column
justify-content: center
// Auctions
#auctions
display: flex
@ -466,12 +473,21 @@ ul.list-container
height: inherit
width: 80%
padding: 2rem
max-width: 70rem
a.button
border: $border_size solid $shadow_clr
border-radius: $border_radius
article
aside
width: 40rem
margin-right: 4rem
.form-container
form
padding: 0
width: inherit
article.post-container
height: 90%
ul
height: 100%
@ -484,34 +500,45 @@ ul.list-container
margin-top: 1.2rem
border: $border_size solid $border_clr
border-radius: $border_radius
min-height: 8rem
height: 100%
transition: .2s border
a
display: flex
display: grid
grid-template-rows: 1fr
grid-template-columns: 14rem 2fr
grid-template-areas: "im in"
text-decoration: none
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
grid-area: im
border-radius: $border_radius
width: 12rem
height: 8rem
height: 100%
background-repeat: no-repeat
background-position: center
background-size: cover
aside
width: 40rem
margin-right: 4rem
.form-container
form
padding: 0
width: inherit
#auctions_new
display: grid
#auction-view
display: grid
max-width: 70rem
grid-template-columns: 1fr 1fr
grid-template-rows: 1fr
grid-template-areas: "im in" "bi bi"

@ -43,7 +43,28 @@
#posts.card
h2 Recent posts
.card-container
//== user.bio_html
- if user.auctions.length > 0
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