Skip to content
Browse files

Moved disallowed/whitelisted gems/projects to config file

  • Loading branch information...
1 parent 42168d0 commit 22d8c8f71d386a892af75d3d743a20cc4cdd454e @lsegal lsegal committed
Showing with 24 additions and 10 deletions.
  1. +10 −10 app.rb
  2. +14 −0 config/config.yaml.sample
View
20 app.rb
@@ -21,11 +21,6 @@ class NilClass; def blank?; true end end
class DocServer < Sinatra::Base
include YARD::Server
- DISALLOWED_GEMS = %w(netsuite_client)
- DISALLOWED_PROJECTS = %w(kraeftemessen/spider-network)
- WHITELISTED_GEMS = %w(yard)
- WHITELISTED_PROJECTS = %w(lsegal/yard)
-
def self.adapter_options
caching = %w(staging production).include?(ENV['RACK_ENV'])
{
@@ -39,6 +34,11 @@ def self.load_configuration
set :name, 'RubyDoc.info'
set :url, 'http://rubydoc.info'
+ set :disallowed_projects, []
+ set :disallowed_gems, []
+ set :whitelisted_projects, []
+ set :whitelisted_gems, []
+
return unless File.file?(CONFIG_FILE)
puts ">> Loading #{CONFIG_FILE}"
@@ -255,11 +255,11 @@ def shorten_commit_link(commit)
url = url.sub(%r{^http://}, 'git://')
if url =~ %r{github\.com/([^/]+)/([^/]+)}
username, project = $1, $2
- if WHITELISTED_PROJECTS.include?("#{username}/#{project}")
+ if settings.whitelisted_projects.include?("#{username}/#{project}")
puts "Dropping safe mode for #{username}/#{project}"
YARD::Config.options[:safe_mode] = false
end
- if DISALLOWED_PROJECTS.include?("#{username}/#{project}")
+ if settings.disallowed_projects.include?("#{username}/#{project}")
return status(503) && "Cannot parse this project"
end
end
@@ -316,7 +316,7 @@ def shorten_commit_link(commit)
get %r{^/(?:(?:search|list)/)?github/([^/]+)/([^/]+)} do |username, project|
@username, @project = username, project
- if WHITELISTED_PROJECTS.include?("#{username}/#{project}")
+ if settings.whitelisted_projects.include?("#{username}/#{project}")
puts "Dropping safe mode for #{username}/#{project}"
YARD::Config.options[:safe_mode] = false
end
@@ -326,8 +326,8 @@ def shorten_commit_link(commit)
end
get %r{^/(?:(?:search|list)/)?gems/([^/]+)} do |gemname|
- return status(503) && "Cannot parse this gem" if DISALLOWED_GEMS.include?(gemname)
- if WHITELISTED_GEMS.include?(gemname)
+ return status(503) && "Cannot parse this gem" if settings.disallowed_gems.include?(gemname)
+ if settings.whitelisted_gems.include?(gemname)
puts "Dropping safe mode for #{gemname}"
YARD::Config.options[:safe_mode] = false
end
View
14 config/config.yaml.sample
@@ -42,3 +42,17 @@
# yard:
# 0.6.4: /path/to/yard/0.6.4
# 0.6.0: /path/to/yard/0.6.0
+
+# Projects / gems that are whitelisted for template and non-plugin code execution:
+# whitelisted_projects:
+# - lsegal/yard
+#
+# whitelisted_gems:
+# - yard
+
+# Projects / gems that are blacklisted from the site
+# disallowed_projects:
+# - user/projectname
+#
+# disallowed_gems:
+# - gemname

0 comments on commit 22d8c8f

Please sign in to comment.
Something went wrong with that request. Please try again.