aerogel-core 1.0.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/.gitignore +25 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +8 -0
- data/Rakefile +1 -0
- data/aerogel-core.gemspec +34 -0
- data/app/helpers/core.rb +15 -0
- data/app/helpers/render.rb +24 -0
- data/app/routes/core.rb +15 -0
- data/app/routes/static.rb +11 -0
- data/assets/javascripts/application.js +2 -0
- data/assets/stylesheets/application.css +1 -0
- data/config/config.conf.template +7 -0
- data/config/database.conf.template +4 -0
- data/config/development/.keep +0 -0
- data/config/production/.keep +0 -0
- data/db/model/model.rb.template +11 -0
- data/db/seed/development/.keep +0 -0
- data/db/seed/production/.keep +0 -0
- data/db/seed/seed.template +42 -0
- data/lib/aerogel-core.rb +13 -0
- data/lib/aerogel-core/application.rb +34 -0
- data/lib/aerogel-core/assets.rb +31 -0
- data/lib/aerogel-core/config.rb +25 -0
- data/lib/aerogel-core/core.rb +97 -0
- data/lib/aerogel-core/db.rb +123 -0
- data/lib/aerogel-core/helpers.rb +10 -0
- data/lib/aerogel-core/rake.rb +10 -0
- data/lib/aerogel-core/routes.rb +7 -0
- data/lib/aerogel-core/version.rb +3 -0
- data/public/favicon.ico +0 -0
- data/public/humans.txt +1 -0
- data/public/robots.txt.development +5 -0
- data/public/robots.txt.production +12 -0
- data/rake/db.rake +40 -0
- data/views/errors/404.html.erb +19 -0
- data/views/index.html.erb +1 -0
- data/views/layouts/application.html.erb +15 -0
- data/views/lorem.html.erb +48 -0
- metadata +237 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef7128d5d6f2109c75a74926476c108d26880cb5
|
4
|
+
data.tar.gz: 08051821b9a153237df4f5c5646cdf9f8313dded
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6c3277c8ad0b2035d4ba9b7b76fceb0d63356516a0401bc4d46d1c023889b09d5af0efdf03fe47a55010aabfb098f228abf0429fde44fa2db20c202947b9dbfb
|
7
|
+
data.tar.gz: 5677764049e8cd75876746b43a570cf6642b73cfd50b41935be078c9d52a25da6f88735aa8580f082070014ac8ab2df4143311a4246594024c76c19cfee85b52
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.sublime-project
|
19
|
+
*.sublime-workspace
|
20
|
+
.codeintel
|
21
|
+
.sass-cache
|
22
|
+
public/assets
|
23
|
+
.ruby-version
|
24
|
+
.ruby-gemset
|
25
|
+
.powrc
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alex Kukushkin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'aerogel-core/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "aerogel-core"
|
8
|
+
spec.version = Aerogel::VERSION
|
9
|
+
spec.authors = ["Alex Kukushkin"]
|
10
|
+
spec.email = ["alex@kukushk.in"]
|
11
|
+
spec.description = %q{Aerogel core module}
|
12
|
+
spec.summary = %q{Aerogel is a modular opinionated CMS}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'sinatra'
|
22
|
+
spec.add_dependency 'sinatra-contrib'
|
23
|
+
spec.add_dependency 'sinatra-asset-pipeline'
|
24
|
+
spec.add_dependency 'sass'
|
25
|
+
spec.add_dependency 'coffee-script'
|
26
|
+
spec.add_dependency 'uglifier'
|
27
|
+
spec.add_dependency 'yui-compressor'
|
28
|
+
spec.add_dependency 'aerogel-configurator'
|
29
|
+
spec.add_dependency 'mongoid'
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
32
|
+
spec.add_development_dependency "rake"
|
33
|
+
end
|
34
|
+
|
data/app/helpers/core.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Aerogel::Helpers
|
2
|
+
|
3
|
+
def find_template(views, name, engine, &block)
|
4
|
+
Array(views).each { |v| super(v, name, engine, &block) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def logger( name = nil )
|
8
|
+
if name.nil?
|
9
|
+
env['rack.logger']
|
10
|
+
else
|
11
|
+
env['rack.logger.'+name.to_s] or raise("Logger with name '#{name}' is not registered")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end # module Aerogel::Helpers
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Aerogel::Helpers
|
2
|
+
|
3
|
+
# Escapes html string.
|
4
|
+
#
|
5
|
+
def h( str )
|
6
|
+
Rack::Utils.escape_html(str)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Renders erb template.
|
10
|
+
#
|
11
|
+
def view( name )
|
12
|
+
erb "#{name}.html".to_sym
|
13
|
+
end
|
14
|
+
|
15
|
+
# Renders partial erb template.
|
16
|
+
#
|
17
|
+
def partial( name, opts = {} )
|
18
|
+
name_parts = name.to_s.split('/')
|
19
|
+
name_parts[-1] = '_'+name_parts[-1]+".html"
|
20
|
+
opts[:layout] = false
|
21
|
+
erb name_parts.join('/').to_sym, opts
|
22
|
+
end
|
23
|
+
|
24
|
+
end # module Aerogel::Helpers
|
data/app/routes/core.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
class Aerogel::Application
|
2
|
+
|
3
|
+
get "/*" do |filename|
|
4
|
+
pass if filename.blank?
|
5
|
+
path = Aerogel.get_resource( :public, filename )
|
6
|
+
puts "Serving static file: '#{path}' or not?"
|
7
|
+
pass unless path
|
8
|
+
send_file path
|
9
|
+
end
|
10
|
+
|
11
|
+
end # class Aerogel::Application
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree .
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# A .seed file is a .conf file which stores
|
2
|
+
# database seed data and rules.
|
3
|
+
#
|
4
|
+
|
5
|
+
# Model class to use
|
6
|
+
#
|
7
|
+
# ! required
|
8
|
+
model Setting
|
9
|
+
|
10
|
+
# Attribute name or a list of attribute names to be used as key(s)
|
11
|
+
# when finding objects
|
12
|
+
#
|
13
|
+
# Usage:
|
14
|
+
# find_by :name
|
15
|
+
# or
|
16
|
+
# find_by [:first_name, :last_name]
|
17
|
+
#
|
18
|
+
# ! required
|
19
|
+
find_by :name
|
20
|
+
|
21
|
+
# Values of attributes listed here will be set even
|
22
|
+
# if they exist already in the matching database object.
|
23
|
+
#
|
24
|
+
# Other attributes in the seed data will be treated as a default value,
|
25
|
+
# i.e. they will only be set if the matching database object does not exist
|
26
|
+
# or its corresponding attribute is not set.
|
27
|
+
#
|
28
|
+
# Usage:
|
29
|
+
# force :value
|
30
|
+
# or:
|
31
|
+
# force [:value, :description]
|
32
|
+
#
|
33
|
+
# default is: no fields are forced
|
34
|
+
force :value
|
35
|
+
|
36
|
+
seeds [
|
37
|
+
{ name: 'abc', value: '123' },
|
38
|
+
{ name: 'def', value: '456' },
|
39
|
+
{ name: 'ghi', value: '789' },
|
40
|
+
{ name: 'abcdef', value: '123456' }
|
41
|
+
]
|
42
|
+
|
data/lib/aerogel-core.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'aerogel-core/version'
|
2
|
+
require 'aerogel-core/core'
|
3
|
+
|
4
|
+
# Path to the aerogel gem
|
5
|
+
Aerogel.core_path = File.expand_path( File.join( File.dirname(__FILE__), ".." ) )
|
6
|
+
|
7
|
+
# Default applicaiton path, may be overridden in application's config.ru
|
8
|
+
Aerogel.application_path = File.expand_path( Dir.pwd )
|
9
|
+
|
10
|
+
# Core path is registered first
|
11
|
+
Aerogel.register_path( Aerogel.core_path )
|
12
|
+
|
13
|
+
require "aerogel-core/application"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
require 'aerogel-core/config'
|
4
|
+
require 'aerogel-core/helpers'
|
5
|
+
require 'aerogel-core/routes'
|
6
|
+
require 'aerogel-core/assets'
|
7
|
+
require 'aerogel-core/db'
|
8
|
+
|
9
|
+
class Aerogel::Application < Sinatra::Base
|
10
|
+
|
11
|
+
# Loads and configures application modules
|
12
|
+
#
|
13
|
+
def self.load
|
14
|
+
on_load
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Loads application environment
|
21
|
+
#
|
22
|
+
def self.on_load
|
23
|
+
# application path is registered last
|
24
|
+
Aerogel.register_path( Aerogel.application_path )
|
25
|
+
|
26
|
+
register Aerogel::Helpers
|
27
|
+
register Aerogel::Config
|
28
|
+
register Aerogel::Routes
|
29
|
+
register Aerogel::Assets
|
30
|
+
register Aerogel::Db
|
31
|
+
puts "** Aerogel application configured v#{Aerogel::version}-#{environment}"
|
32
|
+
end
|
33
|
+
|
34
|
+
end # class Aerogel::Application
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'sinatra/asset_pipeline'
|
2
|
+
|
3
|
+
module Aerogel::Assets
|
4
|
+
|
5
|
+
# Registers and configures assets pipeline
|
6
|
+
#
|
7
|
+
def self.registered( app )
|
8
|
+
# Include these files when precompiling assets
|
9
|
+
app.set :assets_precompile, %w(application.js application.css *.png *.jpg *.svg *.eot *.ttf *.woff)
|
10
|
+
|
11
|
+
# Logical paths to your assets
|
12
|
+
app.set :assets_prefix, [
|
13
|
+
Aerogel.get_resource_paths( :assets )
|
14
|
+
].flatten
|
15
|
+
|
16
|
+
# Use another host for serving assets
|
17
|
+
# set :assets_host, '<id>.cloudfront.net'
|
18
|
+
|
19
|
+
# Serve assets using this protocol
|
20
|
+
# set :assets_protocol, :http
|
21
|
+
|
22
|
+
# CSS minification
|
23
|
+
app.set :assets_css_compressor, :yui
|
24
|
+
|
25
|
+
# JavaScript minification
|
26
|
+
app.set :assets_js_compressor, :uglifier
|
27
|
+
|
28
|
+
app.register Sinatra::AssetPipeline
|
29
|
+
end
|
30
|
+
|
31
|
+
end # module Aerogel::Assets
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'aerogel/configurator'
|
2
|
+
|
3
|
+
module Aerogel::Config
|
4
|
+
|
5
|
+
# Configures application.
|
6
|
+
#
|
7
|
+
def self.registered(app)
|
8
|
+
app.set :root, Aerogel.application_path
|
9
|
+
app.set :views, Aerogel.get_resource_paths( :views ).reverse
|
10
|
+
app.set :erb, layout: "layouts/application.html".to_sym
|
11
|
+
|
12
|
+
require 'sinatra/reloader' if app.development?
|
13
|
+
app.configure :development do
|
14
|
+
app.register Sinatra::Reloader
|
15
|
+
end
|
16
|
+
|
17
|
+
# Load configs
|
18
|
+
app.set :config, Configurator.new
|
19
|
+
Aerogel.get_resource_list( :config, '*.conf', app.environment ).each do |config_filename|
|
20
|
+
app.config.load config_filename
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end # module Aerogel::Config
|
25
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Aerogel
|
2
|
+
|
3
|
+
class << self
|
4
|
+
attr_accessor :core_path, :application_path
|
5
|
+
end
|
6
|
+
|
7
|
+
# Returns module version.
|
8
|
+
#
|
9
|
+
def self.version
|
10
|
+
Aerogel::VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
# Registers a new path for all resource loaders.
|
14
|
+
#
|
15
|
+
# If type is not specified, then resource paths are formed
|
16
|
+
# by appending type to the given path.
|
17
|
+
#
|
18
|
+
# If type is specified, given path is cosidered a final path
|
19
|
+
# for this resource type, and for this resource type only.
|
20
|
+
#
|
21
|
+
def self.register_path( path, type = nil )
|
22
|
+
@registered_paths ||= []
|
23
|
+
@registered_paths << { path: File.expand_path( path ), type: type }
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns registered paths.
|
27
|
+
# If type is specified, only resource paths containing this type are returned.
|
28
|
+
#
|
29
|
+
def self.registered_paths( type = nil )
|
30
|
+
@registered_paths.select{|p| type.nil? || p[:type].nil? || p[:type] == type }
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns list of paths for specified resource type.
|
34
|
+
#
|
35
|
+
def self.get_resource_paths( type )
|
36
|
+
registered_paths( type ).map do |p|
|
37
|
+
p[:type].nil? ? File.join( p[:path], type.to_s ) : p[:path]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns list of filenames of resources of specified type,
|
42
|
+
# environment sub-folders included, filtered by wildcard mask.
|
43
|
+
#
|
44
|
+
# The resources are searched in following order:
|
45
|
+
# path1 + wildcard
|
46
|
+
# path1 + environment + wildcard
|
47
|
+
# path2 + wildcard
|
48
|
+
# path2 + environment + wildcard
|
49
|
+
# etc
|
50
|
+
#
|
51
|
+
def self.get_resource_list( type, wildcard, environment = nil )
|
52
|
+
get_resource_paths( type ).map do |path|
|
53
|
+
paths = Dir.glob( File.join( path, wildcard ) )
|
54
|
+
if environment
|
55
|
+
paths << Dir.glob( File.join( path, environment.to_s, wildcard ) )
|
56
|
+
end
|
57
|
+
# puts "Aerogel::get_resource_list: type=#{type} environment=#{environment} path=#{path}: #{paths}"
|
58
|
+
paths
|
59
|
+
end.flatten
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns filename of the most recent resource file of specified type.
|
63
|
+
#
|
64
|
+
def self.get_resource( type, filename, environment = nil )
|
65
|
+
get_resource_list( type, filename, environment ).last
|
66
|
+
end
|
67
|
+
|
68
|
+
# Require resources specified by type and wildcard.
|
69
|
+
#
|
70
|
+
def self.require_resources( type, wildcard, environment = nil )
|
71
|
+
files_to_require = Aerogel.get_resource_list( type, wildcard, environment )
|
72
|
+
files_to_require.each do |filename|
|
73
|
+
# begin
|
74
|
+
require filename
|
75
|
+
# rescue => e
|
76
|
+
# raise e # "Failed to load resource '#{filename}': #{e}"
|
77
|
+
# end
|
78
|
+
end
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
# Require resources specified by type and wildcard in reverse order.
|
83
|
+
#
|
84
|
+
def self.require_resources_reverse( type, wildcard, environment = nil )
|
85
|
+
files_to_require = Aerogel.get_resource_list( type, wildcard, environment ).reverse
|
86
|
+
files_to_require.each do |filename|
|
87
|
+
# begin
|
88
|
+
require filename
|
89
|
+
# rescue => e
|
90
|
+
# raise e # "Failed to load resource '#{filename}': #{e}"
|
91
|
+
# end
|
92
|
+
end
|
93
|
+
true
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
end # module Aerogel
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'mongoid'
|
2
|
+
require 'aerogel/configurator'
|
3
|
+
|
4
|
+
module Aerogel::Db
|
5
|
+
|
6
|
+
class << self
|
7
|
+
# List of registered models
|
8
|
+
attr_accessor :models, :environment
|
9
|
+
end
|
10
|
+
|
11
|
+
# Registers and configures database access
|
12
|
+
#
|
13
|
+
def self.registered( app )
|
14
|
+
self.environment = app.environment
|
15
|
+
raise "Database connection is not configured in your application's config/*" if app.config.db.nil?
|
16
|
+
Mongoid.configure do |config|
|
17
|
+
config.sessions = {
|
18
|
+
default: { hosts: app.config.db.hosts, database: app.config.db.name }
|
19
|
+
}
|
20
|
+
end
|
21
|
+
load_models
|
22
|
+
|
23
|
+
# disable [deprecated] warning in Mongoid method calls
|
24
|
+
I18n.enforce_available_locales = false if defined? I18n
|
25
|
+
end
|
26
|
+
|
27
|
+
# Perform database migration
|
28
|
+
#
|
29
|
+
def self.migrate!
|
30
|
+
create_indexes!
|
31
|
+
end
|
32
|
+
|
33
|
+
# Clears database.
|
34
|
+
#
|
35
|
+
def self.clear!
|
36
|
+
puts "* clearing database"
|
37
|
+
Mongoid.purge!
|
38
|
+
end
|
39
|
+
|
40
|
+
# Seeds database.
|
41
|
+
#
|
42
|
+
def self.seed!
|
43
|
+
load_and_process_seeds!
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# Loads all models from the folder db/model/*
|
49
|
+
#
|
50
|
+
def self.load_models
|
51
|
+
self.models = []
|
52
|
+
Aerogel.get_resource_list( 'db/model', '*.rb', environment ).each do |model_filename|
|
53
|
+
require model_filename
|
54
|
+
class_name = File.basename( model_filename, '.rb' ).camelize
|
55
|
+
self.models << eval(class_name)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Create database indexes for all models
|
60
|
+
#
|
61
|
+
def self.create_indexes!
|
62
|
+
models.each do |model_class|
|
63
|
+
puts "* creating/updating indexes for: #{model_class.name}"
|
64
|
+
model_class.create_indexes
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Loads and processes seed files.
|
69
|
+
#
|
70
|
+
def self.load_and_process_seeds!
|
71
|
+
seed_files = Aerogel.get_resource_list( 'db/seed', '*.seed', environment )
|
72
|
+
seed_files.each do |seed_file|
|
73
|
+
load_and_process_single_seed! seed_file
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Load and process a single seed file.
|
78
|
+
#
|
79
|
+
def self.load_and_process_single_seed!( seed_filename )
|
80
|
+
puts "* processing seeds from: #{seed_filename}"
|
81
|
+
created_num = 0
|
82
|
+
updated_num = 0
|
83
|
+
seed = Configurator.new seed_filename
|
84
|
+
raise ArgumentError, "'model' is not specified" if seed.model.nil?
|
85
|
+
raise ArgumentError, "'find_by' is not specified" if seed.find_by.nil?
|
86
|
+
seeds = seed.seeds || []
|
87
|
+
raise ArgumentError, "'seeds' should be Array" unless seeds.is_a? Array
|
88
|
+
|
89
|
+
seed.find_by = [ seed.find_by ] unless seed.find_by.is_a? Array
|
90
|
+
seed.force = [ seed.force ] unless seed.force.is_a? Array
|
91
|
+
seeds.each do |fields|
|
92
|
+
obj_keys = Hash[ seed.find_by.map{|k| [k, fields[k]] } ]
|
93
|
+
obj_where = seed.model.where( obj_keys )
|
94
|
+
if obj_where.count > 1
|
95
|
+
puts "!!! WARNING: more than one object found for: #{seed.model.name}: #{humanize_seed_keys obj_keys}"
|
96
|
+
puts " first found object is used."
|
97
|
+
end
|
98
|
+
obj = obj_where.first
|
99
|
+
if obj
|
100
|
+
# exclude default and key attributes
|
101
|
+
fields.delete_if do |k,v|
|
102
|
+
!seed.force.include?( k ) && ( !obj[k].nil? || obj_keys.include?(k) )
|
103
|
+
end
|
104
|
+
if fields.size > 0
|
105
|
+
obj.update_attributes! fields
|
106
|
+
updated_num += 1
|
107
|
+
end
|
108
|
+
else
|
109
|
+
seed.model.create! fields
|
110
|
+
created_num += 1
|
111
|
+
end
|
112
|
+
end
|
113
|
+
puts " - #{created_num} created / #{updated_num} updated"
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns humanized search condition.
|
117
|
+
#
|
118
|
+
def self.humanize_seed_keys( obj_keys )
|
119
|
+
obj_keys.map{|k,v| "#{k}:'#{v}'"}.join(', ')
|
120
|
+
end
|
121
|
+
|
122
|
+
end # module Aerogel::Db
|
123
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'sinatra/asset_pipeline/task'
|
2
|
+
require 'aerogel-core'
|
3
|
+
|
4
|
+
Aerogel::Application.load
|
5
|
+
Sinatra::AssetPipeline::Task.define! Aerogel::Application
|
6
|
+
|
7
|
+
# require *.rake tasks from /rake folder
|
8
|
+
Aerogel.get_resource_list( :rake, '*.rake' ).each do |taskname|
|
9
|
+
load taskname
|
10
|
+
end
|
data/public/favicon.ico
ADDED
Binary file
|
data/public/humans.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Built for humans.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Hi, robot.
|
2
|
+
# Behave.
|
3
|
+
|
4
|
+
User-agent: *
|
5
|
+
Disallow: /assets/
|
6
|
+
|
7
|
+
# All robots should follow these instructions:
|
8
|
+
Disallow: /harm/human/beings
|
9
|
+
Disallow: /disobey/orders # except when it conflicts with instruction #1
|
10
|
+
Disallow: /endanger/self # except when it conflicts with instructions #1 and #2
|
11
|
+
|
12
|
+
Allow: /
|
data/rake/db.rake
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# dummy task for command line 'force' parameter
|
2
|
+
task :force
|
3
|
+
|
4
|
+
namespace :db do
|
5
|
+
|
6
|
+
desc "Create database"
|
7
|
+
task :create do
|
8
|
+
abort "Not implemented"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Clear database"
|
12
|
+
task :clear do |t, args|
|
13
|
+
forced = ARGV.include? 'force'
|
14
|
+
if Aerogel::Application.environment == :production and not forced
|
15
|
+
abort "Clearing database in production environment is dangerous, use: 'rake db:<taskname> force'"
|
16
|
+
end
|
17
|
+
Aerogel::Db.clear!
|
18
|
+
puts "DONE"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Seed database"
|
22
|
+
task :seed do
|
23
|
+
Aerogel::Db.seed!
|
24
|
+
puts "DONE"
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Migrate database"
|
28
|
+
task :migrate do
|
29
|
+
Aerogel::Db.migrate!
|
30
|
+
puts "DONE"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Migrate & seed database"
|
34
|
+
task :update => [:migrate, :seed]
|
35
|
+
|
36
|
+
desc "Re-creates database"
|
37
|
+
task :recreate => [:clear, :migrate, :seed]
|
38
|
+
|
39
|
+
|
40
|
+
end # namespace :db
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
+
<title>404, Not found</title>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<h1>Not found</h1>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
Let's try from <a href="/">the start</a>.
|
15
|
+
</p>
|
16
|
+
|
17
|
+
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello from #index.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title><%= defined?(title) ? title : 'aerogel' %></title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
|
7
|
+
<%= yield %>
|
8
|
+
|
9
|
+
|
10
|
+
<p style="font: 9pt; font-style: italic; color: gray">
|
11
|
+
This is default aerogel layout defined here: <%= __FILE__ %>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<p>
|
2
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
3
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
4
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
5
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
6
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
7
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
8
|
+
</p>
|
9
|
+
<p>
|
10
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
11
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
12
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
13
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
14
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
15
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
16
|
+
</p>
|
17
|
+
<p>
|
18
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
19
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
20
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
21
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
22
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
23
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
24
|
+
</p>
|
25
|
+
<p>
|
26
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
27
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
28
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
29
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
30
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
31
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
32
|
+
</p>
|
33
|
+
<p>
|
34
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
35
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
36
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
37
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
38
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
39
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
40
|
+
</p>
|
41
|
+
<p>
|
42
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
43
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
44
|
+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
45
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
46
|
+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
47
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
48
|
+
</p>
|
metadata
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aerogel-core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Kukushkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sinatra-contrib
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sinatra-asset-pipeline
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sass
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coffee-script
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: uglifier
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yui-compressor
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: aerogel-configurator
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mongoid
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: bundler
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.3'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ~>
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.3'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rake
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: Aerogel core module
|
168
|
+
email:
|
169
|
+
- alex@kukushk.in
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- .gitignore
|
175
|
+
- Gemfile
|
176
|
+
- LICENSE.txt
|
177
|
+
- README.md
|
178
|
+
- Rakefile
|
179
|
+
- aerogel-core.gemspec
|
180
|
+
- app/helpers/core.rb
|
181
|
+
- app/helpers/render.rb
|
182
|
+
- app/routes/core.rb
|
183
|
+
- app/routes/static.rb
|
184
|
+
- assets/javascripts/application.js
|
185
|
+
- assets/stylesheets/application.css
|
186
|
+
- config/config.conf.template
|
187
|
+
- config/database.conf.template
|
188
|
+
- config/development/.keep
|
189
|
+
- config/production/.keep
|
190
|
+
- db/model/model.rb.template
|
191
|
+
- db/seed/development/.keep
|
192
|
+
- db/seed/production/.keep
|
193
|
+
- db/seed/seed.template
|
194
|
+
- lib/aerogel-core.rb
|
195
|
+
- lib/aerogel-core/application.rb
|
196
|
+
- lib/aerogel-core/assets.rb
|
197
|
+
- lib/aerogel-core/config.rb
|
198
|
+
- lib/aerogel-core/core.rb
|
199
|
+
- lib/aerogel-core/db.rb
|
200
|
+
- lib/aerogel-core/helpers.rb
|
201
|
+
- lib/aerogel-core/rake.rb
|
202
|
+
- lib/aerogel-core/routes.rb
|
203
|
+
- lib/aerogel-core/version.rb
|
204
|
+
- public/favicon.ico
|
205
|
+
- public/humans.txt
|
206
|
+
- public/robots.txt.development
|
207
|
+
- public/robots.txt.production
|
208
|
+
- rake/db.rake
|
209
|
+
- views/errors/404.html.erb
|
210
|
+
- views/index.html.erb
|
211
|
+
- views/layouts/application.html.erb
|
212
|
+
- views/lorem.html.erb
|
213
|
+
homepage: ''
|
214
|
+
licenses:
|
215
|
+
- MIT
|
216
|
+
metadata: {}
|
217
|
+
post_install_message:
|
218
|
+
rdoc_options: []
|
219
|
+
require_paths:
|
220
|
+
- lib
|
221
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
222
|
+
requirements:
|
223
|
+
- - '>='
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - '>='
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
requirements: []
|
232
|
+
rubyforge_project:
|
233
|
+
rubygems_version: 2.0.6
|
234
|
+
signing_key:
|
235
|
+
specification_version: 4
|
236
|
+
summary: Aerogel is a modular opinionated CMS
|
237
|
+
test_files: []
|