This commit is contained in:
Robin Malley 2023-07-11 20:57:08 +00:00
parent e4f8f0914f
commit 8c7a1927c1
2 changed files with 88 additions and 17 deletions

View File

@ -1,5 +1,8 @@
@name .
# SMR
## Overview
This repository contains the source code to a pastebin clone. It was made after
@ -9,23 +12,17 @@ be small, fast, and secure. It is built on top of [Kore](https://kore.io), using
[sqlite3](https://sqlite.org) as it's database. SMR is implemented in about
4k SLOC and is expected to never exceed 5k SLOC. Contributions welcome.
```
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Lua 38 231 438 2338
C 4 65 133 719
HTML 18 23 0 562
JavaScript 4 23 34 293
SQL 36 6 35 274
CSS 3 4 8 74
C/C++ Header 4 3 0 48
-------------------------------------------------------------------------------
SUM: 107 355 648 4308
-------------------------------------------------------------------------------
```
Language|files|blank|comment|code
:-------|-------:|-------:|-------:|-------:
Lua|37|331|678|2197
HTML|22|100|0|1021
C|4|102|251|712
JavaScript|4|23|34|293
SQL|36|6|61|274
make|1|30|6|146
CSS|3|4|8|74
C/C++ Header|4|3|0|48
SUM:|111|599|1038|4765
## Roadmap
@ -66,6 +63,32 @@ If you want to contribute to this repository:
7. Clone this repository into the smr folder, cd into the root, and run `make`!
* You may need to modify the configuration in the Makefile, add `test.monster 127.0.0.1` to your `/etc/hosts`, modify command invocation, ect.
## Folder layout
While the core business logic of SMR is kept under 5k SLOC, tests, documentation,
and other resources exceed this limit. The following is an explanation of what
goes where:
<pre>
smr/
assets/ - kore assets, compiled into the binary. Javascript and CSS are kept here.
cert/ - kore certificates. This is a default to get you started, but in production you should set certificates appropriately.
conf/ - kore configuration. See https://docs.kore.io/4.2.0/applications/koreconf.html
doc/ - documentation for smr that doesn't belong to any particular file
kore_chroot/ - a chroot to get you started modifying smr. In production this should be a properly configured chroot
packaging/ - scripts for packaging smr for different systems
spec/ - unit and system tests for smr
src/ - all the business logic of smr
lua/ - Lua shared code between endpoints
endpoints/ - 1-per endpoint business logic
pages/ - Etlua templated html, exposed from src/lua/pages.lua
sql/ - Sqlite queries, exposed from src/lua/queries.lua
tools/ - command line tools for working with the smr database
accounts/ - tool for modifying author accounts
archive/ - tool for generating archives of the site (NOT the same as backups)
migrate/ - tool for migrating/upgrading the smr database
</pre>
## Misc. notes
SMR requires a slightly modified version of Kore to run. See [my kore patches](https://git.fuwafuwa.moe/rmalley/kore_patches)

48
src/pages/edit_bio.etlua Normal file
View File

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<% if author then %>
<meta name="author" content="<%= author %>">
<% end %>
<% if title then %>
<title><%- title %></title>
<% else %>
<title>&#x1f351;</title>
<% end %>
<link href="/_css/milligram.css" rel="stylesheet">
<link href="/_css/style.css" rel="stylesheet">
<% if extra_load then %>
<% for _,load in ipairs(extra_load) do %>
<%- load %>
<% end %>
<% end %>
</head>
<body class="container">
<main class="wrapper">
<h1 class="title">
Edit Biography for <%= user %>
</h1>
<% if err then %><em class="error"><%= err %></em><% end %>
<form action="https://<%= user %>.<%= domain %>/_bio" method="post" class="container">
<fieldset>
<input type="hidden" name="author" value="<%= user %>">
<div class="row">
<textarea name="text" cols=80 rows=24 class="column"><%= text %></textarea><br/>
</div>
<div class="row">
<input type="submit">
</div>
</fieldset>
</form>
<footer class="footer">
</footer>
</main>
</body>
<body>