diff --git a/src/lua/endpoints/index_get.lua b/src/lua/endpoints/index_get.lua index 2c3fdbc..32ced5e 100644 --- a/src/lua/endpoints/index_get.lua +++ b/src/lua/endpoints/index_get.lua @@ -26,7 +26,6 @@ local function get_site_home(req) stmnt_index:bind_names{} local latest = {} for idr, title, iar, dater, author, hits in util.sql_rows(stmnt_index) do - print("got:",tagsr,idr,title,iar,dater,author) table.insert(latest,{ url = util.encode_id(idr), title = title, diff --git a/src/lua/endpoints/paste_get.lua b/src/lua/endpoints/paste_get.lua index 0988ebd..5e46475 100644 --- a/src/lua/endpoints/paste_get.lua +++ b/src/lua/endpoints/paste_get.lua @@ -9,7 +9,6 @@ local function paste_get(req) local text local author,_ = session.get(req) if host == config.domain and author then - print("host:",host,"config.domain:",config.domain,"author:",author) http_response_header(req,"Location",string.format("https://%s.%s/_paste",author,config.domain)) http_response(req,303,"") return @@ -30,7 +29,6 @@ local function paste_get(req) text="", }) elseif host ~= config.domain and author == nil then - print("host:",host,"config.domain:",config.domain,"author:",author) http_response_header(req,"Location",string.format("https://%s/_paste",config.domain)) http_response(req,303,"") return diff --git a/src/lua/endpoints/paste_post.lua b/src/lua/endpoints/paste_post.lua index 0c84d8c..5ab3c41 100644 --- a/src/lua/endpoints/paste_post.lua +++ b/src/lua/endpoints/paste_post.lua @@ -43,16 +43,23 @@ local function anon_paste(req,ps) stmnt_paste:reset() if err == sql.DONE then local rowid = stmnt_paste:last_insert_rowid() + local url = util.encode_id(rowid) assert(stmnt_raw:bind(1,rowid) == sql.OK) assert(stmnt_raw:bind_blob(2,ps.raw) == sql.OK) assert(stmnt_raw:bind(3,ps.markup) == sql.OK) err = util.do_sql(stmnt_raw) stmnt_raw:reset() if err ~= sql.DONE then - print("Failed to save raw text, but paste still went though") + local msg = string.format( + [[Failed to save raw text for %d(%s) but paste still went though: %d: %s]], + rowid, + url, + err, + db.conn:errmsg() + ) + log(LOG_CRIT,msg) end tags.set(rowid,ps.tags) - local url = util.encode_id(rowid) local loc = string.format("https://%s/%s",config.domain,url) http_response_header(req,"Location",loc) http_response(req,303,"") @@ -60,7 +67,7 @@ local function anon_paste(req,ps) cache.dirty(string.format("%s",config.domain)) return elseif err == sql.ERROR or err == sql.MISUSE then - ret = "Failed to paste: " .. tostring(err) + error("Failed to paste:" .. tostring(err)) else error("Error pasting:" .. tostring(err)) end @@ -90,16 +97,23 @@ local function author_paste(req,ps) stmnt_paste:reset() if err == sql.DONE then local rowid = stmnt_paste:last_insert_rowid() + local url = util.encode_id(rowid) assert(stmnt_raw:bind(1,rowid) == sql.OK) assert(stmnt_raw:bind_blob(2,ps.raw) == sql.OK) assert(stmnt_raw:bind(3,ps.markup) == sql.OK) err = util.do_sql(stmnt_raw) stmnt_raw:reset() if err ~= sql.DONE then - print("Failed to save raw text, but paste still went through") + local msg = string.format( + [[Failed to save raw text for %d(%s) but paste still went though: %d: %s]], + rowid, + url, + err, + db.conn:errmsg() + ) + log(LOG_CRIT,msg) end tags.set(rowid,ps.tags) - local url = util.encode_id(rowid) local loc if asanon == "anonymous" then loc = string.format("https://%s/%s",config.domain,url) @@ -113,7 +127,7 @@ local function author_paste(req,ps) cache.dirty(string.format("%s",config.domain)) return elseif err == sql.ERROR or err == sql.MISUSE then - ret = "Failed to paste: " .. tostring(err) + error("Failed to paste: " .. tostring(err) .. " : " .. db.conn:errmsg()) else error("Error pasting:",err) end diff --git a/src/lua/parser_imageboard.lua b/src/lua/parser_imageboard.lua index 2d8902a..2ecff09 100644 --- a/src/lua/parser_imageboard.lua +++ b/src/lua/parser_imageboard.lua @@ -96,44 +96,16 @@ local grammar = P{ marked = V"spoiler" + V"bold" + V"italic" + V"underline" + V"heading" + V"strike" + V"spoiler2" + V"code", plainline = (V"marked" + word)^0, line = Cs(V"greentext" + V"pinktext" + V"plainline" + P"") * P"\n" / function(a) - print("Found line:",a) if a == "\r" then return "
" else return string.format("

%s

",a) end end, - ending = C(P(1)^0) / function(a) print("failed with ending:", a) return sanitize(a) end, + ending = C(P(1)^0) / function(a) return sanitize(a) end, chunk = V"line"^0 * V"plainline" * V"ending" } ---A chunk of text that the parser chokes on: -local s = [=[ -Minor update to the search function, also added a search bar to the front page. - -Characters in '''bold''' are literal characters, things in '''' are substitutions. - - -The search utility searches for stories on the site. At it's most simple, it searches stories based on tags, but it can also filter stories based on the fields: '''title''', '''author''', '''date''', and '''hits'''. In general, the syntax for search is {'''+-'''} '''' '''' '''' - -The first '''+''' or '''-''' specifies weather to include or exclude results based on this search, the '''' specifies what field to search for (or search based on tag if this is missing), and '''' specifies how to search. - -For title and author, the only allowed operator is '''='''. This operator will search for '''' appearing anywhere in the field, case insensitive. For '''hits''' and '''time''', the allowed operators are '''>''','''<''','''>=''', '''<=''','''=''', which searches for greater than, less than, greater than or equal to, less than or equal to, and strictly equal to respectively. '''tag''' does not need a '''' or '''', and only allows exact matches. As a quirk of this system, it is impossible to search for the tags "author", "title", "hits" or "date". - -Examples: -[code] -+author=admin -meta -[/code] -Will return all stories by the users "admin" and "b'''admin'''ton_enthusiast" that do not include the "meta" tag. - -[code] -+hits>20 -date>=1609459201 -[/code] -Will return all stories with more than 20 hits that were posted before January 1, 2021 (unix timestamp 1609459201). - -While the date field is a little hard to use for humans, it may be useful for robots. -]=] ---print(table.concat({grammar:match(s .. "\n")}," ")) return function(text) return table.concat({grammar:match(text .. "\n")}," ") end