Skip to content

Commit c4ed5b2

Browse files
authored
Merge pull request #1888 from codidact/ovalt/user-restore
Assorted improvements
2 parents 74022de + 4ed0ce6 commit c4ed5b2

67 files changed

Lines changed: 670 additions & 230 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CODE-STANDARDS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ onto the next line, and every continuation line must be indented _at least_ one
281281
Wrapped lines may be indented further to align certain elements with one another.
282282

283283
```js
284-
codidact.createDangerConfirmationAudit(document.querySelectorAll('.modal.is-danger > .modal--body'),
285-
'POST', 'https://codidact.org/audits/danger-confirmation');
284+
QPixel.createDangerConfirmationAudit(document.querySelectorAll('.modal.is-danger > .modal--body'),
285+
'POST', 'https://example.com/audits/danger-confirmation');
286286
```
287287

288288
#### Bracing

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ group :test do
9393
gem 'capybara', '~> 3.38'
9494
gem 'selenium-webdriver', '~> 4.7'
9595
gem 'webdrivers', '~> 5.2'
96+
gem 'webmock', '~> 3.26'
9697
end
9798

9899
group :development, :test do

Gemfile.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ GEM
137137
counter_culture (3.11.2)
138138
activerecord (>= 4.2)
139139
activesupport (>= 4.2)
140+
crack (1.0.1)
141+
bigdecimal
142+
rexml
140143
crass (1.0.6)
141144
css_parser (1.21.1)
142145
addressable
@@ -166,6 +169,7 @@ GEM
166169
activesupport (>= 6.1)
167170
groupdate (6.5.1)
168171
activesupport (>= 7)
172+
hashdiff (1.2.1)
169173
hashie (5.0.0)
170174
htmlentities (4.3.4)
171175
i18n (1.14.7)
@@ -448,6 +452,10 @@ GEM
448452
nokogiri (~> 1.6)
449453
rubyzip (>= 1.3.0)
450454
selenium-webdriver (~> 4.0, < 4.11)
455+
webmock (3.26.0)
456+
addressable (>= 2.8.0)
457+
crack (>= 0.3.2)
458+
hashdiff (>= 0.4.0, < 2.0.0)
451459
webrick (1.9.1)
452460
websocket (1.2.11)
453461
websocket-driver (0.8.0)
@@ -530,6 +538,7 @@ DEPENDENCIES
530538
tzinfo-data (~> 1.2022.3)
531539
web-console (~> 4.2)
532540
webdrivers (~> 5.2)
541+
webmock (~> 3.26)
533542
whenever (~> 1.0)
534543
will_paginate (~> 3.3)
535544
will_paginate-bootstrap (~> 1.0)

