Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
- name: Build V
shell: cmd
run: |
make.bat -gcc
makev.bat -gcc
# Must run after "Build V": the script shells out to `v.exe`, which
# does not exist until V is built.
- name: Install SQLite
Expand Down
4 changes: 2 additions & 2 deletions highlight/markdown_test.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module highlight

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

fn test_convert_markdown_to_html() {
rendered := convert_markdown_to_html(markdown)
rendered := convert_markdown_to_html(xss_markdown_sample)
assert !rendered.contains('<script>')
assert rendered.contains('&lt;script&gt;')
assert rendered.contains('test</p>')
Expand Down
42 changes: 35 additions & 7 deletions issue_routes.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn (mut app App) handle_issues_count(username string, repo_name string) veb.Resu
count := app.get_repo_issue_count(repo.id)
return ctx.json(api.ApiIssueCount{
success: true
result: count
result: count
})
}

Expand Down Expand Up @@ -86,8 +86,8 @@ pub fn (mut app App) handle_add_repo_issue(mut ctx Context, username string, rep
app.sync_repo_open_issue_count(repo.id) or { app.info(err.str()) }
app.dispatch_webhook(repo.id, 'issue', WebhookIssuePayload{
action: 'opened'
repo: '${username}/${repo_name}'
title: title
repo: '${username}/${repo_name}'
title: title
author: ctx.user.username
})
has_first_issue_activity := app.has_activity(ctx.user.id, 'first_issue')
Expand Down Expand Up @@ -261,8 +261,8 @@ pub fn (mut app App) handle_edit_issue(mut ctx Context, username string, repo_na
}
app.dispatch_webhook(repo.id, 'issue', WebhookIssuePayload{
action: 'updated'
repo: '${username}/${repo_name}'
title: title.trim_space()
repo: '${username}/${repo_name}'
title: title.trim_space()
author: ctx.user.username
})
return ctx.redirect('/${username}/${repo_name}/issue/${issue.id}')
Expand Down Expand Up @@ -376,8 +376,8 @@ fn change_issue_status(mut app App, mut ctx Context, username string, repo_name
action := if status == .closed { 'closed' } else { 'reopened' }
app.dispatch_webhook(repo.id, 'issue', WebhookIssuePayload{
action: action
repo: '${username}/${repo_name}'
title: issue.title
repo: '${username}/${repo_name}'
title: issue.title
author: ctx.user.username
})
return ctx.redirect('/${username}/${repo_name}/issue/${issue.id}')
Expand Down Expand Up @@ -457,3 +457,31 @@ pub fn (mut app App) user_issues(mut ctx Context, username string, tab string) v
ctx.set_page_title([tab_title, user.username])
return $veb.html()
}

@['/:username/:repo_name/issues/batch'; post]
pub fn (mut app App) handle_batch_issues(mut ctx Context, username string, repo_name string) veb.Result {
repo := app.find_repo_by_name_and_username(repo_name, username) or { return ctx.not_found() }
if !app.can_admin_repo(ctx, repo) {
return ctx.not_found()
}
action := ctx.form['action'] or { '' }
ids_raw := ctx.form['issue_ids'] or { '' }
for part in ids_raw.split(',') {
id := part.trim_space().int()
if id <= 0 { continue }
issue := app.find_issue_by_id(id) or { continue }
if issue.repo_id != repo.id {
continue
}
match action {
'close' {
app.set_issue_status(id, .closed) or { app.info(err.str()) }
}
'open' {
app.set_issue_status(id, .open) or { app.info(err.str()) }
}
else {}
}
}
return ctx.redirect('/${username}/${repo_name}/issues')
}
2 changes: 1 addition & 1 deletion repo/repo.v
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn (mut app App) search_public_repos(query string) []Repo {
// unrelated users.
fn (mut app App) search_repos(query string, user_id int) []Repo {
pattern := sql_like_pattern(query)
repo_rows := db_exec_values(mut app.db, 'select id from ${sql_table('Repo')} where is_deleted is false and (\n\t\t\tlower(name) like lower(${pattern}) or lower(user_name) like lower(${pattern}) or lower(description) like lower(${pattern})\n\t\t) order by nr_stars desc, name asc limit ${search_candidate_limit}') or {
repo_rows := db_exec_values(mut app.db, 'select id from ${sql_table('Repo')} where is_deleted is false and (\n\t\t\tlower(name) like lower(${pattern}) or lower(user_name) like lower(${pattern}) or lower(description) like lower(${pattern})\n\t\t) order by stars_count desc, name asc limit ${search_candidate_limit}') or {
app.warn('Repository search failed: ${err}')
return []
}
Expand Down
1 change: 1 addition & 0 deletions templates/_issue_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ul class="issue-list">
@for issue_with_user in issues_with_users
<li class="issue-row">
<input type="checkbox" name="issue_ids" value="@issue_with_user.item.id" form="batch-form">
<svg class="issue-row__icon" viewBox="0 0 16 16" aria-hidden="true">
<path fill="@{issue_with_user.item.status_color()}" d="M8 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"/>
<path fill="@{issue_with_user.item.status_color()}" fill-rule="evenodd" d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0ZM1.5 8a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0Z"/>
Expand Down
7 changes: 7 additions & 0 deletions templates/issues.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ <h1 class="issues-header__title">%issue_issues</h1>
@if issues_with_users.len == 0
<div class="issues-empty">%issue_none</div>
@else
<form id="batch-form" method="post" action="/@repo.user_name/@repo.name/issues/batch">
<select name="action">
<option value="close">Close selected</option>
<option value="open">Reopen selected</option>
</select>
<button type="submit">Apply</button>
</form>
@include '_issue_list.html'

<div class="issue-pager">
Expand Down
Loading