diff --git a/Makefile b/Makefile
index 668d388..00c9114 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,12 @@
+# Binaries
+ECHO=echo
+KODEV=kodev
+MKDIR=mkdir -p
+COPY=cp
+RM=rm -f
+SPP=spp
+
+
# Config
chroot_dir=kore_chroot/
mirror=http://dl-cdn.alpinelinux.org/alpine/
@@ -5,36 +14,56 @@ arch=aarch64
version=2.10.5-r0
certbot_email=--register-unsafely-without-email
#certbot_email=-m you@cock.li
-domain=test.monster
+user=robin
+port=8888
+domain=test.monster:$(port)
-#Probably don't change stuff past here
-lua_files=$(shell find src/lua -type f)
+#squelch prints
+Q=@
+#Q=
+
+# Probably don't change stuff past here if you're just using smr
+lua_in_files=$(shell find src/lua/*.in -type f)
+lua_files=$(shell find src/lua/*.lua -type f) $(shell find src/lua/endpoints -type f) $(lua_in_files:%.in=%)
src_files=$(shell find src -type f) $(shell find conf -type f)
sql_files=$(shell find src/sql -type f)
test_files=$(shell find spec -type f)
built_tests=$(test_files:%=$(chroot_dir)%)
built_files=$(lua_files:src/lua/%.lua=$(chroot_dir)%.lua)
-page_files=$(shell find src/pages -type f)
+in_page_files=$(shell find src/pages/*.in -type f)
+in_part_files=$(shell find src/pages/parts/*.in -type f)
+page_files=$(in_page_files:%.in=%)
+part_files=$(in_part_files:%.in=%) $(shell find src/pages/parts/*.etlua -type f)
built_pages=$(page_files:src/pages/%.etlua=$(chroot_dir)pages/%.etlua)
built_sql=$(sql_files:src/sql/%.sql=$(chroot_dir)sql/%.sql)
built=$(built_files) $(built_sql) $(built_pages) $(built_tests)
all: $(chroot_dir) smr.so $(built_files) $(built_pages) $(built_sql)
- echo $(built_files)
- kodev run
+ $(Q)$(ECHO) "[running] $@"
+ $(Q)$(KODEV) run
+
+conf/smr.conf : conf/smr.conf.in Makefile
+ $(Q)$(ECHO) "[preprocess] $@"
+ $(Q)$(SPP) -o $@ -D port=$(port) -D kore_chroot=$(chroot_dir) -D chuser=$(user) $<
apk-tools-static-$(version).apk:
# wget -q $(mirror)latest-stable/main/$(arch)/apk-tools-static-$(version).apk
clean:
- kodev clean
+ $(Q)$(ECHO) "[clean] $@"
+ $(Q)$(KODEV) clean
+ $(Q)$(RM) $(page_files)
+ $(Q)$(RM) conf/smr.conf
+ $(Q)$(RM) src/pages/parts/story_breif.etlua
+ $(Q)$(RM) src/lua/config.lua
+
$(chroot_dir): apk-tools-static-$(version).apk
- mkdir -p $(chroot_dir)
- mkdir -p $(chroot_dir)/pages
- mkdir -p $(chroot_dir)/sql
- mkdir -p $(chroot_dir)/data
- mkdir -p $(chroot_dir)/endpoints
+ $(Q)$(MKDIR) $(chroot_dir)
+ $(Q)$(MKDIR) $(chroot_dir)/pages
+ $(Q)$(MKDIR) $(chroot_dir)/sql
+ $(Q)$(MKDIR) $(chroot_dir)/data
+ $(Q)$(MKDIR) $(chroot_dir)/endpoints
#cd $(chroot_dir) && tar -xvzf ../apk-tools-static-*.apk
#cd $(chroot_dir) && sudo ./sbin/apk.static -X $(mirror)latest-stable/main -U --allow-untrusted --root $(chroot_dir) --no-cache --initdb add alpine-base
#ln -s /dev/urandom $(chroot_dir)/dev/random #Prevent an attacker with access to the chroot from exhausting our entropy pool and causing a dos
@@ -64,20 +93,36 @@ $(chroot_dir): apk-tools-static-$(version).apk
code : $(built_files)
$(built_files): $(chroot_dir)%.lua : src/lua/%.lua
- echo built files: $(built_files)
- cp $^ $@
+ $(Q)$(ECHO) "[copy] $@"
+ $(Q)$(COPY) $^ $@
$(built_pages): $(chroot_dir)pages/%.etlua : src/pages/%.etlua
- cp $^ $@
+ $(Q)$(ECHO) "[copy] $@"
+ $(Q)$(COPY) $^ $@
+
+src/lua/config.lua : src/lua/config.lua.in Makefile
+ $(Q)$(ECHO) "[preprocess] $@"
+ $(Q)$(SPP) -o $@ -D domain=$(domain) $<
+
+$(page_files) : % : %.in $(part_files)
+ $(Q)$(ECHO) "[preprocess] $@"
+ $(Q)$(SPP) -o $@ $<
+
+src/pages/parts/story_breif.etlua : src/pages/parts/story_breif.etlua.in
+ $(Q)$(ECHO) "[preprocess] $@"
+ $(Q)$(SPP) -o $@ $<
$(built_sql): $(chroot_dir)sql/%.sql : src/sql/%.sql
- cp $^ $@
+ $(Q)$(ECHO) "[copy] $@"
+ $(Q)$(COPY) $^ $@
$(built_tests) : $(chroot_dir)% : %
- cp $^ $@
+ $(Q)$(ECHO) "[copy] $@"
+ $(Q)$(COPY) $^ $@
-smr.so : $(src_files)
- kodev build
+smr.so : $(src_files) conf/smr.conf conf/build.conf
+ $(Q)$(ECHO) "[build] $@"
+ $(Q)$(KODEV) build
test : $(built)
- cd kore_chroot && busted
+ $(Q)$(CD) kore_chroot && busted
diff --git a/conf/smr.conf b/conf/smr.conf.in
similarity index 93%
rename from conf/smr.conf
rename to conf/smr.conf.in
index 18a72fa..5955320 100644
--- a/conf/smr.conf
+++ b/conf/smr.conf.in
@@ -1,14 +1,18 @@
# smr configuration
server tls {
- bind 0.0.0.0 8888
+ bind 0.0.0.0 <{get port}>
+
}
seccomp_tracing yes
load ./smr.so
-root kore_chroot
-runas robin
-keymgr_runas robin
+root <{get kore_chroot}>
+
+runas <{get chuser }>
+
+keymgr_runas <{get chuser }>
+
keymgr_root .
workers 1
diff --git a/src/lua/config.lua b/src/lua/config.lua.in
similarity index 76%
rename from src/lua/config.lua
rename to src/lua/config.lua.in
index 1737bc4..7d70695 100644
--- a/src/lua/config.lua
+++ b/src/lua/config.lua.in
@@ -3,6 +3,6 @@ Holds configuration.
A one-stop-shop for runtime configuration
]]
return {
- domain = "test.monster:8888",
+ domain = "<{get domain}>",
production = false,
}
diff --git a/src/lua/endpoints/index_get.lua b/src/lua/endpoints/index_get.lua
index b91844a..2c3fdbc 100644
--- a/src/lua/endpoints/index_get.lua
+++ b/src/lua/endpoints/index_get.lua
@@ -25,7 +25,7 @@ local function get_site_home(req)
log(LOG_DEBUG,"Cache miss, rendering site index")
stmnt_index:bind_names{}
local latest = {}
- for idr, title, iar, dater, author in util.sql_rows(stmnt_index) do
+ 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),
@@ -34,6 +34,7 @@ local function get_site_home(req)
posted = os.date("%B %d %Y",tonumber(dater)),
author = author,
tags = libtags.get(idr),
+ hits = hits,
})
end
return pages.index{
@@ -59,12 +60,14 @@ local function get_author_home(req)
stmnt_author_bio:reset()
stmnt_author:bind_names{author=subdomain}
local stories = {}
- for id, title, time in util.sql_rows(stmnt_author) do
+ for id, title, time, hits in util.sql_rows(stmnt_author) do
table.insert(stories,{
url = util.encode_id(id),
title = title,
+ author=subdomain,
posted = os.date("%B %d %Y",tonumber(time)),
tags = libtags.get(id),
+ hits = hits,
})
end
return pages.author_index{
diff --git a/src/lua/endpoints/paste_get.lua b/src/lua/endpoints/paste_get.lua
index a80f435..0988ebd 100644
--- a/src/lua/endpoints/paste_get.lua
+++ b/src/lua/endpoints/paste_get.lua
@@ -9,28 +9,31 @@ 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
elseif host == config.domain and author == nil then
text = cache.render(string.format("%s/_paste",host),function()
log(LOG_DEBUG, "Cache missing, rendering post page")
- return pages.paste{
+ return assert(pages.paste{
domain = config.domain,
err = "",
- }
+ })
end)
http_response(req,200,text)
elseif host ~= config.domain and author then
- text = pages.author_paste{
+ text = assert(pages.author_paste{
domain = config.domain,
user = author,
err = "",
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
else
error(string.format(
"Unable to find a good case for paste:%s,%s,%s",
diff --git a/src/lua/endpoints/search_get.lua b/src/lua/endpoints/search_get.lua
index d7010c3..47fe7fe 100644
--- a/src/lua/endpoints/search_get.lua
+++ b/src/lua/endpoints/search_get.lua
@@ -19,7 +19,16 @@ local function search_get(req)
local host = http_request_get_host(req)
local path = http_request_get_path(req)
http_request_populate_qs(req)
- local searchq = assert(http_argument_get_string(req,"q"))
+ local searchq, err = http_argument_get_string(req,"q")
+ if not searchq then
+ local ret = pages.search{
+ domain = config.domain,
+ results = {},
+ q = "",
+ }
+ http_response(req,200,ret)
+ return
+ end
log(LOG_DEBUG,string.format("search: %q",searchq))
local sqltxt, data = search_parser(searchq)
local stmnt = assert(db.conn:prepare(sqltxt), db.conn:errmsg())
@@ -39,12 +48,13 @@ local function search_get(req)
local results = {}
for row in stmnt:rows() do
table.insert(results,{
- id = util.encode_id(row[1]),
+ url = util.encode_id(row[1]),
title = row[2],
isanon = row[3] == 1,
author = row[4],
- time = os.date("%B %d %Y",tonumber(row[5])),
- tags = libtags.get(row[1])
+ posted = os.date("%B %d %Y",tonumber(row[5])),
+ tags = libtags.get(row[1]),
+ hits = row[6]
})
end
local ret = pages.search{
diff --git a/src/lua/pages.lua b/src/lua/pages.lua
index 099e07b..e2690da 100644
--- a/src/lua/pages.lua
+++ b/src/lua/pages.lua
@@ -19,10 +19,28 @@ local pagenames = {
"search",
}
local pages = {}
-for k,v in pairs(pagenames) do
- local f = assert(io.open("pages/" .. v .. ".etlua","r"))
- pages[v] = assert(et.compile(f:read("*a")))
+local function load1(page)
+ local path = string.format("pages/%s.etlua",page)
+ local parser = et.Parser()
+ local f = assert(io.open(path,"r"))
+ local fdata = assert(f:read("*a"))
+ local code = assert(parser:parse(fdata))
+ local func = assert(parser:load(parser:chunks_to_lua(),path))
f:close()
+ return function(...)
+ buf = assert(parser:run(func,...))
+ return table.concat(buf)
+ end
+end
+local function load2(page)
+ local path = string.format("pages/%s.etlua",page)
+ local f = assert(io.open(path,"r"))
+ local ret = assert(et.compile(f:read("*a")))
+ f:close()
+ return ret
+end
+for k,v in pairs(pagenames) do
+ pages[v] = load1(v)
end
return pages
diff --git a/src/pages/author_edit.etlua b/src/pages/author_edit.etlua
deleted file mode 100644
index a5af321..0000000
--- a/src/pages/author_edit.etlua
+++ /dev/null
@@ -1,42 +0,0 @@
-<% assert(author,"No author specified") %>
-<% assert(bio,"No bio included") %>
-
-
-
-
-
- 🍑
-
-
-
-
-
-
-
-
-
-
- <% if #stories == 0 then %>
- This author has not made any pastes yet.
- <% else %>
-
- <% for k,v in pairs(stories) do %>
- <%= v[1] %> <%= v[2] %>
- <% end %>
-
- <% end %>
-
-
-
-
-
-
diff --git a/src/pages/author_edit.etlua.in b/src/pages/author_edit.etlua.in
new file mode 100644
index 0000000..9dd423a
--- /dev/null
+++ b/src/pages/author_edit.etlua.in
@@ -0,0 +1,27 @@
+<% assert(author,"No author specified") %>
+<% assert(bio,"No bio included") %>
+<{system cat src/pages/parts/header.etlua}>
+
+
+
+
+
+ <%= bio %>
+
+
+
+
+
+ <% if #stories == 0 then %>
+ This author has not made any pastes yet.
+ <% else %>
+
+ <% for k,story in pairs(stories) do %>
+ <{system cat src/pages/parts/story_breif.etlua}>
+ <% end %>
+
+ <% end %>
+
+<{system cat src/pages/parts/footer.etlua}>
diff --git a/src/pages/author_index.etlua b/src/pages/author_index.etlua
deleted file mode 100644
index 98b8f76..0000000
--- a/src/pages/author_index.etlua
+++ /dev/null
@@ -1,49 +0,0 @@
-<% assert(author,"No author specified") %> <% assert(bio,"No bio included") %>
- 🍑
-
-
-
-
-
-
-
-
- <%= bio %>
-
-
- <% if #stories == 0 then %>
- This author has not made any pastes yet.
- <% else %>
-
- <% end %>
-
-
-
-
-
-
-
diff --git a/src/pages/author_index.etlua.in b/src/pages/author_index.etlua.in
new file mode 100644
index 0000000..34c4b4c
--- /dev/null
+++ b/src/pages/author_index.etlua.in
@@ -0,0 +1,25 @@
+<% assert(author,"No author specified") %>
+<% assert(bio,"No bio included") %>
+<{system cat src/pages/parts/header.etlua}>
+
+
+
+ <%= bio %>
+
+
+ <% if #stories == 0 then %>
+ This author has not made any pastes yet.
+ <% else %>
+
+ <% for k,story in pairs(stories) do %>
+ <{system cat src/pages/parts/story_breif.etlua}>
+ <% end %>
+
+ <% end %>
+
+<{system cat src/pages/parts/footer.etlua}>
+
diff --git a/src/pages/author_paste.etlua b/src/pages/author_paste.etlua
deleted file mode 100644
index 04e8401..0000000
--- a/src/pages/author_paste.etlua
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
- 🍑
-
-
-
-
-
-
- Paste
-
- <% if err then %><%= err %> <% end %>
-
-
-
-
-
- <%= user %>
- Anonymous
-
-
- Plain
- Imageboard
-
-
-
-
-
-
- <%= text %>
-
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/author_paste.etlua.in b/src/pages/author_paste.etlua.in
new file mode 100644
index 0000000..e9a791b
--- /dev/null
+++ b/src/pages/author_paste.etlua.in
@@ -0,0 +1,30 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ Paste
+
+<% if err then %><%= err %> <% end %>
+
+
+
+
+
+ <%= user %>
+ Anonymous
+
+
+ Plain
+ Imageboard
+
+
+
+
+
+
+ <%= text %>
+
+
+
+
+
+<{system cat src/pages/parts/footer.etlua}>
+
diff --git a/src/pages/cantedit.etlua b/src/pages/cantedit.etlua
deleted file mode 100644
index f9222e1..0000000
--- a/src/pages/cantedit.etlua
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- 🙁
-
-
-
-
-
-
- 🙁
-
-
-
- You don't have permission to edit: <%= path %>
-
-
-
-
-
-
diff --git a/src/pages/cantedit.etlua.in b/src/pages/cantedit.etlua.in
new file mode 100644
index 0000000..ceb215f
--- /dev/null
+++ b/src/pages/cantedit.etlua.in
@@ -0,0 +1,11 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ 🙁
+
+
+
+ You don't have permission to edit: <%= path %>
+
+
+<{system cat src/pages/parts/footer.etlua}>
+
diff --git a/src/pages/claim.etlua b/src/pages/claim.etlua
deleted file mode 100644
index 01c39ab..0000000
--- a/src/pages/claim.etlua
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
- 🍑
-
-
-
-
-
-
- Register
-
- Once you press submit, you will be prompted to download a file.
- slash.monster uses this file in place of a password, keep it safe.
- Consider keeping a copy on a USB in case your hard drive fails.
- The admin cannot recover your passfile, and will not reset accounts.
- Names may be up to 30 characters, alphanumeric, no symbols, all lower case.
- <% if err then %><%= err %> <% end %>
-
-
- Name:
-
-
-
-
- Once you have your file, you can log in
-
-
-
-
-
diff --git a/src/pages/claim.etlua.in b/src/pages/claim.etlua.in
new file mode 100644
index 0000000..08eaf7d
--- /dev/null
+++ b/src/pages/claim.etlua.in
@@ -0,0 +1,20 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ Register
+
+Once you press submit, you will be prompted to download a file.
+slash.monster uses this file in place of a password, keep it safe.
+Consider keeping a copy on a USB in case your hard drive fails.
+The admin cannot recover your passfile, and will not reset accounts.
+Names may be up to 30 characters, alphanumeric, no symbols, all lower case.
+<% if err then %><%= err %> <% end %>
+
+
+ Name:
+
+
+
+
+Once you have your file, you can log in
+<{system cat src/pages/parts/footer.etlua}>
+
diff --git a/src/pages/edit.etlua b/src/pages/edit.etlua
deleted file mode 100644
index 14a2c90..0000000
--- a/src/pages/edit.etlua
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
-
- 🍑
-
-
-
-
-
-
- Paste
-
- <% if err then %><%= err %> <% end %>
-
-
-
-
-
-
- <% if isanon then %>
- <%= user %>
- Anonymous
- <% else %>
- <%= user %>
- Anonymous
- <% end %>
-
-
- Plain
- Imageboard
-
-
-
-
-
-
- <%= text %>
-
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/edit.etlua.in b/src/pages/edit.etlua.in
new file mode 100644
index 0000000..617f515
--- /dev/null
+++ b/src/pages/edit.etlua.in
@@ -0,0 +1,36 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ Paste
+
+<% if err then %><%= err %> <% end %>
+
+
+
+
+
+
+ <% if isanon then %>
+ <%= user %>
+ Anonymous
+ <% else %>
+ <%= user %>
+ Anonymous
+ <% end %>
+
+
+ Plain
+ Imageboard
+
+
+
+
+
+
+ <%= text %>
+
+
+
+
+
+<{cat src/pages/parts/footer.etlua}>
+
diff --git a/src/pages/index.etlua b/src/pages/index.etlua
deleted file mode 100644
index bc3f16f..0000000
--- a/src/pages/index.etlua
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
-
- 🍑
-
-
-
-
-
-
-
-
-
-
- Welcome to slash.monster, stories of fiction and fantasy
- Not safe for work
- 18+
-
-
-
- <% if #stories == 0 then %>
- No stories available.
- <% else %>
-
- <% for k,v in pairs(stories) do %>
-
-
- <%- v.title %>
-
-
- <% if v.isanon then %>
- By Anonymous
- <% else %>
- By <%= v.author %>
- <% end %>
-
-
- <% for i = 1,math.min(#v.tags, 5) do %>
- <%= v.tags[i] %>
- <% end %>
- <% if #v.tags > 5 then %>
- +<%= #v.tags - 5 %>
- <% end %>
-
-
- <%= v.posted %>
-
- <% end %>
-
- <% end %>
-
-
-
-
-
diff --git a/src/pages/index.etlua.in b/src/pages/index.etlua.in
new file mode 100644
index 0000000..1efc8e6
--- /dev/null
+++ b/src/pages/index.etlua.in
@@ -0,0 +1,36 @@
+<{system cat src/pages/parts/header.etlua}>
+
+
+
+
+
+ Welcome to slash.monster, stories of fiction and fantasy
+ Not safe for work
+ 18+
+
+
+
+ <% if #stories == 0 then %>
+ No stories available.
+ <% else %>
+
+ <% for k,story in pairs(stories) do %>
+ <{system cat src/pages/parts/story_breif.etlua}>
+ <% end %>
+
+ <% end %>
+
+<{system cat src/pages/parts/footer.etlua}>
+
diff --git a/src/pages/login.etlua b/src/pages/login.etlua
deleted file mode 100644
index ae360a6..0000000
--- a/src/pages/login.etlua
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
- 🍑
-
-
-
-
-
-
- Login
-
- <% if err then %><%= err %> <% end %>
-
-
- Name:
-
- Passfile:
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/login.etlua.in b/src/pages/login.etlua.in
new file mode 100644
index 0000000..72b132a
--- /dev/null
+++ b/src/pages/login.etlua.in
@@ -0,0 +1,15 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ Login
+
+<% if err then %><%= err %> <% end %>
+
+
+ Name:
+
+ Passfile:
+
+
+
+
+<{system cat src/pages/parts/footer.etlua}>
diff --git a/src/pages/noauthor.etlua.in b/src/pages/noauthor.etlua.in
new file mode 100644
index 0000000..a2869e2
--- /dev/null
+++ b/src/pages/noauthor.etlua.in
@@ -0,0 +1,11 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ 🙁
+
+
+
+ No author found: <%= author %>
+
+
+<{system cat src/pages/parts/footer.etlua}>
+
diff --git a/src/pages/nostory.etlua b/src/pages/nostory.etlua
deleted file mode 100644
index 2e8f478..0000000
--- a/src/pages/nostory.etlua
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
- 🙁
-
-
-
-
-
-
- 🙁
-
-
-
- No story found: <%= path %>
-
-
-
-
-
-
diff --git a/src/pages/nostory.etlua.in b/src/pages/nostory.etlua.in
new file mode 100644
index 0000000..2bb1747
--- /dev/null
+++ b/src/pages/nostory.etlua.in
@@ -0,0 +1,10 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ 🙁
+
+
+
+ No story found: <%= path %>
+
+
+<{system cat src/pages/parts/footer.etlua}>
diff --git a/src/pages/parts/.gitignore b/src/pages/parts/.gitignore
new file mode 100644
index 0000000..c64a60d
--- /dev/null
+++ b/src/pages/parts/.gitignore
@@ -0,0 +1 @@
+story_breif.etlua
diff --git a/src/pages/parts/footer.etlua b/src/pages/parts/footer.etlua
new file mode 100644
index 0000000..296f1cd
--- /dev/null
+++ b/src/pages/parts/footer.etlua
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/src/pages/noauthor.etlua b/src/pages/parts/header.etlua
similarity index 54%
rename from src/pages/noauthor.etlua
rename to src/pages/parts/header.etlua
index e253077..f56c97d 100644
--- a/src/pages/noauthor.etlua
+++ b/src/pages/parts/header.etlua
@@ -1,22 +1,19 @@
+
+
- 🙁
+ <% if author then %>
+
+ <% end %>
+ <% if title then %>
+ <%- title %>
+ <% else %>
+ 🍑
+ <% end %>
-
- 🙁
-
-
-
- No author found: <%= author %>
-
-
-
-
-
-
diff --git a/src/pages/parts/story_breif.etlua.in b/src/pages/parts/story_breif.etlua.in
new file mode 100644
index 0000000..405d4aa
--- /dev/null
+++ b/src/pages/parts/story_breif.etlua.in
@@ -0,0 +1,23 @@
+
+
+
+ <%- story.title %>
+
+
+ <% if story.isanon then %>
+ By Anonymous
+ <% else %>
+ By <%= story.author %>
+ <% end %>
+
+ <%= story.hits %> hits
+
+
+ <% for i = 1,math.min(#story.tags, 5) do %>
+ <% local tag = story.tags[i] %>
+ <{system cat src/pages/parts/taglist.etlua}>
+ <% end %>
+
+
+ <%= story.posted %>
+
diff --git a/src/pages/parts/taglist.etlua b/src/pages/parts/taglist.etlua
new file mode 100644
index 0000000..0c8e5bb
--- /dev/null
+++ b/src/pages/parts/taglist.etlua
@@ -0,0 +1,5 @@
+
+
+ <%= tag %>
+
+
diff --git a/src/pages/paste.etlua b/src/pages/paste.etlua
deleted file mode 100644
index bff260e..0000000
--- a/src/pages/paste.etlua
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
- 🍑
-
-
-
-
-
-
- Paste
-
- <% if err then %><%= err %> <% end %>
-
-
-
-
- Plain
- Imageboard
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/pages/paste.etlua.in b/src/pages/paste.etlua.in
new file mode 100644
index 0000000..92a5f9f
--- /dev/null
+++ b/src/pages/paste.etlua.in
@@ -0,0 +1,23 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ Paste
+
+<% if err then %><%= err %> <% end %>
+
+
+
+
+ Plain
+ Imageboard
+
+
+
+
+
+
+
+
+
+
+
+<{system cat src/pages/parts/footer.etlua}>
diff --git a/src/pages/read.etlua b/src/pages/read.etlua
deleted file mode 100644
index 4acb10a..0000000
--- a/src/pages/read.etlua
+++ /dev/null
@@ -1,84 +0,0 @@
-
-
-
-
-
- <%- title %>
-
-
-
-
-
- <%= domain %> /<%= idp %>
-
- <% if owner then -%>
-
-
-
-
- <% end -%>
-
-
- <%- title %>
-
-
- <% if isanon or author == nil then -%>
- By Anonymous
- <% else -%>
- By <%= author %>
- <% end -%>
-
- <%- text %>
-
-
- <%= views %> Hits
-
- <% for _,tag in pairs(tags) do -%>
- <%= tag %>
- <% end -%>
-
-
-
-
-
- <% if not show_comments then -%>
-
-
-
-
- <% else %>
-
-
- <% if iam then %>
-
- Anonymous
- <%= iam %>
-
-
- <% else %>
-
-
- <% end %>
-
- <% if comments and #comments == 0 then %>
- No comments yet
- <% else %>
-
- <% for _,comment in pairs(comments) do %>
-
- <% if comment.isanon then %>
- Anonymous
- <% else %>
- <%= comment.author %>
- <% end %>
- <%= comment.text %>
-
- <% end %>
-
- <% end %>
- <% end %>
-
-
-
-
-
diff --git a/src/pages/read.etlua.in b/src/pages/read.etlua.in
new file mode 100644
index 0000000..2b71e14
--- /dev/null
+++ b/src/pages/read.etlua.in
@@ -0,0 +1,73 @@
+<{system cat src/pages/parts/header.etlua}>
+
+ <%= domain %> /<%= idp %>
+
+<% if owner then -%>
+
+
+
+
+<% end -%>
+
+ <%- title %>
+
+ <% if isanon or author == nil then -%>
+ By Anonymous
+ <% else -%>
+ By <%= author %>
+ <% end -%>
+
+ <%- text %>
+
+
+
+
+<%= views %> Hits
+
+
+ <% for _,tag in pairs(tags) do -%>
+ <{system cat src/pages/parts/taglist.etlua}>
+ <% end -%>
+
+
+
+
+
+
+<% if not show_comments then -%>
+
+
+
+
+<% else %>
+
+
+ <% if iam then %>
+
+ Anonymous
+ <%= iam %>
+
+
+ <% else %>
+
+
+ <% end %>
+
+ <% if comments and #comments == 0 then %>
+ No comments yet
+ <% else %>
+
+ <% for _,comment in pairs(comments) do %>
+
+ <% if comment.isanon then %>
+ Anonymous
+ <% else %>
+ <%= comment.author %>
+ <% end %>
+ <%= comment.text %>
+
+ <% end %>
+
+ <% end %>
+<% end %>
+<{system cat src/pages/parts/footer.etlua}>
diff --git a/src/pages/search.etlua b/src/pages/search.etlua
deleted file mode 100644
index 4bf5e3e..0000000
--- a/src/pages/search.etlua
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
- 🍑
-
-
-
-
-
-
-
-
-
-
-
-
-
- <% if #results == 0 then %>
- No stories matched your search.
- <% else %>
-
- <% for k,v in pairs(results) do %>
-
-
- <%- v.title %>
-
-
- <% if v.isanon then %>
- By Anonymous
- <% else %>
- By <%= v.author %>
- <% end %>
-
-
- <% for i = 1,math.min(#v.tags, 5) do %>
- <%= v.tags[i] %>
- <% end %>
- <% if #v.tags > 5 then %>
- +<%= #v.tags - 5%>
- <% end %>
-
-
- <%= v.time %>
-
- <% end %>
-
- <% end %>
-
-
-
-
-
diff --git a/src/pages/search.etlua.in b/src/pages/search.etlua.in
new file mode 100644
index 0000000..bd19abb
--- /dev/null
+++ b/src/pages/search.etlua.in
@@ -0,0 +1,22 @@
+<{system cat src/pages/parts/header.etlua}>
+
+
+
+
+
+
+
+
+ <% if #results == 0 then %>
+ No stories matched your search.
+ <% else %>
+
+ <% for k,story in pairs(results) do %>
+ <{system cat src/pages/parts/story_breif.etlua}>
+ <% end %>
+
+ <% end %>
+
+<{system cat src/pages/parts/footer.etlua}>
diff --git a/src/pages/search_sql.etlua b/src/pages/search_sql.etlua.in
similarity index 93%
rename from src/pages/search_sql.etlua
rename to src/pages/search_sql.etlua.in
index 1b447dd..2f93c7a 100644
--- a/src/pages/search_sql.etlua
+++ b/src/pages/search_sql.etlua.in
@@ -3,7 +3,8 @@ SELECT
posts.post_title,
posts.isanon,
authors.name,
- posts.post_time
+ posts.post_time,
+ posts.views
FROM
posts,authors
WHERE
@@ -30,7 +31,8 @@ SELECT
posts.post_title,
posts.isanon,
authors.name,
- posts.post_time
+ posts.post_time,
+ posts.views
FROM
posts,authors,tags
WHERE
diff --git a/src/sql/select_author_index.sql b/src/sql/select_author_index.sql
index 319da48..7eecab9 100644
--- a/src/sql/select_author_index.sql
+++ b/src/sql/select_author_index.sql
@@ -3,7 +3,8 @@
SELECT
posts.id,
posts.post_title,
- posts.post_time
+ posts.post_time,
+ posts.views
FROM
posts,
authors
diff --git a/src/sql/select_site_index.sql b/src/sql/select_site_index.sql
index 99d8abc..664fd17 100644
--- a/src/sql/select_site_index.sql
+++ b/src/sql/select_site_index.sql
@@ -4,7 +4,8 @@ SELECT
posts.post_title,
posts.isanon,
posts.post_time,
- authors.name
+ authors.name,
+ posts.views
FROM
posts,
authors