attempted fix of tag pages

This commit is contained in:
Tangent 2019-06-28 17:28:48 -07:00
parent 5b92aa7510
commit dbedb15725

View File

@ -2,7 +2,7 @@ lapis = require "lapis"
console = require "lapis.console" console = require "lapis.console"
import respond_to from require "lapis.application" import respond_to from require "lapis.application"
import escape_identifier from require "lapis.db" import escape_literal, escape_identifier from require "lapis.db"
import unescape from require "lapis.util" import unescape from require "lapis.util"
import create_track, update_track, escape_tag from require "helpers" import create_track, update_track, escape_tag from require "helpers"
@ -62,7 +62,8 @@ class extends lapis.Application
@asc_desc = "ASC" @asc_desc = "ASC"
@page = tonumber(@params.page) or 1 @page = tonumber(@params.page) or 1
tracks = Tracks\paginated "WHERE tags LIKE ? ORDER BY #{escape_identifier @order} #{@asc_desc}", escape_tag(unescape(@params.name)), per_page: 32 tag_pattern = " #{escape_literal unescape(@params.name)} "
tracks = Tracks\paginated "WHERE tags LIKE #{tag_pattern} ORDER BY #{escape_identifier @order} #{@asc_desc}", per_page: 32
@last_page = 1 @last_page = 1
if tag = Tags\find name: unescape(@params.name) if tag = Tags\find name: unescape(@params.name)
@last_page = 1 + math.floor tag.count / 32 @last_page = 1 + math.floor tag.count / 32