-
+
diff --git a/lib/enterprise-purge.rb b/lib/enterprise-purge.rb
new file mode 100644
index 0000000000..9ffcb372b5
--- /dev/null
+++ b/lib/enterprise-purge.rb
@@ -0,0 +1,19 @@
+class EnterprisePurgeFilter < Nanoc::Filter
+ identifier :enterprise_purge_filter
+ type :text
+
+ ENTERPRISE_START_STRING = '{{#enterprise-only}}'
+ ENTERPRISE_END_STRING = '{{/enterprise-only}}'
+
+ # if we're running in Dotcom mode, we'll be lazy and just hide the content.
+ # otherwise, when running script/enterprise-cutter, we'll bring these sections back
+ def run(content, params={})
+ start_replacement = ''
+ end_replacement = '
'
+
+ content = content.gsub(%r{#{ENTERPRISE_START_STRING}
}, start_replacement)
+ content = content.gsub(%r{#{ENTERPRISE_END_STRING}
}, end_replacement)
+
+ content
+ end
+end
diff --git a/lib/resources.rb b/lib/resources.rb
index d13b327dda..a989447cd7 100644
--- a/lib/resources.rb
+++ b/lib/resources.rb
@@ -7,6 +7,7 @@
module GitHub
module Resources
module Helpers
+
STATUSES ||= {
200 => '200 OK',
201 => '201 Created',
@@ -117,6 +118,7 @@ def webhook_payload(event_name)
end
CONTENT ||= {
+ 'LATEST_ENTERPRISE_VERSION' => '2.1',
"PUT_CONTENT_LENGTH" => "Note that you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see \"[HTTP verbs](/v3/#http-verbs).\"",
"ORG_HOOK_CONFIG_HASH" =>
'''
@@ -2261,6 +2263,18 @@ def fetch_content(key)
"pretty-print" => "ssh-rsa 01:14:0f:f2:0f:e2:fe:e8:f4:72:62:af:75:f7:1a:88:3e:04:92:64"
}
]
+
+ LDAP_USER_UPDATE ||= {
+ 'ldap_dn' => 'uid=asdf,ou=users,dc=github,dc=com'
+ }.merge(USER)
+
+ LDAP_TEAM_UPDATE ||= {
+ 'ldap_dn' => 'cn=Enterprise Ops,ou=teams,dc=github,dc=com'
+ }.merge(TEAM)
+
+ LDAP_SYNC_CONFIRM ||= {
+ 'status' => 'queued'
+ }
end
end
diff --git a/script/enterprise-backport b/script/enterprise-backport
new file mode 100644
index 0000000000..0a58dca900
--- /dev/null
+++ b/script/enterprise-backport
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+
+# Occasionally, a change made to the latest version of the Enterprise API documentation
+# will need to be backported to the previous verison. This script takes the latest content
+# for /enterprise and moves it into the appropriate version folder.
+
+Dir.glob('tasks/*.rake').each { |r| load r }
+
+if ARGV.length != 1
+ error = '''Error: Run the script like this: bundle exec script/enterprise-backport [VERSION]
+e.g. bundle exec script/enterprise-cutter 2.0
+'''
+ abort error
+end
+
+version = ARGV[0].dup # like, 11.10.340
+
+BRANCH_NAME = "backport-docs-for-#{version}"
+
+setup
+
+temp_dir = Dir.mktmpdir
+begin
+ %x(git checkout `git rev-list -n 1 --before="#{date}" gh-pages`)
+ `cp -r v3/enterprise #{temp_dir}`
+ `git checkout #{BRANCH_NAME}`
+ `cp -r #{temp_dir}/* enterprise/#{version}`
+
+ rewrite_content("enterprise/#{version}")
+
+ `git add enterprise`
+ `git commit -m "Added enterprise-#{version} backported files"`
+ensure
+ FileUtils.remove_entry_secure temp_dir
+end
diff --git a/script/enterprise-cutter b/script/enterprise-cutter
index ce5dc780a0..111b7c428d 100755
--- a/script/enterprise-cutter
+++ b/script/enterprise-cutter
@@ -1,18 +1,27 @@
#!/usr/bin/env ruby
+# When releasing a new Enterprise version, the set of GitHub APIs available to that
+# verison do not match the set of documentation generally available on developer.github.com.
+# That's because the content on developer.github.com represents everything available to DotCom
+# users; since Enterprise is a "managed" product, it's cut off of DotCom at a certain
+# time, and the APIs remain frozen (until an organization upgrades their instance).
+#
+# This script takes two arguments: a date and a version number. Given a date, it
+# fetches the state of the site at that moment in time. It then copies all of that
+# content into a new folder called *enterprise/*. Thus, we're able to preserve
+# the state of the API documentation for a given version at a given time.
+
require 'fileutils'
require 'tmpdir'
require 'nokogiri'
-ERROR_MESSAGE = """
-Error: Run the script like this: bundle exec script/enterprise-cutter [DATE] [VERSION]
-e.g. bundle exec script/enterprise-cutter 2014-07-08 11.10.340
-"""
+Dir.glob('tasks/*.rake').each { |r| load r }
-if ARGV.length == 0
- abort "\n#{ERROR_MESSAGE}\n\n"
-elsif ARGV.length > 2
- abort "\n#{ERROR_MESSAGE}\n\n"
+if ARGV.length != 2
+ error = '''Error: Run the script like this: bundle exec script/enterprise-cutter [DATE] [VERSION]
+e.g. bundle exec script/enterprise-cutter 2014-07-08 11.10.340
+'''
+ abort error
end
date = ARGV[0].dup # yyyy-mm-dd, like, 2014-07-08
@@ -20,50 +29,22 @@ version = ARGV[1].dup # like, 11.10.340
BRANCH_NAME = "add-#{version}-docs"
-%x(git checkout gh-pages)
-%x(git pull origin gh-pages)
-
-%x(git checkout -b #{BRANCH_NAME})
+setup
temp_dir = Dir.mktmpdir
begin
%x(git checkout `git rev-list -n 1 --before="#{date}" gh-pages`)
- %x(cp -r * #{temp_dir})
- %x(git checkout #{BRANCH_NAME})
- version.sub!(/enterprise-/, '')
+ `cp -r * #{temp_dir}`
+ `git checkout #{BRANCH_NAME}`
FileUtils.mkdir_p("enterprise/#{version}")
- %x(cp -r #{temp_dir}/* enterprise/#{version})
-
- # we need to point links not to the root, but to the enterprise version root
- # for assets and links
- Dir.glob("enterprise/#{version}/**/*.html") do |html_file|
- doc = Nokogiri::HTML(File.read(html_file))
- doc.css('a').each do |a|
- a['href'] = "/enterprise/#{version}#{a['href']}" if a['href'] =~ /^\//
- end
- doc.css('link').each do |link|
- link['href'] = "/enterprise/#{version}#{link['href']}" if link['href'] =~ /^\//
- end
- doc.css('script').each do |script|
- script['src'] = "/enterprise/#{version}#{script['src']}" if script['src'] =~ /^\//
- end
- doc.css('img').each do |img|
- img['src'] = "/enterprise/#{version}#{img['src']}" if img['src'] =~ /^\//
- end
- doc.search('//*[@class="not-enterprise"]').remove
- File.open(html_file, 'w') { |file| file.write(doc.to_html) }
- end
+ `cp -r #{temp_dir}/* enterprise/#{version}`
- Dir.glob("enterprise/#{version}/**/*.css") do |css_file|
- contents = File.read(css_file)
- contents.gsub!(/url\(\/shared/, "url(/enterprise/#{version}/shared")
- File.open(css_file, 'w') { |file| file.write(contents) }
- end
+ rewrite_content("enterprise/#{version}")
- %x(git add enterprise)
- %x(git commit -m "Added enterprise-#{version} files")
+ `git add enterprise`
+ `git commit -m "Added enterprise-#{version} files"`
ensure
FileUtils.remove_entry_secure temp_dir
end
-puts "\n\nOkay! Feel free to `git push #{BRANCH_NAME}` if you like."
+puts "\n\nOkay! Feel free to `git push #{BRANCH_NAME}` if you like."
\ No newline at end of file
diff --git a/static/css/documentation.css b/static/css/documentation.css
index 78e4819a61..b858fd6d86 100644
--- a/static/css/documentation.css
+++ b/static/css/documentation.css
@@ -21,6 +21,10 @@ h1 {
font-weight: normal;
}
+body:not(.enterprise) .enterprise-only {
+ display: none;
+}
+
.content h1 {
font-weight: 300;
-webkit-backface-visibility: hidden;
diff --git a/static/search-index.json b/static/search-index.json
index f5a779f727..bdf05d988d 100644
--- a/static/search-index.json
+++ b/static/search-index.json
@@ -58,27 +58,27 @@
{
"url": "/v3/enterprise/",
"title": "Enterprise",
- "section": "API/Enterprise"
+ "section": "API/Enterprise "
},
{
"url": "/v3/enterprise/admin_stats/",
"title": "Admin Stats",
- "section": "API/Enterprise"
+ "section": "API/Enterprise "
},
{
"url": "/v3/enterprise/license/",
"title": "License",
- "section": "API/Enterprise"
+ "section": "API/Enterprise "
},
{
"url": "/v3/enterprise/management_console/",
"title": "Management Console",
- "section": "API/Enterprise"
+ "section": "API/Enterprise "
},
{
"url": "/v3/enterprise/search_indexing/",
"title": "Search Indexing",
- "section": "API/Enterprise"
+ "section": "API/Enterprise "
},
{
"url": "/v3/gists/",
diff --git a/tasks/enterprise.rake b/tasks/enterprise.rake
new file mode 100644
index 0000000000..4f439df007
--- /dev/null
+++ b/tasks/enterprise.rake
@@ -0,0 +1,44 @@
+def setup
+ `git checkout gh-pages`
+ `git pull origin gh-pages`
+
+ `git checkout -b #{BRANCH_NAME}`
+end
+
+# we need to point links not to the root, but to the enterprise version root
+# for assets and links
+def rewrite(path)
+ Dir.glob("#{path}/**/*.html") do |html_file|
+ doc = Nokogiri::HTML(File.read(html_file))
+
+ # add '.enterprise' to `@class` in `body`
+ body = doc.search('body').first
+ classes = body.get_attribute('class').to_s.split(' ')
+ body.set_attribute('class', classes.push('enterprise').uniq.join(' '))
+
+ doc.css('a').each do |a|
+ a['href'] = "/enterprise/#{version}#{a['href']}" if a['href'] =~ /^\//
+ end
+
+ doc.css('link').each do |link|
+ link['href'] = "/enterprise/#{version}#{link['href']}" if link['href'] =~ /^\//
+ end
+
+ doc.css('script').each do |script|
+ script['src'] = "/enterprise/#{version}#{script['src']}" if script['src'] =~ /^\//
+ end
+
+ doc.css('img').each do |img|
+ img['src'] = "/enterprise/#{version}#{img['src']}" if img['src'] =~ /^\//
+ end
+
+ doc.search('//*[@class="not-enterprise"]').remove
+ File.open(html_file, 'w') { |file| file.write(doc.to_html) }
+ end
+
+ Dir.glob("#{path}/**/*.css") do |css_file|
+ contents = File.read(css_file)
+ contents.gsub!(/url\(\/shared/, "url(/enterprise/#{version}/shared")
+ File.open(css_file, 'w') { |file| file.write(contents) }
+ end
+end