Skip to content

Commit 4471d69

Browse files
committed
Merge branch 'develop' into 0valt/1759/select-init
2 parents 8f5a654 + 806dd65 commit 4471d69

5 files changed

Lines changed: 56 additions & 11 deletions

File tree

app/assets/stylesheets/tour.scss

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
.codidactyl {
2-
width: 80px;
3-
padding: 2rem;
4-
margin-top: 1rem;
2+
width: 80px;
3+
padding: 2rem;
4+
margin-top: 1rem;
5+
}
6+
7+
.codidactyl + .is-flexible {
8+
width: 0;
59
}
6-
.codidactyl + .is-flexible { width: 0; }
710

811
.codidactyl-sticky {
9-
position: sticky;
10-
top: 0.5rem;
11-
padding: 1rem;
12+
position: sticky;
13+
top: 0.5rem;
14+
padding: 1rem;
1215
}
1316

1417
.codidactyl-small {
15-
max-height: 1em;
16-
}
18+
max-height: 1em;
19+
}
20+
21+
@media (max-width: 768px) {
22+
.tour-editor-wrapper {
23+
order: 2;
24+
}
25+
26+
.tour-hints-wrapper {
27+
order: 1;
28+
}
29+
}

app/controllers/categories_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ def show
2121

2222
def homepage
2323
@category = Category.where(is_homepage: true).first
24+
25+
unless @category.present?
26+
redirect_to categories_path
27+
return
28+
end
29+
2430
update_last_visit(@category)
2531
set_list_posts
2632
render :show
@@ -199,6 +205,9 @@ def set_list_posts
199205
@posts = @posts.paginate(page: params[:page], per_page: 50).order(sort_param)
200206
end
201207

208+
# Updates last visit cache for a given category
209+
# @param category [Category] category to update
210+
# @return [Boolean] whether the cache entry is deleted
202211
def update_last_visit(category)
203212
return if current_user.blank?
204213

app/models/category.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class Category < ApplicationRecord
2727
'pink',
2828
'red'].freeze
2929

30+
# Is the category set as the homepage?
31+
# @return [Boolean] check result
32+
def homepage?
33+
is_homepage == true
34+
end
35+
3036
# Can anyone view the category (even if not logged in)?
3137
# @return [Boolean] check result
3238
def public?

app/views/tour/question2.html.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<%= render 'posts/markdown_script' %>
2+
<%= render 'posts/image_upload' %>
23

34
<div class="grid step-0">
45
<div class="grid--cell codidactyl">
@@ -20,7 +21,7 @@
2021
<hr>
2122

2223
<div class="grid">
23-
<div class="grid--cell is-8">
24+
<div class="grid--cell is-8-lg is-12-md is-12-sm tour-editor-wrapper">
2425
<h1>New Post in Q&amp;A</h1>
2526
<div class="notice is-info">
2627
<%= raw(sanitize(render_markdown(SiteSetting['AskingGuidance']), scrubber: scrubber)) %>
@@ -53,7 +54,7 @@
5354
</div>
5455

5556
</div>
56-
<div class="grid--cell is-4">
57+
<div class="grid--cell is-4-lg is-12-md is-12-sm tour-hints-wrapper">
5758
<div class="codidactyl-hints codidactyl-sticky">
5859
<div class="widget step-1 hide">
5960
<div class="widget--header">

test/controllers/categories_controller_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ class CategoriesControllerTest < ActionController::TestCase
99
assert_not_nil assigns(:categories)
1010
end
1111

12+
test ':homepage should correctly show the homepage category' do
13+
get :homepage
14+
assert_response(:success)
15+
@category = assigns(:category)
16+
assert_not_nil @category
17+
assert @category.homepage?
18+
end
19+
20+
test ':homepage should redirect to the categories list if there is no default category' do
21+
Category.where(is_homepage: true).destroy_all
22+
23+
get :homepage
24+
assert_response(:found)
25+
assert_redirected_to(categories_path)
26+
end
27+
1228
test 'should correctly show public categories' do
1329
public_categories = categories.select(&:public?)
1430

0 commit comments

Comments
 (0)