a mini social media app for small communities

add instance-wide renaming

Changed files
+25 -9
doc
src
+5 -1
config.maple
··· 1 1 dev_mode = false 2 + static_path = 'src/static' 2 3 3 - static_path = 'src/static' 4 + instance = { 5 + name = 'beeper' 6 + welcome = 'welcome to beep!' 7 + } 4 8 5 9 http = { 6 10 port = 8008
+1
doc/todo.md
··· 6 6 7 7 ## planing 8 8 9 + - [ ] site:message of the day (admins can add a welcome message displayed on index.html) 9 10 - [ ] post:mentioning ('tagging') other users in posts 10 11 - [ ] post:replies 11 12 - [ ] post:tags ('hashtags')
+11
src/config.v
··· 6 6 pub mut: 7 7 dev_mode bool 8 8 static_path string 9 + instance struct { 10 + pub mut: 11 + name string 12 + welcome string 13 + } 9 14 http struct { 10 15 pub mut: 11 16 port int ··· 55 60 56 61 config.dev_mode = loaded.get('dev_mode').to_bool() 57 62 config.static_path = loaded.get('static_path').to_str() 63 + 64 + loaded_instance := loaded.get('instance') 65 + // yes i am still sanatizing these despite being configured exclusively 66 + // by the instance owner. redundant? maybe. 67 + config.instance.name = sanatize(loaded_instance.get('name').to_str()) 68 + config.instance.welcome = sanatize(loaded_instance.get('welcome').to_str()) 58 69 59 70 loaded_http := loaded.get('http') 60 71 config.http.port = loaded_http.get('port').to_int()
+7 -7
src/pages.v
··· 4 4 import entity { User, Post } 5 5 6 6 fn (mut app App) index(mut ctx Context) veb.Result { 7 - ctx.title = 'beep' 7 + ctx.title = app.config.instance.name 8 8 user := app.whoami(mut ctx) or { User{} } 9 9 recent_posts := app.get_recent_posts() 10 10 pinned_posts := app.get_pinned_posts() ··· 12 12 } 13 13 14 14 fn (mut app App) login(mut ctx Context) veb.Result { 15 - ctx.title = 'login to beep' 15 + ctx.title = 'login to ${app.config.instance.name}' 16 16 user := app.whoami(mut ctx) or { User{} } 17 17 return $veb.html() 18 18 } 19 19 20 20 fn (mut app App) register(mut ctx Context) veb.Result { 21 - ctx.title = 'register for beep' 21 + ctx.title = 'register for ${app.config.instance.name}' 22 22 user := app.whoami(mut ctx) or { User{} } 23 23 return $veb.html() 24 24 } ··· 28 28 ctx.error('not logged in') 29 29 return ctx.redirect('/login') 30 30 } 31 - ctx.title = 'beep - ${user.get_name()}' 31 + ctx.title = '${app.config.instance.name} - ${user.get_name()}' 32 32 return $veb.html() 33 33 } 34 34 35 35 fn (mut app App) admin(mut ctx Context) veb.Result { 36 - ctx.title = 'beep dashboard' 36 + ctx.title = '${app.config.instance.name} dashboard' 37 37 user := app.whoami(mut ctx) or { User{} } 38 38 return $veb.html() 39 39 } ··· 44 44 ctx.error('user not found') 45 45 return ctx.redirect('/') 46 46 } 47 - ctx.title = 'beep - ${user.get_name()}' 47 + ctx.title = '${app.config.instance.name} - ${user.get_name()}' 48 48 return $veb.html() 49 49 } 50 50 ··· 54 54 ctx.error('no such post') 55 55 return ctx.redirect('/') 56 56 } 57 - ctx.title = 'beep - ${post.title}' 57 + ctx.title = '${app.config.instance.name} - ${post.title}' 58 58 user := app.whoami(mut ctx) or { User{} } 59 59 return $veb.html() 60 60 }
+1 -1
src/templates/index.html
··· 1 1 @include 'partial/header.html' 2 2 3 - <h1>welcome to beep</h1> 3 + <h1>@app.config.instance.welcome</h1> 4 4 5 5 @if ctx.is_logged_in() 6 6 <p>logged in as: @{user.get_name()}</p>