Don't require tags

Don't require tags to make a paste
This commit is contained in:
Robin Malley 2020-10-12 15:07:26 +00:00
parent 4c65fc3692
commit fce26b2fde
1 changed files with 19 additions and 9 deletions

View File

@ -127,9 +127,10 @@ function configure()
--we can use it for "download as image" or "download as pdf"
--in the future too. Stil stored zlib compressed
assert(db:exec(queries.create_table_raw_text))
assert(db:exec(queries.create_table_images)) --TODO
assert(db:exec(queries.create_table_comments)) --TODO
assert(db:exec(queries.create_table_tags)) --TODO
assert(db:exec(queries.create_table_images))
assert(db:exec(queries.create_table_comments))
assert(db:exec(queries.create_table_tags))
assert(db:exec(queries.create_index_tags))
--Store a cookie for logged in users. Logged in users can edit
--their own posts.
assert(db:exec(queries.create_table_session))
@ -613,8 +614,11 @@ function paste(req)
local title = assert(http_argument_get_string(req,"title"))
local text = assert(http_argument_get_string(req,"text"))
local markup = assert(http_argument_get_string(req,"markup"))
local tag_str = assert(http_argument_get_string(req,"tags"))
local tags = parse_tags(tag_str)
local tag_str = http_argument_get_string(req,"tags")
local tags = {}
if tag_str then
tags = parse_tags(tag_str)
end
local pasteas
local raw = zlib.compress(text)
text = string.gsub(text,"%%(%x%x)",decodeentities)
@ -1035,7 +1039,7 @@ function edit(req)
local text = assert(http_argument_get_string(req,"text"))
local pasteas = assert(http_argument_get_string(req,"pasteas"))
local markup = assert(http_argument_get_string(req,"markup"))
local tags_str = assert(http_argument_get_string(req,"tags"))
local tags_str = http_argument_get_string(req,"tags")
stmnt_author_of:bind_names{
id = storyid
}
@ -1051,7 +1055,10 @@ function edit(req)
local parsed = parsers[markup](text)
local compr_raw = zlib.compress(text)
local compr = zlib.compress(parsed)
local tags = parse_tags(tags_str)
local tags = {}
if tags_str then
tags = parse_tags(tags_str)
end
assert(stmnt_update_raw:bind_blob(1,compr_raw) == sql.OK)
assert(stmnt_update_raw:bind(2,markup) == sql.OK)
assert(stmnt_update_raw:bind(3,storyid) == sql.OK)
@ -1137,8 +1144,11 @@ function preview(req)
local title = assert(http_argument_get_string(req,"title"))
local text = assert(http_argument_get_string(req,"text"))
local markup = assert(http_argument_get_string(req,"markup"))
local tag_str = assert(http_argument_get_string(req,"tags"))
local tags = parse_tags(tag_str)
local tag_str = http_argument_get_string(req,"tags")
local tags = {}
if tag_str then
tags = parse_tags(tag_str)
end
print("title:",title,"text:",text,"markup:",markup)
local parsed = parsers[markup](text)
local ret = pages.read{