a mini social media app for small communities

assorted fixes and clean-up

+3
.gitignore
··· 29 29 30 30 # Local Clockwork install 31 31 /clockwork/ 32 + 33 + # "Real" config (contains secrets and such) 34 + /config.real.maple
+7 -7
build.maple
··· 1 1 plugins = [ 'v' ] 2 2 3 3 task:db.init = { 4 - description = 'Initialize and start a test postgres database' 4 + description = 'Initialize and start a local Postgres database via Docker' 5 5 category = 'db' 6 6 run = 'docker run -it \ 7 7 --name beep-database \ ··· 14 14 } 15 15 16 16 task:db.start = { 17 - description = 'Start the docker image for the database' 17 + description = 'Start the docker image for the local database' 18 18 category = 'db' 19 19 run = 'docker start beep-database' 20 20 } 21 21 22 22 task:db.stop = { 23 - description = 'Stop the docker image for the database' 23 + description = 'Stop the docker image for the local database' 24 24 category = 'db' 25 25 run = 'docker stop beep-database' 26 26 } 27 27 28 28 task:db.login = { 29 - description = 'Log into and modify the database' 29 + description = 'Log into and modify the local database' 30 30 category = 'db' 31 31 run = 'docker exec -it beep-database psql -h localhost -p 5432 -d beep -U beep -W' 32 32 } 33 33 34 34 task:db.shell = { 35 - description = 'Open a shell in the database' 35 + description = 'Open a shell in the local database' 36 36 category = 'db' 37 37 run = 'docker exec -it beep-database sh' 38 38 } 39 39 40 40 task:db.dangerous.nuke = { 41 - description = 'Nuke the docker image AND ITS DATA. This will delete **EVERYTHING** in the database.' 41 + description = 'Delete the docker image AND ITS DATA. This will delete **EVERYTHING** in the database.' 42 42 category = 'db' 43 43 run = 'docker rm beep-database && docker volume rm beep-data' 44 44 } ··· 46 46 task:run = { 47 47 description = 'Run beep' 48 48 category = 'run' 49 - run = '${v} -d veb_livereload watch run ${v_main}' 49 + run = '${v} -d veb_livereload watch run ${v_main} config.maple' 50 50 }
-9
config.maple
··· 12 12 db = 'beep' 13 13 } 14 14 15 - // At least one must be enabled for beep to work. 16 - oauth = { 17 - github = { 18 - enabled = true 19 - id = '' 20 - secret = '' 21 - } 22 - } 23 - 24 15 post = { 25 16 title_max_len = 50 26 17 body_max_len = 500
+18 -4
readme.md
··· 1 1 # beep 2 2 3 - a self-hosted mini-blogger 3 + > *a legendary land of lowercase lovers.* 4 + 5 + a self-hosted mini-blogger. 4 6 5 7 technically made because i wanted to mess around with rss, but i also wanted a 6 - teensy little blog for myself 8 + teensy little blog/slow-paced-chat-app for myself and my friends. 7 9 8 10 ## hosting 9 11 12 + you will need a postgresql database somewhere, along with v to compile beep: 13 + 14 + edit `config.maple` to set the url, port, username, password, and database name. 15 + 16 + > `config.maple` also has settings to configure the feel of your beep instance, 17 + > including toggling images, post length, username length, etc etc. 18 + 19 + > **do not** push your `config.maple`'s secrets to git! 20 + > instead, use `config.real.maple` if you plan to push anywhere. 21 + > it will be gitignored to keep your secrets a secret. 22 + 10 23 ```sh 11 24 git clone https://github.com/emmathemartian/beep 25 + cd beep 12 26 v -prod . 13 - ./beep [port] 27 + ./beep config.maple 14 28 ``` 15 29 16 - then go to `localhost:[port]` to view 30 + then go to the configured url to view (default is `http://localhost:8008`).
+2 -1
src/auth/auth.v
··· 1 1 // From: https://github.com/vlang/v/blob/1fae506900c79e3aafc00e08e1f861fc7cbf8012/vlib/veb/auth/auth.v 2 2 // The original file's source is licensed under MIT. 3 3 4 - // This "fork" re-introduces the `ip` field of each token for additional security. 4 + // This fork re-introduces the `ip` field of each token for additional security, 5 + // along with delete_tokens_for_ip 5 6 6 7 module auth 7 8
-15
src/config.v
··· 17 17 password string 18 18 db string 19 19 } 20 - oauth struct { 21 - pub mut: 22 - github struct { 23 - pub mut: 24 - enabled bool 25 - id string 26 - secret string 27 - } 28 - } 29 20 post struct { 30 21 pub mut: 31 22 title_max_len int ··· 60 51 config.postgres.user = loaded_postgres.get('user').to_str() 61 52 config.postgres.password = loaded_postgres.get('password').to_str() 62 53 config.postgres.db = loaded_postgres.get('db').to_str() 63 - 64 - loaded_oauth := loaded.get('oauth') 65 - loaded_oauth_github := loaded_oauth.get('github') 66 - config.oauth.github.enabled = loaded_oauth_github.get('enabled').to_bool() 67 - config.oauth.github.id = loaded_oauth_github.get('id').to_str() 68 - config.oauth.github.secret = loaded_oauth_github.get('secret').to_str() 69 54 70 55 loaded_post := loaded.get('post') 71 56 config.post.title_max_len = loaded_post.get('title_max_len').to_int()
+2 -1
src/main.v
··· 4 4 import veb 5 5 import auth 6 6 import entity 7 + import os 7 8 8 9 fn init_db(db pg.DB) ! { 9 10 sql db { ··· 13 14 } 14 15 15 16 fn main() { 16 - config := load_config_from('config.maple') 17 + config := load_config_from(os.args[1]) 17 18 18 19 mut db := pg.connect(pg.Config{ 19 20 host: config.postgres.host
+1 -1
src/templates/admin.html
··· 13 13 <div> 14 14 @for u in app.get_users() 15 15 <div> 16 - <a href="/user/@u.id">@u.get_name() (@@@u.username) [@u.id]</a> 16 + <a href="/user/@u.username">@u.get_name() (@@@u.username) [@u.id]</a> 17 17 <p>muted=@u.muted, admin=@u.admin</p> 18 18 <p>created_at=@u.created_at</p> 19 19 </div>
+6 -1
src/templates/partial/header.html
··· 13 13 <body> 14 14 15 15 <header> 16 + @if app.config.dev_mode 17 + <span><strong>dev mode</strong></span> 18 + - 19 + @end 20 + 16 21 <a href="/">home</a> 17 22 - 18 23 ··· 24 29 @if ctx.is_logged_in() 25 30 <a href="/me">profile</a> 26 31 - 27 - <a href="/api/full_logout">log out</a> 32 + <a href="/api/user/logout">log out</a> 28 33 @else 29 34 <a href="/login">log in</a> 30 35 <span>or</span>
+23
todo.md
··· 1 + # todo 2 + 3 + > i use `:` to denote categories 4 + 5 + ## in-progress 6 + 7 + - [ ] user:nicknames 8 + 9 + ## planing 10 + 11 + - [ ] site:stylesheet (and a toggle for html-only mode) 12 + - [ ] post:mentioning ('tagging') other users in posts 13 + - [ ] post:replies 14 + - [ ] post:likes/dislikes/favourites 15 + - [ ] post:tags ('hashtags') 16 + - [ ] post:images (should have a config.maple toggle to enable/disable) 17 + - [ ] user:deletion 18 + - [ ] user:bio/about me 19 + - [ ] user:listed pronouns 20 + 21 + ## ideas 22 + 23 + ## done