a mini social media app for small communities

assorted fixes and clean-up

+3
.gitignore
··· 29 30 # Local Clockwork install 31 /clockwork/
··· 29 30 # Local Clockwork install 31 /clockwork/ 32 + 33 + # "Real" config (contains secrets and such) 34 + /config.real.maple
+7 -7
build.maple
··· 1 plugins = [ 'v' ] 2 3 task:db.init = { 4 - description = 'Initialize and start a test postgres database' 5 category = 'db' 6 run = 'docker run -it \ 7 --name beep-database \ ··· 14 } 15 16 task:db.start = { 17 - description = 'Start the docker image for the database' 18 category = 'db' 19 run = 'docker start beep-database' 20 } 21 22 task:db.stop = { 23 - description = 'Stop the docker image for the database' 24 category = 'db' 25 run = 'docker stop beep-database' 26 } 27 28 task:db.login = { 29 - description = 'Log into and modify the database' 30 category = 'db' 31 run = 'docker exec -it beep-database psql -h localhost -p 5432 -d beep -U beep -W' 32 } 33 34 task:db.shell = { 35 - description = 'Open a shell in the database' 36 category = 'db' 37 run = 'docker exec -it beep-database sh' 38 } 39 40 task:db.dangerous.nuke = { 41 - description = 'Nuke the docker image AND ITS DATA. This will delete **EVERYTHING** in the database.' 42 category = 'db' 43 run = 'docker rm beep-database && docker volume rm beep-data' 44 } ··· 46 task:run = { 47 description = 'Run beep' 48 category = 'run' 49 - run = '${v} -d veb_livereload watch run ${v_main}' 50 }
··· 1 plugins = [ 'v' ] 2 3 task:db.init = { 4 + description = 'Initialize and start a local Postgres database via Docker' 5 category = 'db' 6 run = 'docker run -it \ 7 --name beep-database \ ··· 14 } 15 16 task:db.start = { 17 + description = 'Start the docker image for the local database' 18 category = 'db' 19 run = 'docker start beep-database' 20 } 21 22 task:db.stop = { 23 + description = 'Stop the docker image for the local database' 24 category = 'db' 25 run = 'docker stop beep-database' 26 } 27 28 task:db.login = { 29 + description = 'Log into and modify the local database' 30 category = 'db' 31 run = 'docker exec -it beep-database psql -h localhost -p 5432 -d beep -U beep -W' 32 } 33 34 task:db.shell = { 35 + description = 'Open a shell in the local database' 36 category = 'db' 37 run = 'docker exec -it beep-database sh' 38 } 39 40 task:db.dangerous.nuke = { 41 + description = 'Delete the docker image AND ITS DATA. This will delete **EVERYTHING** in the database.' 42 category = 'db' 43 run = 'docker rm beep-database && docker volume rm beep-data' 44 } ··· 46 task:run = { 47 description = 'Run beep' 48 category = 'run' 49 + run = '${v} -d veb_livereload watch run ${v_main} config.maple' 50 }
-9
config.maple
··· 12 db = 'beep' 13 } 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 post = { 25 title_max_len = 50 26 body_max_len = 500
··· 12 db = 'beep' 13 } 14 15 post = { 16 title_max_len = 50 17 body_max_len = 500
+18 -4
readme.md
··· 1 # beep 2 3 - a self-hosted mini-blogger 4 5 technically made because i wanted to mess around with rss, but i also wanted a 6 - teensy little blog for myself 7 8 ## hosting 9 10 ```sh 11 git clone https://github.com/emmathemartian/beep 12 v -prod . 13 - ./beep [port] 14 ``` 15 16 - then go to `localhost:[port]` to view
··· 1 # beep 2 3 + > *a legendary land of lowercase lovers.* 4 + 5 + a self-hosted mini-blogger. 6 7 technically made because i wanted to mess around with rss, but i also wanted a 8 + teensy little blog/slow-paced-chat-app for myself and my friends. 9 10 ## hosting 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 + 23 ```sh 24 git clone https://github.com/emmathemartian/beep 25 + cd beep 26 v -prod . 27 + ./beep config.maple 28 ``` 29 30 + then go to the configured url to view (default is `http://localhost:8008`).
+2 -1
src/auth/auth.v
··· 1 // From: https://github.com/vlang/v/blob/1fae506900c79e3aafc00e08e1f861fc7cbf8012/vlib/veb/auth/auth.v 2 // The original file's source is licensed under MIT. 3 4 - // This "fork" re-introduces the `ip` field of each token for additional security. 5 6 module auth 7
··· 1 // From: https://github.com/vlang/v/blob/1fae506900c79e3aafc00e08e1f861fc7cbf8012/vlib/veb/auth/auth.v 2 // The original file's source is licensed under MIT. 3 4 + // This fork re-introduces the `ip` field of each token for additional security, 5 + // along with delete_tokens_for_ip 6 7 module auth 8
-15
src/config.v
··· 17 password string 18 db string 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 post struct { 30 pub mut: 31 title_max_len int ··· 60 config.postgres.user = loaded_postgres.get('user').to_str() 61 config.postgres.password = loaded_postgres.get('password').to_str() 62 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 70 loaded_post := loaded.get('post') 71 config.post.title_max_len = loaded_post.get('title_max_len').to_int()
··· 17 password string 18 db string 19 } 20 post struct { 21 pub mut: 22 title_max_len int ··· 51 config.postgres.user = loaded_postgres.get('user').to_str() 52 config.postgres.password = loaded_postgres.get('password').to_str() 53 config.postgres.db = loaded_postgres.get('db').to_str() 54 55 loaded_post := loaded.get('post') 56 config.post.title_max_len = loaded_post.get('title_max_len').to_int()
+2 -1
src/main.v
··· 4 import veb 5 import auth 6 import entity 7 8 fn init_db(db pg.DB) ! { 9 sql db { ··· 13 } 14 15 fn main() { 16 - config := load_config_from('config.maple') 17 18 mut db := pg.connect(pg.Config{ 19 host: config.postgres.host
··· 4 import veb 5 import auth 6 import entity 7 + import os 8 9 fn init_db(db pg.DB) ! { 10 sql db { ··· 14 } 15 16 fn main() { 17 + config := load_config_from(os.args[1]) 18 19 mut db := pg.connect(pg.Config{ 20 host: config.postgres.host
+1 -1
src/templates/admin.html
··· 13 <div> 14 @for u in app.get_users() 15 <div> 16 - <a href="/user/@u.id">@u.get_name() (@@@u.username) [@u.id]</a> 17 <p>muted=@u.muted, admin=@u.admin</p> 18 <p>created_at=@u.created_at</p> 19 </div>
··· 13 <div> 14 @for u in app.get_users() 15 <div> 16 + <a href="/user/@u.username">@u.get_name() (@@@u.username) [@u.id]</a> 17 <p>muted=@u.muted, admin=@u.admin</p> 18 <p>created_at=@u.created_at</p> 19 </div>
+6 -1
src/templates/partial/header.html
··· 13 <body> 14 15 <header> 16 <a href="/">home</a> 17 - 18 ··· 24 @if ctx.is_logged_in() 25 <a href="/me">profile</a> 26 - 27 - <a href="/api/full_logout">log out</a> 28 @else 29 <a href="/login">log in</a> 30 <span>or</span>
··· 13 <body> 14 15 <header> 16 + @if app.config.dev_mode 17 + <span><strong>dev mode</strong></span> 18 + - 19 + @end 20 + 21 <a href="/">home</a> 22 - 23 ··· 29 @if ctx.is_logged_in() 30 <a href="/me">profile</a> 31 - 32 + <a href="/api/user/logout">log out</a> 33 @else 34 <a href="/login">log in</a> 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