cartoonist 0.0.19.3 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/settings_controller.rb +1 -0
- data/app/controllers/admin_controller.rb +0 -18
- data/app/controllers/backup_controller.rb +17 -0
- data/app/models/backup.rb +19 -23
- data/cartoonist.gemspec +3 -4
- data/config/locales/en.yml +2 -1
- data/db/migrate/20131117042451_ensure_secrets_are_set.rb +30 -0
- data/lib/cartoonist/engine.rb +10 -1
- data/lib/cartoonist/version.rb +1 -1
- data/lib/cartoonist.rb +1 -1
- metadata +8 -7
- data/lib/cartoonist/nginxtra.rb +0 -103
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fdb2663d615944f6df0658c68f6afc244720e71
|
4
|
+
data.tar.gz: b058bf06907f2d1627952a859a68296f38cb6170
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 418c3d4b10260d1d6d3581f93b9102058e09fcc3a5c04aba619c064256372d7b05dc98ba074378d088573c887999adbbf4b9ccc9432490aa1c5b7d47287bd3af
|
7
|
+
data.tar.gz: 4f860bb05491304f94ff880d849fc98d6d818dc8cf3a2ccad4003b2ac4b91ae2225520f4be1e493de7e702839b4f3ea17db277547822b5fab081fdeb612ea4ca
|
@@ -42,6 +42,7 @@ class Admin::SettingsController < AdminCartoonistController
|
|
42
42
|
Setting[:secret_token] = SecureRandom.hex 30
|
43
43
|
Setting[:secret_key_base] = SecureRandom.hex 64
|
44
44
|
Setting[:devise_pepper] = SecureRandom.hex 64
|
45
|
+
Setting[:devise_secret_key] = SecureRandom.hex 64
|
45
46
|
# This MUST go AFTER we set the pepper
|
46
47
|
User.create! :email => params[:admin_email], :password => params[:admin_password], :password_confirmation => params[:admin_confirm_password], :name => params[:admin_name]
|
47
48
|
redirect_to "/admin"
|
@@ -6,24 +6,6 @@ class AdminController < AdminCartoonistController
|
|
6
6
|
redirect_to "/admin/main"
|
7
7
|
end
|
8
8
|
|
9
|
-
def backup
|
10
|
-
respond_to do |format|
|
11
|
-
format.html { redirect_to "/admin/main" }
|
12
|
-
|
13
|
-
format.tgz do
|
14
|
-
backup = Backup.new :tgz
|
15
|
-
headers["Content-Disposition"] = backup.content_disposition
|
16
|
-
self.response_body = backup.response_body
|
17
|
-
end
|
18
|
-
|
19
|
-
format.zip do
|
20
|
-
backup = Backup.new :zip
|
21
|
-
headers["Content-Disposition"] = backup.content_disposition
|
22
|
-
self.response_body = backup.response_body
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
9
|
def reload
|
28
10
|
if Rails.env.production?
|
29
11
|
%x[git pull]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class BackupController < AdminCartoonistController
|
2
|
+
include ActionController::Live
|
3
|
+
|
4
|
+
def backup
|
5
|
+
respond_to do |format|
|
6
|
+
format.html { redirect_to "/admin/main" }
|
7
|
+
|
8
|
+
format.tgz do
|
9
|
+
Backup.new(:tgz).stream_to response
|
10
|
+
end
|
11
|
+
|
12
|
+
format.zip do
|
13
|
+
Backup.new(:zip).stream_to response
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/app/models/backup.rb
CHANGED
@@ -15,43 +15,39 @@ class Backup
|
|
15
15
|
"#{prefix}cartoonist-backup-#{Time.now.strftime("%Y-%m-%d_%H%M%S")}.#{@extension}"
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def stream_to(response)
|
19
|
+
response.headers["Content-Disposition"] = content_disposition
|
20
|
+
send @extension, response.stream
|
21
|
+
ensure
|
22
|
+
response.stream.close
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
# TODO: Maybe investigate zipline gem a little more and figure out
|
26
|
+
# how it streams zips, and use that here, so this can be properly
|
27
|
+
# streamed.
|
28
|
+
def zip(stream)
|
29
|
+
buffer = Zip::OutputStream.write_buffer do |zos|
|
26
30
|
Backup.each do |entry|
|
27
31
|
zos.put_next_entry entry.path
|
28
32
|
zos.write entry.content
|
29
33
|
end
|
30
34
|
end
|
31
35
|
|
32
|
-
|
36
|
+
stream.write buffer.string
|
33
37
|
end
|
34
38
|
|
35
|
-
def tgz(
|
36
|
-
gzip = Zlib::GzipWriter.new
|
39
|
+
def tgz(stream)
|
40
|
+
gzip = Zlib::GzipWriter.new stream
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
output.write entry.content
|
43
|
-
end
|
42
|
+
Archive::Tar::Minitar::Writer.open gzip do |tar|
|
43
|
+
Backup.each do |entry|
|
44
|
+
tar.add_file_simple entry.path, :mode => 0644, :size => entry.content.length do |output|
|
45
|
+
output.write entry.content
|
44
46
|
end
|
45
47
|
end
|
46
|
-
ensure
|
47
|
-
gzip.close
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class ResponseOutWriter < Struct.new(:stream)
|
52
|
-
def write(content)
|
53
|
-
stream << content
|
54
48
|
end
|
49
|
+
ensure
|
50
|
+
gzip.close
|
55
51
|
end
|
56
52
|
|
57
53
|
class << self
|
data/cartoonist.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cartoonist"
|
3
|
-
|
4
|
-
s.version = File.read File.join(File.dirname(__FILE__), "../CARTOONIST_VERSION")
|
3
|
+
s.version = "0.0.20"
|
5
4
|
s.date = Time.now.strftime "%Y-%m-%d"
|
6
5
|
s.summary = "Cartoonist Core"
|
7
6
|
s.description = "This provides the main functionality and plugin api for Cartoonist."
|
@@ -12,11 +11,11 @@ Gem::Specification.new do |s|
|
|
12
11
|
s.require_paths = ["lib"]
|
13
12
|
s.homepage = "http://reasonnumber.com/cartoonist"
|
14
13
|
s.add_dependency "actionpack-page_caching", "~> 1.0"
|
15
|
-
s.add_dependency "devise", "~> 3.
|
14
|
+
s.add_dependency "devise", "~> 3.2"
|
16
15
|
s.add_dependency "jquery-rails", "~> 3.0"
|
17
16
|
s.add_dependency "omniauth-openid", "~> 1.0"
|
18
17
|
s.add_dependency "railties", "~> 4.0"
|
19
18
|
s.add_dependency "redcarpet", "~> 3.0"
|
20
|
-
s.add_dependency "rubyzip", "~> 0
|
19
|
+
s.add_dependency "rubyzip", "~> 1.0"
|
21
20
|
s.add_dependency "minitar", "~> 0.5"
|
22
21
|
end
|
data/config/locales/en.yml
CHANGED
@@ -41,7 +41,7 @@ en:
|
|
41
41
|
general:
|
42
42
|
actions:
|
43
43
|
backup_tgz: Download Backup (tarball)
|
44
|
-
backup_zip: Download Backup (zip)
|
44
|
+
backup_zip: "Download Backup (zip) (WARNING: Not Streamed)"
|
45
45
|
reload: Update and Reload
|
46
46
|
layout:
|
47
47
|
actions: Actions
|
@@ -122,6 +122,7 @@ en:
|
|
122
122
|
secret_key_base: "Secret Key Base: "
|
123
123
|
secret_token: "Secret Token: "
|
124
124
|
devise_pepper: "Devise Pepper: "
|
125
|
+
devise_secret_key: "Devise Secret Key: "
|
125
126
|
tabs:
|
126
127
|
advanced: Advanced
|
127
128
|
general: General
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class EnsureSecretsAreSet < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
# We don't need to do any of this if they haven't gone through
|
4
|
+
# initial setup yet.
|
5
|
+
return if User.count == 0
|
6
|
+
|
7
|
+
if Setting[:secret_token] == Setting::Meta[:secret_token].default
|
8
|
+
puts "Setting secret_token"
|
9
|
+
Setting[:secret_token] = SecureRandom.hex 30
|
10
|
+
end
|
11
|
+
|
12
|
+
if Setting[:secret_key_base] == Setting::Meta[:secret_key_base].default
|
13
|
+
puts "Setting secret_key_base"
|
14
|
+
Setting[:secret_key_base] = SecureRandom.hex 64
|
15
|
+
end
|
16
|
+
|
17
|
+
if Setting[:devise_pepper] == Setting::Meta[:devise_pepper].default
|
18
|
+
puts "Setting devise_pepper"
|
19
|
+
Setting[:devise_pepper] = SecureRandom.hex 64
|
20
|
+
end
|
21
|
+
|
22
|
+
if Setting[:devise_secret_key] == Setting::Meta[:devise_secret_key].default
|
23
|
+
puts "Setting devise_secret_key"
|
24
|
+
Setting[:devise_secret_key] = SecureRandom.hex 64
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def down
|
29
|
+
end
|
30
|
+
end
|
data/lib/cartoonist/engine.rb
CHANGED
@@ -89,6 +89,7 @@ module Cartoonist
|
|
89
89
|
|
90
90
|
# Setup a pepper to generate the encrypted password.
|
91
91
|
devise_config.pepper = "temporary... this is initialized later, in the to_prepare block"
|
92
|
+
devise_config.secret_key = "temporary... this is initialized later, in the to_prepare block"
|
92
93
|
|
93
94
|
# ==> Configuration for :confirmable
|
94
95
|
# A period that the user is allowed to access the website even without
|
@@ -271,6 +272,12 @@ module Cartoonist
|
|
271
272
|
end
|
272
273
|
end
|
273
274
|
|
275
|
+
devise_secret_key_changed = lambda do
|
276
|
+
Devise.setup do |devise_config|
|
277
|
+
devise_config.secret_key = Setting[:devise_secret_key]
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
274
281
|
Setting.define :domain, :order => 1
|
275
282
|
Setting.define :site_name, :order => 2
|
276
283
|
Setting.define :site_heading, :order => 3
|
@@ -300,11 +307,13 @@ module Cartoonist
|
|
300
307
|
Setting.define :secret_token, :default => "ThisTokenMustBeRegenerated....", :onchange => secret_token_changed
|
301
308
|
Setting.define :secret_key_base, :default => "ThisTokenMustBeRegenerated....", :onchange => secret_key_base_changed
|
302
309
|
Setting.define :devise_pepper, :default => "ThisTokenMustBeRegenerated....", :onchange => devise_pepper_changed
|
310
|
+
Setting.define :devise_secret_key, :default => "ThisTokenMustBeRegenerated....", :onchange => devise_secret_key_changed
|
303
311
|
end
|
304
312
|
|
305
313
|
secret_token_changed.call
|
306
314
|
secret_key_base_changed.call
|
307
315
|
devise_pepper_changed.call
|
316
|
+
devise_secret_key_changed.call
|
308
317
|
end
|
309
318
|
|
310
319
|
Mime::Type.register "image/x-icon", :ico
|
@@ -337,11 +346,11 @@ module Cartoonist
|
|
337
346
|
get "favicon" => "site#favicon", :defaults => { :format => "ico" }
|
338
347
|
get "sitemap" => "site#sitemap", :defaults => { :format => "xml" }
|
339
348
|
get "robots" => "site#robots", :defaults => { :format => "text" }
|
349
|
+
get "admin/backup" => "backup#backup"
|
340
350
|
|
341
351
|
resource :admin, :controller => :admin, :only => [:show] do
|
342
352
|
collection do
|
343
353
|
get "cron"
|
344
|
-
get "backup"
|
345
354
|
get "main"
|
346
355
|
get "reload"
|
347
356
|
end
|
data/lib/cartoonist/version.rb
CHANGED
data/lib/cartoonist.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartoonist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Virata-Stone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack-page_caching
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
40
|
+
version: '3.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: jquery-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '1.0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: minitar
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- app/controllers/admin/static_cache_controller.rb
|
140
140
|
- app/controllers/admin_cartoonist_controller.rb
|
141
141
|
- app/controllers/admin_controller.rb
|
142
|
+
- app/controllers/backup_controller.rb
|
142
143
|
- app/controllers/cartoonist_controller.rb
|
143
144
|
- app/controllers/site_controller.rb
|
144
145
|
- app/helpers/admin/cache_helper.rb
|
@@ -191,9 +192,9 @@ files:
|
|
191
192
|
- db/migrate/20120524032959_add_extension_to_database_files.rb
|
192
193
|
- db/migrate/20121205091909_add_omniautable_to_users.rb
|
193
194
|
- db/migrate/20130724085513_create_secret_key_base.rb
|
195
|
+
- db/migrate/20131117042451_ensure_secrets_are_set.rb
|
194
196
|
- lib/cartoonist.rb
|
195
197
|
- lib/cartoonist/engine.rb
|
196
|
-
- lib/cartoonist/nginxtra.rb
|
197
198
|
- lib/cartoonist/version.rb
|
198
199
|
- public/errors/404.html
|
199
200
|
- public/errors/422.html
|
data/lib/cartoonist/nginxtra.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
Nginxtra::Config::Extension.partial "nginx.conf", "cartoonist_rails" do |args, block|
|
2
|
-
rails_server = args[:server] || :passenger
|
3
|
-
ssl_details = args[:ssl]
|
4
|
-
ruby_version = args[:ruby]
|
5
|
-
|
6
|
-
if ssl_details
|
7
|
-
default_port = 443
|
8
|
-
else
|
9
|
-
default_port = 80
|
10
|
-
end
|
11
|
-
|
12
|
-
if rails_server == :passenger && !@passenger_requirements_done
|
13
|
-
@config.require_passenger!
|
14
|
-
passenger_root!
|
15
|
-
passenger_ruby! unless ruby_version
|
16
|
-
@passenger_requirements_done = true
|
17
|
-
end
|
18
|
-
|
19
|
-
server do
|
20
|
-
listen(args[:port] || default_port)
|
21
|
-
server_name(args[:server_name] || "localhost")
|
22
|
-
root File.join(File.absolute_path(File.expand_path(args[:root] || ".")), "public")
|
23
|
-
gzip_static "on"
|
24
|
-
passenger_ruby ruby_version if ruby_version
|
25
|
-
passenger_on! if rails_server == :passenger
|
26
|
-
rails_env(args[:environment] || "production")
|
27
|
-
|
28
|
-
if ssl_details
|
29
|
-
ssl "on"
|
30
|
-
ssl_certificate ssl_details[:ssl_cert]
|
31
|
-
ssl_certificate_key ssl_details[:ssl_key]
|
32
|
-
@config.compile_option "--with-http_ssl_module"
|
33
|
-
end
|
34
|
-
|
35
|
-
block.call
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
Nginxtra::Config::Extension.partial "nginx.conf", "cartoonist" do |args, block|
|
40
|
-
if !@passenger_requirements_done
|
41
|
-
@config.require_passenger!
|
42
|
-
passenger_root!
|
43
|
-
passenger_ruby!
|
44
|
-
@passenger_requirements_done = true
|
45
|
-
end
|
46
|
-
|
47
|
-
cartoonist_type = args[:type] || "www"
|
48
|
-
server_name = args[:server_name]
|
49
|
-
root_path = args[:root]
|
50
|
-
ssl_details = args[:ssl]
|
51
|
-
ssl_details = { :ssl => ssl_details } if ssl_details
|
52
|
-
short_expiration = args[:short_expiration] || "2h"
|
53
|
-
long_expiration = args[:long_expiration] || "7d"
|
54
|
-
ruby_version = args[:ruby]
|
55
|
-
|
56
|
-
[{}, ssl_details].compact.each do |additional_options|
|
57
|
-
options = { :server => :custom, :server_name => server_name, :root => root_path, :ruby => ruby_version }.merge additional_options
|
58
|
-
|
59
|
-
cartoonist_rails options do
|
60
|
-
location "~*", "^/_long_expiration_/#{cartoonist_type}(/.*?)(?:\\.html)?$" do
|
61
|
-
expires long_expiration
|
62
|
-
add_header "Cache-Control", "public"
|
63
|
-
try_files "$1", "$1.html", "/cache/static$1", "@passenger"
|
64
|
-
end
|
65
|
-
|
66
|
-
["/cache/static$uri", "$uri", "$uri.html"].each do |condition|
|
67
|
-
_if "-f #{root_path}/public#{condition}" do
|
68
|
-
rewrite "^(.*)$", "/_long_expiration_/#{cartoonist_type}$1", "last"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
["html", "json", "rss"].each do |extension|
|
73
|
-
location "~*", "^/_short_#{extension}_expiration_/#{cartoonist_type}(/.*?)(?:\\.#{extension})?$" do
|
74
|
-
expires short_expiration
|
75
|
-
add_header "Cache-Control", "public"
|
76
|
-
try_files "/cache$1.#{cartoonist_type}.tmp.#{extension}", "@passenger"
|
77
|
-
end
|
78
|
-
|
79
|
-
location "~*", "^/_long_#{extension}_expiration_/#{cartoonist_type}(/.*?)(?:\\.#{extension})?$" do
|
80
|
-
expires long_expiration
|
81
|
-
add_header "Cache-Control", "public"
|
82
|
-
try_files "/cache$1.#{cartoonist_type}.#{extension}", "@passenger"
|
83
|
-
end
|
84
|
-
|
85
|
-
_if "-f #{root_path}/public/cache$uri.#{cartoonist_type}.tmp.#{extension}" do
|
86
|
-
rewrite "^(.*)$", "/_short_#{extension}_expiration_/#{cartoonist_type}$1", "last"
|
87
|
-
end
|
88
|
-
|
89
|
-
_if "-f #{root_path}/public/cache$uri.#{cartoonist_type}.#{extension}" do
|
90
|
-
rewrite "^(.*)$", "/_long_#{extension}_expiration_/#{cartoonist_type}$1", "last"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
location "/" do
|
95
|
-
try_files "/_jump_to_passenger_", "@passenger"
|
96
|
-
end
|
97
|
-
|
98
|
-
location "@passenger" do
|
99
|
-
passenger_on!
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|