Skip to content

Commit

Permalink
First attempt to fix marklogic-community#365
Browse files Browse the repository at this point in the history
  • Loading branch information
grtjn committed Feb 20, 2015
1 parent 3048508 commit db4faf8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
51 changes: 51 additions & 0 deletions deploy/lib/server_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
require 'date'
require 'ml_rest'

optional_require 'open-uri'
optional_require 'nokogiri'

class ExitException < Exception; end

class HelpException < Exception
Expand Down Expand Up @@ -383,6 +386,54 @@ def self.build_element_index
end
end

def self.howto
begin
search = ARGV.first
doc = Nokogiri::HTML(open('http://github.com/marklogic/roxy/wiki/_pages'))

pages = doc.css('.content').select do |page|
search == nil or page.text.downcase().include? search
end

selected = 1

if pages.length > 1
count = 0
pages.each do |page|
count = count + 1
puts "#{count} - #{page.text}\n\thttps://github.com/#{page.xpath('a/@href').text}"
end

print "Select a page: "
selected = STDIN.gets.chomp().to_i
if selected == 0
exit
end

if selected > pages.length
selected = pages.length
end
end

count = 0
pages.each do |page|
count = count + 1
if count == selected

puts "\n#{page.text}\n\thttps://github.com/#{page.xpath('a/@href').text}"

uri = "https://github.com/#{page.xpath('a/@href').text}"
doc = Nokogiri::HTML(open(uri))

puts doc.css('.markdown-body').text.gsub(/\n\n\n+/, "\n\n")

end
end
rescue NameError => e
puts "Missing library: #{e}"
end
end

def execute_query(query, properties = {})
r = nil
if @server_version == 4
Expand Down
7 changes: 7 additions & 0 deletions deploy/lib/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ def present?
def to_b
present? && ['true', 'TRUE', 'yes', 'YES', 'y', 'Y', 't', 'T'].include?(self)
end

def optional_require(feature)
begin
require feature
rescue LoadError
end
end
end

def parse_json(body)
Expand Down

0 comments on commit db4faf8

Please sign in to comment.