File tree 5 files changed +60
-26
lines changed
5 files changed +60
-26
lines changed Original file line number Diff line number Diff line change
1
+ name : CI
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ push :
6
+ pull_request :
7
+
8
+ jobs :
9
+ basic-checks :
10
+ runs-on : ubuntu-20.04
11
+ steps :
12
+
13
+ - name : Checkout V
14
+ uses : actions/checkout@v2
15
+ with :
16
+ repository : vlang/v
17
+
18
+ - name : Checkout vorum
19
+ uses : actions/checkout@v2
20
+ with :
21
+ path : vorum
22
+
23
+ - name : Build V
24
+ run : |
25
+ make
26
+ ./v symlink -githubci
27
+
28
+ - name : Build Vorum
29
+ run : v vorum
30
+
31
+ - name : Check Vorum code is VFMTed
32
+ run : v fmt -verify vorum/
33
+
34
+ - name : Vet Vorum
35
+ run : v vet vorum
Original file line number Diff line number Diff line change @@ -6,19 +6,17 @@ import net.http
6
6
import time
7
7
import log
8
8
9
- const (
10
- port = 8092
11
- db_name = 'vorum'
12
- db_user = 'vorum'
13
- )
9
+ const port = 8092
10
+ const db_name = 'vorum'
11
+ const db_user = 'vorum'
14
12
15
13
pub struct App {
16
14
vweb.Context
17
15
pub mut :
18
16
db pg.DB
19
17
user User
20
18
logged_in bool
21
- logger log.Log [vweb_global]
19
+ logger log.Log @ [vweb_global]
22
20
}
23
21
24
22
fn main () {
@@ -49,7 +47,7 @@ pub fn (mut app App) index() vweb.Result {
49
47
return $vweb.html ()
50
48
}
51
49
52
- ['/post/:id' ]
50
+ @ ['/post/:id' ]
53
51
pub fn (mut app App) post (id int ) vweb.Result {
54
52
post := app.get_post (id) or { return app.text ('Discussion not found.' ) }
55
53
app.inc_post_views (id) or { app.warn (err.str ()) }
@@ -69,7 +67,7 @@ pub fn (mut app App) new() vweb.Result {
69
67
return $vweb.html ()
70
68
}
71
69
72
- [post]
70
+ @ [post]
73
71
pub fn (mut app App) new_post () vweb.Result {
74
72
app.auth ()
75
73
@@ -89,7 +87,7 @@ pub fn (mut app App) new_post() vweb.Result {
89
87
return app.redirect ('/' )
90
88
}
91
89
92
- ['/comment/:post_id' ; post]
90
+ @ ['/comment/:post_id' ; post]
93
91
fn (mut app App) comment (post_id int ) vweb.Result {
94
92
app.auth ()
95
93
@@ -110,7 +108,7 @@ fn (mut app App) comment(post_id int) vweb.Result {
110
108
return app.redirect ('/post/${post_id} ' ) // so that refreshing a page won't do a post again
111
109
}
112
110
113
- ['/posts/:id' ; delete]
111
+ @ ['/posts/:id' ; delete]
114
112
pub fn (mut app App) deletepost (post_id int ) vweb.Result {
115
113
app.auth ()
116
114
Original file line number Diff line number Diff line change @@ -5,12 +5,10 @@ import json
5
5
import os
6
6
import vweb
7
7
8
- const (
9
- // oauth_client_id = os.getenv('VORUM_OAUTH_CLIENT_ID')
10
- // oauth_client_secret = os.getenv('VORUM_OAUTH_SECRET')
11
- client_id = os.getenv ('VORUM_OAUTH_CLIENT_ID' )
12
- client_secret = os.getenv ('VORUM_OAUTH_SECRET' )
13
- )
8
+ // oauth_client_id = os.getenv('VORUM_OAUTH_CLIENT_ID')
9
+ // oauth_client_secret = os.getenv('VORUM_OAUTH_SECRET')
10
+ const client_id = os.getenv ('VORUM_OAUTH_CLIENT_ID' )
11
+ const client_secret = os.getenv ('VORUM_OAUTH_SECRET' )
14
12
15
13
struct GitHubUser {
16
14
login string
Original file line number Diff line number Diff line change @@ -2,22 +2,22 @@ module main
2
2
3
3
import time
4
4
5
- [table: 'posts' ]
5
+ @ [table: 'posts' ]
6
6
struct Post {
7
7
id int
8
8
title string
9
9
text string
10
- url string [skip]
10
+ url string @ [skip]
11
11
nr_comments int
12
- time time.Time [orm: skip]
12
+ time time.Time @ [orm: skip]
13
13
last_reply time.Time
14
14
nr_views int
15
15
is_locked bool
16
16
is_blog bool
17
17
is_deleted bool
18
18
}
19
19
20
- [table: 'comments' ]
20
+ @ [table: 'comments' ]
21
21
struct Comment {
22
22
id int
23
23
post_id int
@@ -48,13 +48,16 @@ order by last_reply desc')!
48
48
for row in rows {
49
49
id := row.vals[0 ]
50
50
title := row.vals[1 ]
51
+ nr_comments := row.vals[4 ]
52
+ ts := row.vals[3 ]
53
+ is_locked := row.vals[5 ]
51
54
posts << Post{
52
- id: id.int ()
55
+ id: id or { '' } .int ()
53
56
url: '/post/${id} '
54
- title: title
55
- nr_comments: row.vals[ 4 ] .int ()
56
- time: time.unix (row.vals[ 3 ] .int ())
57
- is_locked: row.vals[ 5 ] == 't'
57
+ title: title or { '' }
58
+ nr_comments: nr_comments or { '' } .int ()
59
+ time: time.unix (ts or { '' } .int ())
60
+ is_locked: is_locked or { '' } == 't'
58
61
}
59
62
}
60
63
return posts
Original file line number Diff line number Diff line change 1
1
module main
2
2
3
- [table: 'users' ]
3
+ @ [table: 'users' ]
4
4
struct User {
5
5
mut :
6
6
id int
You can’t perform that action at this time.
0 commit comments