rubko 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/rubko-deploy +48 -38
- data/lib/rubko.rb +1 -1
- data/lib/rubko/app.rb +53 -22
- data/lib/rubko/asset.rb +5 -5
- data/lib/rubko/base.rb +1 -1
- data/lib/rubko/plugins/db.rb +8 -8
- data/lib/rubko/plugins/facebook.rb +1 -1
- data/lib/rubko/plugins/session.rb +1 -1
- data/lib/rubko/plugins/url.rb +9 -9
- data/stamp/config/deploy.rb +7 -0
- data/stamp/public/js/jquery/translate.js +20 -16
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dda5882684cd22f6df19f6aae673980ab60b223
|
4
|
+
data.tar.gz: 2e480c180915d74789de1f3085787224726a8eb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c6fcdc3e99d8bb505c778c9e7ae0c4b832506231fb4467b33a55ba5ca84e1b048b7505c392d86719c0bb06fa4b257a95b6e1904cf2e9a989c8e09876bd4a6ac
|
7
|
+
data.tar.gz: 22dd3ac23cca2ec497f613c1c4589bba902f4d7237f6eda55a3811f9ffdc69e9e3f933f4959eadda4a961cb9ecb0ac20ac5cf7301cf5513b853a971c969686d9
|
data/bin/rubko-deploy
CHANGED
@@ -1,40 +1,50 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
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
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
3
|
+
require 'rubko'
|
4
|
+
|
5
|
+
class Rubko::Deploy
|
6
|
+
def initialize
|
7
|
+
@protocol = :sftp # :ftp
|
8
|
+
@remote = "/srv/http/#{File.basename Dir.getwd}"
|
9
|
+
|
10
|
+
@exclude = [
|
11
|
+
'.dev/',
|
12
|
+
'.run/',
|
13
|
+
'.repo/',
|
14
|
+
'.gitignore',
|
15
|
+
'.git/'
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_reader :protocol, :remote, :user, :host, :exclude
|
20
|
+
|
21
|
+
def password
|
22
|
+
return @password if @password
|
23
|
+
|
24
|
+
require 'io/console'
|
25
|
+
print 'Password: ';
|
26
|
+
STDIN.noecho(&:gets).strip.tap {
|
27
|
+
puts
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def deploy!
|
32
|
+
config
|
33
|
+
|
34
|
+
commands = [
|
35
|
+
'set ftp:list-options -a',
|
36
|
+
"open #{protocol}://#{user}:#{password}@#{host}",
|
37
|
+
'lcd ./',
|
38
|
+
"cd #{remote}",
|
39
|
+
'mirror -L --reverse --only-newer --verbose ' + exclude.map { |el|
|
40
|
+
'--exclude-glob ' + el
|
41
|
+
} * ' '
|
42
|
+
]
|
43
|
+
|
44
|
+
system 'lftp', '-c', commands * ';'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
require './config/deploy.rb'
|
49
|
+
|
50
|
+
Rubko::Deploy.new.deploy!
|
data/lib/rubko.rb
CHANGED
data/lib/rubko/app.rb
CHANGED
@@ -14,7 +14,7 @@ class Rubko::App
|
|
14
14
|
@finalizers = []
|
15
15
|
|
16
16
|
@env = env
|
17
|
-
params = Rack::Utils.parse_nested_query
|
17
|
+
params = Rack::Utils.parse_nested_query env['rack.input'].read
|
18
18
|
@params = Hash[ params.map { |k, v|
|
19
19
|
[ k.to_sym, v ]
|
20
20
|
} ]
|
@@ -31,49 +31,80 @@ class Rubko::App
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def request(name = :welcome, action = nil, *path)
|
34
|
-
controller = loadController(name) || loadController(:error404)
|
34
|
+
@controller = loadController(name) || loadController(:error404)
|
35
35
|
|
36
36
|
calls = [ action ? "_#{action}" : 'index' ]
|
37
37
|
calls << calls.first + '_' + url.method
|
38
38
|
|
39
39
|
calls.map! { |call|
|
40
|
-
if controller.respond_to? call
|
41
|
-
@body = controller.__send__ call, *path
|
40
|
+
if @controller.respond_to? call
|
41
|
+
@body = @controller.__send__ call, *path
|
42
42
|
true
|
43
43
|
end
|
44
44
|
}
|
45
45
|
if calls.compact.empty?
|
46
|
-
@body = controller.other action, *path
|
46
|
+
@body = @controller.other action, *path
|
47
47
|
end
|
48
48
|
|
49
49
|
# finalize request
|
50
50
|
finalizers.reverse_each(&:finalize)
|
51
|
-
|
51
|
+
prepareBody!
|
52
|
+
prepareHeaders!
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
[status, headers, body]
|
55
|
+
end
|
56
|
+
|
57
|
+
def production?
|
58
|
+
ENV['RACK_ENV'] == 'production'
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def prepareBody!
|
64
|
+
# if object is a Hash, return JSON
|
65
|
+
if Hash === body
|
66
|
+
@mime = 'application/json'
|
67
|
+
@body = if production?
|
68
|
+
body.to_json
|
69
|
+
else
|
70
|
+
JSON.pretty_generate body, indent: "\t"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# make sure body responds to #each
|
75
|
+
@body = body.to_s if Integer === body
|
76
|
+
@body = [body] if String === body
|
77
|
+
@body = [] unless body.respond_to? :each
|
78
|
+
end
|
79
|
+
|
80
|
+
def prepareHeaders!
|
81
|
+
# apply mime type header
|
82
|
+
unless status == 304
|
83
|
+
headers['Content-Type'] = "#{mime}; charset=utf-8"
|
84
|
+
end
|
57
85
|
|
58
86
|
# compress
|
59
|
-
if controller.compressible?
|
87
|
+
if @controller.compressible?
|
60
88
|
headers['Content-Encoding'] = 'gzip'
|
61
|
-
@body = Rubko::Asset::GzipStream.new
|
89
|
+
@body = Rubko::Asset::GzipStream.new body
|
62
90
|
end
|
63
91
|
|
64
92
|
# add Content-Length header
|
65
|
-
if
|
66
|
-
|
67
|
-
elsif Array ===
|
68
|
-
|
93
|
+
headers['Content-Length'] = if body.respond_to? :bytesize
|
94
|
+
body.bytesize
|
95
|
+
elsif Array === body
|
96
|
+
body.reduce(0) { |sum, x|
|
69
97
|
sum + x.bytesize
|
70
|
-
}
|
98
|
+
}
|
71
99
|
end
|
72
100
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
101
|
+
# rack requires strings as values
|
102
|
+
headers.each { |k, v|
|
103
|
+
if v.nil?
|
104
|
+
headers.delete k
|
105
|
+
elsif not String === v
|
106
|
+
headers[k] = v.to_s
|
107
|
+
end
|
108
|
+
}
|
78
109
|
end
|
79
110
|
end
|
data/lib/rubko/asset.rb
CHANGED
@@ -24,9 +24,9 @@ class Rubko::Asset < Rubko::Controller
|
|
24
24
|
private :hit, :cache, :miss
|
25
25
|
|
26
26
|
def compressible?
|
27
|
-
super &&
|
27
|
+
super && mime != 'application/octet-stream' &&
|
28
28
|
['application', 'text'].any? { |type|
|
29
|
-
|
29
|
+
mime.start_with? type+'/'
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
@@ -43,10 +43,10 @@ class Rubko::Asset < Rubko::Controller
|
|
43
43
|
end
|
44
44
|
|
45
45
|
path.shift if path[0] =~ /^\d*$/
|
46
|
-
path = "#{
|
46
|
+
path = "#{dir}/#{path * '/'}"
|
47
47
|
@mime = Rack::Mime.mime_type File.extname(path)
|
48
48
|
if File.file? path
|
49
|
-
self.mime =
|
49
|
+
self.mime = mime
|
50
50
|
headers['Cache-Control'] = 'public'
|
51
51
|
headers['Vary'] = 'Accept-Encoding'
|
52
52
|
|
@@ -55,7 +55,7 @@ class Rubko::Asset < Rubko::Controller
|
|
55
55
|
headers['Last-Modified'] = @modified.httpdate
|
56
56
|
headers['Expires'] = (DateTime.now >> 12).httpdate
|
57
57
|
|
58
|
-
if
|
58
|
+
if modified.to_i <= since
|
59
59
|
cache( *path )
|
60
60
|
self.status = 304
|
61
61
|
''
|
data/lib/rubko/base.rb
CHANGED
data/lib/rubko/plugins/db.rb
CHANGED
@@ -14,9 +14,9 @@ class DbPlugin < Rubko::Plugin
|
|
14
14
|
def handle
|
15
15
|
unless @handle
|
16
16
|
config if @handle.nil?
|
17
|
-
if
|
18
|
-
@sig = [
|
19
|
-
@handle = (
|
17
|
+
if pool
|
18
|
+
@sig = [host, port, user, password, db]
|
19
|
+
@handle = ( pool[:db, *@sig] ||= [] ).pop
|
20
20
|
end
|
21
21
|
@handle = connect unless @handle
|
22
22
|
end
|
@@ -27,20 +27,20 @@ class DbPlugin < Rubko::Plugin
|
|
27
27
|
attr_reader :affectedRows
|
28
28
|
|
29
29
|
def connect
|
30
|
-
PG.connect host:
|
30
|
+
PG.connect host: host, port: port, user: user, password: password, dbname: db
|
31
31
|
end
|
32
32
|
|
33
33
|
def release
|
34
34
|
return true unless @handle
|
35
|
-
if
|
36
|
-
|
35
|
+
if pool && handle.transaction_status == 0
|
36
|
+
pool[:db, *@sig].push @handle
|
37
37
|
@handle = false
|
38
38
|
return true
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def poolSize
|
43
|
-
|
43
|
+
pool.keys(:db, *@sig).size
|
44
44
|
end
|
45
45
|
|
46
46
|
# PostgreSQL array OIDs and coresponding data type
|
@@ -330,7 +330,7 @@ class DbPlugin < Rubko::Plugin
|
|
330
330
|
yield
|
331
331
|
raw 'COMMIT' if inTransaction
|
332
332
|
rescue => e
|
333
|
-
|
333
|
+
p e
|
334
334
|
puts e.backtrace
|
335
335
|
rollback
|
336
336
|
puts 'Transaction rolled back.'
|
@@ -31,7 +31,7 @@ class FacebookPlugin < Rubko::Plugin
|
|
31
31
|
})
|
32
32
|
@token = parse( httpGet url )['access_token']
|
33
33
|
|
34
|
-
jsonParse httpGet build 'https://graph.facebook.com/me', access_token:
|
34
|
+
jsonParse httpGet build 'https://graph.facebook.com/me', access_token: token
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
data/lib/rubko/plugins/url.rb
CHANGED
@@ -10,8 +10,8 @@ class UrlPlugin < Rubko::Plugin
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def path=(path)
|
13
|
-
len = path.start_with?(
|
14
|
-
@path = URI.unescape(path)[len..-1].chomp(
|
13
|
+
len = path.start_with?(base) ? base.length : 1
|
14
|
+
@path = URI.unescape(path)[len..-1].chomp(ending).split '/', -1
|
15
15
|
@newPath = nil
|
16
16
|
|
17
17
|
@protocol = env['rack.url_scheme'] + '://'
|
@@ -22,7 +22,7 @@ class UrlPlugin < Rubko::Plugin
|
|
22
22
|
|
23
23
|
def newPath
|
24
24
|
unless @newPath
|
25
|
-
@newPath =
|
25
|
+
@newPath = path * '/'
|
26
26
|
config
|
27
27
|
@newPath = @newPath.split '/', -1
|
28
28
|
end
|
@@ -47,14 +47,14 @@ class UrlPlugin < Rubko::Plugin
|
|
47
47
|
def generate(*path)
|
48
48
|
path.compact!
|
49
49
|
path.map! { |seg|
|
50
|
-
seg =
|
50
|
+
seg = path[seg] if seg.kind_of? Integer
|
51
51
|
URI.escape seg
|
52
52
|
}
|
53
|
-
(
|
53
|
+
(protocol+host if fullPath).to_s + base + path.join('/')
|
54
54
|
end
|
55
55
|
|
56
56
|
def link(*path)
|
57
|
-
generate(*path) + (
|
57
|
+
generate(*path) + (ending unless path.empty?).to_s
|
58
58
|
end
|
59
59
|
|
60
60
|
def linkSlug(*path)
|
@@ -64,7 +64,7 @@ class UrlPlugin < Rubko::Plugin
|
|
64
64
|
def file(*path)
|
65
65
|
name = 'public/' + path.join('/')
|
66
66
|
time = File.mtime(name).to_i / 3 % 1000000 if File.exists? name
|
67
|
-
generate
|
67
|
+
generate fileBase, (time.to_s if fileTime), *path
|
68
68
|
end
|
69
69
|
|
70
70
|
def redirect(*path)
|
@@ -79,11 +79,11 @@ class UrlPlugin < Rubko::Plugin
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def refresh
|
82
|
-
redirect(
|
82
|
+
redirect(*path)
|
83
83
|
end
|
84
84
|
|
85
85
|
def forceSSL
|
86
|
-
if
|
86
|
+
if protocol != 'https://'
|
87
87
|
@protocol, @fullPath = 'https://', true
|
88
88
|
refresh
|
89
89
|
end
|
@@ -43,7 +43,7 @@
|
|
43
43
|
if (translation) {
|
44
44
|
var temp=str.replace(value, translation);
|
45
45
|
if (value[0].toLowerCase()===value[0])
|
46
|
-
return temp[0].toLowerCase()+temp.slice(1)
|
46
|
+
return temp[0].toLowerCase()+temp.slice(1);
|
47
47
|
return temp[0].toUpperCase()+temp.slice(1);
|
48
48
|
}
|
49
49
|
$.each($.translate.dictionary[module][language].regex, function(key, val) {
|
@@ -74,13 +74,14 @@
|
|
74
74
|
language = language || $.translate.language;
|
75
75
|
$.translate.textNodes(this).each(function() {
|
76
76
|
$(this).untranslate(true);
|
77
|
-
if (
|
78
|
-
if (
|
79
|
-
|
80
|
-
var translation =
|
81
|
-
if (language === $.translate.original || (translation = $.translate.lookup(
|
77
|
+
if (this.trO || $.translate.clear($.translate.get(this))) {
|
78
|
+
if (!this.trO)
|
79
|
+
this.trO = $.translate.get(this);
|
80
|
+
var translation = this.trO;
|
81
|
+
if (language === $.translate.original || (translation = $.translate.lookup(this.trO, module, language)) ) {
|
82
82
|
$.translate.set(this, translation);
|
83
|
-
|
83
|
+
this.trM = module;
|
84
|
+
this.trL = language;
|
84
85
|
} else $(this).untranslate(true);
|
85
86
|
}
|
86
87
|
});
|
@@ -89,13 +90,14 @@
|
|
89
90
|
|
90
91
|
$.fn.retranslate = function(module_, language_) {
|
91
92
|
$.translate.textNodes(this).each(function() {
|
92
|
-
if (
|
93
|
-
var module = module_ ||
|
94
|
-
var language = language_ ||
|
95
|
-
var translation =
|
96
|
-
if (language === $.translate.original || (translation = $.translate.lookup(
|
93
|
+
if (this.trO) {
|
94
|
+
var module = module_ || this.trM;
|
95
|
+
var language = language_ || this.trL;
|
96
|
+
var translation = this.trO;
|
97
|
+
if (language === $.translate.original || (translation = $.translate.lookup(this.trO, module, language)) ) {
|
97
98
|
$.translate.set(this, translation);
|
98
|
-
|
99
|
+
this.trM = module;
|
100
|
+
this.trL = language;
|
99
101
|
}
|
100
102
|
}
|
101
103
|
});
|
@@ -104,9 +106,11 @@
|
|
104
106
|
|
105
107
|
$.fn.untranslate = function(undo) {
|
106
108
|
$.translate.textNodes(this).each(function() {
|
107
|
-
if (undo &&
|
108
|
-
$.translate.set(this,
|
109
|
-
|
109
|
+
if (undo && this.trO)
|
110
|
+
$.translate.set(this, this.trO);
|
111
|
+
delete this.trM;
|
112
|
+
delete this.trL;
|
113
|
+
delete this.trO;
|
110
114
|
});
|
111
115
|
};
|
112
116
|
//})();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rok Kralj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- stamp/.gitignore
|
60
60
|
- stamp/config.ru
|
61
61
|
- stamp/config/db.rb
|
62
|
+
- stamp/config/deploy.rb
|
62
63
|
- stamp/config/facebook.rb
|
63
64
|
- stamp/config/session.rb
|
64
65
|
- stamp/config/url.rb
|
@@ -93,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
96
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.0.
|
97
|
+
rubygems_version: 2.0.14
|
97
98
|
signing_key:
|
98
99
|
specification_version: 4
|
99
100
|
summary: Web framework
|