diff --git a/highlight/highlight.v b/highlight/highlight.v index dc8a65b4..a143330d 100644 --- a/highlight/highlight.v +++ b/highlight/highlight.v @@ -2,9 +2,7 @@ // Use of this source code is governed by a GPL license that can be found in the LICENSE file. module highlight -const ( - tab = ' ' // ' -) +const tab = ' ' // ' // returns HTML code, number of lines, number of lines with source code pub fn highlight_text(st string, file_path string, commit bool) (string, int, int) { diff --git a/highlight/langs.v b/highlight/langs.v index c8637fd0..953711e3 100644 --- a/highlight/langs.v +++ b/highlight/langs.v @@ -2,13 +2,9 @@ // Use of this source code is governed by a GPL license that can be found in the LICENSE file. module highlight -const ( - lang_path = 'langs' -) +const lang_path = 'langs' -const ( - langs = init_langs() -) +const langs = init_langs() pub struct Lang { keywords []string diff --git a/highlight/markdown.v b/highlight/markdown.v index b4bda8c2..733ba347 100644 --- a/highlight/markdown.v +++ b/highlight/markdown.v @@ -3,73 +3,71 @@ module highlight import markdown import pcre -const ( - allowed_tags = [ - 'a', - 'abbr', - 'b', - 'blockquote', - 'body', - 'br', - 'center', - 'code', - 'dd', - 'details', - 'div', - 'dl', - 'dt', - 'em', - 'font', - 'h1', - 'h2', - 'h3', - 'h4', - 'h5', - 'h6', - 'hr', - 'i', - 'img', - 'kbd', - 'label', - 'li', - 'ol', - 'p', - 'pre', - 'small', - 'source', - 'span', - 'strong', - 'sub', - 'summary', - 'sup', - 'table', - 'tbody', - 'tr', - 'td', - 'th', - 'thead', - 'ul', - 'u', - 'video', - ] - allowed_attributes = [ - 'align', - 'color', - 'controls', - 'height', - 'href', - 'id', - 'src', - 'style', - 'target', - 'title', - 'type', - 'width', - ] - unallowed_schemas = [ - 'javascript:', - ] -) +const allowed_tags = [ + 'a', + 'abbr', + 'b', + 'blockquote', + 'body', + 'br', + 'center', + 'code', + 'dd', + 'details', + 'div', + 'dl', + 'dt', + 'em', + 'font', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'hr', + 'i', + 'img', + 'kbd', + 'label', + 'li', + 'ol', + 'p', + 'pre', + 'small', + 'source', + 'span', + 'strong', + 'sub', + 'summary', + 'sup', + 'table', + 'tbody', + 'tr', + 'td', + 'th', + 'thead', + 'ul', + 'u', + 'video', +] +const allowed_attributes = [ + 'align', + 'color', + 'controls', + 'height', + 'href', + 'id', + 'src', + 'style', + 'target', + 'title', + 'type', + 'width', +] +const unallowed_schemas = [ + 'javascript:', +] pub fn convert_markdown_to_html(code string) string { markdown_code := sanitize_markdown_code(code) diff --git a/highlight/markdown_test.v b/highlight/markdown_test.v index f8847e70..d24a03f6 100644 --- a/highlight/markdown_test.v +++ b/highlight/markdown_test.v @@ -1,9 +1,7 @@ module highlight -const ( - markdown = ' test' - html = '

test

' -) +const markdown = ' test' +const html = '

test

