diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index bf9cb8ec..00000000 --- a/Gemfile.lock +++ /dev/null @@ -1,37 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - coderay (1.1.1) - method_source (0.8.2) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - puma (3.6.0) - rack (1.6.4) - rack-protection (1.5.3) - rack - rack-rewrite (1.5.1) - rake (11.2.2) - sinatra (1.4.7) - rack (~> 1.5) - rack-protection (~> 1.4) - tilt (>= 1.3, < 3) - sinatra-param (1.4.0) - sinatra (~> 1.3) - slop (3.6.0) - tilt (2.0.5) - -PLATFORMS - ruby - -DEPENDENCIES - pry - puma - rack-rewrite - rake - sinatra - sinatra-param - -BUNDLED WITH - 1.12.5 diff --git a/app.rb b/app.rb index a5b7a065..b14a431c 100644 --- a/app.rb +++ b/app.rb @@ -1,15 +1,15 @@ # encoding: utf-8 require 'json' +require 'bundler' Bundler.require( :default, ENV[ 'RACK_ENV' ].to_sym ) +require_relative './config/options' require_relative './lib/ledger' # Sinatra app serving API class LedgerRbApp < Sinatra::Base - helpers Sinatra::Param - before do content_type :json, 'charset' => 'utf-8' end @@ -19,13 +19,16 @@ class LedgerRbApp < Sinatra::Base send_file './public/app/index.html' end + get '/budget' do + content_type :html + erb :budget + end + get '/api/ledger/accounts/?' do Ledger.accounts.to_json end get '/api/ledger/accounts/depth/:depth/?' do - param :depth, Integer, required: true - Ledger.accounts( params[ :depth ] ).to_json end @@ -34,20 +37,12 @@ class LedgerRbApp < Sinatra::Base end get '/api/ledger/register/?' do - param :period, String, default: nil - param :categories, String, required: true - { key: params[ :categories ], values: Ledger.register( params[ :period ], params[ :categories ] ) } .to_json end get '/api/ledger/balance/?' do - param :depth, Integer, default: false - param :period, String, default: nil - param :cleared, Boolean, default: false - param :categories, String, default: '' - Ledger.balance( params[ :cleared ], params[ :depth ], params[ :period ], @@ -60,17 +55,11 @@ class LedgerRbApp < Sinatra::Base end get '/api/ledger/budget/?' do - param :period, String, default: 'this month' - param :categories, String, required: true - Ledger.budget( params[ :period ], params[ :categories ] ).to_json end - - get '/api/ledger/graph_values/?' do - param :period, String, default: nil - param :categories, String, default: 'Expenses' + get '/api/ledger/graph_values/?' do Ledger.graph_values( params[:period], params[:categories].split(' ') ).to_json end diff --git a/config.ru b/config.ru index 604d9e61..e738e1a5 100644 --- a/config.ru +++ b/config.ru @@ -1,12 +1,7 @@ # encoding: utf-8 -require 'bundler' - -require_relative './config/options' require_relative './app' -use Rack::Rewrite do - rewrite %r{^/(.*(css|js|ttf|woff|html|png|jpg|jpeg|gif|ico)$)}, '/app/$1' +map "/" do + run LedgerRbApp end - -run LedgerRbApp diff --git a/gems.locked b/gems.locked new file mode 100644 index 00000000..5d6ad81f --- /dev/null +++ b/gems.locked @@ -0,0 +1,32 @@ +GEM + remote: https://rubygems.org/ + specs: + coderay (1.1.2) + method_source (0.9.0) + mustermann (1.0.1) + pry (0.11.1) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + puma (3.10.0) + rack (2.0.3) + rack-protection (2.0.0) + rack + rake (12.1.0) + sinatra (2.0.0) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.0) + tilt (~> 2.0) + tilt (2.0.8) + +PLATFORMS + ruby + +DEPENDENCIES + pry + puma + rake + sinatra + +BUNDLED WITH + 1.14.3 diff --git a/Gemfile b/gems.rb similarity index 71% rename from Gemfile rename to gems.rb index 2a5e60a0..3887f1eb 100644 --- a/Gemfile +++ b/gems.rb @@ -2,9 +2,7 @@ source 'https://rubygems.org' -gem 'rack-rewrite' gem 'sinatra' -gem 'sinatra-param' gem 'puma' gem 'rake' gem 'pry' diff --git a/public/app/index.html b/public/app/index.html index f3174f30..75382084 100644 --- a/public/app/index.html +++ b/public/app/index.html @@ -12,9 +12,9 @@ - - - + + + @@ -23,27 +23,27 @@
- - - - - + + + + + - - - - - - - - - + + + + + + + + + - - - - + + + +