boxlet 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 747a9a9bfd1d9d2e35526a2598de8068da0b6b50
4
- data.tar.gz: 216e7a7e1e347af798051937e49f5ce1346d900c
3
+ metadata.gz: 956d2071a94833442316b9e97b35eaaf40284976
4
+ data.tar.gz: a6997a8a7258f156543cddc80eff0b6527d740b3
5
5
  SHA512:
6
- metadata.gz: 662a886c81d25f08002955fee77fe75d505b5cb87481b21477f804c9774f0b8458a8ca9c5326a311a25c3033b0e75e61e0f7e2a25e104db03dd65804cebc01a2
7
- data.tar.gz: c2ba14e886be4d2661de8655bbf2869ea45586b808a5eeddcf095c5a9d8e6131ab0c39dbca2a077006bdeb75c91b7cae5c8698fd14d4ecc781b2b80d521c6412
6
+ metadata.gz: b2162347f5df7546e58b33372afe319fca9360d46551a8bcdc1e549f47961be04fc207c0b4404f899d04e316415f7749e81d1f0902db5d939989c276f646b55f
7
+ data.tar.gz: a550939df3ccbd8588f7a9a62af995f36aa3d6a9fc941b2066a7c9491d03a9665ac81e58a41c598f2137011eadc52b0e522df553603baeb806c93b5455b9aeb0
File without changes
data/README.md CHANGED
@@ -22,7 +22,7 @@ From the mobile iOS app, you can specify any server:port where the Boxlet server
22
22
 
23
23
  ## Usage
24
24
 
25
- Run `boxlet` from any folder to stat the server with default settings.
25
+ Run `boxlet run` from any folder to stat the server with default settings.
26
26
 
27
27
  See below for config and parameters.
28
28
 
@@ -104,8 +104,7 @@ Many config options are available as command-line parameters
104
104
 
105
105
  ## Contributing
106
106
 
