-
Notifications
You must be signed in to change notification settings - Fork 12
/
sachet.rb
35 lines (28 loc) · 890 Bytes
/
sachet.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'rubygems'
require 'sinatra'
require 'yaml'
require 'tempfile'
require 'zipruby'
require './lib/vim_downloadable'
CONFIGURATION = YAML.load_file('data/configuration.yaml')
THEMES = YAML.load_file('data/themes.yaml')
PLUGINS = YAML.load_file('data/plugins.yaml')
get '/' do
erb :index, :locals => {:configuration => CONFIGURATION,
:themes => THEMES,
:plugins => PLUGINS}
end
post '/download' do
options = CONFIGURATION + THEMES + PLUGINS
# mark selected theme
params[params['step2']] = 'on'
params.delete('step2')
# generate vim.rc
vim = VimDownloadable.new(options)
vim.process_params(params)
# serve zip file
send_file vim.serve_package, :type => 'application/zip',
:disposition => 'attachment',
:filename => 'sachet.zip'
vim.cleanup
end