1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 10:18:21 +01:00
antd-web-apps/blog/views/default/post/posts.ls

91 lines
3.2 KiB
Plaintext
Raw Normal View History

2018-02-23 19:52:10 +01:00
<?lua
2018-09-05 16:56:04 +02:00
local datas = posts
2018-02-25 13:54:37 +01:00
local class = "card"
2018-03-07 14:18:25 +01:00
local first_id = nil
local last_id = nil
2018-02-25 13:54:37 +01:00
if HEADER.mobile then
class = "card mobile"
end
2018-09-05 16:56:04 +02:00
2018-02-24 19:14:46 +01:00
for idx,v in pairs(order) do
local data = datas[v]
2018-03-07 14:18:25 +01:00
if not last_id then last_id = data.id end
first_id = data.id
2018-02-23 19:52:10 +01:00
?>
2018-02-25 13:54:37 +01:00
<div class = "<?=class?>">
2018-02-23 19:52:10 +01:00
<div class = "side">
<span class = "date"><?=data.ctimestr:gsub("%s+.*$","")?></span>
<span class = "tags">
<?lua
local atags = {}
local i = 1
for tag in data.tags:gmatch(",*([^,]+)") do
tag = std.trim(tag, " ")
2018-02-25 01:57:42 +01:00
if tag ~= "" then
local b64tag = std.b64encode(tag)
2018-09-05 16:56:04 +02:00
atags[i] = '<a href = "'..HTTP_ROOT..'/post/bytag/'..b64tag:gsub("=","")..'/'..POST_LIMIT..'">'..tag.."</a>"
2018-02-25 01:57:42 +01:00
i = i+ 1
end
2018-02-23 19:52:10 +01:00
end
echo(table.concat(atags, ", "))
2018-09-05 16:56:04 +02:00
local url = HTTP_ROOT.."/post/id/"..data.id
2018-02-23 19:52:10 +01:00
?>
</span>
2018-02-27 11:39:18 +01:00
<div class="fb-like" data-href="<?=url?>" data-layout="button_count" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div>
2018-06-05 15:40:15 +02:00
<!--div class="g-plusone" data-action="share" data-size="medium" data-href="<?=url?>"></div-->
2018-02-27 11:39:18 +01:00
<a class="twitter-share-button" href='https://twitter.com/intent/tweet?url=<?=url?>&text=<?=data.title?>'></a>
2018-02-23 19:52:10 +01:00
</div>
<div class = "blogentry">
<div class = "shortcontent">
<?lua
2018-02-25 02:31:13 +01:00
local content = bytes.__tostring(std.b64decode(data.rendered)):gsub("%%","%%%%")
2018-02-23 19:52:10 +01:00
local r, s = content:find("(<hr/?>)")
2018-02-25 15:19:31 +01:00
local title = nil
2018-02-23 19:52:10 +01:00
if r then
content = content:sub(0,r-1)
end
2018-02-25 15:19:31 +01:00
local a,b = content:find("<[Hh]1[^>]*>")
local c,d
if a then
c,d = content:find("</[Hh]1>")
if c then
title = content:sub(b+1, c-1)
end
end
if title then
echo(content:sub(0, b))
2018-09-05 16:56:04 +02:00
echo("<a class = 'title_link' href='"..HTTP_ROOT.."/post/id/"..data.id.."'>"..title.."</a>")
2018-02-25 15:19:31 +01:00
echo(content:sub(c))
else
echo(content)
end
2018-02-23 19:52:10 +01:00
?>
</div>
<div class = "detail">
<span></span>
2018-09-05 16:56:04 +02:00
<?='<a href="'..HTTP_ROOT..'/post/id/'..data.id..'" ></a>'?>
2018-02-23 19:52:10 +01:00
<span></span>
</div>
</div>
</div>
<?lua
end
2018-09-05 16:56:04 +02:00
local beforelk = HTTP_ROOT.."/post/beforeof/"..first_id.."/"..POST_LIMIT
local afterlk = HTTP_ROOT.."/post/afterof/"..last_id.."/"..POST_LIMIT
2018-03-07 14:18:25 +01:00
if action == "bytag" or action == "search" then
2018-09-05 16:56:04 +02:00
beforelk = HTTP_ROOT.."/post/"..action.."/"..query.."/"..POST_LIMIT.."/before/"..first_id
afterlk = HTTP_ROOT.."/post/"..action.."/"..query.."/"..POST_LIMIT.."/after/"..last_id
2018-03-07 14:18:25 +01:00
end
?>
<div class = "time-travel">
<?lua
if first_id ~= minid then
?>
<a href = "<?=beforelk?>" class = "past"><< Older posts</a>
<?lua
end
if last_id ~= maxid then
2018-02-23 19:52:10 +01:00
?>
2018-03-07 14:18:25 +01:00
<a href = "<?=afterlk?>" class = "future">Newer posts >></a>
<?lua end ?>
</div>