107
- 1. Fork it
108
- 2. Create your feature branch (`git checkout -b my-new-feature`)
109
- 3. Commit your changes (`git commit -am 'Add some feature'`)
110
- 4. Push to the branch (`git push origin my-new-feature`)
111
- 5. Create new Pull Request
107
+ 1. Fork this repo
108
+ 2. Create an [issue/feature request](https://github.com/arktisklada/boxlet/issues)
109
+ 3. Create, commit, and push your feature branch (my-new-feature)
110
+ 4. Create new Pull Request
data/Rakefile CHANGED
File without changes
File without changes
data/config.yml CHANGED
File without changes
@@ -6,12 +6,9 @@ require 'boxlet/log'
6
6
  require 'boxlet/config'
7
7
  require 'boxlet/runner'
8
8
 
9
-
10
9
  APP_ROOT = Dir.pwd
11
10
 
12
-
13
11
  module Boxlet
14
-
15
12
  extend self
16
13
  extend Boxlet::Config
17
14
 
@@ -22,13 +19,24 @@ module Boxlet
22
19
  @log = Boxlet::Log.new(@config[:log_file], (debug? ? Logger::DEBUG : Logger::INFO))
23
20
  @app = Boxlet::App.new
24
21
 
22
+ command = command.to_s.to_sym
25
23
  case command
26
- when 'run'
27
- Boxlet.log(:debug, @config)
28
- @runner = Boxlet::Runner.new
29
- @runner.start(@app.bind, &blk)
30
- else
24
+ when :run
25
+ Boxlet.log(:debug, @config)
26
+ @runner = Boxlet::Runner.new
27
+ @runner.start(@app.bind, &blk)
28
+ when :stop
29
+ if @config[:daemonize] == true
30
+ pid = File.read(@config[:pid_file]).to_i
31
+ puts "Killing #{pid}..."
32
+ Process.kill(Signal.list["TERM"], pid)
33
+ end
34
+ else
35
+ if App::PUBLIC_COMMANDS.keys.include?(command)
31
36
  @app.send(command, argv)
37
+ else
38
+ print_menu
39
+ end
32
40
  end
33
41
 
34
42
  @app
@@ -39,22 +47,36 @@ module Boxlet
39
47
  @app
40
48
  end
41
49
 
42
-
43
50
  def debug?
44
51
  @config[:debug] == true
45
52
  end
53
+
46
54
  def config
47
55
  @config
48
56
  end
57
+
49
58
  def params
50
59
  @params
51
60
  end
61
+
52
62
  def log(level, message)
53
63
  @log.write(level, message)
54
64
  end
55
65
 
56
- end
66
+ private
57
67
 
68
+ def print_menu
69
+ puts "Usage: boxlet command [args]"
70
+ puts
71
+ puts "Available commands are as follows:"
72
+ commands_with_descriptions = App::PUBLIC_COMMANDS.merge run: "Run the Boxlet server"
73
+ commands = commands_with_descriptions.keys
74
+ max_chars = commands.sort { |a, b| a.length <=> b.length }.last.length
75
+ commands.sort.each do |command|
76
+ puts " #{command.to_s.ljust(max_chars)} #{commands_with_descriptions[command]}"
77
+ end
78
+ end
79
+ end
58
80
 
59
81
  # Configure our temporary folder
60
82
  class Dir
@@ -72,4 +94,4 @@ class Dir
72
94
  File.expand_path(tmp)
73
95
  end
74
96
  end
75
- end
97
+ end
@@ -10,9 +10,14 @@ require 'boxlet/app/models'
10
10
 
11
11
  module Boxlet
12
12
  class App
13
-
14
13
  include Sys
15
14
 
15
+ PUBLIC_COMMANDS = {
16
+ add_user: "Add a new user to the database",
17
+ change_password: "Change a user's password",
18
+ setup: "Initialize a directory as a Boxlet app (create folders, check space, etc.)."
19
+ }.freeze
20
+
16
21
  def self.routes
17
22
  routes = {
18
23
  # ["/", :get] => :index,
@@ -47,7 +52,6 @@ module Boxlet
47
52
  end.to_app
48
53
  end
49
54
 
50
-
51
55
  def setup(args)
52
56
  begin
53
57
  Boxlet.log(:debug, Boxlet.config)
@@ -88,7 +92,6 @@ module Boxlet
88
92
  end
89
93
  end
90
94
 
91
-
92
95
  def add_user(args)
93
96
  unless username = args['-u']
94
97
  raise 'You must specify a username with -u'
@@ -135,6 +138,5 @@ module Boxlet
135
138
  rescue Exception => e
136
139
  Boxlet.log(:fatal, "ERROR: #{e}")
137
140
  end
138
-
139
141
  end
140
- end
142
+ end
@@ -36,9 +36,7 @@ module Boxlet
36
36
  {format: @format, content: action_response}
37
37
  end
38
38
 
39
-
40
39
  # actions
41
-
42
40
  def index
43
41
  '<html><body><form action="/push_files" method="post" enctype="multipart/form-data">UUID:<input type="text" name="uuid"><br><input type="file" name="file"><input type="submit"></form>'
44
42
  end
@@ -103,6 +101,7 @@ module Boxlet
103
101
  filename: new_filename,
104
102
  size: file.size,
105
103
  local_date: file.mtime.to_i,
104
+ orientation: @params[:orientation],
106
105
  thumbnail: new_thumb_filename,
107
106
  asset_path: @params[:asset_path],
108
107
  asset_date: @params[:asset_date],
@@ -225,4 +224,4 @@ module Boxlet
225
224
  end
226
225
  end
227
226
  end
228
- end
227
+ end
@@ -21,6 +21,5 @@ module Boxlet
21
21
  last_activity: Time.now
22
22
  }
23
23
  end
24
-
25
24
  end
26
- end
25
+ end
@@ -6,7 +6,6 @@ require 'json'
6
6
 
7
7
  module Boxlet
8
8
  class Router
9
-
10
9
  attr_accessor :method, :action
11
10
 
12
11
  def initialize(method, action)
@@ -38,6 +37,5 @@ module Boxlet
38
37
 
39
38
  response.finish
40
39
  end
41
-
42
40
  end
43
- end
41
+ end
@@ -64,7 +64,6 @@ module Boxlet
64
64
  }
