server.rb 1005 Bytes
Newer Older
1
2
3
4
5
6
7
#!/usr/bin/env ruby

require 'rubygems'
require 'bundler/setup'

require 'sinatra'
require 'haml'
Michael Witrant's avatar
Michael Witrant committed
8
require './extract_amendments'
9
10

get '/' do
Michael Witrant's avatar
Michael Witrant committed
11
  haml :index, locals: {template: File.read("template.erb")}
12
13
14
end

post '/extract' do
Michael Witrant's avatar
Michael Witrant committed
15
16
  result = AmendmentExtractor.new.extract(params['file'][:tempfile].path)
  haml :extract, locals: {result: result}
17
18
end

Michael Witrant's avatar
Michael Witrant committed
19
20
21
22
get '/bootstrap.min.css' do
  send_file 'bootstrap.min.css'
end

23
24
25
26
__END__

@@ layout
%html
Michael Witrant's avatar
Michael Witrant committed
27
28
29
  %head
    %link{:href => "/bootstrap.min.css", :rel => "stylesheet"}/

30
  %body
Michael Witrant's avatar
Michael Witrant committed
31
32
33
    .container
      %h1 Amendment Extractor
      = yield
34
35
    
@@ index
Michael Witrant's avatar
Michael Witrant committed
36
37
38
39
40
41
42
43
44
.well
  %form.form-horizontal{action: "/extract", method: "POST", enctype: 'multipart/form-data'}
    .control-group
      %label.control-label{:for => "file"} ODT File
      .controls
        %input#file{type: "file", name: "file"}
    .control-group
      .controls
        %button.btn.btn-primary{:type => "submit"} Extract
45
46

@@ extract
Michael Witrant's avatar
Michael Witrant committed
47
%textarea{rows: 20, style: 'width: 100%'}= Rack::Utils.escape_html(result)