From 31b1cb297e0cd7893d102dbf7410a58b89a2cf54 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 28 Jun 2026 19:27:12 +0300 Subject: [PATCH] strip whitespace --- config.json | 3 +- config/loader.v | 1 + config/loader_test.v | 1 + main.v | 1 + pr_routes.v | 38 +++++++- static/assets/version | 2 +- static/css/gitly.scss | 37 +++++++ templates/clone_size_limit.html | 3 + templates/pricing.html | 22 ++++- templates/pull_files.html | 29 +----- translations/cn.tr | 18 ++++ translations/en.tr | 18 ++++ translations/es.tr | 18 ++++ translations/jp.tr | 18 ++++ translations/pt.tr | 18 ++++ translations/ru.tr | 18 ++++ utils.v | 164 ++++++++++++++++++++++++++++++++ 17 files changed, 376 insertions(+), 33 deletions(-) diff --git a/config.json b/config.json index cdd0719..6c50def 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,6 @@ "archive_path": "./archives", "avatars_path": "./avatars", "hostname": "gitly.org", - "ci_service_url": "http://localhost:8081" + "ci_service_url": "http://localhost:8081", + "usdt_wallet": "" } diff --git a/config/loader.v b/config/loader.v index 4f176d3..f4728ef 100644 --- a/config/loader.v +++ b/config/loader.v @@ -10,6 +10,7 @@ pub: avatars_path string hostname string ci_service_url string + usdt_wallet string // ci_secret is the shared secret used to authenticate CI status callbacks // from gitly_ci (HMAC-SHA256 over the request body). Must match gitly_ci's // ci_secret. When empty, callbacks are accepted unauthenticated (insecure). diff --git a/config/loader_test.v b/config/loader_test.v index d894404..dad653a 100644 --- a/config/loader_test.v +++ b/config/loader_test.v @@ -18,4 +18,5 @@ fn test_read_config_uses_database_defaults() { assert conf.pg.user == 'gitly' assert conf.pg.password == 'gitly' assert conf.sqlite.path == 'gitly.sqlite' + assert conf.usdt_wallet == '' } diff --git a/main.v b/main.v index a8fa998..3c3da9a 100644 --- a/main.v +++ b/main.v @@ -42,6 +42,7 @@ fn main() { mut app := new_app()! app.use(handler: app.before_request) + app.route_use('/:username/:repo_name/pull/:id/files', handler: minify_pr_files_html, after: true) app.port = get_port(app.config) diff --git a/pr_routes.v b/pr_routes.v index fce6a0a..ad735ae 100644 --- a/pr_routes.v +++ b/pr_routes.v @@ -81,6 +81,39 @@ fn (row PrFileTreeRow) status() string { return 'M' } +fn render_pr_file_diff(fd FileDiff, comments_by_key map[string][]PrReviewCommentWithUser, can_comment bool, lang Lang) veb.RawHtml { + mut out := strings.new_builder(1024) + path := html_escape_text(fd.path) + out.write_string('
') + if fd.is_renamed && fd.old_path != fd.path { + old_path := html_escape_text(fd.old_path) + renamed_label := tr_text(lang, 'commit_file_renamed') + out.write_string('${renamed_label}${old_path} →') + } + out.write_string(path) + if fd.is_new { + new_label := tr_text(lang, 'commit_file_new') + out.write_string('${new_label}') + } + if fd.is_deleted { + deleted_label := tr_text(lang, 'commit_file_deleted') + out.write_string('${deleted_label}') + } + out.write_string('+${fd.additions}-${fd.deletions}
') + if fd.is_binary { + binary_label := tr_text(lang, 'pr_binary_file') + out.write_string('
${binary_label}
') + } else { + out.write_string(pr_diff_table_html(fd, comments_by_key, can_comment)) + } + out.write_string('
') + return veb.RawHtml(out.str()) +} + +fn tr_text(lang Lang, key string) string { + return html_escape_text(veb.tr(lang.str(), key).trim_space()) +} + fn build_pr_file_tree_rows(file_diffs []FileDiff) []PrFileTreeRow { mut sorted := file_diffs.clone() sorted.sort(a.path < b.path) @@ -331,6 +364,7 @@ pub fn (mut app App) pull_request_files(mut ctx Context, username string, repo_n } } can_comment := ctx.logged_in && pr.is_open() + line_comment_placeholder := veb.tr(ctx.lang.str(), 'pr_line_comment_placeholder').trim_space() return $veb.html('templates/pull_files.html') } @@ -634,7 +668,7 @@ fn merge_branches_in_bare(repo Repo, base string, head string, author string, me return commit_sha } -fn render_pr_diff_table(fd FileDiff, comments_by_key map[string][]PrReviewCommentWithUser, can_comment bool) veb.RawHtml { +fn pr_diff_table_html(fd FileDiff, comments_by_key map[string][]PrReviewCommentWithUser, can_comment bool) string { mut out := strings.new_builder(1024) out.write_string('
') for hunk in fd.hunks { @@ -650,7 +684,7 @@ fn render_pr_diff_table(fd FileDiff, comments_by_key map[string][]PrReviewCommen } } out.write_string('
') - return veb.RawHtml(out.str()) + return out.str() } // inline_comments_html returns any line comments attached to a given diff line, diff --git a/static/assets/version b/static/assets/version index 62063e2..469a03c 100644 --- a/static/assets/version +++ b/static/assets/version @@ -1 +1 @@ -bc9003f \ No newline at end of file +3e6e162 \ No newline at end of file diff --git a/static/css/gitly.scss b/static/css/gitly.scss index b8d7a5d..e53b0b3 100644 --- a/static/css/gitly.scss +++ b/static/css/gitly.scss @@ -147,6 +147,16 @@ pre > code { } } +.clone-status-button--usdt { + background: #26a17b; + border: 1px solid #26a17b; + + &:hover { + background: #1d7f61; + border-color: #1d7f61; + } +} + .clone-status-url { color: $gray-dark; margin: 10px auto 0; @@ -611,6 +621,12 @@ form { } } +.pricing-plan__actions { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + gap: 10px; +} + .pricing-plan__button--secondary { background: #0969da; border-color: #0969da; @@ -621,6 +637,16 @@ form { } } +.pricing-plan__button--usdt { + background: #26a17b; + border-color: #26a17b; + + &:hover { + background: #1d7f61; + border-color: #1d7f61; + } +} + .pricing-plan__features { margin: 18px 0 0 18px; @@ -646,6 +672,17 @@ form { } } +.pricing-note--usdt { + code { + display: inline-block; + max-width: 100%; + padding: 3px 6px; + border-radius: $small-radius; + background: #f6f8fa; + overflow-wrap: anywhere; + } +} + @keyframes alert-show { 0% { right: -100px; } 100% { right: 20px; } diff --git a/templates/clone_size_limit.html b/templates/clone_size_limit.html index 845657c..633f313 100644 --- a/templates/clone_size_limit.html +++ b/templates/clone_size_limit.html @@ -17,6 +17,9 @@ @end
%clone_size_limit_purchase_premium + @if app.config.usdt_wallet != '' + %clone_size_limit_purchase_usdt + @end %clone_size_limit_pricing_link
@if clone_progress != '' diff --git a/templates/pricing.html b/templates/pricing.html index 0306f78..e5eb0d6 100644 --- a/templates/pricing.html +++ b/templates/pricing.html @@ -21,7 +21,12 @@ %pricing_premium_price %pricing_per_month - %pricing_buy_premium +
+ %pricing_buy_premium + @if app.config.usdt_wallet != '' + %pricing_buy_premium_usdt + @end +