65
65
  }
66
66
 
67
-
68
67
  def populate_params!(argv, path_to_config)
69
68
  @raw_config = load_config_file(path_to_config)
70
69
  @raw_params = parse_arguments(argv)
@@ -73,7 +72,6 @@ module Boxlet
73
72
  @config[:debug] = @raw_config[:debug] || @raw_params[:debug]
74
73
  end
75
74
 
76
-
77
75
  def symbolize_keys(hash)
78
76
  hash.inject({}){|result, (key, value)|
79
77
  new_key = key.instance_of?(String) ? key.to_sym : key
@@ -84,7 +82,6 @@ module Boxlet
84
82
  }
85
83
  end
86
84
 
87
-
88
85
  private
89
86
 
90
87
  def parse_arguments(argv)
@@ -121,4 +118,4 @@ module Boxlet
121
118
  end
122
119
  end
123
120
  end
124
- end
121
+ end
@@ -3,7 +3,6 @@ require 'mongo'
3
3
 
4
4
  module Boxlet
5
5
  module Db
6
-
7
6
  extend self
8
7
  include Mongo
9
8
 
@@ -24,6 +23,5 @@ module Boxlet
24
23
  db = client.db(db_config[:db] || 'boxlet_development')
25
24
  return db
26
25
  end
27
-
28
26
  end
29
- end
27
+ end
File without changes
@@ -32,6 +32,5 @@ module Boxlet
32
32
  def thin(app, params)
33
33
  Boxlet::Handlers::Thin.new(app, params)
34
34
  end
35
-
36
35
  end
37
- end
36
+ end
@@ -5,13 +5,11 @@ module Boxlet
5
5
  include Sys
6
6
 
7
7
  # Auth methods
8
-
9
8
  def self.encrypt(string)
10
9
  (Digest::SHA256.new << string).to_s
11
10
  end
12
11
 
13
12
  # App disk space functions
14
-
15
13
  def self.free_space
16
14
  return -1 if Boxlet.config[:s3][:enabled]
17
15
  Boxlet::Util.app_space_capacity - Boxlet::Util.app_space_usage
@@ -41,7 +39,6 @@ module Boxlet
41
39
  end
42
40
 
43
41
  # Drive disk space functions
44
-
45
42
  def self.drive_free_space
46
43
  stat = Filesystem.stat(Boxlet.config[:file_system_root])
47
44
  (stat.block_size * stat.blocks_available).to_mb
@@ -51,6 +48,5 @@ module Boxlet
51
48
  stat = Filesystem.stat(Boxlet.config[:file_system_root])
52
49
  (stat.block_size * stat.blocks).to_mb
53
50
  end
54
-
55
51
  end
56
- end
52
+ end
@@ -1,3 +1,3 @@
1
1
  module Boxlet
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
@@ -36,4 +36,4 @@ module Boxlet
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -7,10 +7,10 @@ module Rack
7
7
 
8
8
  private
9
9
 
10
- def generate_map(default_app, mapping)
11
- mapped = default_app ? {'/' => default_app} : {}
12
- mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b) }
13
- BoxletUrlMap.new(mapped)
14
- end
10
+ def generate_map(default_app, mapping)
11
+ mapped = default_app ? {'/' => default_app} : {}
12
+ mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b) }
13
+ BoxletUrlMap.new(mapped)
14
+ end
15
15
  end
16
- end
16
+ end
@@ -56,11 +56,9 @@ module Rack
56
56
  end
57
57
 
58
58
  [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path}"]]
59
-
60
59
  ensure
61
60
  env['PATH_INFO'] = path
62
61
  env['SCRIPT_NAME'] = script_name
63
62
  end
64
-
65
63
  end
66
64
  end
@@ -25,97 +25,97 @@ module Rack
25
25
  end
26
26
  end
