tomify 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/app/assets/images/tomify/gifs/basketball.gif +0 -0
- data/app/assets/images/tomify/gifs/laughing.gif +0 -0
- data/app/assets/images/tomify/gifs/sneer.gif +0 -0
- data/app/assets/images/tomify/gifs/wind.gif +0 -0
- data/app/assets/images/tomify/gifs/woods.gif +0 -0
- data/app/assets/javascripts/tomify/default/array.coffee +4 -0
- data/app/assets/javascripts/tomify/default/jquery.patch.coffee +9 -0
- data/app/assets/javascripts/tomify/default/object.coffee +4 -0
- data/app/assets/javascripts/tomify/default/string.coffee +40 -0
- data/app/assets/javascripts/tomify/dynamic/classes/component.coffee +7 -0
- data/app/assets/javascripts/tomify/dynamic/classes/field.coffee +24 -0
- data/app/assets/javascripts/tomify/dynamic/classes/form.coffee +72 -0
- data/app/assets/javascripts/tomify/dynamic/classes/model.coffee +41 -0
- data/app/assets/javascripts/tomify/dynamic/classes/namespace.coffee +24 -0
- data/app/assets/javascripts/tomify/dynamic/classes/observer.coffee +22 -0
- data/app/assets/javascripts/tomify/dynamic/classes/request.coffee +26 -0
- data/app/assets/javascripts/tomify/dynamic/classes/store.coffee +37 -0
- data/app/assets/javascripts/tomify/dynamic/global.coffee +16 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/pages.coffee.erb +30 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/settings.coffee +27 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/sidebars.coffee +16 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/uploads.coffee +13 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/users.coffee +18 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/edit.coffee +51 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/fields/checkbox.coffee +8 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/fields/default.coffee +3 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/fields/file.coffee +3 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/fields/markdown.coffee +9 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/fields/select.coffee +8 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/fields/textarea.coffee +3 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/index.coffee +87 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/admin_navbar.coffee +29 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/analytics.coffee +34 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/footer.coffee +11 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/header.coffee +28 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/messages.coffee +18 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/navbar.coffee +6 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/public_navbar.coffee +56 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/new.coffee +48 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/pagination.coffee +29 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/public/passwords/new.coffee +38 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/public/sessions/new.coffee +40 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/public/sessions/show.coffee +35 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/public/users/edit.coffee +42 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/public/users/new.coffee +35 -0
- data/app/assets/javascripts/tomify/dynamic/react/mixins/follow.coffee +51 -0
- data/app/assets/javascripts/tomify/dynamic/react/mixins/will-initialize.coffee +7 -0
- data/app/assets/javascripts/tomify/dynamic/react/mount.coffee +9 -0
- data/app/assets/javascripts/tomify/turbolinks/compatibility.coffee +29 -0
- data/app/assets/javascripts/tomify/turbolinks/react.coffee +5 -0
- data/app/assets/javascripts/tomify-dynamic.js +8 -0
- data/app/assets/javascripts/tomify.js +1 -0
- data/app/assets/stylesheets/_tomify.scss +1 -0
- data/app/assets/stylesheets/tomify/_default.scss +26 -0
- data/app/assets/stylesheets/tomify/_footer.scss +1 -0
- data/app/assets/stylesheets/tomify/_navbar.scss +43 -0
- data/app/assets/stylesheets/tomify/_page.scss +31 -0
- data/app/assets/stylesheets/tomify/_pagination.scss +5 -0
- data/app/assets/stylesheets/tomify/_variables.scss +10 -0
- data/app/controllers/tomify/admin/controller.rb +7 -0
- data/app/controllers/tomify/admin/pages_controller.rb +2 -0
- data/app/controllers/tomify/admin/settings_controller.rb +2 -0
- data/app/controllers/tomify/admin/sidebars_controller.rb +2 -0
- data/app/controllers/tomify/admin/uploads_controller.rb +2 -0
- data/app/controllers/tomify/admin/users_controller.rb +2 -0
- data/app/controllers/tomify/api/admin/controller.rb +3 -0
- data/app/controllers/tomify/api/admin/pages_controller.rb +2 -0
- data/app/controllers/tomify/api/admin/settings_controller.rb +2 -0
- data/app/controllers/tomify/api/admin/sidebars_controller.rb +2 -0
- data/app/controllers/tomify/api/admin/uploads_controller.rb +2 -0
- data/app/controllers/tomify/api/admin/users_controller.rb +7 -0
- data/app/controllers/tomify/api/public/controller.rb +3 -0
- data/app/controllers/tomify/api/public/passwords_controller.rb +10 -0
- data/app/controllers/tomify/api/public/sessions_controller.rb +19 -0
- data/app/controllers/tomify/api/public/users_controller.rb +25 -0
- data/app/controllers/tomify/concerns/api/admin.rb +9 -0
- data/app/controllers/tomify/concerns/api/helpers.rb +57 -0
- data/app/controllers/tomify/concerns/api/json.rb +46 -0
- data/app/controllers/tomify/concerns/api/public.rb +9 -0
- data/app/controllers/tomify/concerns/default/auth_helper.rb +22 -0
- data/app/controllers/tomify/concerns/default/env_helper.rb +34 -0
- data/app/controllers/tomify/concerns/default/helper.rb +13 -0
- data/app/controllers/tomify/concerns/default/react_helper.rb +7 -0
- data/app/controllers/tomify/concerns/default.rb +17 -0
- data/app/controllers/tomify/public/controller.rb +2 -0
- data/app/controllers/tomify/public/pages_controller.rb +22 -0
- data/app/controllers/tomify/public/sessions_controller.rb +5 -0
- data/app/controllers/tomify/public/users_controller.rb +7 -0
- data/app/controllers/tomify_controller.rb +3 -0
- data/app/helpers/tomify/carrierwave_helper.rb +17 -0
- data/app/helpers/tomify/email_helper.rb +19 -0
- data/app/helpers/tomify/render_helper.rb +13 -0
- data/app/helpers/tomify/timezone_helper.rb +5 -0
- data/app/mailers/tomify/user_mailer.rb +13 -0
- data/app/mailers/tomify_mailer.rb +14 -0
- data/app/models/tomify/concerns/page.rb +74 -0
- data/app/models/tomify/concerns/sidebar.rb +18 -0
- data/app/models/tomify/concerns/token.rb +18 -0
- data/app/models/tomify/concerns/upload.rb +36 -0
- data/app/models/tomify/concerns/user.rb +52 -0
- data/app/models/tomify/page.rb +3 -0
- data/app/models/tomify/setting/boolean.rb +11 -0
- data/app/models/tomify/setting/json.rb +11 -0
- data/app/models/tomify/setting/text.rb +3 -0
- data/app/models/tomify/setting/uploader.rb +6 -0
- data/app/models/tomify/setting.rb +48 -0
- data/app/models/tomify/sidebar.rb +3 -0
- data/app/models/tomify/token.rb +3 -0
- data/app/models/tomify/upload.rb +3 -0
- data/app/models/tomify/user.rb +3 -0
- data/app/models/tomify_record.rb +33 -0
- data/app/uploaders/tomify/file_uploader.rb +5 -0
- data/app/uploaders/tomify/setting_uploader.rb +7 -0
- data/app/uploaders/tomify_uploader.rb +20 -0
- data/app/views/templates/contact.haml +24 -0
- data/app/views/templates/default.haml +4 -0
- data/app/views/tomify/defaults/_body.haml +8 -0
- data/app/views/tomify/defaults/_container.haml +3 -0
- data/app/views/tomify/defaults/_env.haml +2 -0
- data/app/views/tomify/defaults/_head.haml +14 -0
- data/app/views/tomify/defaults/_meta.haml +17 -0
- data/app/views/tomify/defaults/_sharing.haml +23 -0
- data/app/views/tomify/layouts/application.haml +4 -0
- data/app/views/tomify/layouts/mailer.haml +7 -0
- data/app/views/tomify/mailers/user_mailer/invite.haml +13 -0
- data/app/views/tomify/mailers/user_mailer/reset_password.haml +17 -0
- data/config/initializers/assets.rb +7 -0
- data/config/initializers/database.rb +3 -0
- data/config/initializers/flash_patch.rb +15 -0
- data/config/initializers/mailer.rb +4 -0
- data/config/initializers/renderers.rb +4 -0
- data/config/initializers/settings.rb +5 -0
- data/config/routes.rb +38 -0
- data/db/migrate/19900000000000_create_users.rb +13 -0
- data/db/migrate/19900000000001_create_tokens.rb +10 -0
- data/db/migrate/19900000000002_create_settings.rb +13 -0
- data/db/migrate/19900000000003_create_uploads.rb +13 -0
- data/db/migrate/19900000000004_create_pages.rb +22 -0
- data/db/migrate/19900000000005_create_sidebars.rb +12 -0
- data/db/seeds.rb +43 -0
- data/lib/generators/tomify/bundle/bundle_generator.rb +12 -0
- data/lib/generators/tomify/bundle/templates/default.js +2 -0
- data/lib/generators/tomify/bundle/templates/react.js +3 -0
- data/lib/previews/tomify/user_preview.rb +9 -0
- data/lib/previews/tomify_preview.rb +6 -0
- data/lib/tasks/package.rake +40 -0
- data/lib/tomify/constantly.rb +12 -0
- data/lib/tomify/engine.rb +11 -0
- data/lib/tomify/version.rb +3 -0
- data/lib/tomify.rb +40 -0
- data/vendor/tomify/development/react.js +20494 -0
- data/vendor/tomify/production/react.js +20352 -0
- metadata +219 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateSettings < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :settings do |t|
|
4
|
+
t.boolean :public, default: true, null: false, index: true
|
5
|
+
t.string :type, null: false, index: true
|
6
|
+
t.string :name, null: false, index: true
|
7
|
+
t.string :value
|
8
|
+
t.json :json, default: {}, null: false
|
9
|
+
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateUploads < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :uploads do |t|
|
4
|
+
t.string :uuid, null: false, index: true
|
5
|
+
t.string :name, null: false, index: true
|
6
|
+
t.string :file, null: false
|
7
|
+
t.string :size, null: false
|
8
|
+
t.string :content_type, null: false
|
9
|
+
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreatePages < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :pages do |t|
|
4
|
+
t.integer :parent_id, index: true
|
5
|
+
t.integer :sidebar_id
|
6
|
+
t.boolean :active, default: false, null: false, index: true
|
7
|
+
t.boolean :root, default: false, null: false, index: true
|
8
|
+
t.integer :rank, default: 100, null: false, index: true
|
9
|
+
t.string :path, null: false, index: true
|
10
|
+
t.string :name, null: false
|
11
|
+
t.string :template, null: false
|
12
|
+
t.string :title
|
13
|
+
t.string :description
|
14
|
+
t.string :cover_image
|
15
|
+
t.string :share_image
|
16
|
+
t.text :text
|
17
|
+
|
18
|
+
t.timestamps null: false
|
19
|
+
t.index [:active, :rank]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateSidebars < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :sidebars do |t|
|
4
|
+
t.boolean :active, default: false, null: false, index: true
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :heading
|
7
|
+
t.text :text
|
8
|
+
|
9
|
+
t.timestamps null: false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
def debug(record)
|
2
|
+
puts record.errors.full_messages unless record.valid?
|
3
|
+
end
|
4
|
+
|
5
|
+
if Tomify.models.user.count.zero?
|
6
|
+
puts "Creating Default Users"
|
7
|
+
debug Tomify.models.user.create(
|
8
|
+
admin: true,
|
9
|
+
email: "tom@tomify.me",
|
10
|
+
first_name: "Tom",
|
11
|
+
last_name: "Prats",
|
12
|
+
password: "password"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
if Tomify.models.setting.count.zero?
|
17
|
+
puts "Creating Default Settings"
|
18
|
+
debug Tomify::Setting::Text.create(name: "name", value: "Tomify", public: true)
|
19
|
+
debug Tomify::Setting::Text.create(name: "timezone", value: "Eastern Time (US & Canada)")
|
20
|
+
debug Tomify::Setting::Boolean.create(name: "allow_signup", value: false, public: true)
|
21
|
+
debug Tomify::Setting::Json.create(name: "aws", value: {
|
22
|
+
access_key: "",
|
23
|
+
secret_key: "",
|
24
|
+
bucket: "",
|
25
|
+
})
|
26
|
+
debug Tomify::Setting::Json.create(name: "email", value: {
|
27
|
+
username: "",
|
28
|
+
password: "",
|
29
|
+
base_url: "http://localhost:3000"
|
30
|
+
})
|
31
|
+
end
|
32
|
+
|
33
|
+
if Tomify.models.page.count.zero?
|
34
|
+
puts "Creating Default Pages"
|
35
|
+
debug Tomify.models.page.create(
|
36
|
+
root: true,
|
37
|
+
active: true,
|
38
|
+
rank: 10,
|
39
|
+
path: "home",
|
40
|
+
name: "Home",
|
41
|
+
template: Tomify.models.page.templates.first
|
42
|
+
)
|
43
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Tomify
|
2
|
+
module Generators
|
3
|
+
class BundleGenerator < ::Rails::Generators::NamedBase
|
4
|
+
desc "Creates a default bundle js file"
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
6
|
+
|
7
|
+
def create_default
|
8
|
+
copy_file "default.js", "config/bundles/#{file_name}.js"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "active_support/core_ext/object/blank"
|
2
|
+
|
3
|
+
namespace :tomify do
|
4
|
+
desc "Generate Package from Bundle"
|
5
|
+
task :package do
|
6
|
+
root = Gem::Specification.find_by_name("tomify").gem_dir
|
7
|
+
|
8
|
+
# Should be passed as arguments
|
9
|
+
package = "react.js"
|
10
|
+
package_bundle = "#{root}/lib/generators/tomify/bundle/templates/react.js"
|
11
|
+
|
12
|
+
package_path = package.split("/")[0...-1].join("/")
|
13
|
+
package_path = "#{pwd}/vendor/tomify" if package_path.blank?
|
14
|
+
package_name = package.split("/")[-1]
|
15
|
+
development = create_file "#{package_path}/development", package_name
|
16
|
+
production = create_file "#{package_path}/production", package_name
|
17
|
+
|
18
|
+
mkdir_p "tmp/tomify"
|
19
|
+
bundle = "#{pwd}/tmp/tomify/bundle.js"
|
20
|
+
cp package_bundle, bundle
|
21
|
+
cd "tmp/tomify" do
|
22
|
+
# Install
|
23
|
+
packages = File.read(bundle).match(/^\/\/ (.*)$/)[1]
|
24
|
+
sh "npm --loglevel=error install browserify #{packages}"
|
25
|
+
|
26
|
+
# Package
|
27
|
+
command = "node_modules/.bin/browserify"
|
28
|
+
sh "#{command} #{bundle} > #{development}"
|
29
|
+
sh "NODE_ENV=production #{command} #{bundle} > #{production}"
|
30
|
+
end
|
31
|
+
rm_rf "tmp/tomify"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_file(path, name)
|
36
|
+
file = "#{path}/#{name}"
|
37
|
+
mkdir_p path
|
38
|
+
touch file
|
39
|
+
file
|
40
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Tomify
|
2
|
+
class Constantly
|
3
|
+
def initialize(methods)
|
4
|
+
methods.each do |key, value|
|
5
|
+
define_singleton_method(key) { value.constantize }
|
6
|
+
define_singleton_method("#{key}=") do |new_value|
|
7
|
+
define_singleton_method(key) { new_value.constantize }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/tomify.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "tomify/constantly"
|
2
|
+
require "tomify/engine"
|
3
|
+
require "tomify/version"
|
4
|
+
|
5
|
+
module Tomify
|
6
|
+
mattr_accessor :controllers
|
7
|
+
self.controllers = Constantly.new(
|
8
|
+
admin: "Tomify::Admin::Controller",
|
9
|
+
admin_api: "Tomify::Api::Admin::Controller",
|
10
|
+
base: "TomifyController",
|
11
|
+
public: "Tomify::Public::Controller",
|
12
|
+
public_api: "Tomify::Api::Public::Controller"
|
13
|
+
)
|
14
|
+
|
15
|
+
mattr_accessor :mailers
|
16
|
+
self.mailers = Constantly.new(
|
17
|
+
base: "TomifyMailer",
|
18
|
+
preview: "TomifyPreview",
|
19
|
+
user: "Tomify::UserMailer"
|
20
|
+
)
|
21
|
+
|
22
|
+
mattr_accessor :models
|
23
|
+
self.models = Constantly.new(
|
24
|
+
base: "TomifyRecord",
|
25
|
+
page: "Tomify::Page",
|
26
|
+
setting: "Tomify::Setting",
|
27
|
+
user: "Tomify::User"
|
28
|
+
)
|
29
|
+
|
30
|
+
mattr_accessor :uploaders
|
31
|
+
self.uploaders = Constantly.new(base: "TomifyUploader")
|
32
|
+
|
33
|
+
def self.root
|
34
|
+
Pathname.new Gem::Specification.find_by_name("tomify").gem_dir
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.setting(name)
|
38
|
+
Tomify.models.setting.find_by(name: name).try(:value)
|
39
|
+
end
|
40
|
+
end
|