fixed a couple bugs

This commit is contained in:
Tangent 2019-04-17 22:17:04 -07:00
parent 10a66adb7c
commit 99b81c6da1
2 changed files with 7 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import Tracks from require "models"
class extends lapis.Application class extends lapis.Application
"/console": console.make! "/console": console.make!
[tracks: "/tracks(/:order[%a])(/:asc_desc[%u])(/:page[%d])"]: => [tracks: "/tracks(/:order[%a])(/:asc_desc)(/:page[%d])"]: =>
@order = tostring(@params.order)\lower! @order = tostring(@params.order)\lower!
-- validate order field -- validate order field
@order = "id" unless Tracks.fields[@order] @order = "id" unless Tracks.fields[@order]
@ -16,8 +16,11 @@ class extends lapis.Application
@asc_desc = "ASC" if @asc_desc != "DESC" @asc_desc = "ASC" if @asc_desc != "DESC"
@page = tonumber(@params.page) or 1 @page = tonumber(@params.page) or 1
tracks = Tracks\paginated "* ORDER BY ? ?", @order, @asc_desc, per_page: 32 tracks = Tracks\paginated "* ORDER BY #{@order} #{@asc_desc}", per_page: 32
@last_page = tracks\num_pages! -- @last_page = tracks\num_pages! -- TODO figure out why this errors
@last_page = 150
-- if true
-- return "success this far"
-- validate page -- validate page
if @page < 1 if @page < 1
return redirect_to: @url_for "tracks", order: @order, asc_desc: @asc_desc, page: 1 return redirect_to: @url_for "tracks", order: @order, asc_desc: @asc_desc, page: 1

View File

@ -3,7 +3,7 @@ import Widget from require "lapis.html"
import Tracks from require "models" import Tracks from require "models"
class extends Widget class extends Widget
@menu: => menu: =>
div -> div ->
if @page != 1 if @page != 1
a href: @url_for("tracks", order: @order, asc_desc: @asc_desc, page: 1), "<<" a href: @url_for("tracks", order: @order, asc_desc: @asc_desc, page: 1), "<<"