27
27
 
28
-
29
28
  private
30
29
 
31
- def convert_and_pass_on(env)
32
- if env['rack.input'].kind_of?(Tempfile)
33
- env['rack.input'].extend(EqlFix)
34
- tempfile = env['rack.input']
35
- else
36
- tempfile = Tempfile.new('raw-upload.', @tmpdir)
37
-
38
- env['rack.input'].each do |chunk|
39
- if chunk.respond_to?(:force_encoding)
40
- tempfile << chunk.force_encoding('UTF-8')
41
- else
42
- tempfile << chunk
30
+ def convert_and_pass_on(env)
31
+ if env['rack.input'].kind_of?(Tempfile)
32
+ env['rack.input'].extend(EqlFix)
33
+ tempfile = env['rack.input']
34
+ else
35
+ tempfile = Tempfile.new('raw-upload.', @tmpdir)
36
+
37
+ env['rack.input'].each do |chunk|
38
+ if chunk.respond_to?(:force_encoding)
39
+ tempfile << chunk.force_encoding('UTF-8')
40
+ else
41
+ tempfile << chunk
42
+ end
43
43
  end
44
+ env['rack.input'].rewind
45
+
46
+ tempfile.flush
47
+ tempfile.rewind
44
48
  end
45
- env['rack.input'].rewind
46
49
 
47
- tempfile.flush
48
- tempfile.rewind
49
- end
50
- fake_file = {
51
- :filename => env['HTTP_X_FILE_NAME'],
52
- :type => env['CONTENT_TYPE'],
53
- :tempfile => tempfile,
54
- }
55
- env['rack.request.form_input'] = env['rack.input']
56
- env['rack.request.form_hash'] ||= {}
57
- env['rack.request.query_hash'] ||= {}
58
- env['rack.request.form_hash']['file'] = fake_file
59
- env['rack.request.query_hash']['file'] = fake_file
60
- if env['HTTP_X_QUERY_PARAMS']
61
- env['rack.errors'].puts("Warning! The header X-Query-Params is deprecated. Please use X-JSON-Params instead.")
62
- inject_json_params!(env, env['HTTP_X_QUERY_PARAMS'])
63
- end
64
- if env['HTTP_X_JSON_PARAMS']
65
- inject_json_params!(env, env['HTTP_X_JSON_PARAMS'])
66
- end
67
- if env['HTTP_X_PARAMS']
68
- inject_query_params!(env, env['HTTP_X_PARAMS'])
50
+ fake_file = {
51
+ :filename => env['HTTP_X_FILE_NAME'],
52
+ :type => env['CONTENT_TYPE'],
53
+ :tempfile => tempfile,
54
+ }
55
+ env['rack.request.form_input'] = env['rack.input']
56
+ env['rack.request.form_hash'] ||= {}
57
+ env['rack.request.query_hash'] ||= {}
58
+ env['rack.request.form_hash']['file'] = fake_file
59
+ env['rack.request.query_hash']['file'] = fake_file
60
+ if env['HTTP_X_QUERY_PARAMS']
61
+ env['rack.errors'].puts("Warning! The header X-Query-Params is deprecated. Please use X-JSON-Params instead.")
62
+ inject_json_params!(env, env['HTTP_X_QUERY_PARAMS'])
63
+ end
64
+ if env['HTTP_X_JSON_PARAMS']
65
+ inject_json_params!(env, env['HTTP_X_JSON_PARAMS'])
66
+ end
67
+ if env['HTTP_X_PARAMS']
68
+ inject_query_params!(env, env['HTTP_X_PARAMS'])
69
+ end
70
+ @app.call(env)
69
71
  end
70
- @app.call(env)
71
- end
72
72
 
