smithycms 0.0.3 → 0.4.0
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 +7 -0
- data/README.md +4 -1
- data/Rakefile +6 -12
- data/app/controllers/smithy/assets_controller.rb +3 -3
- data/app/controllers/smithy/base_controller.rb +9 -0
- data/app/controllers/smithy/content_blocks_controller.rb +3 -3
- data/app/controllers/smithy/content_pieces_controller.rb +6 -6
- data/app/controllers/smithy/contents_controller.rb +3 -3
- data/app/controllers/smithy/images_controller.rb +3 -3
- data/app/controllers/smithy/page_contents_controller.rb +4 -4
- data/app/controllers/smithy/pages_controller.rb +3 -3
- data/app/controllers/smithy/settings_controller.rb +3 -3
- data/app/controllers/smithy/templates_controller.rb +5 -5
- data/app/models/smithy/asset.rb +4 -5
- data/app/models/smithy/content.rb +0 -2
- data/app/models/smithy/content_block.rb +1 -3
- data/app/models/smithy/content_block_template.rb +1 -3
- data/app/models/smithy/image.rb +0 -2
- data/app/models/smithy/page.rb +5 -3
- data/app/models/smithy/page_content.rb +3 -5
- data/app/models/smithy/page_list.rb +0 -2
- data/app/models/smithy/permitted_params.rb +57 -0
- data/app/models/smithy/setting.rb +0 -1
- data/app/models/smithy/template.rb +6 -9
- data/app/models/smithy/template_container.rb +1 -3
- data/app/views/smithy/assets/edit.html.erb +1 -1
- data/app/views/smithy/assets/new.html.erb +4 -10
- data/config/initializers/dragonfly.rb +18 -38
- data/config/routes.rb +8 -8
- data/lib/smithy/content_blocks/registry.rb +1 -1
- data/lib/smithy/dependencies.rb +0 -1
- data/lib/smithy/dragonfly/asset_helper.rb +11 -11
- data/lib/smithy/dragonfly/remote_data_store.rb +3 -9
- data/lib/smithy/dragonfly.rb +1 -1
- data/lib/smithy/engine.rb +2 -1
- data/lib/smithy/formatter.rb +4 -5
- data/lib/smithy/version.rb +1 -1
- metadata +120 -220
@@ -1,48 +1,28 @@
|
|
1
|
-
require 'uri'
|
2
1
|
require 'dragonfly'
|
3
|
-
begin
|
4
|
-
require 'rack/cache'
|
5
|
-
rescue LoadError => e
|
6
|
-
puts "Couldn't find rack-cache - make sure you have it in your Gemfile:"
|
7
|
-
puts " gem 'rack-cache', :require => 'rack/cache'"
|
8
|
-
puts " or configure dragonfly manually instead of using 'dragonfly/rails/images'"
|
9
|
-
raise e
|
10
|
-
end
|
11
|
-
|
12
|
-
## initialize Dragonfly ##
|
13
|
-
app = Dragonfly[:files]
|
14
|
-
app.configure_with(:rails)
|
15
|
-
app.configure_with(:imagemagick)
|
16
2
|
|
17
|
-
#
|
18
|
-
app.
|
3
|
+
# Configure
|
4
|
+
Dragonfly.app.configure do
|
5
|
+
plugin :imagemagick
|
19
6
|
|
20
|
-
|
21
|
-
|
22
|
-
app.define_macro(ActiveRecord::Base, :file_accessor)
|
7
|
+
protect_from_dos_attacks true
|
8
|
+
secret "7fb765cbc9f1d92d5d1a56a43193d34d4f9b54dced3e62cb4e42f25d2500dd0f"
|
23
9
|
|
24
|
-
|
25
|
-
|
26
|
-
# Convert absolute location needs to be specified
|
27
|
-
# to avoid issues with Phusion Passenger not using $PATH
|
28
|
-
c.convert_command = `which convert`.strip.presence || "/usr/local/bin/convert"
|
29
|
-
c.identify_command = `which identify`.strip.presence || "/usr/local/bin/identify"
|
10
|
+
convert_command = `which convert`.strip.presence || "/usr/local/bin/convert"
|
11
|
+
identify_command = `which identify`.strip.presence || "/usr/local/bin/identify"
|
30
12
|
|
31
|
-
|
32
|
-
c.allow_fetch_file = true
|
13
|
+
url_format '/uploads/assets/:job/:basename.:format'
|
33
14
|
|
34
|
-
|
15
|
+
datastore Smithy::Asset.dragonfly_datastore
|
35
16
|
end
|
36
17
|
|
37
|
-
|
18
|
+
# Logger
|
19
|
+
Dragonfly.logger = Rails.logger
|
38
20
|
|
39
|
-
#
|
40
|
-
|
21
|
+
# Mount as middleware
|
22
|
+
Rails.application.middleware.use Dragonfly::Middleware
|
41
23
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
Rails.application.middleware.insert_after Rack::Cache, Dragonfly::Middleware, :files
|
24
|
+
# Add model functionality
|
25
|
+
if defined?(ActiveRecord::Base)
|
26
|
+
ActiveRecord::Base.extend Dragonfly::Model
|
27
|
+
ActiveRecord::Base.extend Dragonfly::Model::Validations
|
28
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Smithy::Engine.routes.draw do
|
2
2
|
root :to => 'pages#show'
|
3
3
|
scope "/smithy" do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
get '/' => redirect('/smithy/pages')
|
5
|
+
get '/login' => redirect('/'), :as => :login unless has_named_route?(:login)
|
6
|
+
delete '/logout' => redirect('/'), :as => :logout unless has_named_route?(:logout)
|
7
7
|
# CMS admin
|
8
8
|
resources :assets
|
9
9
|
resources :content_blocks
|
@@ -12,7 +12,7 @@ Smithy::Engine.routes.draw do
|
|
12
12
|
collection do
|
13
13
|
get :order
|
14
14
|
end
|
15
|
-
resources :contents, :controller => "
|
15
|
+
resources :contents, :controller => "page_contents", :except => [ :index ] do
|
16
16
|
member do
|
17
17
|
get :preview
|
18
18
|
end
|
@@ -31,8 +31,8 @@ Smithy::Engine.routes.draw do
|
|
31
31
|
# end
|
32
32
|
end
|
33
33
|
# Sitemap
|
34
|
-
resource :sitemap, :controller => "
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
resource :sitemap, :controller => "sitemap", :only => [ :show ]
|
35
|
+
get '/templates/javascripts/*javascript' => 'templates#javascript', :defaults => { :format => 'js' }
|
36
|
+
get '/templates/stylesheets/*stylesheet' => 'templates#stylesheet', :format => 'css'
|
37
|
+
get '*path' => 'pages#show'
|
38
38
|
end
|
@@ -20,7 +20,7 @@ module Smithy
|
|
20
20
|
return unless ActiveRecord::Base.connection.table_exists?(content_block.table_name)
|
21
21
|
content_block_name = content_block.to_s.demodulize
|
22
22
|
@@content_blocks << content_block_name unless @@content_blocks.include?(content_block_name)
|
23
|
-
cb = Smithy::ContentBlock.
|
23
|
+
cb = Smithy::ContentBlock.find_or_initialize_by(name: content_block_name)
|
24
24
|
cb.save
|
25
25
|
@@content_blocks
|
26
26
|
end
|
data/lib/smithy/dependencies.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'dragonfly/s3_data_store'
|
2
|
+
|
1
3
|
module Smithy
|
2
4
|
module Dragonfly
|
3
5
|
module AssetHelper
|
@@ -21,20 +23,18 @@ module Smithy
|
|
21
23
|
|
22
24
|
def dragonfly_datastore
|
23
25
|
if ENV['AWS_ACCESS_KEY_ID'].present? && ENV['AWS_SECRET_ACCESS_KEY'].present? && ENV['AWS_S3_BUCKET'].present?
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# c.storage_headers = {'some' => 'thing'} # defaults to {'x-amz-acl' => 'public-read'}
|
31
|
-
# c.url_scheme = 'https' # defaults to 'http'
|
32
|
-
# c.url_host = 'some.custom.host' # defaults to "<bucket_name>.s3.amazonaws.com"
|
26
|
+
Dragonfly.app.configure do
|
27
|
+
# Allow amazon s3 urls to work
|
28
|
+
fetch_url_whitelist [
|
29
|
+
/s3\.amazonaws\.com\/#{ENV['AWS_S3_BUCKET']}/,
|
30
|
+
/#{ENV['AWS_S3_BUCKET']}\.s3\.amazonaws\.com/
|
31
|
+
]
|
33
32
|
end
|
33
|
+
::Dragonfly::S3DataStore.new(bucket_name: ENV['AWS_S3_BUCKET'], access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'])
|
34
34
|
else
|
35
|
-
|
35
|
+
Dragonfly.app.configure { fetch_url_whitelist [] }
|
36
|
+
::Dragonfly::FileDataStore.new(root_path: Rails.root.join('public/system/dragonfly', Rails.env), server_root: Rails.root.join('public'))
|
36
37
|
end
|
37
|
-
datastore
|
38
38
|
end
|
39
39
|
|
40
40
|
def dragonfly_remote_datastore
|
@@ -3,19 +3,13 @@ module Smithy
|
|
3
3
|
module Dragonfly
|
4
4
|
module DataStorage
|
5
5
|
class RemoteDataStore
|
6
|
-
|
7
|
-
|
8
|
-
def store(temp_object, opts={})
|
6
|
+
def write(content, opts={})
|
9
7
|
# raise "Sorry friend, this datastore is read-only."
|
10
8
|
end
|
11
9
|
|
12
|
-
def
|
10
|
+
def read(uid)
|
13
11
|
response = HTTParty.get uid, :timeout => 3
|
14
|
-
unless response.ok?
|
15
|
-
#raise Forbidden if response.code == 403
|
16
|
-
raise DataNotFound
|
17
|
-
end
|
18
|
-
|
12
|
+
raise DataNotFound unless response.ok?
|
19
13
|
content = response.body
|
20
14
|
extra_data = {}
|
21
15
|
[
|
data/lib/smithy/dragonfly.rb
CHANGED
data/lib/smithy/engine.rb
CHANGED
@@ -35,7 +35,8 @@ module Smithy
|
|
35
35
|
# we need to require all our model files so that ContentBlocks
|
36
36
|
# are registered with the engine
|
37
37
|
Dir[Smithy::Engine.root.join('app', 'models', 'smithy', '*.rb')].each do |file|
|
38
|
-
|
38
|
+
table_name = File.basename(file, '.rb').pluralize
|
39
|
+
require_dependency file if ActiveRecord::Base.connection.table_exists?(table_name)
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
data/lib/smithy/formatter.rb
CHANGED
@@ -13,11 +13,10 @@ module Smithy
|
|
13
13
|
def sanitize_config
|
14
14
|
{
|
15
15
|
elements: %w(
|
16
|
-
p
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
img object param del
|
16
|
+
p div ul ol li blockquote pre h1 h2 h3 h4 h5 h6 object
|
17
|
+
hr param
|
18
|
+
a span sub sup strong em abbr code del small big
|
19
|
+
br img
|
21
20
|
),
|
22
21
|
attributes: {
|
23
22
|
:all => ['class', 'style', 'title', 'id'],
|
data/lib/smithy/version.rb
CHANGED