From 5d4e5ec109c6d4178b3f7946b90d933c27a10d01 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 13 Apr 2016 15:19:54 -0700 Subject: [PATCH 1/4] supporters intelligence for proxy servers --- Rakefile | 20 +++++++++++++++++--- models/site.rb | 4 ++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 6bd93497..fa7b10ae 100644 --- a/Rakefile +++ b/Rakefile @@ -65,13 +65,27 @@ task :update_blocked_ips => [:environment] do end end -desc 'Compile domain map for nginx' -task :compile_domain_map => [:environment] do +desc 'Compile nginx mapfiles' +task :compile_nginx_mapfiles => [:environment] do File.open('./files/map.txt', 'w') do |file| - Site.exclude(domain: nil).exclude(domain: '').select(:username,:domain).all.collect do |site| + Site.exclude(domain: nil).exclude(domain: '').select(:username,:domain).all.each do |site| file.write ".#{site.values[:domain]} #{site.username};\n" end end + + File.open('./files/supporter-map.txt', 'w') do |file| + file.write "hostnames;\n" + file.write "default 0;\n" + Site.select(:username, :domain).exclude(plan_type: 'free').exclude(plan_type: nil).all.each do |parent_site| + sites = [parent_site] + parent_site.children + sites.each do |site| + file.write "#{site.username}.neocities.org 1;\n" + unless site.host.match(/\.neocities\.org$/) + file.write ".#{site.values[:domain]} 1;\n" + end + end + end + end end desc 'Produce SSL config package for proxy' diff --git a/models/site.rb b/models/site.rb index 6202c4a0..f7fd2ba5 100644 --- a/models/site.rb +++ b/models/site.rb @@ -1052,7 +1052,7 @@ class Site < Sequel::Model ((total_space_used.to_f / maximum_space) * 100).round(1) end - # Note: Change Stat#prune! if you change this business logic. + # Note: Change Stat#prune! and the nginx map compiler if you change this business logic. def supporter? owner.plan_type != 'free' end @@ -1078,7 +1078,7 @@ class Site < Sequel::Model !values[:plan_type].match(/plan_/).nil? end - # Note: Change Stat#prune! if you change this business logic. + # Note: Change Stat#prune! and the nginx map compiler if you change this business logic. def plan_type return 'supporter' if owner.values[:paypal_active] == true return 'free' if owner.values[:plan_type].nil? From fafca061b7ff49946ad10eb4a8818b2af42bd1e3 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 13 Apr 2016 15:47:54 -0700 Subject: [PATCH 2/4] included in config, not needed in map file --- Rakefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Rakefile b/Rakefile index fa7b10ae..7f28a44f 100644 --- a/Rakefile +++ b/Rakefile @@ -74,8 +74,6 @@ task :compile_nginx_mapfiles => [:environment] do end File.open('./files/supporter-map.txt', 'w') do |file| - file.write "hostnames;\n" - file.write "default 0;\n" Site.select(:username, :domain).exclude(plan_type: 'free').exclude(plan_type: nil).all.each do |parent_site| sites = [parent_site] + parent_site.children sites.each do |site| From 110a8f508a034a7d8418354f8cac54e490ee8ffa Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 13 Apr 2016 17:37:52 -0700 Subject: [PATCH 3/4] Add hotlinking and CORS to comparison page --- views/plan/_compare.erb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/views/plan/_compare.erb b/views/plan/_compare.erb index 0a9ac813..3ffb1a56 100644 --- a/views/plan/_compare.erb +++ b/views/plan/_compare.erb @@ -141,6 +141,20 @@ + + + Hotlinking Support + + + + + + + Cross Origin (CORS) Support + + + +