' fn test_convert_markdown_to_html() { assert convert_markdown_to_html(highlight.markdown) == highlight.html diff --git a/src/admin_routes.v b/src/admin_routes.v index a4800aee..67d09484 100644 --- a/src/admin_routes.v +++ b/src/admin_routes.v @@ -2,9 +2,7 @@ module main import vweb -const ( - admin_users_per_page = 30 -) +const admin_users_per_page = 30 // TODO move to admin controller diff --git a/src/avatar.v b/src/avatar.v index 34f0de36..4ab43e1f 100644 --- a/src/avatar.v +++ b/src/avatar.v @@ -2,16 +2,14 @@ module main import os -const ( - default_avatar_name = 'default_avatar.png' - assets_path = 'assets' - avatar_max_file_size = 1 * 1024 * 1024 // 1 megabyte - supported_mime_types = [ - 'image/jpeg', - 'image/png', - 'image/webp', - ] -) +const default_avatar_name = 'default_avatar.png' +const assets_path = 'assets' +const avatar_max_file_size = 1 * 1024 * 1024 // 1 megabyte +const supported_mime_types = [ + 'image/jpeg', + 'image/png', + 'image/webp', +] fn validate_avatar_content_type(content_type string) bool { return supported_mime_types.contains(content_type) diff --git a/src/feed.v b/src/feed.v index 21768b03..19b22323 100644 --- a/src/feed.v +++ b/src/feed.v @@ -13,9 +13,7 @@ struct FeedItem { message string } -const ( - feed_items_per_page = 30 -) +const feed_items_per_page = 30 fn (mut app App) build_user_feed_as_page(user_id int, offset int) []FeedItem { mut feed := []FeedItem{} diff --git a/src/gitly.v b/src/gitly.v index 010d51fd..3fc2c05b 100644 --- a/src/gitly.v +++ b/src/gitly.v @@ -10,17 +10,15 @@ import db.sqlite import api import config -const ( - commits_per_page = 35 - expire_length = 200 - posts_per_day = 5 - max_username_len = 40 - max_login_attempts = 5 - max_user_repos = 10 - max_repo_name_len = 100 - max_namechanges = 3 - namechange_period = time.hour * 24 -) +const commits_per_page = 35 +const expire_length = 200 +const posts_per_day = 5 +const max_username_len = 40 +const max_login_attempts = 5 +const max_user_repos = 10 +const max_repo_name_len = 100 +const max_namechanges = 3 +const namechange_period = time.hour * 24 struct App { vweb.Context diff --git a/src/lang_stats.v b/src/lang_stats.v index 3179b6d6..28ebb4cd 100644 --- a/src/lang_stats.v +++ b/src/lang_stats.v @@ -11,22 +11,20 @@ struct LangStat { color string } -const ( - test_lang_stats = [ - LangStat{ - name: 'V' - pct: 989 - lines_count: 96657 - color: '#5d87bd' - }, - LangStat{ - name: 'JavaScript' - lines_count: 1131 - color: '#f1e05a' - pct: 11 - }, - ] -) +const test_lang_stats = [ + LangStat{ + name: 'V' + pct: 989 + lines_count: 96657 + color: '#5d87bd' + }, + LangStat{ + name: 'JavaScript' + lines_count: 1131 + color: '#f1e05a' + pct: 11 + }, +] fn (app App) add_lang_stat(lang_stat LangStat) ! { sql app.db { diff --git a/src/release_routes.v b/src/release_routes.v index a2f9fa1a..7b633c5e 100644 --- a/src/release_routes.v +++ b/src/release_routes.v @@ -3,9 +3,7 @@ module main import vweb import time -const ( - releases_per_page = 20 -) +const releases_per_page = 20 @['/:username/:repo_name/releases'] pub fn (mut app App) releases_default(username string, repo_name string) vweb.Result { diff --git a/src/repo.v b/src/repo.v index 1818ed1c..b7db5a77 100644 --- a/src/repo.v +++ b/src/repo.v @@ -43,11 +43,9 @@ mut: } // log_field_separator is declared as constant in case we need to change it later -const ( - max_git_res_size = 1000 - log_field_separator = '\x7F' - ignored_folder = ['thirdparty'] -) +const max_git_res_size = 1000 +const log_field_separator = '\x7F' +const ignored_folder = ['thirdparty'] enum RepoStatus { done