diff --git a/git/libgit.v b/git/libgit.v index bd32a19e..07dc98a0 100644 --- a/git/libgit.v +++ b/git/libgit.v @@ -48,7 +48,7 @@ struct C.git_error { message &char } -[typedef] +@[typedef] struct C.git_tree_entry {} struct C.git_clone_options { @@ -100,7 +100,7 @@ fn (r Repo) str() string { return 'Repo{ path:${r.path} }' } -[params] +@[params] struct LogParams { n int dir string // -C "dir" diff --git a/src/activity.v b/src/activity.v index c9104123..44bc1721 100644 --- a/src/activity.v +++ b/src/activity.v @@ -4,7 +4,7 @@ import time struct Activity { mut: - id int [primary; sql: serial] + id int @[primary; sql: serial] user_id int name string created_at time.Time diff --git a/src/admin_routes.v b/src/admin_routes.v index ff994be4..a4800aee 100644 --- a/src/admin_routes.v +++ b/src/admin_routes.v @@ -8,7 +8,7 @@ const ( // TODO move to admin controller -['/admin/settings'] +@['/admin/settings'] pub fn (mut app App) admin_settings() vweb.Result { if !app.is_admin() { return app.redirect_to_index() @@ -17,7 +17,7 @@ pub fn (mut app App) admin_settings() vweb.Result { return $vweb.html() } -['/admin/settings'; post] +@['/admin/settings'; post] pub fn (mut app App) handle_admin_update_settings(oauth_client_id string, oauth_client_secret string) vweb.Result { if !app.is_admin() { return app.redirect_to_index() @@ -28,7 +28,7 @@ pub fn (mut app App) handle_admin_update_settings(oauth_client_id string, oauth_ return app.redirect('/admin') } -['/admin/users/:user'; post] +@['/admin/users/:user'; post] pub fn (mut app App) handle_admin_edit_user(user_id string) vweb.Result { if !app.is_admin() { return app.redirect_to_index() @@ -43,12 +43,12 @@ pub fn (mut app App) handle_admin_edit_user(user_id string) vweb.Result { return app.redirect('/admin') } -['/admin/users'] +@['/admin/users'] pub fn (mut app App) admin_users_default() vweb.Result { return app.admin_users(0) } -['/admin/users/:page'] +@['/admin/users/:page'] pub fn (mut app App) admin_users(page int) vweb.Result { if !app.is_admin() { return app.redirect_to_index() @@ -65,7 +65,7 @@ pub fn (mut app App) admin_users(page int) vweb.Result { return $vweb.html() } -['/admin/statistics'] +@['/admin/statistics'] pub fn (mut app App) admin_statistics() vweb.Result { if !app.is_admin() { return app.redirect_to_index() diff --git a/src/branch.v b/src/branch.v index a7c88e35..226b8e88 100644 --- a/src/branch.v +++ b/src/branch.v @@ -5,9 +5,9 @@ import git struct Branch { mut: - id int [primary; sql: serial] - repo_id int [unique: 'branch'] - name string [unique: 'branch'] + id int @[primary; sql: serial] + repo_id int @[unique: 'branch'] + name string @[unique: 'branch'] author string // author of latest commit on branch hash string // hash of latest commit on branch date int // time of latest commit on branch diff --git a/src/branch_routes.v b/src/branch_routes.v index f15dc03d..d925a770 100644 --- a/src/branch_routes.v +++ b/src/branch_routes.v @@ -3,7 +3,7 @@ module main import vweb import api -['/api/v1/:user/:repo_name/branches/count'] +@['/api/v1/:user/:repo_name/branches/count'] fn (mut app App) handle_branch_count(username string, repo_name string) vweb.Result { has_access := app.has_user_repo_read_access_by_repo_name(app.user.id, username, repo_name) @@ -23,7 +23,7 @@ fn (mut app App) handle_branch_count(username string, repo_name string) vweb.Res }) } -['/:user/:repo/branches'] +@['/:user/:repo/branches'] pub fn (mut app App) branches(username string, repo_name string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.json_error('Not found') diff --git a/src/comment.v b/src/comment.v index 161cfec9..aeb6ee55 100644 --- a/src/comment.v +++ b/src/comment.v @@ -8,14 +8,14 @@ import time struct Comment { mut: - id int [primary; sql: serial] + id int @[primary; sql: serial] author_id int issue_id int created_at int text string } -['/:username/:repo_name/comments'; post] +@['/:username/:repo_name/comments'; post] pub fn (mut app App) handle_add_comment(username string, repo_name string) vweb.Result { app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } text := app.form['text'] diff --git a/src/commit.v b/src/commit.v index 9c23eba6..eaee504f 100644 --- a/src/commit.v +++ b/src/commit.v @@ -6,13 +6,13 @@ import time struct Commit { mut: - id int [primary; sql: serial] + id int @[primary; sql: serial] author_id int author string - hash string [unique: 'commit'] + hash string @[unique: 'commit'] created_at int - repo_id int [unique: 'commit'] - branch_id int [unique: 'commit'] + repo_id int @[unique: 'commit'] + branch_id int @[unique: 'commit'] message string } diff --git a/src/commit_routes.v b/src/commit_routes.v index ce182bdf..cd2eda16 100644 --- a/src/commit_routes.v +++ b/src/commit_routes.v @@ -5,7 +5,7 @@ import highlight import time import api -['/api/v1/:user/:repo_name/:branch_name/commits/count'] +@['/api/v1/:user/:repo_name/:branch_name/commits/count'] fn (mut app App) handle_commits_count(username string, repo_name string, branch_name string) vweb.Result { has_access := app.has_user_repo_read_access_by_repo_name(app.user.id, username, repo_name) @@ -26,7 +26,7 @@ fn (mut app App) handle_commits_count(username string, repo_name string, branch_ }) } -['/:username/:repo_name/:branch_name/commits/:page'] +@['/:username/:repo_name/:branch_name/commits/:page'] pub fn (mut app App) commits(username string, repo_name string, branch_name string, page int) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } @@ -70,7 +70,7 @@ pub fn (mut app App) commits(username string, repo_name string, branch_name stri return $vweb.html() } -['/:username/:repo_name/commit/:hash'] +@['/:username/:repo_name/commit/:hash'] pub fn (mut app App) commit(username string, repo_name string, hash string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } diff --git a/src/feed_routes.v b/src/feed_routes.v index 1f41aaac..9395f4f3 100644 --- a/src/feed_routes.v +++ b/src/feed_routes.v @@ -2,12 +2,12 @@ module main import vweb -['/:username/feed'] +@['/:username/feed'] pub fn (mut app App) user_feed_default(username string) vweb.Result { return app.user_feed(username, 0) } -['/:username/feed/:page'] +@['/:username/feed/:page'] pub fn (mut app App) user_feed(username string, page int) vweb.Result { exists, user := app.check_username(username) diff --git a/src/file.v b/src/file.v index 7f14a6e4..2209e894 100644 --- a/src/file.v +++ b/src/file.v @@ -5,12 +5,12 @@ import math import os struct File { - id int [primary; sql: serial] - repo_id int [unique: 'file'] - name string [unique: 'file'] - parent_path string [unique: 'file'] + id int @[primary; sql: serial] + repo_id int @[unique: 'file'] + name string @[unique: 'file'] + parent_path string @[unique: 'file'] is_dir bool - branch string [unique: 'file'] + branch string @[unique: 'file'] contributors_count int last_hash string size int @@ -18,7 +18,7 @@ struct File { mut: last_msg string last_time int - commit Commit [skip] + commit Commit @[skip] } fn (f File) url() string { diff --git a/src/git_routes.v b/src/git_routes.v index 5fc79927..deddad70 100644 --- a/src/git_routes.v +++ b/src/git_routes.v @@ -6,7 +6,7 @@ import vweb import git import compress.deflate -['/:username/:repo_name/info/refs'] +@['/:username/:repo_name/info/refs'] fn (mut app App) handle_git_info(username string, git_repo_name string) vweb.Result { repo_name := git.remove_git_extension_if_exists(git_repo_name) user := app.get_user_by_username(username) or { return app.not_found() } @@ -33,7 +33,7 @@ fn (mut app App) handle_git_info(username string, git_repo_name string) vweb.Res return app.ok(git_response) } -['/:user/:repo_name/git-upload-pack'; post] +@['/:user/:repo_name/git-upload-pack'; post] fn (mut app App) handle_git_upload_pack(username string, git_repo_name string) vweb.Result { body := app.parse_body() repo_name := git.remove_git_extension_if_exists(git_repo_name) @@ -52,7 +52,7 @@ fn (mut app App) handle_git_upload_pack(username string, git_repo_name string) v return app.ok(git_response) } -['/:user/:repo_name/git-receive-pack'; post] +@['/:user/:repo_name/git-receive-pack'; post] fn (mut app App) handle_git_receive_pack(username string, git_repo_name string) vweb.Result { body := app.parse_body() repo_name := git.remove_git_extension_if_exists(git_repo_name) diff --git a/src/github.v b/src/github.v index e4181125..3ba3fae9 100644 --- a/src/github.v +++ b/src/github.v @@ -14,13 +14,13 @@ struct OAuthRequest { } struct GitHubUser { - username string [json: 'login'] + username string @[json: 'login'] name string email string - avatar string [json: 'avatar_url'] + avatar string @[json: 'avatar_url'] } -['/oauth'] +@['/oauth'] pub fn (mut app App) handle_oauth() vweb.Result { code := app.query['code'] state := app.query['state'] diff --git a/src/gitly.v b/src/gitly.v index edaed285..010d51fd 100644 --- a/src/gitly.v +++ b/src/gitly.v @@ -24,13 +24,13 @@ const ( struct App { vweb.Context - started_at i64 [vweb_global] + started_at i64 @[vweb_global] pub mut: db sqlite.DB mut: - version string [vweb_global] - logger log.Log [vweb_global] - config config.Config [vweb_global] + version string @[vweb_global] + logger log.Log @[vweb_global] + config config.Config @[vweb_global] settings Settings current_path string page_gen_time string @@ -136,7 +136,7 @@ pub fn (mut app App) before_request() { } } -['/'] +@['/'] pub fn (mut app App) index() vweb.Result { user_count := app.get_users_count() or { 0 } no_users := user_count == 0 diff --git a/src/issue.v b/src/issue.v index b870be6e..ab34c0db 100644 --- a/src/issue.v +++ b/src/issue.v @@ -5,21 +5,21 @@ module main import time struct Issue { - id int [primary; sql: serial] + id int @[primary; sql: serial] mut: author_id int repo_id int is_pr bool - assigned []int [skip] - labels []int [skip] + assigned []int @[skip] + labels []int @[skip] comments_count int title string text string created_at int - status IssueStatus [skip] - linked_issues []int [skip] - repo_author string [skip] - repo_name string [skip] + status IssueStatus @[skip] + linked_issues []int @[skip] + repo_author string @[skip] + repo_name string @[skip] } enum IssueStatus { diff --git a/src/issue_routes.v b/src/issue_routes.v index 22d44a59..edc515b2 100644 --- a/src/issue_routes.v +++ b/src/issue_routes.v @@ -12,7 +12,7 @@ struct ItemWithUser[T] { type IssueWithUser = ItemWithUser[Issue] type CommentWithUser = ItemWithUser[Comment] -['/api/v1/:username/:repo_name/issues/count'] +@['/api/v1/:username/:repo_name/issues/count'] fn (mut app App) handle_issues_count(username string, repo_name string) vweb.Result { has_access := app.has_user_repo_read_access_by_repo_name(app.user.id, username, repo_name) if !has_access { @@ -28,7 +28,7 @@ fn (mut app App) handle_issues_count(username string, repo_name string) vweb.Res }) } -['/:username/:repo_name/issues/new'] +@['/:username/:repo_name/issues/new'] pub fn (mut app App) new_issue(username string, repo_name string) vweb.Result { if !app.logged_in { return app.not_found() @@ -37,12 +37,12 @@ pub fn (mut app App) new_issue(username string, repo_name string) vweb.Result { return $vweb.html() } -['/:username/issues'] +@['/:username/issues'] pub fn (mut app App) handle_get_user_issues(username string) vweb.Result { return app.user_issues(username, 0) } -['/:username/:repo_name/issues'; post] +@['/:username/:repo_name/issues'; post] pub fn (mut app App) handle_add_repo_issue(username string, repo_name string) vweb.Result { // TODO: use captcha instead of user restrictions if !app.logged_in || (app.logged_in && app.user.posts_count >= posts_per_day) { @@ -66,12 +66,12 @@ pub fn (mut app App) handle_add_repo_issue(username string, repo_name string) vw return app.redirect('/${username}/${repo_name}/issues') } -['/:username/:repo_name/issues'] +@['/:username/:repo_name/issues'] pub fn (mut app App) handle_get_repo_issues(username string, repo_name string) vweb.Result { return app.issues(username, repo_name, 0) } -['/:username/:repo_name/issues/:page'] +@['/:username/:repo_name/issues/:page'] pub fn (mut app App) issues(username string, repo_name string, page int) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } mut issues_with_users := []IssueWithUser{} @@ -103,7 +103,7 @@ pub fn (mut app App) issues(username string, repo_name string, page int) vweb.Re return $vweb.html() } -['/:username/:repo_name/issue/:id'] +@['/:username/:repo_name/issue/:id'] pub fn (mut app App) issue(username string, repo_name string, id string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } issue := app.find_issue_by_id(id.int()) or { return app.not_found() } @@ -119,7 +119,7 @@ pub fn (mut app App) issue(username string, repo_name string, id string) vweb.Re return $vweb.html() } -['/:username/issues/:page'] +@['/:username/issues/:page'] pub fn (mut app App) user_issues(username string, page int) vweb.Result { if !app.logged_in { return app.not_found() diff --git a/src/lang_stats.v b/src/lang_stats.v index 751b9e4a..3179b6d6 100644 --- a/src/lang_stats.v +++ b/src/lang_stats.v @@ -3,9 +3,9 @@ module main import vweb struct LangStat { - id int [primary; sql: serial] - repo_id int [unique: 'langstat'] - name string [unique: 'langstat'] + id int @[primary; sql: serial] + repo_id int @[unique: 'langstat'] + name string @[unique: 'langstat'] lines_count int pct int // out of 1000 color string diff --git a/src/release.v b/src/release.v index 8c2969b1..48fa5c5f 100644 --- a/src/release.v +++ b/src/release.v @@ -3,14 +3,14 @@ module main import time struct Release { - id int [primary; sql: serial] - repo_id int [unique: 'release'] + id int @[primary; sql: serial] + repo_id int @[unique: 'release'] mut: - tag_id int [unique: 'release'] + tag_id int @[unique: 'release'] notes string - tag_name string [skip] - tag_hash string [skip] - user string [skip] + tag_name string @[skip] + tag_hash string @[skip] + user string @[skip] date time.Time } diff --git a/src/release_routes.v b/src/release_routes.v index e011bc69..a2f9fa1a 100644 --- a/src/release_routes.v +++ b/src/release_routes.v @@ -7,12 +7,12 @@ const ( releases_per_page = 20 ) -['/:username/:repo_name/releases'] +@['/:username/:repo_name/releases'] pub fn (mut app App) releases_default(username string, repo_name string) vweb.Result { return app.releases(username, repo_name, 0) } -['/:username/:repo_name/releases/:page'] +@['/:username/:repo_name/releases/:page'] pub fn (mut app App) releases(username string, repo_name string, page int) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } diff --git a/src/repo.v b/src/repo.v index a76ef3c0..f4d4c093 100644 --- a/src/repo.v +++ b/src/repo.v @@ -9,37 +9,37 @@ import highlight import validation struct Repo { - id int [primary; sql: serial] + id int @[primary; sql: serial] git_dir string name string user_id int user_name string - clone_url string [skip] + clone_url string @[skip] primary_branch string description string is_public bool - users_contributed []string [skip] - users_authorized []string [skip] - nr_topics int [skip] + users_contributed []string @[skip] + users_authorized []string @[skip] + nr_topics int @[skip] views_count int - latest_update_hash string [skip] - latest_activity time.Time [skip] + latest_update_hash string @[skip] + latest_activity time.Time @[skip] mut: - git_repo &git.Repo [skip] // libgit wrapper repo + git_repo &git.Repo @[skip] // libgit wrapper repo webhook_secret string tags_count int - nr_open_issues int [orm: 'open_issues_count'] - nr_open_prs int [orm: 'open_prs_count'] - nr_releases int [orm: 'releases_count'] - nr_branches int [orm: 'branches_count'] + nr_open_issues int @[orm: 'open_issues_count'] + nr_open_prs int @[orm: 'open_prs_count'] + nr_releases int @[orm: 'releases_count'] + nr_branches int @[orm: 'branches_count'] nr_tags int - nr_stars int [orm: 'stars_count'] - lang_stats []LangStat [skip] + nr_stars int @[orm: 'stars_count'] + lang_stats []LangStat @[skip] created_at int nr_contributors int - labels []Label [skip] - status RepoStatus [skip] - msg_cache map[string]string [skip] + labels []Label @[skip] + status RepoStatus @[skip] + msg_cache map[string]string @[skip] } // log_field_separator is declared as constant in case we need to change it later diff --git a/src/repo_routes.v b/src/repo_routes.v index c290bfc5..38f2c8da 100644 --- a/src/repo_routes.v +++ b/src/repo_routes.v @@ -8,7 +8,7 @@ import time import validation import git -['/:username/repos'] +@['/:username/repos'] pub fn (mut app App) user_repos(username string) vweb.Result { exists, user := app.check_username(username) @@ -25,7 +25,7 @@ pub fn (mut app App) user_repos(username string) vweb.Result { return $vweb.html() } -['/:username/stars'] +@['/:username/stars'] pub fn (mut app App) user_stars(username string) vweb.Result { exists, user := app.check_username(username) @@ -38,7 +38,7 @@ pub fn (mut app App) user_stars(username string) vweb.Result { return $vweb.html() } -['/:username/:repo_name/settings'] +@['/:username/:repo_name/settings'] pub fn (mut app App) repo_settings(username string, repo_name string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.redirect_to_repository(username, repo_name) @@ -52,7 +52,7 @@ pub fn (mut app App) repo_settings(username string, repo_name string) vweb.Resul return $vweb.html() } -['/:username/:repo_name/settings'; post] +@['/:username/:repo_name/settings'; post] pub fn (mut app App) handle_update_repo_settings(username string, repo_name string, webhook_secret string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.redirect_to_repository(username, repo_name) @@ -71,7 +71,7 @@ pub fn (mut app App) handle_update_repo_settings(username string, repo_name stri return app.redirect_to_repository(username, repo_name) } -['/:user/:repo_name/delete'; post] +@['/:user/:repo_name/delete'; post] pub fn (mut app App) handle_repo_delete(username string, repo_name string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.redirect_to_repository(username, repo_name) @@ -92,7 +92,7 @@ pub fn (mut app App) handle_repo_delete(username string, repo_name string) vweb. return app.redirect_to_index() } -['/:username/:repo_name/move'; post] +@['/:username/:repo_name/move'; post] pub fn (mut app App) handle_repo_move(username string, repo_name string, dest string, verify string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.redirect_to_index() @@ -134,7 +134,7 @@ pub fn (mut app App) handle_repo_move(username string, repo_name string, dest st return app.redirect_to_index() } -['/:username/:repo_name'] +@['/:username/:repo_name'] pub fn (mut app App) handle_tree(username string, repo_name string) vweb.Result { match repo_name { 'repos' { @@ -154,14 +154,14 @@ pub fn (mut app App) handle_tree(username string, repo_name string) vweb.Result return app.tree(username, repo_name, repo.primary_branch, '') } -['/:username/:repo_name/tree/:branch_name'] +@['/:username/:repo_name/tree/:branch_name'] pub fn (mut app App) handle_branch_tree(username string, repo_name string, branch_name string) vweb.Result { app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } return app.tree(username, repo_name, branch_name, '') } -['/:username/:repo_name/update'] +@['/:username/:repo_name/update'] pub fn (mut app App) handle_repo_update(username string, repo_name string) vweb.Result { mut repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() @@ -175,7 +175,7 @@ pub fn (mut app App) handle_repo_update(username string, repo_name string) vweb. return app.redirect_to_repository(username, repo_name) } -['/new'] +@['/new'] pub fn (mut app App) new() vweb.Result { if !app.logged_in { return app.redirect_to_login() @@ -183,7 +183,7 @@ pub fn (mut app App) new() vweb.Result { return $vweb.html() } -['/new'; post] +@['/new'; post] pub fn (mut app App) handle_new_repo(name string, clone_url string, description string, no_redirect string) vweb.Result { mut valid_clone_url := clone_url is_clone_url_empty := validation.is_string_empty(clone_url) @@ -287,7 +287,7 @@ pub fn (mut app App) foo(mut new_repo Repo) { // git.clone(valid_clone_url, repo_path) } -['/:user/:repository/tree/:branch_name/:path...'] +@['/:user/:repository/tree/:branch_name/:path...'] pub fn (mut app App) tree(username string, repo_name string, branch_name string, path string) vweb.Result { mut repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() @@ -425,7 +425,7 @@ pub fn (mut app App) tree(username string, repo_name string, branch_name string, return $vweb.html() } -['/api/v1/repos/:repo_id/star'; 'post'] +@['/api/v1/repos/:repo_id/star'; 'post'] pub fn (mut app App) handle_api_repo_star(repo_id_str string) vweb.Result { repo_id := repo_id_str.int() @@ -444,7 +444,7 @@ pub fn (mut app App) handle_api_repo_star(repo_id_str string) vweb.Result { return app.json_success(is_repo_starred) } -['/api/v1/repos/:repo_id/watch'; 'post'] +@['/api/v1/repos/:repo_id/watch'; 'post'] pub fn (mut app App) handle_api_repo_watch(repo_id_str string) vweb.Result { repo_id := repo_id_str.int() @@ -463,7 +463,7 @@ pub fn (mut app App) handle_api_repo_watch(repo_id_str string) vweb.Result { return app.json_success(is_watching) } -['/:username/:repo_name/contributors'] +@['/:username/:repo_name/contributors'] pub fn (mut app App) contributors(username string, repo_name string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } @@ -472,7 +472,7 @@ pub fn (mut app App) contributors(username string, repo_name string) vweb.Result return $vweb.html() } -['/:username/:repo_name/blob/:branch_name/:path...'] +@['/:username/:repo_name/blob/:branch_name/:path...'] pub fn (mut app App) blob(username string, repo_name string, branch_name string, path string) vweb.Result { repo := app.find_repo_by_name_and_username(repo_name, username) or { return app.not_found() } @@ -499,7 +499,7 @@ pub fn (mut app App) blob(username string, repo_name string, branch_name string, return $vweb.html() } -['/:user/:repository/raw/:branch_name/:path...'] +@['/:user/:repository/raw/:branch_name/:path...'] pub fn (mut app App) handle_raw(username string, repo_name string, branch_name string, path string) vweb.Result { user := app.get_user_by_username(username) or { return app.not_found() } repo := app.find_repo_by_name_and_user_id(repo_name, user.id) or { return app.not_found() } diff --git a/src/search_routes.v b/src/search_routes.v index b6c7949d..fa7a8ee0 100644 --- a/src/search_routes.v +++ b/src/search_routes.v @@ -3,7 +3,7 @@ module main import vweb import regex -['/search'] +@['/search'] pub fn (mut app App) search() vweb.Result { query := app.query['query'] search_type := if 'type' in app.query { app.query['type'] } else { 'repos' } diff --git a/src/security_log.v b/src/security_log.v index aef17309..ee4eab95 100644 --- a/src/security_log.v +++ b/src/security_log.v @@ -14,7 +14,7 @@ enum SecurityLogKind { } struct SecurityLog { - id int [primary; sql: serial] + id int @[primary; sql: serial] user_id int kind_id int ip string @@ -22,7 +22,7 @@ struct SecurityLog { arg2 string created_at int mut: - kind SecurityLogKind [skip] + kind SecurityLogKind @[skip] } fn (mut app App) add_security_log(log SecurityLog) ! { diff --git a/src/security_log_routes.v b/src/security_log_routes.v index 9ada1d66..29f8f567 100644 --- a/src/security_log_routes.v +++ b/src/security_log_routes.v @@ -2,7 +2,7 @@ module main import vweb -['/settings/security'] +@['/settings/security'] fn (mut app App) security() vweb.Result { logs := app.get_all_user_security_logs(app.user.id) diff --git a/src/settings.v b/src/settings.v index 594e00a4..cf90d1b0 100644 --- a/src/settings.v +++ b/src/settings.v @@ -3,7 +3,7 @@ module main struct Settings { - id int [primary; sql: serial] + id int @[primary; sql: serial] mut: oauth_client_id string oauth_client_secret string diff --git a/src/ssh_key.v b/src/ssh_key.v index 5e955bdf..6275db68 100644 --- a/src/ssh_key.v +++ b/src/ssh_key.v @@ -3,9 +3,9 @@ module main import time struct SshKey { - id int [primary; sql: serial] - user_id int [unique: 'ssh_key'] - title string [unique: 'ssh_key'] + id int @[primary; sql: serial] + user_id int @[unique: 'ssh_key'] + title string @[unique: 'ssh_key'] key string created_at time.Time } diff --git a/src/ssh_key_routes.v b/src/ssh_key_routes.v index 994eb6e5..8b8cca53 100644 --- a/src/ssh_key_routes.v +++ b/src/ssh_key_routes.v @@ -4,7 +4,7 @@ import vweb import validation import api -['/:username/settings/ssh-keys'] +@['/:username/settings/ssh-keys'] pub fn (mut app App) user_ssh_keys_list(username string) vweb.Result { is_users_settings := username == app.user.username @@ -17,7 +17,7 @@ pub fn (mut app App) user_ssh_keys_list(username string) vweb.Result { return $vweb.html() } -['/:username/settings/ssh-keys'; 'post'] +@['/:username/settings/ssh-keys'; 'post'] pub fn (mut app App) handle_add_ssh_key(username string) vweb.Result { is_users_settings := username == app.user.username @@ -52,7 +52,7 @@ pub fn (mut app App) handle_add_ssh_key(username string) vweb.Result { return app.redirect('/${username}/settings/ssh-keys') } -['/:username/settings/ssh-keys/:id'; 'delete'] +@['/:username/settings/ssh-keys/:id'; 'delete'] pub fn (mut app App) handle_remove_ssh_key(username string, id int) vweb.Result { is_users_settings := username == app.user.username @@ -71,7 +71,7 @@ pub fn (mut app App) handle_remove_ssh_key(username string, id int) vweb.Result return app.ok('') } -['/:username/settings/ssh-keys/new'] +@['/:username/settings/ssh-keys/new'] pub fn (mut app App) user_ssh_keys_new(username string) vweb.Result { is_users_settings := username == app.user.username diff --git a/src/star.v b/src/star.v index 549dd446..66b3e8ea 100644 --- a/src/star.v +++ b/src/star.v @@ -1,9 +1,9 @@ module main struct Star { - id int [primary; sql: serial] - user_id int [unique: 'repo_star'] - repo_id int [unique: 'repo_star'] + id int @[primary; sql: serial] + user_id int @[unique: 'repo_star'] + repo_id int @[unique: 'repo_star'] } fn (mut app App) add_star(repo_id int, user_id int) ! { diff --git a/src/tag.v b/src/tag.v index c5b6809a..64020b07 100644 --- a/src/tag.v +++ b/src/tag.v @@ -5,10 +5,10 @@ module main import time struct Tag { - id int [primary; sql: serial] - repo_id int [unique: 'tag'] + id int @[primary; sql: serial] + repo_id int @[unique: 'tag'] mut: - name string [unique: 'tag'] + name string @[unique: 'tag'] hash string message string user_id int diff --git a/src/tag_routes.v b/src/tag_routes.v index 8e10034e..14c4de02 100644 --- a/src/tag_routes.v +++ b/src/tag_routes.v @@ -3,7 +3,7 @@ module main import vweb import os -['/:username/:repo_name/tag/:tag/:format'] +@['/:username/:repo_name/tag/:tag/:format'] pub fn (mut app App) handle_download_tag_archive(username string, repo_name string, tag string, format string) vweb.Result { // access checking will be implemented in another module user := app.get_user_by_username(username) or { return app.not_found() } diff --git a/src/token.v b/src/token.v index 92e60351..bf4b5ee5 100644 --- a/src/token.v +++ b/src/token.v @@ -5,7 +5,7 @@ module main import rand struct Token { - id int [primary; sql: serial] + id int @[primary; sql: serial] user_id int value string ip string diff --git a/src/user.v b/src/user.v index e34a19a1..fe86c990 100644 --- a/src/user.v +++ b/src/user.v @@ -5,9 +5,9 @@ import time import os struct User { - id int [primary; sql: serial] + id int @[primary; sql: serial] full_name string - username string [unique] + username string @[unique] github_username string password string salt string @@ -16,7 +16,7 @@ struct User { is_registered bool is_blocked bool is_admin bool - oauth_state string [skip] + oauth_state string @[skip] mut: // for github oauth XSRF protection namechanges_count int @@ -24,20 +24,20 @@ mut: posts_count int last_post_time int avatar string - emails []Email [skip] + emails []Email @[skip] login_attempts int } struct Email { - id int [primary; sql: serial] + id int @[primary; sql: serial] user_id int - email string [unique] + email string @[unique] } struct Contributor { - id int [primary; sql: serial] - user_id int [unique: 'contributor'] - repo_id int [unique: 'contributor'] + id int @[primary; sql: serial] + user_id int @[unique: 'contributor'] + repo_id int @[unique: 'contributor'] } pub fn (mut app App) set_user_block_status(user_id int, status bool) ! { diff --git a/src/user_routes.v b/src/user_routes.v index cf55594d..920bc09c 100644 --- a/src/user_routes.v +++ b/src/user_routes.v @@ -18,7 +18,7 @@ pub fn (mut app App) login() vweb.Result { return $vweb.html() } -['/login'; post] +@['/login'; post] pub fn (mut app App) handle_login(username string, password string) vweb.Result { if username == '' || password == '' { return app.redirect_to_login() @@ -59,14 +59,14 @@ pub fn (mut app App) handle_login(username string, password string) vweb.Result return app.redirect('/${username}') } -['/logout'] +@['/logout'] pub fn (mut app App) handle_logout() vweb.Result { app.set_cookie(name: 'token', value: '') return app.redirect_to_index() } -['/:username'] +@['/:username'] pub fn (mut app App) user(username string) vweb.Result { exists, user := app.check_username(username) @@ -86,7 +86,7 @@ pub fn (mut app App) user(username string) vweb.Result { return $vweb.html() } -['/:username/settings'] +@['/:username/settings'] pub fn (mut app App) user_settings(username string) vweb.Result { is_users_settings := username == app.user.username @@ -97,7 +97,7 @@ pub fn (mut app App) user_settings(username string) vweb.Result { return $vweb.html() } -['/:username/settings'; post] +@['/:username/settings'; post] pub fn (mut app App) handle_update_user_settings(username string) vweb.Result { is_users_settings := username == app.user.username @@ -188,7 +188,7 @@ pub fn (mut app App) register() vweb.Result { return $vweb.html() } -['/register'; post] +@['/register'; post] pub fn (mut app App) handle_register(username string, email string, password string, no_redirect string) vweb.Result { user_count := app.get_users_count() or { app.error('Failed to register') @@ -283,7 +283,7 @@ pub fn (mut app App) handle_register(username string, email string, password str return app.redirect('/' + username) } -['/api/v1/users/avatar'; post] +@['/api/v1/users/avatar'; post] pub fn (mut app App) handle_upload_avatar() vweb.Result { if !app.logged_in { return app.not_found() diff --git a/src/watch.v b/src/watch.v index bb11c767..95bf7a1e 100644 --- a/src/watch.v +++ b/src/watch.v @@ -1,9 +1,9 @@ module main struct Watch { - id int [primary; sql: serial] - user_id int [unique: 'repo_watch'] - repo_id int [unique: 'repo_watch'] + id int @[primary; sql: serial] + user_id int @[unique: 'repo_watch'] + repo_id int @[unique: 'repo_watch'] } fn (mut app App) watch_repo(repo_id int, user_id int) ! { diff --git a/tests/first_run.v b/tests/first_run.v index ba71f8ab..4f6ebe27 100644 --- a/tests/first_run.v +++ b/tests/first_run.v @@ -80,7 +80,7 @@ fn run_gitly() { } } -[noreturn] +@[noreturn] fn exit_with_message(message string) { println(message) exit(1)