forked from aam1r/sachet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsachet.rb
37 lines (29 loc) · 914 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
36
37
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['part2']] = 'on'
params.delete('part2')
# generate vim.rc
vim = VimDownloadable.new(options)
vim.process_params(params)
print params.inspect
# serve zip file
send_file vim.serve_package, :type => 'application/zip',
:disposition => 'attachment',
:filename => 'sachet.zip'
vim.cleanup
end