mirror of
				https://github.com/stedolan/jq.git
				synced 2024-05-11 05:55:39 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			77 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
require 'bonsai'
 | 
						|
require 'json'
 | 
						|
require 'liquid'
 | 
						|
require 'maruku'
 | 
						|
 | 
						|
module ExtraFilters
 | 
						|
  def markdownify(input)
 | 
						|
    Maruku.new(input).to_html
 | 
						|
  end
 | 
						|
  def search_id(input)
 | 
						|
    input.gsub(/`/, '')
 | 
						|
  end
 | 
						|
  def section_id(input)
 | 
						|
    input.gsub(/[^a-zA-Z0-9_]/, '')
 | 
						|
  end
 | 
						|
  def entry_id(input)
 | 
						|
    input.gsub(/[ `]/, '')
 | 
						|
  end
 | 
						|
  def no_paragraph(input)
 | 
						|
    input.gsub('<p>', '').gsub('</p>', '')
 | 
						|
  end
 | 
						|
  def json(input)
 | 
						|
    input.to_json
 | 
						|
  end
 | 
						|
  def unique(input)
 | 
						|
    @n = (@n || 0) + 1
 | 
						|
    input + @n.to_s
 | 
						|
  end
 | 
						|
end
 | 
						|
 | 
						|
Liquid::Template.register_filter(ExtraFilters)
 | 
						|
 | 
						|
begin
 | 
						|
  `java 2>&1`
 | 
						|
rescue
 | 
						|
  class Bonsai::Exporter
 | 
						|
    def self.compress_assets
 | 
						|
      Bonsai.log "java not found! Not compressing javascript or stylesheets"
 | 
						|
    end
 | 
						|
  end
 | 
						|
end
 | 
						|
 | 
						|
task :build do
 | 
						|
  Bonsai.root_dir = Dir.pwd
 | 
						|
  Bonsai::Exporter.publish!
 | 
						|
end
 | 
						|
 | 
						|
task :serve do
 | 
						|
  begin
 | 
						|
    Bonsai.log "Press Control+C to quit"
 | 
						|
 | 
						|
    require 'rack'
 | 
						|
    require 'sinatra'
 | 
						|
    require 'watch'
 | 
						|
    require 'launchy'
 | 
						|
 | 
						|
    Bonsai.root_dir = Dir.pwd
 | 
						|
 | 
						|
    server = fork {
 | 
						|
      app = Rack::Builder.app {
 | 
						|
        map "/jq" do
 | 
						|
          use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
 | 
						|
        end
 | 
						|
        run Bonsai::DevelopmentServer
 | 
						|
      }
 | 
						|
      Rack::Handler.default.run(app, :Port => 5000) do
 | 
						|
        Launchy.open("http://localhost:5000/jq/")
 | 
						|
      end
 | 
						|
    }
 | 
						|
    Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
 | 
						|
  rescue Interrupt
 | 
						|
    Process.kill("QUIT", server)
 | 
						|
    Process.wait(server)
 | 
						|
    exit
 | 
						|
  end
 | 
						|
end
 |