reorganize site settings a bit

This commit is contained in:
Jeff Atwood 2014-10-19 23:14:50 -07:00
parent ba9e4b42fe
commit 92b615b503
9 changed files with 20 additions and 20 deletions

View File

@ -149,7 +149,7 @@ Discourse.PostStream = Em.Object.extend({
var firstIndex = this.indexOf(firstPost);
if (firstIndex === -1) { return []; }
var startIndex = firstIndex - Discourse.SiteSettings.posts_per_page;
var startIndex = firstIndex - Discourse.SiteSettings.posts_chunksize;
if (startIndex < 0) { startIndex = 0; }
return stream.slice(startIndex, firstIndex);
@ -173,7 +173,7 @@ Discourse.PostStream = Em.Object.extend({
if ((lastIndex + 1) >= this.get('highest_post_number')) { return []; }
// find our window of posts
return stream.slice(lastIndex+1, lastIndex+Discourse.SiteSettings.posts_per_page+1);
return stream.slice(lastIndex+1, lastIndex+Discourse.SiteSettings.posts_chunksize+1);
}.property('lastLoadedPost', 'stream.@each'),

View File

@ -58,7 +58,7 @@ class TopicsController < ApplicationController
end
page = params[:page].to_i
if (page < 0) || ((page - 1) * SiteSetting.posts_per_page > @topic_view.topic.highest_post_number)
if (page < 0) || ((page - 1) * SiteSetting.posts_chunksize > @topic_view.topic.highest_post_number)
raise Discourse::NotFound
end

View File

@ -733,7 +733,7 @@ en:
share_links: "Determine which items appear on the share dialog, and in what order."
track_external_right_clicks: "Track external links that are right clicked (eg: open in new tab) disabled by default because it rewrites URLs"
topics_per_page: "How many topics are loaded by default on the topic list, and when scrolling down to load more topics"
posts_per_page: "How many posts are loaded by default on a topic, and when scrolling down to load more posts"
posts_chunksize: "How many posts are loaded by default on a topic, and when scrolling down to load more posts"
site_contact_username: "All automated private messages will be from this user; if left blank the default System account will be used."
send_welcome_message: "Send all new users a welcome private message with a quick start guide."
suppress_reply_directly_below: "Don't show the expandable reply count on a post when there is only a single reply directly below this post."

View File

@ -158,10 +158,6 @@ basic:
show_subcategory_list:
default: false
client: true
posts_per_page:
client: true
default: 20
min: 1
enable_badges:
client: true
default: true
@ -632,6 +628,10 @@ developer:
verbose_localization:
default: false
client: true
posts_chunksize:
client: true
default: 20
min: 1
embedding:
embeddable_host: ''

View File

@ -21,7 +21,7 @@ class TopicView
@page = @page.to_i
@page = 1 if @page.zero?
@limit ||= SiteSetting.posts_per_page
@limit ||= SiteSetting.posts_chunksize
setup_filtered_posts

View File

@ -118,7 +118,7 @@ describe TopicView do
end
it "generates a canonical correctly for paged results" do
SiteSetting.stubs(:posts_per_page).returns(5)
SiteSetting.stubs(:posts_chunksize).returns(5)
TopicView.new(1234, user, post_number: 50).canonical_path.should eql("/1234?page=10")
end
end
@ -136,7 +136,7 @@ describe TopicView do
TopicView.any_instance.expects(:find_topic).with(1234).returns(topic)
TopicView.any_instance.stubs(:filter_posts)
TopicView.any_instance.stubs(:last_post).returns(p2)
SiteSetting.stubs(:posts_per_page).returns(2)
SiteSetting.stubs(:posts_chunksize).returns(2)
end
it "should return the next page" do
@ -245,7 +245,7 @@ describe TopicView do
let!(:p3) { Fabricate(:post, topic: topic, user: first_poster)}
before do
SiteSetting.posts_per_page = 3
SiteSetting.posts_chunksize = 3
# Update them to the sort order we're checking for
[p1, p2, p3, p4, p5, p6, p7].each_with_index do |p, idx|
@ -289,7 +289,7 @@ describe TopicView do
describe '#filter_posts_paged' do
before { SiteSetting.stubs(:posts_per_page).returns(2) }
before { SiteSetting.stubs(:posts_chunksize).returns(2) }
it 'returns correct posts for all pages' do
topic_view.filter_posts_paged(1).should == [p1, p2]
@ -362,7 +362,7 @@ describe TopicView do
end
context "when 'posts per page' exceeds the number of posts" do
before { SiteSetting.stubs(:posts_per_page).returns(100) }
before { SiteSetting.stubs(:posts_chunksize).returns(100) }
it 'returns all the posts' do
near_view = topic_view_near(p5)

View File

@ -656,19 +656,19 @@ describe TopicsController do
context 'filters' do
it 'grabs first page when no filter is provided' do
SiteSetting.stubs(:posts_per_page).returns(20)
SiteSetting.stubs(:posts_chunksize).returns(20)
TopicView.any_instance.expects(:filter_posts_in_range).with(0, 19)
xhr :get, :show, topic_id: topic.id, slug: topic.slug
end
it 'grabs first page when first page is provided' do
SiteSetting.stubs(:posts_per_page).returns(20)
SiteSetting.stubs(:posts_chunksize).returns(20)
TopicView.any_instance.expects(:filter_posts_in_range).with(0, 19)
xhr :get, :show, topic_id: topic.id, slug: topic.slug, page: 1
end
it 'grabs correct range when a page number is provided' do
SiteSetting.stubs(:posts_per_page).returns(20)
SiteSetting.stubs(:posts_chunksize).returns(20)
TopicView.any_instance.expects(:filter_posts_in_range).with(20, 39)
xhr :get, :show, topic_id: topic.id, slug: topic.slug, page: 2
end

View File

@ -1,3 +1,3 @@
/*jshint maxlen:10000000 */
Discourse.SiteSettingsOriginal = {"title":"Discourse Meta","logo_url":"/assets/logo.png","logo_small_url":"/assets/logo-single.png","mobile_logo_url":"","favicon_url":"//meta.discourse.org/uploads/default/2499/79d53726406d87af.ico","allow_user_locale":false,"suggested_topics":7,"track_external_right_clicks":false,"ga_universal_tracking_code":"","ga_universal_domain_name":"auto","ga_tracking_code":"UA-33736483-2","ga_domain_name":"","top_menu":"latest|new|unread|starred|categories|top","post_menu":"like|share|flag|edit|bookmark|delete|admin|reply","post_menu_hidden_items":"edit|delete|admin","share_links":"twitter|facebook|google+|email","category_colors":"BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890","enable_mobile_theme":true,"relative_date_duration":14,"category_featured_topics":4,"fixed_category_positions":false,"show_subcategory_list":false,"posts_per_page":20,"enable_badges":true,"invite_only":false,"login_required":false,"must_approve_users":false,"enable_local_logins":true,"allow_new_registrations":true,"enable_google_logins":true,"enable_google_oauth2_logins":false,"enable_yahoo_logins":true,"enable_twitter_logins":true,"enable_facebook_logins":true,"enable_github_logins":true,"enable_sso":false,"min_username_length":3,"max_username_length":20,"min_password_length":8,"enable_names":true,"invites_shown":30,"delete_user_max_post_age":60,"delete_all_posts_max":15,"min_post_length":20,"min_private_message_post_length":10,"max_post_length":32000,"min_topic_title_length":15,"max_topic_title_length":255,"min_private_message_title_length":2,"allow_uncategorized_topics":true,"min_title_similar_length":10,"min_body_similar_length":15,"edit_history_visible_to_public":true,"delete_removed_posts_after":24,"traditional_markdown_linebreaks":false,"suppress_reply_directly_below":true,"suppress_reply_directly_above":true,"newuser_max_images":0,"newuser_max_attachments":0,"display_name_on_posts":true,"short_progress_text_threshold":10000,"default_code_lang":"lang-auto","autohighlight_all_code":false,"email_in":false,"max_image_size_kb":3072,"max_attachment_size_kb":1024,"authorized_extensions":".jpg|.jpeg|.png|.gif|.svg|.txt|.ico|.yml","max_image_width":690,"max_image_height":500,"allow_profile_backgrounds":true,"allow_uploaded_avatars":true,"allow_animated_avatars":false,"tl1_requires_read_posts":30,"enable_long_polling":true,"polling_interval":3000,"anon_polling_interval":30000,"flush_timings_secs":5,"tos_url":"","privacy_policy_url":"","tos_accept_required":false,"faq_url":"","allow_restore":false,"maximum_backups":7,"version_checks":true,"suppress_uncategorized_badge":true,"min_search_term_length":3,"topic_views_heat_low":1000,"topic_views_heat_medium":2000,"topic_views_heat_high":5000,"global_notice":"","show_create_topics_notice":true,"available_locales":"cs|da|de|en|es|fr|he|id|it|ja|ko|nb_NO|nl|pl_PL|pt|pt_BR|ru|sv|uk|zh_CN|zh_TW"};
Discourse.SiteSettingsOriginal = {"title":"Discourse Meta","logo_url":"/assets/logo.png","logo_small_url":"/assets/logo-single.png","mobile_logo_url":"","favicon_url":"//meta.discourse.org/uploads/default/2499/79d53726406d87af.ico","allow_user_locale":false,"suggested_topics":7,"track_external_right_clicks":false,"ga_universal_tracking_code":"","ga_universal_domain_name":"auto","ga_tracking_code":"UA-33736483-2","ga_domain_name":"","top_menu":"latest|new|unread|starred|categories|top","post_menu":"like|share|flag|edit|bookmark|delete|admin|reply","post_menu_hidden_items":"edit|delete|admin","share_links":"twitter|facebook|google+|email","category_colors":"BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890","enable_mobile_theme":true,"relative_date_duration":14,"category_featured_topics":4,"fixed_category_positions":false,"show_subcategory_list":false,"posts_chunksize":20,"enable_badges":true,"invite_only":false,"login_required":false,"must_approve_users":false,"enable_local_logins":true,"allow_new_registrations":true,"enable_google_logins":true,"enable_google_oauth2_logins":false,"enable_yahoo_logins":true,"enable_twitter_logins":true,"enable_facebook_logins":true,"enable_github_logins":true,"enable_sso":false,"min_username_length":3,"max_username_length":20,"min_password_length":8,"enable_names":true,"invites_shown":30,"delete_user_max_post_age":60,"delete_all_posts_max":15,"min_post_length":20,"min_private_message_post_length":10,"max_post_length":32000,"min_topic_title_length":15,"max_topic_title_length":255,"min_private_message_title_length":2,"allow_uncategorized_topics":true,"min_title_similar_length":10,"min_body_similar_length":15,"edit_history_visible_to_public":true,"delete_removed_posts_after":24,"traditional_markdown_linebreaks":false,"suppress_reply_directly_below":true,"suppress_reply_directly_above":true,"newuser_max_images":0,"newuser_max_attachments":0,"display_name_on_posts":true,"short_progress_text_threshold":10000,"default_code_lang":"lang-auto","autohighlight_all_code":false,"email_in":false,"max_image_size_kb":3072,"max_attachment_size_kb":1024,"authorized_extensions":".jpg|.jpeg|.png|.gif|.svg|.txt|.ico|.yml","max_image_width":690,"max_image_height":500,"allow_profile_backgrounds":true,"allow_uploaded_avatars":true,"allow_animated_avatars":false,"tl1_requires_read_posts":30,"enable_long_polling":true,"polling_interval":3000,"anon_polling_interval":30000,"flush_timings_secs":5,"tos_url":"","privacy_policy_url":"","tos_accept_required":false,"faq_url":"","allow_restore":false,"maximum_backups":7,"version_checks":true,"suppress_uncategorized_badge":true,"min_search_term_length":3,"topic_views_heat_low":1000,"topic_views_heat_medium":2000,"topic_views_heat_high":5000,"global_notice":"","show_create_topics_notice":true,"available_locales":"cs|da|de|en|es|fr|he|id|it|ja|ko|nb_NO|nl|pl_PL|pt|pt_BR|ru|sv|uk|zh_CN|zh_TW"};
Discourse.SiteSettings = jQuery.extend(true, {}, Discourse.SiteSettingsOriginal);

View File

@ -182,7 +182,7 @@ test("loading", function() {
});
test("nextWindow", function() {
Discourse.SiteSettings.posts_per_page = 5;
Discourse.SiteSettings.posts_chunksize = 5;
var postStream = buildStream(1234, [1,2,3,5,8,9,10,11,13,14,15,16]);
blank(postStream.get('nextWindow'), 'With no posts loaded, the window is blank');
@ -199,7 +199,7 @@ test("nextWindow", function() {
});
test("previousWindow", function() {
Discourse.SiteSettings.posts_per_page = 5;
Discourse.SiteSettings.posts_chunksize = 5;
var postStream = buildStream(1234, [1,2,3,5,8,9,10,11,13,14,15,16]);
blank(postStream.get('previousWindow'), 'With no posts loaded, the window is blank');