app/assets/javascripts/keyboard_tools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ $(() => {
102102

103103
if (isHelp) {
104104
_CodidactKeyboard.dialog(
105-
'Codidact Keyboard Shortcuts\n' +
105+
'Keyboard Shortcuts\n' +
106106
'===========================\n' +
107107
'? Open this help\n' +
108108
'esc Close this help\n' +

app/assets/javascripts/markdown.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $(() => {
1919
const $tgt = $(ev.target);
2020
const $button = $tgt.is('a') ? $tgt : $tgt.parents('a');
2121
const action = $button.attr('data-action');
22-
22+
2323
/** @type {JQuery<HTMLTextAreaElement | HTMLInputElement>} */
2424
const $field = $('.js-post-field');
2525

@@ -33,7 +33,7 @@ $(() => {
3333
heading: ['\n# ', null],
3434
hr: ['\n\n-----\n\n', null],
3535
table: ['\n\n| Title1 | Title2 |\n|- | - |\n| row1_1 | row1_2 |\n\n', null],
36-
mathjax: ['$', '$']
36+
mathjax: ['$', '$'],
3737
};
3838

3939
if (Object.keys(actions).indexOf(action) !== -1) {
@@ -58,7 +58,7 @@ $(() => {
5858
case 66:
5959
$('[data-action="bold"]').click();
6060
break;
61-
61+
6262
case 73:
6363
$('[data-action="italic"]').click();
6464
break;
@@ -123,12 +123,13 @@ $(() => {
123123
});
124124

125125
QPixel.addPrePostValidation((text) => {
126-
// This regex catches Markdown images with no or default alt text.
127-
const altRegex = /!\[(?:Image_alt_text)?\](?:\(.+(?!\\\))\)|\[.+(?!\\\])\])/gi;
126+
// catch Markdown images with no or default alt text: https://regex101.com/r/ubcVn4/2
127+
const altRegex = /!\[(?:Image_alt_text)?\](?:\([^\)]+?\)|\[.+(?!\\\])\])/gi;
128128
if (text.match(altRegex)) {
129-
const message = `It looks like you're posting an image with no alt text. Alt text is important for ` +
130-
`accessibility. Consider adding alt text to the images in your post - ` +
131-
`<a href="/help/alt-text">read this help article</a> for details and help writing alt text.`;
129+
const message =
130+
`It looks like you're posting an image with no alt text. Alt text is important for ` +
131+
`accessibility. Consider adding alt text to the images in your post - ` +
132+
`<a href="/help/alt-text">read this help article</a> for details and help writing alt text.`;
132133
return [false, [{ type: 'warning', message }]];
133134
}
134135
else {

app/assets/stylesheets/comment_threads.scss

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import 'variables';
2+
13
.post--comments-thread-wrapper {
24
.post--comments-thread {
35
.widget--body:not(.widget--deleted-comments):not(.widget--more-comments) {
@@ -19,6 +21,33 @@
1921
}
2022

2123
.thread {
24+
&.widget {
25+
.widget--header {
26+
display: flex;
27+
flex-wrap: wrap;
28+
gap: 0.5em;
29+
justify-content: space-between;
30+
}
31+
32+
.widget--header-link {
33+
font-size: 0.75em;
34+
margin: 0;
35+
padding: 0;
36+
white-space: nowrap;
37+
}
38+
}
39+
40+
.thread--actions {
41+
display: flex;
42+
flex-wrap:wrap;
43+
gap: 0.5em;
44+
justify-content: end;
45+
margin-top: 0.2rem;
46+
47+
@media screen and (max-width: $screen-sm) {
48+
justify-content: start;
49+
}
50+
}
2251

2352
.widget--full-thread,
2453
.widget--more-comments,

app/assets/stylesheets/search.scss

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,56 @@
44
border-top: 1px solid $muted-graphic;
55
}
66

7+
.search-filters-filter {
8+
align-items: end;
9+
display: grid;
10+
gap: 1.25em;
11+
grid-template-columns: auto max-content;
12+
13+
margin: {
14+
top: 0;
15+
bottom: 1em;
16+
}
17+
18+
.select2-container {
19+
height: 35px;
20+
margin: 2px 0;
21+
22+
.selection {
23+
.select2-selection {
24+
border-color: $muted-graphic;
25+
height: 100%;
26+
padding: 4px 0;
27+
}
28+
29+
.select2-selection__arrow {
30+
top: 50%;
31+
translate: 0 -50%;
32+
}
33+
}
34+
}
35+
36+
@media screen and (max-width: $screen-md) {
37+
gap: 0.5em;
38+
}
39+
40+
@media screen and (min-width: $screen-md) {
41+
margin: {
42+
left: 0.5em;
43+
right: 0.5em;
44+
}
45+
}
46+
47+
@media screen and (max-width: $screen-sm) {
48+
grid-template-columns: repeat(1, 1fr);
49+
}
50+
}
51+
52+
.search-filters-filter-actions {
53+
display: flex;
54+
gap: 0.5em;
55+
}
56+
757
.search-filters-constraints {
858
display: grid;
959
column-gap: 0.5em;
@@ -22,6 +72,16 @@
2272
}
2373
}
2474

75+
.search-filters-tags {
76+
display: grid;
77+
column-gap: 0.5em;
78+
grid-template-columns: repeat(2, 1fr);
79+
80+
@media screen and (max-width: $screen-sm) {
81+
grid-template-columns: repeat(1, 1fr);
82+
}
83+
}
84+
2585
.search-sorting {
2686
align-items: center;
2787
display: flex;

app/controllers/comments_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def check_if_target_post_locked
457457
# @return [Array<Integer>] list of pinged user ids
458458
def check_for_pings(thread, content)
459459
pingable = thread.pingable
460-
matches = content.scan(/@#(\d+)/)
460+
matches = content.scan(Comment::USER_PING_REG_EXP)
461461
matches.flatten.select { |m| pingable.include?(m.to_i) }.map(&:to_i)
462462
end
463463

app/controllers/moderator_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def handle_spammy_users
8383
spam = User.where(id: params[:spam_ids])
8484
spam.each do |user|
8585
user.block('Profile spam', length: 10.years, automatic: false)
86-
user.do_soft_delete(current_user)
86+
user.soft_delete(current_user)
8787
end
8888
flash[:success] = "#{spam.size} users blocked and deleted."
8989
redirect_to mod_spammers_path

app/controllers/users/registrations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def do_delete
4646
else
4747
UserMailer.with(user: @user, host: RequestContext.community.host, community: RequestContext.community)
4848
.deletion_confirmation.deliver_later
49-
@user.do_soft_delete(@user)
49+
@user.soft_delete(@user)
5050
flash[:info] = 'Sorry to see you go!'
5151
redirect_to root_path
5252
end

0 commit comments

Comments
 (0)