Skip to content

Commit

Permalink
run v fmt -w .
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Apr 17, 2024
1 parent 53179f2 commit 7c93fd7
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 131 deletions.
4 changes: 1 addition & 3 deletions highlight/highlight.v
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 2 additions & 6 deletions highlight/langs.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
132 changes: 65 additions & 67 deletions highlight/markdown.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions highlight/markdown_test.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module highlight

const (
markdown = '<script> alert(true) </script> <!-- comment -->test'
html = '<p>test</p>'
)
const markdown = '<script> alert(true) </script> <!-- comment -->test'
const html = '<p>test</p>'

fn test_convert_markdown_to_html() {
assert convert_markdown_to_html(highlight.markdown) == highlight.html
Expand Down
4 changes: 1 addition & 3 deletions src/admin_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 8 additions & 10 deletions src/avatar.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions src/feed.v
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
20 changes: 9 additions & 11 deletions src/gitly.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 14 additions & 16 deletions src/lang_stats.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/release_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions src/repo.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7c93fd7

Please sign in to comment.