32 lines
851 B
Lua
32 lines
851 B
Lua
local parsers = require("parsers")
|
|
local tags = require("tags")
|
|
local util = require("util")
|
|
local pages = require("pages")
|
|
local config = require("config")
|
|
|
|
local function preview_post(req)
|
|
local host = http_request_get_host(req)
|
|
local path = http_request_get_path(req)
|
|
http_request_populate_post(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 = http_argument_get_string(req,"tags")
|
|
local tags = {}
|
|
if tag_str then
|
|
tags = util.parse_tags(tag_str)
|
|
end
|
|
local parsed = parsers[markup](text)
|
|
local ret = pages.read{
|
|
domain = config.domain,
|
|
title = title,
|
|
author = "preview",
|
|
idp = "preview",
|
|
text = parsed,
|
|
tags = tags,
|
|
}
|
|
http_response(req,200,ret)
|
|
end
|
|
|
|
return preview_post
|