73
- def kick_in?(env)
74
- env['HTTP_X_FILE_UPLOAD'] == 'true' ||
75
- ! @explicit && env['HTTP_X_FILE_UPLOAD'] != 'false' && raw_file_upload?(env) ||
76
- env.has_key?('HTTP_X_FILE_UPLOAD') && env['HTTP_X_FILE_UPLOAD'] != 'false' && raw_file_upload?(env)
77
- end
73
+ def kick_in?(env)
74
+ env['HTTP_X_FILE_UPLOAD'] == 'true' ||
75
+ ! @explicit && env['HTTP_X_FILE_UPLOAD'] != 'false' && raw_file_upload?(env) ||
76
+ env.has_key?('HTTP_X_FILE_UPLOAD') && env['HTTP_X_FILE_UPLOAD'] != 'false' && raw_file_upload?(env)
77
+ end
78
78
 
79
- def raw_file_upload?(env)
80
- upload_path?(env['PATH_INFO']) &&
81
- %{POST PUT}.include?(env['REQUEST_METHOD']) &&
82
- content_type_of_raw_file?(env['CONTENT_TYPE']) &&
83
- env['CONTENT_LENGTH'].to_i > 0
84
- end
79
+ def raw_file_upload?(env)
80
+ upload_path?(env['PATH_INFO']) &&
81
+ %{POST PUT}.include?(env['REQUEST_METHOD']) &&
82
+ content_type_of_raw_file?(env['CONTENT_TYPE']) &&
83
+ env['CONTENT_LENGTH'].to_i > 0
84
+ end
85
85
 
86
- def literal_path_match?(request_path, candidate)
87
- candidate == request_path
88
- end
86
+ def literal_path_match?(request_path, candidate)
87
+ candidate == request_path
88
+ end
89
89
 
90
- def wildcard_path_match?(request_path, candidate)
91
- return false unless candidate.include?('*')
92
- regexp = '^' + candidate.gsub('.', '\.').gsub('*', '[^/]*') + '$'
93
- !! (Regexp.new(regexp) =~ request_path)
94
- end
90
+ def wildcard_path_match?(request_path, candidate)
91
+ return false unless candidate.include?('*')
92
+ regexp = '^' + candidate.gsub('.', '\.').gsub('*', '[^/]*') + '$'
93
+ !! (Regexp.new(regexp) =~ request_path)
94
+ end
95
95
 
96
- def content_type_of_raw_file?(content_type)
97
- case content_type
98
- when %r{^application/x-www-form-urlencoded}, %r{^multipart/form-data}
99
- false
100
- else
101
- true
96
+ def content_type_of_raw_file?(content_type)
97
+ case content_type
98
+ when %r{^application/x-www-form-urlencoded}, %r{^multipart/form-data}
99
+ false
100
+ else
101
+ true
102
+ end
102
103
  end
103
- end
104
104
 
105
- def random_string
106
- (0...8).map{65.+(rand(25)).chr}.join
107
- end
105
+ def random_string
106
+ (0...8).map{65.+(rand(25)).chr}.join
107
+ end
108
108
 
109
- def inject_json_params!(env, params)
110
- json = MultiJson.load(params)
111
- env['rack.request.form_hash'].merge!(json)
112
- env['rack.request.query_hash'].merge!(json)
113
- end
109
+ def inject_json_params!(env, params)
110
+ json = MultiJson.load(params)
111
+ env['rack.request.form_hash'].merge!(json)
112
+ env['rack.request.query_hash'].merge!(json)
113
+ end
114
114
 
115
- def inject_query_params!(env, params)
116
- json = Rack::Utils.parse_query(params)
117
- env['rack.request.form_hash'].merge!(json)
118
- env['rack.request.query_hash'].merge!(json)
115
+ def inject_query_params!(env, params)
116
+ json = Rack::Utils.parse_query(params)
117
+ env['rack.request.form_hash'].merge!(json)
118
+ env['rack.request.query_hash'].merge!(json)
119
+ end
119
120
  end
120
- end
121
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - arktisklada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-18 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -237,8 +237,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  version: '0'
238
238
  requirements: []
239
239
  rubyforge_project:
240
- rubygems_version: 2.2.2
240
+ rubygems_version: 2.5.0
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: Upload pics from your phone
244
244
  test_files: []
245
+ has_rdoc: